atcommand.c 314 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include <limits.h>
  9. #include "../common/cbasetypes.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "../common/malloc.h"
  16. #include "../common/socket.h"
  17. #include "atcommand.h"
  18. #include "log.h"
  19. #include "clif.h"
  20. #include "chrif.h"
  21. #include "intif.h"
  22. #include "itemdb.h"
  23. #include "map.h"
  24. #include "pc.h"
  25. #include "status.h"
  26. #include "skill.h"
  27. #include "mob.h"
  28. #include "pet.h"
  29. #include "mercenary.h" //[orn]
  30. #include "battle.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "npc.h"
  35. #include "trade.h"
  36. #include "unit.h"
  37. #ifndef TXT_ONLY
  38. #include "mail.h"
  39. #endif
  40. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  41. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  42. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  43. ACMD_FUNC(broadcast);
  44. ACMD_FUNC(localbroadcast);
  45. ACMD_FUNC(rura);
  46. ACMD_FUNC(where);
  47. ACMD_FUNC(jumpto);
  48. ACMD_FUNC(jump);
  49. ACMD_FUNC(who);
  50. ACMD_FUNC(who2);
  51. ACMD_FUNC(who3);
  52. ACMD_FUNC(whomap);
  53. ACMD_FUNC(whomap2);
  54. ACMD_FUNC(whomap3);
  55. ACMD_FUNC(whogm); // by Yor
  56. ACMD_FUNC(whozeny); // [Valaris]
  57. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  58. ACMD_FUNC(save);
  59. ACMD_FUNC(load);
  60. ACMD_FUNC(speed);
  61. ACMD_FUNC(charspeed);
  62. ACMD_FUNC(storage);
  63. ACMD_FUNC(guildstorage);
  64. ACMD_FUNC(option);
  65. ACMD_FUNC(hide);
  66. ACMD_FUNC(jobchange);
  67. ACMD_FUNC(die);
  68. ACMD_FUNC(kill);
  69. ACMD_FUNC(alive);
  70. ACMD_FUNC(kami);
  71. ACMD_FUNC(heal);
  72. ACMD_FUNC(item);
  73. ACMD_FUNC(item2);
  74. ACMD_FUNC(itemreset);
  75. ACMD_FUNC(baselevelup);
  76. ACMD_FUNC(joblevelup);
  77. ACMD_FUNC(help);
  78. ACMD_FUNC(help2);
  79. ACMD_FUNC(gm);
  80. ACMD_FUNC(pvpoff);
  81. ACMD_FUNC(pvpon);
  82. ACMD_FUNC(gvgoff);
  83. ACMD_FUNC(gvgon);
  84. ACMD_FUNC(model);
  85. ACMD_FUNC(go);
  86. ACMD_FUNC(monster);
  87. ACMD_FUNC(monstersmall);
  88. ACMD_FUNC(monsterbig);
  89. ACMD_FUNC(spawn);
  90. ACMD_FUNC(killmonster);
  91. ACMD_FUNC(killmonster2);
  92. ACMD_FUNC(refine);
  93. ACMD_FUNC(produce);
  94. ACMD_FUNC(memo);
  95. ACMD_FUNC(gat);
  96. ACMD_FUNC(packet);
  97. ACMD_FUNC(waterlevel);
  98. ACMD_FUNC(statuspoint);
  99. ACMD_FUNC(skillpoint);
  100. ACMD_FUNC(zeny);
  101. ACMD_FUNC(param);
  102. ACMD_FUNC(guildlevelup);
  103. ACMD_FUNC(makeegg);
  104. ACMD_FUNC(hatch);
  105. ACMD_FUNC(petfriendly);
  106. ACMD_FUNC(pethungry);
  107. ACMD_FUNC(petrename);
  108. ACMD_FUNC(recall);
  109. ACMD_FUNC(recallall);
  110. ACMD_FUNC(revive);
  111. ACMD_FUNC(night);
  112. ACMD_FUNC(day);
  113. ACMD_FUNC(doom);
  114. ACMD_FUNC(doommap);
  115. ACMD_FUNC(raise);
  116. ACMD_FUNC(raisemap);
  117. ACMD_FUNC(kick);
  118. ACMD_FUNC(kickall);
  119. ACMD_FUNC(allskill);
  120. ACMD_FUNC(questskill);
  121. ACMD_FUNC(lostskill);
  122. ACMD_FUNC(spiritball);
  123. ACMD_FUNC(party);
  124. ACMD_FUNC(guild);
  125. ACMD_FUNC(agitstart);
  126. ACMD_FUNC(agitend);
  127. ACMD_FUNC(reloaditemdb);
  128. ACMD_FUNC(reloadmobdb);
  129. ACMD_FUNC(reloadskilldb);
  130. ACMD_FUNC(reloadscript);
  131. ACMD_FUNC(reloadgmdb); // by Yor
  132. ACMD_FUNC(reloadatcommand);
  133. ACMD_FUNC(reloadbattleconf);
  134. ACMD_FUNC(reloadstatusdb);
  135. ACMD_FUNC(reloadpcdb);
  136. ACMD_FUNC(reloadmotd); // [Valaris]
  137. ACMD_FUNC(mapexit);
  138. ACMD_FUNC(idsearch);
  139. ACMD_FUNC(mapinfo);
  140. ACMD_FUNC(dye); //** by fritz
  141. ACMD_FUNC(hair_style); //** by fritz
  142. ACMD_FUNC(hair_color); //** by fritz
  143. ACMD_FUNC(stat_all); //** by fritz
  144. ACMD_FUNC(char_block); // by Yor
  145. ACMD_FUNC(char_ban); // by Yor
  146. ACMD_FUNC(char_unblock); // by Yor
  147. ACMD_FUNC(char_unban); // by Yor
  148. ACMD_FUNC(mount_peco); // by Valaris
  149. ACMD_FUNC(char_mount_peco); // by Yor
  150. ACMD_FUNC(guildspy); // [Syrus22]
  151. ACMD_FUNC(partyspy); // [Syrus22]
  152. ACMD_FUNC(repairall); // [Valaris]
  153. ACMD_FUNC(guildrecall); // by Yor
  154. ACMD_FUNC(partyrecall); // by Yor
  155. ACMD_FUNC(nuke); // [Valaris]
  156. ACMD_FUNC(shownpc);
  157. ACMD_FUNC(hidenpc);
  158. ACMD_FUNC(loadnpc);
  159. ACMD_FUNC(unloadnpc);
  160. ACMD_FUNC(servertime); // by Yor
  161. ACMD_FUNC(chardelitem); // by Yor
  162. ACMD_FUNC(jail); // by Yor
  163. ACMD_FUNC(unjail); // by Yor
  164. ACMD_FUNC(jailfor); // Alias Meruru
  165. ACMD_FUNC(jailtime); // Coltaro
  166. ACMD_FUNC(charjailtime); // Coltaro
  167. ACMD_FUNC(disguise); // [Valaris]
  168. ACMD_FUNC(undisguise); // by Yor
  169. ACMD_FUNC(chardisguise); // Kalaspuff
  170. ACMD_FUNC(charundisguise); // Kalaspuff
  171. ACMD_FUNC(email); // by Yor
  172. ACMD_FUNC(effect);//by Apple
  173. ACMD_FUNC(character_cart_list); // by Yor
  174. ACMD_FUNC(addwarp); // by MouseJstr
  175. ACMD_FUNC(follow); // by MouseJstr
  176. ACMD_FUNC(skillon); // by MouseJstr
  177. ACMD_FUNC(skilloff); // by MouseJstr
  178. ACMD_FUNC(killer); // by MouseJstr
  179. ACMD_FUNC(npcmove); // by MouseJstr
  180. ACMD_FUNC(killable); // by MouseJstr
  181. ACMD_FUNC(charkillable); // by MouseJstr
  182. ACMD_FUNC(dropall); // by MouseJstr
  183. ACMD_FUNC(chardropall); // by MouseJstr
  184. ACMD_FUNC(storeall); // by MouseJstr
  185. ACMD_FUNC(charstoreall); // by MouseJstr
  186. ACMD_FUNC(skillid); // by MouseJstr
  187. ACMD_FUNC(useskill); // by MouseJstr
  188. ACMD_FUNC(summon);
  189. ACMD_FUNC(rain);
  190. ACMD_FUNC(snow);
  191. ACMD_FUNC(sakura);
  192. ACMD_FUNC(clouds);
  193. ACMD_FUNC(clouds2); // [Valaris]
  194. ACMD_FUNC(fog);
  195. ACMD_FUNC(fireworks);
  196. ACMD_FUNC(leaves);
  197. ACMD_FUNC(adjgmlvl); // by MouseJstr
  198. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  199. ACMD_FUNC(trade); // by MouseJstr
  200. ACMD_FUNC(send); // by davidsiaw
  201. ACMD_FUNC(setbattleflag); // by MouseJstr
  202. ACMD_FUNC(unmute); // [Valaris]
  203. ACMD_FUNC(clearweather); // Dexity
  204. ACMD_FUNC(uptime); // by MC Cameri
  205. ACMD_FUNC(changesex); // by MC Cameri
  206. ACMD_FUNC(mute); // celest
  207. ACMD_FUNC(refresh); // by MC Cameri
  208. ACMD_FUNC(petid); // by MC Cameri
  209. ACMD_FUNC(identify); // by MC Cameri
  210. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  211. ACMD_FUNC(misceffect); // by MC Cameri
  212. ACMD_FUNC(mobsearch);
  213. ACMD_FUNC(cleanmap);
  214. ACMD_FUNC(npctalk);
  215. ACMD_FUNC(pettalk);
  216. ACMD_FUNC(users);
  217. ACMD_FUNC(reset);
  218. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  219. #ifndef TXT_ONLY
  220. ACMD_FUNC(checkmail); // [Valaris]
  221. ACMD_FUNC(listmail); // [Valaris]
  222. ACMD_FUNC(listnewmail); // [Valaris]
  223. ACMD_FUNC(readmail); // [Valaris]
  224. ACMD_FUNC(sendmail); // [Valaris]
  225. ACMD_FUNC(sendprioritymail); // [Valaris]
  226. ACMD_FUNC(deletemail); // [Valaris]
  227. ACMD_FUNC(refreshonline); // [Valaris]
  228. #endif /* TXT_ONLY */
  229. ACMD_FUNC(skilltree); // by MouseJstr
  230. ACMD_FUNC(marry); // by MouseJstr
  231. ACMD_FUNC(divorce); // by MouseJstr
  232. ACMD_FUNC(grind); // by MouseJstr
  233. ACMD_FUNC(grind2); // by MouseJstr
  234. #ifdef DMALLOC
  235. ACMD_FUNC(dmstart); // by MouseJstr
  236. ACMD_FUNC(dmtick); // by MouseJstr
  237. #endif
  238. ACMD_FUNC(jumptoid); // by Dino9021
  239. ACMD_FUNC(jumptoid2); // by Dino9021
  240. ACMD_FUNC(recallid); // by Dino9021
  241. ACMD_FUNC(recallid2); // by Dino9021
  242. ACMD_FUNC(kickid); // by Dino9021
  243. ACMD_FUNC(kickid2); // by Dino9021
  244. ACMD_FUNC(reviveid); // by Dino9021
  245. ACMD_FUNC(reviveid2); // by Dino9021
  246. ACMD_FUNC(killid); // by Dino9021
  247. ACMD_FUNC(killid2); // by Dino9021
  248. ACMD_FUNC(charkillableid); // by Dino9021
  249. ACMD_FUNC(charkillableid2); // by Dino9021
  250. ACMD_FUNC(sound);
  251. ACMD_FUNC(undisguiseall);
  252. ACMD_FUNC(disguiseall);
  253. ACMD_FUNC(changelook);
  254. ACMD_FUNC(mobinfo); //by Lupus
  255. ACMD_FUNC(exp); // by Skotlex
  256. ACMD_FUNC(adopt); // by Veider
  257. ACMD_FUNC(version); // by Ancyker
  258. ACMD_FUNC(mutearea); // by MouseJstr
  259. ACMD_FUNC(shuffle); // by MouseJstr
  260. ACMD_FUNC(rates); // by MouseJstr
  261. ACMD_FUNC(iteminfo); // Lupus
  262. ACMD_FUNC(whodrops); //Skotlex
  263. ACMD_FUNC(mapflag); // Lupus
  264. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  265. ACMD_FUNC(monsterignore); // [Valaris]
  266. ACMD_FUNC(fakename); //[Valaris]
  267. ACMD_FUNC(size); //[Valaris]
  268. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  269. ACMD_FUNC(showzeny);
  270. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  271. ACMD_FUNC(autotrade);// durf
  272. ACMD_FUNC(changeleader);// [Skotlex]
  273. ACMD_FUNC(partyoption);// [Skotlex]
  274. ACMD_FUNC(changegm);// durf
  275. // Duel [LuzZza]
  276. ACMD_FUNC(invite);
  277. ACMD_FUNC(duel);
  278. ACMD_FUNC(leave);
  279. ACMD_FUNC(accept);
  280. ACMD_FUNC(reject);
  281. ACMD_FUNC(away); // LuzZza
  282. ACMD_FUNC(main); // LuzZza
  283. ACMD_FUNC(clone); // [Valaris]
  284. ACMD_FUNC(tonpc); // LuzZza
  285. ACMD_FUNC(commands); // [Skotlex]
  286. ACMD_FUNC(noask); //LuzZza
  287. ACMD_FUNC(request); //[Skotlex]
  288. ACMD_FUNC(homlevel); //[orn]
  289. ACMD_FUNC(homevolution); //[orn]
  290. ACMD_FUNC(makehomun); //[orn]
  291. ACMD_FUNC(homfriendly); //[orn]
  292. ACMD_FUNC(homhungry); //[orn]
  293. ACMD_FUNC(homtalk); //[orn]
  294. ACMD_FUNC(hominfo); //[Toms]
  295. ACMD_FUNC(showmobs); //KarLaeda
  296. /*==========================================
  297. *AtCommandInfo atcommand_info[]構造体の定義
  298. *------------------------------------------
  299. */
  300. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  301. // to set default level, read atcommand_athena.conf first please.
  302. static AtCommandInfo atcommand_info[] = {
  303. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  304. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  305. { AtCommand_Where, "@where", 1, atcommand_where },
  306. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  307. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  308. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  309. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  310. { AtCommand_Who, "@who", 20, atcommand_who },
  311. { AtCommand_Who, "@whois", 20, atcommand_who },
  312. { AtCommand_Who, "@w", 20, atcommand_who },
  313. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  314. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  315. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  316. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  317. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  318. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  319. { AtCommand_Save, "@save", 40, atcommand_save },
  320. { AtCommand_Load, "@return", 40, atcommand_load },
  321. { AtCommand_Load, "@load", 40, atcommand_load },
  322. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  323. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  324. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  325. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  326. { AtCommand_Option, "@option", 40, atcommand_option },
  327. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  328. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  329. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  330. { AtCommand_Die, "@die", 1, atcommand_die },
  331. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  332. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  333. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  334. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  335. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  336. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  337. { AtCommand_Item, "@item", 60, atcommand_item },
  338. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  339. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  340. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  341. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  342. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  343. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  344. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  345. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  346. { AtCommand_H, "@h", 20, atcommand_help },
  347. { AtCommand_Help, "@help", 20, atcommand_help },
  348. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  349. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  350. { AtCommand_GM, "@gm", 100,atcommand_gm },
  351. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  352. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  353. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  354. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  355. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  356. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  357. { AtCommand_Model, "@model", 20, atcommand_model },
  358. { AtCommand_Go, "@go", 10, atcommand_go },
  359. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  360. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  361. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  362. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  363. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  364. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  365. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  366. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  367. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  368. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  369. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  370. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  371. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  372. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  373. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  374. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  375. { AtCommand_Strength, "@str", 60, atcommand_param },
  376. { AtCommand_Agility, "@agi", 60, atcommand_param },
  377. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  378. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  379. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  380. { AtCommand_Luck, "@luk", 60, atcommand_param },
  381. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  382. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  383. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  384. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  385. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  386. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  387. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  388. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  389. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  390. { AtCommand_Night, "@night", 80, atcommand_night },
  391. { AtCommand_Day, "@day", 80, atcommand_day },
  392. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  393. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  394. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  395. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  396. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  397. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  398. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  400. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  401. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  402. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  403. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  404. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  405. { AtCommand_Party, "@party", 1, atcommand_party },
  406. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  407. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  408. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  409. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  410. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  411. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  412. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  413. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  414. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  415. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  416. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  417. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  418. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  419. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  420. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  421. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  422. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  423. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  424. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  425. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  426. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  427. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  428. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  429. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  430. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  431. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  432. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  433. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  434. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  435. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  436. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  437. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  438. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  440. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  441. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  442. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  443. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  444. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  446. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  447. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  448. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  449. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  450. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  451. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  452. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  453. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  454. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  455. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  456. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  457. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  458. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  459. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  460. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  463. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  464. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  465. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  466. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  467. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  468. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  469. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  470. { AtCommand_JailFor, "@jailfor", 20, atcommand_jailfor }, //Meruru
  471. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime }, //Change this to 0 in atcommand_conf.txt if you want it accessible to players (you most likely will ;))
  472. { AtCommand_CharJailTime, "@charjailtime", 20, atcommand_charjailtime },
  473. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  474. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  475. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  476. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  477. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  478. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  479. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  480. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  481. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  482. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  483. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  484. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  485. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  486. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  487. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  488. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  489. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  490. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  491. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  492. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  493. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  494. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  495. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  496. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  497. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  498. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  499. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  500. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  501. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  502. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  503. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  504. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  505. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  506. { AtCommand_Send, "@send", 60, atcommand_send },
  507. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  508. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  509. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  510. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  511. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken] <- why not? [Skotlex]
  512. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  513. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  514. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  515. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  516. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  517. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  518. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  519. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  520. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  521. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  522. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  523. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  524. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  525. { AtCommand_Users, "@users", 40, atcommand_users },
  526. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  527. #ifndef TXT_ONLY // sql-only commands
  528. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  529. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  530. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  531. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  532. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  533. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  534. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  535. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  536. #endif /* TXT_ONLY */
  537. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  538. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  539. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  540. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  541. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  542. #ifdef DMALLOC
  543. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  544. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  545. #endif
  546. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  547. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  548. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  549. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  550. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  551. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  552. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  553. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  554. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  555. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  556. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  557. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  558. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  559. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  560. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  561. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  562. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  563. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  564. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  565. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  566. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  567. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  568. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  569. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  570. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  571. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  572. { AtCommand_Version, "@version", 1, atcommand_version },
  573. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  574. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  575. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  576. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  577. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  578. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  579. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  580. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  581. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  582. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  583. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  584. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  585. { AtCommand_Size, "@size", 20, atcommand_size },
  586. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  587. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  588. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  589. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  590. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  591. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  592. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  593. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  594. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  595. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  596. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  597. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  598. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  599. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  600. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  601. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  602. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  603. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  604. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  605. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  606. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  607. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  608. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  609. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  610. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  611. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  612. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  613. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  614. { AtCommand_HomTalk, "@homtalk", 0, atcommand_homtalk },
  615. { AtCommand_HomInfo, "@hominfo", 0, atcommand_hominfo },
  616. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  617. // add new commands before this line
  618. { AtCommand_Unknown, NULL, 1, NULL }
  619. };
  620. /*=========================================
  621. * Generic variables
  622. *-----------------------------------------
  623. */
  624. char atcmd_output[200];
  625. char atcmd_player_name[100];
  626. char atcmd_temp[100];
  627. /*==========================================
  628. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  629. *------------------------------------------
  630. */
  631. char *estr_lower(char *str)
  632. {
  633. int i;
  634. for (i=0; str[i]; i++)
  635. if ((str[i] >= 65) && (str[i] <= 90))
  636. str[i] += 32;
  637. return str;
  638. }
  639. // compare function for sorting high to lowest
  640. int hightolow_compare (const void * a, const void * b)
  641. {
  642. return ( *(int*)b - *(int*)a );
  643. }
  644. // compare function for sorting lowest to highest
  645. int lowtohigh_compare (const void * a, const void * b)
  646. {
  647. return ( *(int*)a - *(int*)b );
  648. }
  649. //-----------------------------------------------------------
  650. // Return the message string of the specified number by [Yor]
  651. //-----------------------------------------------------------
  652. char * msg_txt(int msg_number) {
  653. if (msg_number >= 0 && msg_number < MAX_MSG &&
  654. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  655. return msg_table[msg_number];
  656. return "??";
  657. }
  658. //-----------------------------------------------------------
  659. // Returns Players title (from msg_athena.conf) [Lupus]
  660. //-----------------------------------------------------------
  661. char * player_title_txt(int level) {
  662. if (level < battle_config.title_lvl1)
  663. return ""; //w/o any titles
  664. if (level >= battle_config.title_lvl8)
  665. sprintf(atcmd_temp, msg_txt(332), level);
  666. else
  667. if (level >= battle_config.title_lvl7)
  668. sprintf(atcmd_temp, msg_txt(331), level);
  669. else
  670. if (level >= battle_config.title_lvl6)
  671. sprintf(atcmd_temp, msg_txt(330), level);
  672. else
  673. if (level >= battle_config.title_lvl5)
  674. sprintf(atcmd_temp, msg_txt(329), level);
  675. else
  676. if (level >= battle_config.title_lvl4)
  677. sprintf(atcmd_temp, msg_txt(328), level);
  678. else
  679. if (level >= battle_config.title_lvl3)
  680. sprintf(atcmd_temp, msg_txt(327), level);
  681. else
  682. if (level >= battle_config.title_lvl2)
  683. sprintf(atcmd_temp, msg_txt(326), level);
  684. else
  685. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  686. return atcmd_temp;
  687. }
  688. //------------------------------------------------------------
  689. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  690. //------------------------------------------------------------
  691. int e_mail_check(char *email) {
  692. char ch;
  693. char* last_arobas;
  694. // athena limits
  695. if (strlen(email) < 3 || strlen(email) > 39)
  696. return 0;
  697. // part of RFC limits (official reference of e-mail description)
  698. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  699. return 0;
  700. if (email[strlen(email)-1] == '.')
  701. return 0;
  702. last_arobas = strrchr(email, '@');
  703. if (strstr(last_arobas, "@.") != NULL ||
  704. strstr(last_arobas, "..") != NULL)
  705. return 0;
  706. for(ch = 1; ch < 32; ch++) {
  707. if (strchr(last_arobas, ch) != NULL) {
  708. return 0;
  709. break;
  710. }
  711. }
  712. if (strchr(last_arobas, ' ') != NULL ||
  713. strchr(last_arobas, ';') != NULL)
  714. return 0;
  715. // all correct
  716. return 1;
  717. }
  718. /*==========================================
  719. * get_atcommand_level @コマンドの必要レベルを取得
  720. *------------------------------------------
  721. */
  722. int get_atcommand_level(const AtCommandType type) {
  723. int i;
  724. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  725. if (atcommand_info[i].type == type)
  726. return atcommand_info[i].level;
  727. return 100; // 100: command can not be used
  728. }
  729. AtCommandType
  730. atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
  731. AtCommandInfo info;
  732. AtCommandType type;
  733. malloc_set(&info, 0, sizeof(info));
  734. type = atcommand(sd, gmlvl, str, &info);
  735. if (type != AtCommand_None) {
  736. char command[100];
  737. const char* p = str;
  738. if (map[sd->bl.m].nocommand &&
  739. gmlvl < map[sd->bl.m].nocommand)
  740. { //Command not allowed on this map.
  741. sprintf(atcmd_output, msg_txt(143));
  742. clif_displaymessage(fd, atcmd_output);
  743. return AtCommand_None;
  744. }
  745. malloc_tsetdword(command, '\0', sizeof(command));
  746. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  747. while (*p && !isspace(*p))
  748. p++;
  749. if (p - str >= sizeof(command)) // too long
  750. return AtCommand_Unknown;
  751. strncpy(command, str, p - str);
  752. while (isspace(*p))
  753. p++;
  754. if (type == AtCommand_Unknown || info.proc == NULL) {
  755. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  756. clif_displaymessage(fd, atcmd_output);
  757. } else {
  758. if (info.proc(fd, sd, command, p) != 0) {
  759. // Command can not be executed
  760. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  761. clif_displaymessage(fd, atcmd_output);
  762. }
  763. }
  764. return info.type;
  765. }
  766. return AtCommand_None;
  767. }
  768. /*==========================================
  769. *is_atcommand @コマンドに存在するかどうか確認する
  770. *------------------------------------------
  771. */
  772. AtCommandType
  773. is_atcommand(const int fd, struct map_session_data* sd, const char* message) {
  774. const char* str = message;
  775. int s_flag = 0;
  776. nullpo_retr(AtCommand_None, sd);
  777. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  778. return AtCommand_Unknown;
  779. }
  780. if (!message || !*message)
  781. return AtCommand_None;
  782. str += strlen(sd->status.name);
  783. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  784. if (*str == ':')
  785. s_flag = 1;
  786. str++;
  787. }
  788. if (!*str)
  789. return AtCommand_None;
  790. return atcommand_sub(fd,sd,str,pc_isGM(sd));
  791. }
  792. /*==========================================
  793. *
  794. *------------------------------------------
  795. */
  796. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  797. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  798. if (!info)
  799. return AtCommand_None;
  800. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  801. return AtCommand_None;
  802. if (!p || !*p) {
  803. ShowError("at command message is empty\n");
  804. return AtCommand_None;
  805. }
  806. if(p[0] == '|')
  807. p += 3;
  808. if (*p == atcommand_symbol) { // check first char, try to skip |00 (or something else) [Lance]
  809. char command[101];
  810. int i = 0;
  811. malloc_set(info, 0, sizeof(AtCommandInfo));
  812. sscanf(p, "%100s", command);
  813. command[sizeof(command)-1] = '\0';
  814. while (atcommand_info[i].type != AtCommand_Unknown) {
  815. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  816. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  817. break;
  818. }
  819. i++;
  820. }
  821. if (atcommand_info[i].type == AtCommand_Unknown) {
  822. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  823. if (level == 0)
  824. return AtCommand_None;
  825. else
  826. return AtCommand_Unknown;
  827. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  828. log_atcommand(sd, message);
  829. }
  830. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  831. } else {
  832. return AtCommand_None;
  833. }
  834. return info->type;
  835. }
  836. /*==========================================
  837. * Read Message Data
  838. *------------------------------------------
  839. */
  840. int msg_config_read(const char *cfgName) {
  841. int msg_number;
  842. char line[1024], w1[1024], w2[1024];
  843. FILE *fp;
  844. static int called = 1;
  845. if ((fp = fopen(cfgName, "r")) == NULL) {
  846. ShowError("Messages file not found: %s\n", cfgName);
  847. return 1;
  848. }
  849. if ((--called) == 0)
  850. malloc_tsetdword(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  851. while(fgets(line, sizeof(line)-1, fp)) {
  852. if (line[0] == '/' && line[1] == '/')
  853. continue;
  854. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  855. if (strcmpi(w1, "import") == 0) {
  856. msg_config_read(w2);
  857. } else {
  858. msg_number = atoi(w1);
  859. if (msg_number >= 0 && msg_number < MAX_MSG) {
  860. if (msg_table[msg_number] != NULL)
  861. aFree(msg_table[msg_number]);
  862. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  863. strcpy(msg_table[msg_number],w2);
  864. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  865. }
  866. }
  867. }
  868. }
  869. fclose(fp);
  870. return 0;
  871. }
  872. /*==========================================
  873. * Cleanup Message Data
  874. *------------------------------------------
  875. */
  876. void do_final_msg (void) {
  877. int i;
  878. for (i = 0; i < MAX_MSG; i++)
  879. aFree(msg_table[i]);
  880. return;
  881. }
  882. /*==========================================
  883. *
  884. *------------------------------------------
  885. */
  886. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  887. int i;
  888. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  889. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  890. return &atcommand_info[i];
  891. return NULL;
  892. }
  893. /*==========================================
  894. *
  895. *------------------------------------------
  896. */
  897. int atcommand_config_read(const char *cfgName) {
  898. char line[1024], w1[1024], w2[1024];
  899. AtCommandInfo* p;
  900. FILE* fp;
  901. if ((fp = fopen(cfgName, "r")) == NULL) {
  902. ShowError("At commands configuration file not found: %s\n", cfgName);
  903. return 1;
  904. }
  905. while (fgets(line, sizeof(line)-1, fp)) {
  906. if (line[0] == '/' && line[1] == '/')
  907. continue;
  908. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  909. continue;
  910. p = get_atcommandinfo_byname(w1);
  911. if (p != NULL) {
  912. p->level = atoi(w2);
  913. if (p->level > 100)
  914. p->level = 100;
  915. else if (p->level < 0)
  916. p->level = 0;
  917. }
  918. if (strcmpi(w1, "import") == 0)
  919. atcommand_config_read(w2);
  920. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  921. w2[0] != '/' && // symbol of standard ragnarok GM commands
  922. w2[0] != '%' && // symbol of party chat speaking
  923. w2[0] != '$' && // symbol of guild chat
  924. w2[0] != '#') // symbol of charcommand
  925. atcommand_symbol = w2[0];
  926. }
  927. fclose(fp);
  928. return 0;
  929. }
  930. /*==========================================
  931. // @ command processing functions
  932. *------------------------------------------
  933. */
  934. /*==========================================
  935. * @commands Lists available @ commands to you (code 98% from Meruru)
  936. *------------------------------------------
  937. */
  938. int atcommand_commands(
  939. const int fd, struct map_session_data* sd,
  940. const char* command, const char* message)
  941. {
  942. char cz_line_buff[MESSAGE_SIZE+1];
  943. register char *lpcz_cur = cz_line_buff;
  944. register unsigned int ui_slen;
  945. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  946. malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
  947. cz_line_buff[MESSAGE_SIZE] = 0;
  948. clif_displaymessage(fd, msg_txt(273));
  949. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  950. {
  951. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  952. continue;
  953. count++;
  954. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  955. //rember not <= bc we need null terminator
  956. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  957. {
  958. clif_displaymessage(fd,(char*)cz_line_buff);
  959. lpcz_cur = cz_line_buff;
  960. malloc_tsetdword(cz_line_buff,' ',MESSAGE_SIZE);
  961. cz_line_buff[MESSAGE_SIZE] = 0;
  962. }
  963. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  964. lpcz_cur += ui_slen+(10-ui_slen%10);
  965. }
  966. clif_displaymessage(fd,(char*)cz_line_buff);
  967. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  968. clif_displaymessage(fd, atcmd_output);
  969. return 0;
  970. }
  971. /*==========================================
  972. * @send (used for testing packet sends from the client)
  973. *------------------------------------------
  974. */
  975. int atcommand_send(
  976. const int fd, struct map_session_data* sd,
  977. const char* command, const char* message)
  978. {
  979. int len=0,off,end,type;
  980. long num;
  981. (void)command; // not used
  982. // read message type as hex number (without the 0x)
  983. if(!message || !*message ||
  984. !((sscanf(message, "len %x", &type)==1 && (len=1))
  985. || sscanf(message, "%x", &type)==1) )
  986. {
  987. clif_displaymessage(fd, "Usage:");
  988. clif_displaymessage(fd, " @send len <packet hex number>");
  989. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  990. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  991. return -1;
  992. }
  993. #define PARSE_ERROR(error,p) \
  994. {\
  995. clif_displaymessage(fd, (error));\
  996. sprintf(atcmd_output, ">%s", (p));\
  997. clif_displaymessage(fd, atcmd_output);\
  998. }
  999. //define PARSE_ERROR
  1000. #define CHECK_EOS(p) \
  1001. if(*(p) == 0){\
  1002. clif_displaymessage(fd, "Unexpected end of string");\
  1003. return -1;\
  1004. }
  1005. //define CHECK_EOS
  1006. #define SKIP_VALUE(p) \
  1007. {\
  1008. while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
  1009. while(*(p) && isspace(*(p))) ++(p); /* space */\
  1010. }
  1011. //define SKIP_VALUE
  1012. #define GET_VALUE(p,num) \
  1013. {\
  1014. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  1015. PARSE_ERROR("Invalid number in:",(p));\
  1016. return -1;\
  1017. }\
  1018. }
  1019. //define GET_VALUE
  1020. if (type > 0 && type < MAX_PACKET_DB) {
  1021. if(len)
  1022. {// show packet length
  1023. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  1024. clif_displaymessage(fd, atcmd_output);
  1025. return 0;
  1026. }
  1027. len=packet_db[sd->packet_ver][type].len;
  1028. off=2;
  1029. if(len == 0)
  1030. {// unknown packet - ERROR
  1031. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  1032. clif_displaymessage(fd, atcmd_output);
  1033. return -1;
  1034. } else if(len == -1)
  1035. {// dynamic packet
  1036. len=SHRT_MAX-4; // maximum length
  1037. off=4;
  1038. }
  1039. WFIFOHEAD(fd, len);
  1040. WFIFOW(fd,0)=TOW(type);
  1041. // parse packet contents
  1042. SKIP_VALUE(message);
  1043. while(*message != 0 && off < len){
  1044. if(isdigit(*message) || *message == '-' || *message == '+')
  1045. {// default (byte)
  1046. GET_VALUE(message,num);
  1047. WFIFOB(fd,off)=TOB(num);
  1048. ++off;
  1049. } else if(toupper(*message) == 'B')
  1050. {// byte
  1051. ++message;
  1052. GET_VALUE(message,num);
  1053. WFIFOB(fd,off)=TOB(num);
  1054. ++off;
  1055. } else if(toupper(*message) == 'W')
  1056. {// word (2 bytes)
  1057. ++message;
  1058. GET_VALUE(message,num);
  1059. WFIFOW(fd,off)=TOW(num);
  1060. off+=2;
  1061. } else if(toupper(*message) == 'L')
  1062. {// long word (4 bytes)
  1063. ++message;
  1064. GET_VALUE(message,num);
  1065. WFIFOL(fd,off)=TOL(num);
  1066. off+=4;
  1067. } else if(toupper(*message) == 'S')
  1068. {// string - escapes are valid
  1069. // get string length - num <= 0 means not fixed length (default)
  1070. ++message;
  1071. if(*message == '"'){
  1072. num=0;
  1073. } else {
  1074. GET_VALUE(message,num);
  1075. while(*message != '"')
  1076. {// find start of string
  1077. if(*message == 0 || isspace(*message)){
  1078. PARSE_ERROR("Not a string:",message);
  1079. return -1;
  1080. }
  1081. ++message;
  1082. }
  1083. }
  1084. // parse string
  1085. ++message;
  1086. CHECK_EOS(message);
  1087. end=(num<=0? 0: min(off+((int)num),len));
  1088. for(; *message != '"' && (off < end || end == 0); ++off){
  1089. if(*message == '\\'){
  1090. ++message;
  1091. CHECK_EOS(message);
  1092. switch(*message){
  1093. case 'a': num=0x07; break; // Bell
  1094. case 'b': num=0x08; break; // Backspace
  1095. case 't': num=0x09; break; // Horizontal tab
  1096. case 'n': num=0x0A; break; // Line feed
  1097. case 'v': num=0x0B; break; // Vertical tab
  1098. case 'f': num=0x0C; break; // Form feed
  1099. case 'r': num=0x0D; break; // Carriage return
  1100. case 'e': num=0x1B; break; // Escape
  1101. default: num=*message; break;
  1102. case 'x': // Hexadecimal
  1103. {
  1104. ++message;
  1105. CHECK_EOS(message);
  1106. if(!isxdigit(*message)){
  1107. PARSE_ERROR("Not a hexadecimal digit:",message);
  1108. return -1;
  1109. }
  1110. num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1111. if(isxdigit(*message)){
  1112. ++message;
  1113. CHECK_EOS(message);
  1114. num<<=8;
  1115. num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1116. }
  1117. WFIFOB(fd,off)=TOB(num);
  1118. ++message;
  1119. CHECK_EOS(message);
  1120. continue;
  1121. }
  1122. case '0':
  1123. case '1':
  1124. case '2':
  1125. case '3':
  1126. case '4':
  1127. case '5':
  1128. case '6':
  1129. case '7': // Octal
  1130. {
  1131. num=*message-'0'; // 1st octal digit
  1132. ++message;
  1133. CHECK_EOS(message);
  1134. if(isdigit(*message) && *message < '8'){
  1135. num<<=3;
  1136. num+=*message-'0'; // 2nd octal digit
  1137. ++message;
  1138. CHECK_EOS(message);
  1139. if(isdigit(*message) && *message < '8'){
  1140. num<<=3;
  1141. num+=*message-'0'; // 3rd octal digit
  1142. ++message;
  1143. CHECK_EOS(message);
  1144. }
  1145. }
  1146. WFIFOB(fd,off)=TOB(num);
  1147. continue;
  1148. }
  1149. }
  1150. } else
  1151. num=*message;
  1152. WFIFOB(fd,off)=TOB(num);
  1153. ++message;
  1154. CHECK_EOS(message);
  1155. }//for
  1156. while(*message != '"')
  1157. {// ignore extra characters
  1158. ++message;
  1159. CHECK_EOS(message);
  1160. }
  1161. // terminate the string
  1162. if(off < end)
  1163. {// fill the rest with 0's
  1164. memset(WFIFOP(fd,off),0,end-off);
  1165. off=end;
  1166. }
  1167. } else
  1168. {// unknown
  1169. PARSE_ERROR("Unknown type of value in:",message);
  1170. return -1;
  1171. }
  1172. SKIP_VALUE(message);
  1173. }
  1174. if(packet_db[sd->packet_ver][type].len == -1)
  1175. {// send dynamic packet
  1176. WFIFOW(fd,2)=TOW(off);
  1177. WFIFOSET(fd,off);
  1178. } else
  1179. {// send static packet
  1180. if(off < len)
  1181. memset(WFIFOP(fd,off),0,len-off);
  1182. WFIFOSET(fd,len);
  1183. }
  1184. } else {
  1185. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1186. return -1;
  1187. }
  1188. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1189. clif_displaymessage(fd, atcmd_output);
  1190. return 0;
  1191. #undef PARSE_ERROR
  1192. #undef CHECK_EOS
  1193. #undef SKIP_VALUE
  1194. #undef GET_VALUE
  1195. }
  1196. // @rura
  1197. /*==========================================
  1198. *
  1199. *------------------------------------------
  1200. */
  1201. int atcommand_rura(
  1202. const int fd, struct map_session_data* sd,
  1203. const char* command, const char* message)
  1204. {
  1205. char map_name[MAP_NAME_LENGTH];
  1206. unsigned short mapindex;
  1207. int x = 0, y = 0;
  1208. int m = -1;
  1209. nullpo_retr(-1, sd);
  1210. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1211. if (!message || !*message ||
  1212. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1213. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1214. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1215. return -1;
  1216. }
  1217. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1218. strcat(map_name, ".gat");
  1219. mapindex = mapindex_name2id(map_name);
  1220. if (mapindex)
  1221. m = map_mapindex2mapid(mapindex);
  1222. if (!mapindex || m < 0) {
  1223. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1224. return -1;
  1225. }
  1226. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1227. clif_displaymessage(fd, msg_txt(2));
  1228. x = y = 0; //Invalid cell, use random spot.
  1229. }
  1230. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1231. clif_displaymessage(fd, msg_txt(247));
  1232. return -1;
  1233. }
  1234. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1235. clif_displaymessage(fd, msg_txt(248));
  1236. return -1;
  1237. }
  1238. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1239. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1240. else {
  1241. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1242. return -1;
  1243. }
  1244. return 0;
  1245. }
  1246. /*==========================================
  1247. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1248. *------------------------------------------
  1249. */
  1250. int atcommand_where(
  1251. const int fd, struct map_session_data* sd,
  1252. const char* command, const char* message)
  1253. {
  1254. struct map_session_data *pl_sd = NULL;
  1255. int GM_level, pl_GM_level;
  1256. nullpo_retr(-1, sd);
  1257. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1258. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1259. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1260. return -1;
  1261. }
  1262. pl_sd = map_nick2sd(atcmd_player_name);
  1263. if (pl_sd == NULL)
  1264. return -1;
  1265. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1266. return -1;
  1267. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1268. pl_GM_level = pc_isGM(pl_sd);
  1269. if (battle_config.hide_GM_session) {
  1270. if(GM_level < pl_GM_level) {
  1271. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1272. return -1;
  1273. }
  1274. }
  1275. }
  1276. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1277. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1278. clif_displaymessage(fd, atcmd_output);
  1279. return 0;
  1280. }
  1281. /*==========================================
  1282. *
  1283. *------------------------------------------
  1284. */
  1285. int atcommand_jumpto(
  1286. const int fd, struct map_session_data* sd,
  1287. const char* command, const char* message)
  1288. {
  1289. struct map_session_data *pl_sd = NULL;
  1290. nullpo_retr(-1, sd);
  1291. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1292. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1293. return -1;
  1294. }
  1295. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1296. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1297. return -1;
  1298. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1299. return -1;
  1300. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1301. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1302. clif_displaymessage(fd, msg_txt(247));
  1303. return -1;
  1304. }
  1305. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1306. clif_displaymessage(fd, msg_txt(248));
  1307. return -1;
  1308. }
  1309. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1310. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1311. clif_displaymessage(fd, atcmd_output);
  1312. } else {
  1313. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1314. return -1;
  1315. }
  1316. return 0;
  1317. }
  1318. /*==========================================
  1319. *
  1320. *------------------------------------------
  1321. */
  1322. int atcommand_jump(
  1323. const int fd, struct map_session_data* sd,
  1324. const char* command, const char* message)
  1325. {
  1326. int x = 0, y = 0;
  1327. nullpo_retr(-1, sd);
  1328. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1329. sscanf(message, "%d %d", &x, &y);
  1330. if (x <= 0) //If coordinates are 'wrong', random jump.
  1331. x = -1;
  1332. if (y <= 0)
  1333. y = -1;
  1334. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1335. clif_displaymessage(fd, msg_txt(248));
  1336. return -1;
  1337. }
  1338. pc_setpos(sd, sd->mapindex, x, y, 3);
  1339. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1340. clif_displaymessage(fd, atcmd_output);
  1341. return 0;
  1342. }
  1343. /*==========================================
  1344. * @who3 = Player name, his location
  1345. *------------------------------------------
  1346. */
  1347. int atcommand_who3(
  1348. const int fd, struct map_session_data* sd,
  1349. const char* command, const char* message)
  1350. {
  1351. char temp0[100];
  1352. struct map_session_data *pl_sd, **pl_allsd;
  1353. int i, j, count, users;
  1354. int pl_GM_level, GM_level;
  1355. char match_text[100];
  1356. char player_name[NAME_LENGTH];
  1357. nullpo_retr(-1, sd);
  1358. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1359. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1360. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1361. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1362. strcpy(match_text, "");
  1363. for (j = 0; match_text[j]; j++)
  1364. match_text[j] = tolower(match_text[j]);
  1365. count = 0;
  1366. GM_level = pc_isGM(sd);
  1367. pl_allsd = map_getallusers(&users);
  1368. for (i = 0; i < users; i++) {
  1369. if ((pl_sd = pl_allsd[i])) {
  1370. pl_GM_level = pc_isGM(pl_sd);
  1371. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1372. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1373. for (j = 0; player_name[j]; j++)
  1374. player_name[j] = tolower(player_name[j]);
  1375. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1376. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1377. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1378. } else {
  1379. atcmd_output[0]=0;
  1380. }
  1381. //Player name
  1382. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1383. strcat(atcmd_output,temp0);
  1384. //Player title, if exists
  1385. if (pl_GM_level > 0) {
  1386. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1387. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1388. strcat(atcmd_output,temp0);
  1389. }
  1390. //Players Location: map x y
  1391. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1392. strcat(atcmd_output,temp0);
  1393. clif_displaymessage(fd, atcmd_output);
  1394. count++;
  1395. }
  1396. }
  1397. }
  1398. }
  1399. if (count == 0)
  1400. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1401. else if (count == 1)
  1402. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1403. else {
  1404. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1405. clif_displaymessage(fd, atcmd_output);
  1406. }
  1407. return 0;
  1408. }
  1409. /*==========================================
  1410. * Player name, BLevel, Job,
  1411. *------------------------------------------
  1412. */
  1413. int atcommand_who2(
  1414. const int fd, struct map_session_data* sd,
  1415. const char* command, const char* message)
  1416. {
  1417. char temp0[100];
  1418. struct map_session_data *pl_sd, **pl_allsd;
  1419. int i, j, count, users;
  1420. int pl_GM_level, GM_level;
  1421. char match_text[100];
  1422. char player_name[NAME_LENGTH];
  1423. nullpo_retr(-1, sd);
  1424. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1425. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1426. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1427. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1428. strcpy(match_text, "");
  1429. for (j = 0; match_text[j]; j++)
  1430. match_text[j] = tolower(match_text[j]);
  1431. count = 0;
  1432. GM_level = pc_isGM(sd);
  1433. pl_allsd = map_getallusers(&users);
  1434. for (i = 0; i < users; i++) {
  1435. if ((pl_sd = pl_allsd[i])) {
  1436. pl_GM_level = pc_isGM(pl_sd);
  1437. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1438. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1439. for (j = 0; player_name[j]; j++)
  1440. player_name[j] = tolower(player_name[j]);
  1441. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1442. //Players Name
  1443. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1444. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1445. //Player title, if exists
  1446. if (pl_GM_level > 0) {
  1447. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1448. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1449. strcat(atcmd_output,temp0);
  1450. }
  1451. //Players Base Level / Job name
  1452. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1453. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1454. strcat(atcmd_output,temp0);
  1455. clif_displaymessage(fd, atcmd_output);
  1456. count++;
  1457. }
  1458. }
  1459. }
  1460. }
  1461. if (count == 0)
  1462. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1463. else if (count == 1)
  1464. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1465. else {
  1466. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1467. clif_displaymessage(fd, atcmd_output);
  1468. }
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. * Player name, Playrs Party / Guild name
  1473. *------------------------------------------
  1474. */
  1475. int atcommand_who(
  1476. const int fd, struct map_session_data* sd,
  1477. const char* command, const char* message)
  1478. {
  1479. char temp0[100];
  1480. struct map_session_data *pl_sd, **pl_allsd;
  1481. int i, j, count, users;
  1482. int pl_GM_level, GM_level;
  1483. char match_text[100];
  1484. char player_name[NAME_LENGTH];
  1485. struct guild *g;
  1486. struct party_data *p;
  1487. nullpo_retr(-1, sd);
  1488. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1489. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1490. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1491. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1492. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1493. strcpy(match_text, "");
  1494. for (j = 0; match_text[j]; j++)
  1495. match_text[j] = tolower(match_text[j]);
  1496. count = 0;
  1497. GM_level = pc_isGM(sd);
  1498. pl_allsd = map_getallusers(&users);
  1499. for (i = 0; i < users; i++) {
  1500. if ((pl_sd = pl_allsd[i])) {
  1501. pl_GM_level = pc_isGM(pl_sd);
  1502. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1503. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1504. for (j = 0; player_name[j]; j++)
  1505. player_name[j] = tolower(player_name[j]);
  1506. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1507. g = guild_search(pl_sd->status.guild_id);
  1508. p = party_search(pl_sd->status.party_id);
  1509. //Players Name
  1510. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1511. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1512. //Player title, if exists
  1513. if (pl_GM_level > 0) {
  1514. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1515. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1516. strcat(atcmd_output,temp0);
  1517. }
  1518. //Players Party if exists
  1519. if (p != NULL) {
  1520. //sprintf(temp0," | Party: '%s'", p->name);
  1521. sprintf(temp0, msg_txt(335), p->party.name);
  1522. strcat(atcmd_output,temp0);
  1523. }
  1524. //Players Guild if exists
  1525. if (g != NULL) {
  1526. //sprintf(temp0," | Guild: '%s'", g->name);
  1527. sprintf(temp0, msg_txt(336), g->name);
  1528. strcat(atcmd_output,temp0);
  1529. }
  1530. clif_displaymessage(fd, atcmd_output);
  1531. count++;
  1532. }
  1533. }
  1534. }
  1535. }
  1536. if (count == 0)
  1537. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1538. else if (count == 1)
  1539. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1540. else {
  1541. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1542. clif_displaymessage(fd, atcmd_output);
  1543. }
  1544. return 0;
  1545. }
  1546. /*==========================================
  1547. *
  1548. *------------------------------------------
  1549. */
  1550. int atcommand_whomap3(
  1551. const int fd, struct map_session_data* sd,
  1552. const char* command, const char* message)
  1553. {
  1554. struct map_session_data *pl_sd, **pl_allsd;
  1555. int i, count, users;
  1556. int pl_GM_level, GM_level;
  1557. int map_id;
  1558. char map_name[MAP_NAME_LENGTH];
  1559. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1560. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1561. if (!message || !*message)
  1562. map_id = sd->bl.m;
  1563. else {
  1564. sscanf(message, "%15s", map_name);
  1565. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1566. strcat(map_name, ".gat");
  1567. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1568. map_id = sd->bl.m;
  1569. }
  1570. count = 0;
  1571. GM_level = pc_isGM(sd);
  1572. pl_allsd = map_getallusers(&users);
  1573. for (i = 0; i < users; i++) {
  1574. if ((pl_sd = pl_allsd[i])) {
  1575. pl_GM_level = pc_isGM(pl_sd);
  1576. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1577. if (pl_sd->bl.m == map_id) {
  1578. if (pl_GM_level > 0)
  1579. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1580. else
  1581. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1582. clif_displaymessage(fd, atcmd_output);
  1583. count++;
  1584. }
  1585. }
  1586. }
  1587. }
  1588. if (count == 0)
  1589. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1590. else if (count == 1)
  1591. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1592. else {
  1593. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1594. }
  1595. clif_displaymessage(fd, atcmd_output);
  1596. return 0;
  1597. }
  1598. /*==========================================
  1599. *
  1600. *------------------------------------------
  1601. */
  1602. int atcommand_whomap2(
  1603. const int fd, struct map_session_data* sd,
  1604. const char* command, const char* message)
  1605. {
  1606. struct map_session_data *pl_sd, **pl_allsd;
  1607. int i, count, users;
  1608. int pl_GM_level, GM_level;
  1609. int map_id = 0;
  1610. char map_name[MAP_NAME_LENGTH];
  1611. nullpo_retr(-1, sd);
  1612. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1613. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1614. if (!message || !*message)
  1615. map_id = sd->bl.m;
  1616. else {
  1617. sscanf(message, "%15s", map_name);
  1618. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1619. strcat(map_name, ".gat");
  1620. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1621. map_id = sd->bl.m;
  1622. }
  1623. count = 0;
  1624. GM_level = pc_isGM(sd);
  1625. pl_allsd = map_getallusers(&users);
  1626. for (i = 0; i < users; i++) {
  1627. if ((pl_sd = pl_allsd[i])) {
  1628. pl_GM_level = pc_isGM(pl_sd);
  1629. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1630. if (pl_sd->bl.m == map_id) {
  1631. if (pl_GM_level > 0)
  1632. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1633. else
  1634. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1635. clif_displaymessage(fd, atcmd_output);
  1636. count++;
  1637. }
  1638. }
  1639. }
  1640. }
  1641. if (count == 0)
  1642. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1643. else if (count == 1)
  1644. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1645. else {
  1646. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1647. }
  1648. clif_displaymessage(fd, atcmd_output);
  1649. return 0;
  1650. }
  1651. /*==========================================
  1652. *
  1653. *------------------------------------------
  1654. */
  1655. int atcommand_whomap(
  1656. const int fd, struct map_session_data* sd,
  1657. const char* command, const char* message)
  1658. {
  1659. char temp0[100];
  1660. char temp1[100];
  1661. struct map_session_data *pl_sd, **pl_allsd;
  1662. int i, count, users;
  1663. int pl_GM_level, GM_level;
  1664. int map_id = 0;
  1665. char map_name[MAP_NAME_LENGTH];
  1666. struct guild *g;
  1667. struct party_data *p;
  1668. nullpo_retr(-1, sd);
  1669. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1670. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  1671. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1672. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  1673. if (!message || !*message)
  1674. map_id = sd->bl.m;
  1675. else {
  1676. sscanf(message, "%15s", map_name);
  1677. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1678. strcat(map_name, ".gat");
  1679. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1680. map_id = sd->bl.m;
  1681. }
  1682. count = 0;
  1683. GM_level = pc_isGM(sd);
  1684. pl_allsd = map_getallusers(&users);
  1685. for (i = 0; i < users; i++) {
  1686. if ((pl_sd = pl_allsd[i])) {
  1687. pl_GM_level = pc_isGM(pl_sd);
  1688. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1689. if (pl_sd->bl.m == map_id) {
  1690. g = guild_search(pl_sd->status.guild_id);
  1691. if (g == NULL)
  1692. sprintf(temp1, "None");
  1693. else
  1694. sprintf(temp1, "%s", g->name);
  1695. p = party_search(pl_sd->status.party_id);
  1696. if (p == NULL)
  1697. sprintf(temp0, "None");
  1698. else
  1699. sprintf(temp0, "%s", p->party.name);
  1700. if (pl_GM_level > 0)
  1701. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1702. else
  1703. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1704. clif_displaymessage(fd, atcmd_output);
  1705. count++;
  1706. }
  1707. }
  1708. }
  1709. }
  1710. if (count == 0)
  1711. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1712. else if (count == 1)
  1713. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1714. else {
  1715. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1716. }
  1717. clif_displaymessage(fd, atcmd_output);
  1718. return 0;
  1719. }
  1720. /*==========================================
  1721. *
  1722. *------------------------------------------
  1723. */
  1724. int atcommand_whogm(
  1725. const int fd, struct map_session_data* sd,
  1726. const char* command, const char* message)
  1727. {
  1728. char temp0[100];
  1729. char temp1[100];
  1730. struct map_session_data *pl_sd, **pl_allsd;
  1731. int i, j, count, users;
  1732. int pl_GM_level, GM_level;
  1733. char match_text[100];
  1734. char player_name[NAME_LENGTH];
  1735. struct guild *g;
  1736. struct party_data *p;
  1737. nullpo_retr(-1, sd);
  1738. malloc_tsetdword(temp0, '\0', sizeof(temp0));
  1739. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  1740. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1741. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1742. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1743. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1744. strcpy(match_text, "");
  1745. for (j = 0; match_text[j]; j++)
  1746. match_text[j] = tolower(match_text[j]);
  1747. count = 0;
  1748. GM_level = pc_isGM(sd);
  1749. pl_allsd = map_getallusers(&users);
  1750. for (i = 0; i < users; i++) {
  1751. if ((pl_sd = pl_allsd[i])) {
  1752. pl_GM_level = pc_isGM(pl_sd);
  1753. if (pl_GM_level > 0) {
  1754. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1755. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1756. for (j = 0; player_name[j]; j++)
  1757. player_name[j] = tolower(player_name[j]);
  1758. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1759. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1760. clif_displaymessage(fd, atcmd_output);
  1761. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1762. clif_displaymessage(fd, atcmd_output);
  1763. g = guild_search(pl_sd->status.guild_id);
  1764. if (g == NULL)
  1765. sprintf(temp1, "None");
  1766. else
  1767. sprintf(temp1, "%s", g->name);
  1768. p = party_search(pl_sd->status.party_id);
  1769. if (p == NULL)
  1770. sprintf(temp0, "None");
  1771. else
  1772. sprintf(temp0, "%s", p->party.name);
  1773. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1774. clif_displaymessage(fd, atcmd_output);
  1775. count++;
  1776. }
  1777. }
  1778. }
  1779. }
  1780. }
  1781. if (count == 0)
  1782. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1783. else if (count == 1)
  1784. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1785. else {
  1786. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1787. clif_displaymessage(fd, atcmd_output);
  1788. }
  1789. return 0;
  1790. }
  1791. int atcommand_whozeny(
  1792. const int fd, struct map_session_data* sd,
  1793. const char* command, const char* message)
  1794. {
  1795. struct map_session_data *pl_sd, **pl_allsd;
  1796. int i, j, count,c, users;
  1797. char match_text[100];
  1798. char player_name[NAME_LENGTH];
  1799. int *zeny;
  1800. int *counted;
  1801. nullpo_retr(-1, sd);
  1802. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1803. malloc_tsetdword(match_text, '\0', sizeof(match_text));
  1804. malloc_tsetdword(player_name, '\0', sizeof(player_name));
  1805. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1806. strcpy(match_text, "");
  1807. for (j = 0; match_text[j]; j++)
  1808. match_text[j] = tolower(match_text[j]);
  1809. count = 0;
  1810. pl_allsd = map_getallusers(&users);
  1811. if (users < 1)
  1812. {
  1813. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1814. return 0;
  1815. }
  1816. zeny = (int *)aMallocA(users*sizeof(int));
  1817. counted = (int *)aMallocA(users*sizeof(int));
  1818. for (i = 0; i < users; i++) {
  1819. if ((pl_sd = pl_allsd[i])) {
  1820. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1821. for (j = 0; player_name[j]; j++)
  1822. player_name[j] = tolower(player_name[j]);
  1823. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1824. zeny[count]=pl_sd->status.zeny;
  1825. counted[i]=0;
  1826. count++;
  1827. }
  1828. }
  1829. }
  1830. qsort(zeny, count, sizeof(int), hightolow_compare);
  1831. for (c = 0; c < count && c < 50; c++) {
  1832. if(!zeny[c])
  1833. continue;
  1834. for (i = 0; i < users; i++) {
  1835. if(!zeny[c])
  1836. continue;
  1837. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1838. if(pl_sd->status.zeny==zeny[c]) {
  1839. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1840. clif_displaymessage(fd, atcmd_output);
  1841. zeny[c]=0;
  1842. counted[i]=1;
  1843. }
  1844. }
  1845. }
  1846. }
  1847. if (count == 0)
  1848. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1849. else if (count == 1)
  1850. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1851. else {
  1852. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1853. clif_displaymessage(fd, atcmd_output);
  1854. }
  1855. aFree(zeny);
  1856. aFree(counted);
  1857. return 0;
  1858. }
  1859. // cause random emote on all online players [Valaris]
  1860. int atcommand_happyhappyjoyjoy(
  1861. const int fd, struct map_session_data* sd,
  1862. const char* command, const char* message)
  1863. {
  1864. struct map_session_data *pl_sd, **pl_allsd;
  1865. int i,e, users;
  1866. nullpo_retr(-1, sd);
  1867. pl_allsd = map_getallusers(&users);
  1868. for (i = 0; i < users; i++) {
  1869. if ((pl_sd = pl_allsd[i])) {
  1870. e=rand()%40;
  1871. if(e==34)
  1872. e = 0;
  1873. clif_emotion(&pl_sd->bl,e);
  1874. }
  1875. }
  1876. return 0;
  1877. }
  1878. /*==========================================
  1879. *
  1880. *------------------------------------------
  1881. */
  1882. int atcommand_save(
  1883. const int fd, struct map_session_data* sd,
  1884. const char* command, const char* message)
  1885. {
  1886. nullpo_retr(-1, sd);
  1887. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1888. if (sd->status.pet_id > 0 && sd->pd)
  1889. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1890. chrif_save(sd,0);
  1891. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1892. return 0;
  1893. }
  1894. /*==========================================
  1895. *
  1896. *------------------------------------------
  1897. */
  1898. int atcommand_load(
  1899. const int fd, struct map_session_data* sd,
  1900. const char* command, const char* message)
  1901. {
  1902. int m;
  1903. nullpo_retr(-1, sd);
  1904. m = map_mapindex2mapid(sd->status.save_point.map);
  1905. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1906. clif_displaymessage(fd, msg_txt(249));
  1907. return -1;
  1908. }
  1909. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1910. clif_displaymessage(fd, msg_txt(248));
  1911. return -1;
  1912. }
  1913. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1914. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1915. return 0;
  1916. }
  1917. /*==========================================
  1918. *
  1919. *------------------------------------------
  1920. */
  1921. int atcommand_speed(
  1922. const int fd, struct map_session_data* sd,
  1923. const char* command, const char* message)
  1924. {
  1925. int speed;
  1926. nullpo_retr(-1, sd);
  1927. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1928. if (!message || !*message) {
  1929. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1930. clif_displaymessage(fd, atcmd_output);
  1931. return -1;
  1932. }
  1933. speed = atoi(message);
  1934. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1935. sd->base_status.speed = speed;
  1936. status_calc_bl(&sd->bl, SCB_SPEED);
  1937. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1938. } else {
  1939. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1940. clif_displaymessage(fd, atcmd_output);
  1941. return -1;
  1942. }
  1943. return 0;
  1944. }
  1945. /*==========================================
  1946. *
  1947. *------------------------------------------
  1948. */
  1949. int atcommand_charspeed(
  1950. const int fd, struct map_session_data* sd,
  1951. const char* command, const char* message)
  1952. {
  1953. struct map_session_data *pl_sd;
  1954. int speed;
  1955. nullpo_retr(-1, sd);
  1956. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  1957. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1958. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1959. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1960. clif_displaymessage(fd, atcmd_output);
  1961. return -1;
  1962. }
  1963. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1964. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1965. return -1;
  1966. }
  1967. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1968. { //GM level check
  1969. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1970. return -1;
  1971. }
  1972. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1973. pl_sd->base_status.speed = speed;
  1974. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1975. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1976. if(pl_sd->fd)
  1977. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1978. } else {
  1979. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1980. clif_displaymessage(fd, atcmd_output);
  1981. return -1;
  1982. }
  1983. return 0;
  1984. }
  1985. /*==========================================
  1986. *
  1987. *------------------------------------------
  1988. */
  1989. int atcommand_storage(
  1990. const int fd, struct map_session_data* sd,
  1991. const char* command, const char* message)
  1992. {
  1993. nullpo_retr(-1, sd);
  1994. if (storage_storageopen(sd) == 1)
  1995. { //Already open.
  1996. clif_displaymessage(fd, msg_txt(250));
  1997. return -1;
  1998. }
  1999. return 0;
  2000. }
  2001. /*==========================================
  2002. *
  2003. *------------------------------------------
  2004. */
  2005. int atcommand_guildstorage(
  2006. const int fd, struct map_session_data* sd,
  2007. const char* command, const char* message)
  2008. {
  2009. struct storage *stor; //changes from Freya/Yor
  2010. nullpo_retr(-1, sd);
  2011. if (sd->status.guild_id > 0) {
  2012. if (sd->state.storage_flag) {
  2013. clif_displaymessage(fd, msg_txt(251));
  2014. return -1;
  2015. }
  2016. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  2017. clif_displaymessage(fd, msg_txt(251));
  2018. return -1;
  2019. }
  2020. storage_guild_storageopen(sd);
  2021. } else {
  2022. clif_displaymessage(fd, msg_txt(252));
  2023. return -1;
  2024. }
  2025. return 0;
  2026. }
  2027. /*==========================================
  2028. *
  2029. *------------------------------------------
  2030. */
  2031. int atcommand_option(
  2032. const int fd, struct map_session_data* sd,
  2033. const char* command, const char* message)
  2034. {
  2035. int param1 = 0, param2 = 0, param3 = 0;
  2036. nullpo_retr(-1, sd);
  2037. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  2038. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  2039. return -1;
  2040. }
  2041. sd->sc.opt1 = param1;
  2042. sd->sc.opt2 = param2;
  2043. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  2044. clif_cartlist(sd);
  2045. clif_updatestatus(sd, SP_CARTINFO);
  2046. }
  2047. pc_setoption(sd, param3);
  2048. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  2049. return 0;
  2050. }
  2051. /*==========================================
  2052. *
  2053. *------------------------------------------
  2054. */
  2055. int atcommand_hide(
  2056. const int fd, struct map_session_data* sd,
  2057. const char* command, const char* message)
  2058. {
  2059. nullpo_retr(-1, sd);
  2060. if (sd->sc.option & OPTION_INVISIBLE) {
  2061. sd->sc.option &= ~OPTION_INVISIBLE;
  2062. if (sd->disguise)
  2063. status_set_viewdata(&sd->bl, sd->disguise);
  2064. else
  2065. status_set_viewdata(&sd->bl, sd->status.class_);
  2066. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2067. } else {
  2068. sd->sc.option |= OPTION_INVISIBLE;
  2069. sd->vd.class_ = INVISIBLE_CLASS;
  2070. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2071. }
  2072. clif_changeoption(&sd->bl);
  2073. return 0;
  2074. }
  2075. /*==========================================
  2076. * 転職する upperを指定すると転生や養子にもなれる
  2077. *------------------------------------------
  2078. */
  2079. int atcommand_jobchange(
  2080. const int fd, struct map_session_data* sd,
  2081. const char* command, const char* message)
  2082. {
  2083. int job = 0, upper = 0;
  2084. nullpo_retr(-1, sd);
  2085. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2086. int i, found = 0;
  2087. const struct { char name[16]; int id; } jobs[] = {
  2088. { "novice", 0 },
  2089. { "swordsman", 1 },
  2090. { "mage", 2 },
  2091. { "archer", 3 },
  2092. { "acolyte", 4 },
  2093. { "merchant", 5 },
  2094. { "thief", 6 },
  2095. { "knight", 7 },
  2096. { "priest", 8 },
  2097. { "priestess", 8 },
  2098. { "wizard", 9 },
  2099. { "blacksmith", 10 },
  2100. { "hunter", 11 },
  2101. { "assassin", 12 },
  2102. { "crusader", 14 },
  2103. { "monk", 15 },
  2104. { "sage", 16 },
  2105. { "rogue", 17 },
  2106. { "alchemist", 18 },
  2107. { "bard", 19 },
  2108. { "dancer", 20 },
  2109. { "super novice", 23 },
  2110. { "supernovice", 23 },
  2111. { "gunslinger", 24 },
  2112. { "gunner", 24 },
  2113. { "ninja", 25 },
  2114. { "high novice", 4001 },
  2115. { "swordsman high", 4002 },
  2116. { "mage high", 4003 },
  2117. { "archer high", 4004 },
  2118. { "acolyte high", 4005 },
  2119. { "merchant high", 4006 },
  2120. { "thief high", 4007 },
  2121. { "lord knight", 4008 },
  2122. { "high priest", 4009 },
  2123. { "high priestess", 4009 },
  2124. { "high wizard", 4010 },
  2125. { "whitesmith", 4011 },
  2126. { "sniper", 4012 },
  2127. { "assassin cross", 4013 },
  2128. { "paladin", 4015 },
  2129. { "champion", 4016 },
  2130. { "professor", 4017 },
  2131. { "stalker", 4018 },
  2132. { "creator", 4019 },
  2133. { "clown", 4020 },
  2134. { "gypsy", 4021 },
  2135. { "baby novice", 4023 },
  2136. { "baby swordsman", 4024 },
  2137. { "baby mage", 4025 },
  2138. { "baby archer", 4026 },
  2139. { "baby acolyte", 4027 },
  2140. { "baby merchant", 4028 },
  2141. { "baby thief", 4029 },
  2142. { "baby knight", 4030 },
  2143. { "baby priest", 4031 },
  2144. { "baby priestess", 4031 },
  2145. { "baby wizard", 4032 },
  2146. { "baby blacksmith",4033 },
  2147. { "baby hunter", 4034 },
  2148. { "baby assassin", 4035 },
  2149. { "baby crusader", 4037 },
  2150. { "baby monk", 4038 },
  2151. { "baby sage", 4039 },
  2152. { "baby rogue", 4040 },
  2153. { "baby alchemist", 4041 },
  2154. { "baby bard", 4042 },
  2155. { "baby dancer", 4043 },
  2156. { "super baby", 4045 },
  2157. { "taekwon", 4046 },
  2158. { "taekwon boy", 4046 },
  2159. { "taekwon girl", 4046 },
  2160. { "star gladiator", 4047 },
  2161. { "soul linker", 4049 },
  2162. };
  2163. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2164. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2165. job = jobs[i].id;
  2166. upper = 0;
  2167. found = 1;
  2168. break;
  2169. }
  2170. }
  2171. if (!found) {
  2172. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2173. return -1;
  2174. }
  2175. }
  2176. if (job == 37 ||job == 45)
  2177. return 0;
  2178. if ((job >= 0 && job < MAX_PC_CLASS))
  2179. {
  2180. int j;
  2181. for (j=0; j < MAX_INVENTORY; j++) {
  2182. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2183. pc_unequipitem(sd, j, 3);
  2184. }
  2185. if (pc_jobchange(sd, job, upper) == 0)
  2186. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2187. else {
  2188. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2189. return -1;
  2190. }
  2191. } else {
  2192. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2193. return -1;
  2194. }
  2195. return 0;
  2196. }
  2197. /*==========================================
  2198. *
  2199. *------------------------------------------
  2200. */
  2201. int atcommand_die(
  2202. const int fd, struct map_session_data* sd,
  2203. const char* command, const char* message)
  2204. {
  2205. nullpo_retr(-1, sd);
  2206. clif_specialeffect(&sd->bl,450,SELF);
  2207. status_kill(&sd->bl);
  2208. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2209. return 0;
  2210. }
  2211. /*==========================================
  2212. *
  2213. *------------------------------------------
  2214. */
  2215. int atcommand_kill(
  2216. const int fd, struct map_session_data* sd,
  2217. const char* command, const char* message)
  2218. {
  2219. struct map_session_data *pl_sd;
  2220. nullpo_retr(-1, sd);
  2221. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2222. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2223. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2224. return -1;
  2225. }
  2226. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2227. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2228. status_kill(&pl_sd->bl);
  2229. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2230. } else {
  2231. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2232. return -1;
  2233. }
  2234. } else {
  2235. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2236. return -1;
  2237. }
  2238. return 0;
  2239. }
  2240. /*==========================================
  2241. *
  2242. *------------------------------------------
  2243. */
  2244. int atcommand_alive(
  2245. const int fd, struct map_session_data* sd,
  2246. const char* command, const char* message)
  2247. {
  2248. nullpo_retr(-1, sd);
  2249. if (!status_revive(&sd->bl, 100, 100))
  2250. return -1;
  2251. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2252. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2253. return 0;
  2254. }
  2255. /*==========================================
  2256. * +kamic [LuzZza]
  2257. *------------------------------------------
  2258. */
  2259. int atcommand_kami(
  2260. const int fd, struct map_session_data* sd,
  2261. const char* command, const char* message)
  2262. {
  2263. unsigned long color=0;
  2264. nullpo_retr(-1, sd);
  2265. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2266. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2267. if (!message || !*message) {
  2268. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2269. return -1;
  2270. }
  2271. sscanf(message, "%199[^\n]", atcmd_output);
  2272. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2273. } else {
  2274. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2275. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2276. return -1;
  2277. }
  2278. if(color > 0xFFFFFF) {
  2279. clif_displaymessage(fd, "Invalid color.");
  2280. return -1;
  2281. }
  2282. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2283. }
  2284. return 0;
  2285. }
  2286. /*==========================================
  2287. *
  2288. *------------------------------------------
  2289. */
  2290. int atcommand_heal(
  2291. const int fd, struct map_session_data* sd,
  2292. const char* command, const char* message)
  2293. {
  2294. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2295. nullpo_retr(-1, sd);
  2296. sscanf(message, "%d %d", &hp, &sp);
  2297. if (hp == 0 && sp == 0) {
  2298. if (!status_percent_heal(&sd->bl, 100, 100))
  2299. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2300. else
  2301. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2302. return 0;
  2303. }
  2304. if(hp > 0 && sp >= 0) {
  2305. if(!status_heal(&sd->bl, hp, sp, 0))
  2306. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2307. else
  2308. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2309. return 0;
  2310. }
  2311. if(hp < 0 && sp <= 0) {
  2312. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2313. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2314. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2315. return 0;
  2316. }
  2317. //Opposing signs.
  2318. if (hp) {
  2319. if (hp > 0)
  2320. status_heal(&sd->bl, hp, 0, 0);
  2321. else {
  2322. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2323. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2324. }
  2325. }
  2326. if (sp) {
  2327. if (sp > 0)
  2328. status_heal(&sd->bl, 0, sp, 0);
  2329. else
  2330. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2331. }
  2332. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2337. *------------------------------------------
  2338. */
  2339. int atcommand_item(
  2340. const int fd, struct map_session_data* sd,
  2341. const char* command, const char* message)
  2342. {
  2343. char item_name[100];
  2344. int number = 0, item_id, flag;
  2345. struct item item_tmp;
  2346. struct item_data *item_data;
  2347. int get_count, i;
  2348. nullpo_retr(-1, sd);
  2349. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  2350. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2351. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2352. return -1;
  2353. }
  2354. if (number <= 0)
  2355. number = 1;
  2356. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2357. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2358. {
  2359. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2360. return -1;
  2361. }
  2362. item_id = item_data->nameid;
  2363. get_count = number;
  2364. //Check if it's stackable.
  2365. if (!itemdb_isstackable2(item_data))
  2366. get_count = 1;
  2367. for (i = 0; i < number; i += get_count) {
  2368. // if not pet egg
  2369. if (!pet_create_egg(sd, item_id)) {
  2370. malloc_set(&item_tmp, 0, sizeof(item_tmp));
  2371. item_tmp.nameid = item_id;
  2372. item_tmp.identify = 1;
  2373. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2374. clif_additem(sd, 0, 0, flag);
  2375. }
  2376. }
  2377. //Logs (A)dmins items [Lupus]
  2378. if(log_config.enable_logs&0x400)
  2379. log_pick_pc(sd, "A", item_id, number, NULL);
  2380. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2381. return 0;
  2382. }
  2383. /*==========================================
  2384. *
  2385. *------------------------------------------
  2386. */
  2387. int atcommand_item2(
  2388. const int fd, struct map_session_data* sd,
  2389. const char* command, const char* message)
  2390. {
  2391. struct item item_tmp;
  2392. struct item_data *item_data;
  2393. char item_name[100];
  2394. int item_id, number = 0;
  2395. int identify = 0, refine = 0, attr = 0;
  2396. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2397. int flag;
  2398. int loop, get_count, i;
  2399. nullpo_retr(-1, sd);
  2400. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  2401. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2402. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2403. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2404. return -1;
  2405. }
  2406. if (number <= 0)
  2407. number = 1;
  2408. item_id = 0;
  2409. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2410. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2411. item_id = item_data->nameid;
  2412. if (item_id > 500) {
  2413. loop = 1;
  2414. get_count = number;
  2415. if (item_data->type == 4 || item_data->type == 5 ||
  2416. item_data->type == 7 || item_data->type == 8) {
  2417. loop = number;
  2418. get_count = 1;
  2419. if (item_data->type == 7) {
  2420. identify = 1;
  2421. refine = 0;
  2422. }
  2423. if (item_data->type == 8)
  2424. refine = 0;
  2425. if (refine > 10)
  2426. refine = 10;
  2427. } else {
  2428. identify = 1;
  2429. refine = attr = 0;
  2430. }
  2431. for (i = 0; i < loop; i++) {
  2432. malloc_set(&item_tmp, 0, sizeof(item_tmp));
  2433. item_tmp.nameid = item_id;
  2434. item_tmp.identify = identify;
  2435. item_tmp.refine = refine;
  2436. item_tmp.attribute = attr;
  2437. item_tmp.card[0] = c1;
  2438. item_tmp.card[1] = c2;
  2439. item_tmp.card[2] = c3;
  2440. item_tmp.card[3] = c4;
  2441. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2442. clif_additem(sd, 0, 0, flag);
  2443. }
  2444. //Logs (A)dmins items [Lupus]
  2445. if(log_config.enable_logs&0x400)
  2446. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2447. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2448. } else {
  2449. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2450. return -1;
  2451. }
  2452. return 0;
  2453. }
  2454. /*==========================================
  2455. *
  2456. *------------------------------------------
  2457. */
  2458. int atcommand_itemreset(
  2459. const int fd, struct map_session_data* sd,
  2460. const char* command, const char* message)
  2461. {
  2462. int i;
  2463. nullpo_retr(-1, sd);
  2464. for (i = 0; i < MAX_INVENTORY; i++) {
  2465. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2466. //Logs (A)dmins items [Lupus]
  2467. if(log_config.enable_logs&0x400)
  2468. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2469. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2470. }
  2471. }
  2472. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2473. return 0;
  2474. }
  2475. /*==========================================
  2476. * Atcommand @lvlup
  2477. *------------------------------------------
  2478. */
  2479. int atcommand_baselevelup(
  2480. const int fd, struct map_session_data* sd,
  2481. const char* command, const char* message)
  2482. {
  2483. int level=0, i=0, status_point=0;
  2484. nullpo_retr(-1, sd);
  2485. level = atoi(message);
  2486. if (!message || !*message || !level) {
  2487. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2488. return -1;
  2489. }
  2490. if (level > 0) {
  2491. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2492. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2493. return -1;
  2494. } /* End Addition */
  2495. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2496. level = pc_maxbaselv(sd) - sd->status.base_level;
  2497. for (i = 1; i <= level; i++)
  2498. status_point += (sd->status.base_level + i + 14) / 5;
  2499. if (sd->status.status_point > USHRT_MAX - status_point)
  2500. sd->status.status_point = USHRT_MAX;
  2501. else
  2502. sd->status.status_point += status_point;
  2503. sd->status.base_level += (unsigned int)level;
  2504. clif_updatestatus(sd, SP_BASELEVEL);
  2505. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2506. clif_updatestatus(sd, SP_STATUSPOINT);
  2507. status_calc_pc(sd, 0);
  2508. status_percent_heal(&sd->bl, 100, 100);
  2509. clif_misceffect(&sd->bl, 0);
  2510. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2511. } else {
  2512. if (sd->status.base_level == 1) {
  2513. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2514. return -1;
  2515. }
  2516. level*=-1;
  2517. if ((unsigned int)level >= sd->status.base_level)
  2518. level = sd->status.base_level-1;
  2519. if (sd->status.status_point > 0) {
  2520. for (i = 0; i > -level; i--)
  2521. status_point += (sd->status.base_level + i + 14) / 5;
  2522. if (sd->status.status_point < status_point)
  2523. pc_resetstate(sd);
  2524. if (sd->status.status_point < status_point)
  2525. sd->status.status_point = 0;
  2526. else
  2527. sd->status.status_point -= status_point;
  2528. clif_updatestatus(sd, SP_STATUSPOINT);
  2529. } /* to add: remove status points from stats */
  2530. sd->status.base_level -= (unsigned int)level;
  2531. clif_updatestatus(sd, SP_BASELEVEL);
  2532. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2533. status_calc_pc(sd, 0);
  2534. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2535. }
  2536. return 0;
  2537. }
  2538. /*==========================================
  2539. *
  2540. *------------------------------------------
  2541. */
  2542. int atcommand_joblevelup(
  2543. const int fd, struct map_session_data* sd,
  2544. const char* command, const char* message)
  2545. {
  2546. int level=0;
  2547. nullpo_retr(-1, sd);
  2548. level = atoi(message);
  2549. if (!message || !*message || !level) {
  2550. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2551. return -1;
  2552. }
  2553. if (level > 0) {
  2554. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2555. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2556. return -1;
  2557. }
  2558. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2559. level = pc_maxjoblv(sd) - sd->status.job_level;
  2560. sd->status.job_level += (unsigned int)level;
  2561. clif_updatestatus(sd, SP_JOBLEVEL);
  2562. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2563. if (sd->status.skill_point > USHRT_MAX - level)
  2564. sd->status.skill_point = USHRT_MAX;
  2565. else
  2566. sd->status.skill_point += level;
  2567. clif_updatestatus(sd, SP_SKILLPOINT);
  2568. status_calc_pc(sd, 0);
  2569. clif_misceffect(&sd->bl, 1);
  2570. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2571. } else {
  2572. if (sd->status.job_level == 1) {
  2573. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2574. return -1;
  2575. }
  2576. level *=-1;
  2577. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2578. level = sd->status.job_level-1;
  2579. sd->status.job_level -= (unsigned int)level;
  2580. clif_updatestatus(sd, SP_JOBLEVEL);
  2581. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2582. if (sd->status.skill_point < level)
  2583. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2584. if (sd->status.skill_point < level)
  2585. sd->status.skill_point = 0;
  2586. else
  2587. sd->status.skill_point -= level;
  2588. clif_updatestatus(sd, SP_SKILLPOINT);
  2589. status_calc_pc(sd, 0);
  2590. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2591. }
  2592. return 0;
  2593. }
  2594. /*==========================================
  2595. * @help
  2596. *------------------------------------------
  2597. */
  2598. int atcommand_help(
  2599. const int fd, struct map_session_data* sd,
  2600. const char* command, const char* message)
  2601. {
  2602. char buf[2048], w1[2048], w2[2048];
  2603. int i, gm_level;
  2604. FILE* fp;
  2605. nullpo_retr(-1, sd);
  2606. malloc_tsetdword(buf, '\0', sizeof(buf));
  2607. if ((fp = fopen(help_txt, "r")) != NULL) {
  2608. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2609. gm_level = pc_isGM(sd);
  2610. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2611. if (buf[0] == '/' && buf[1] == '/')
  2612. continue;
  2613. for (i = 0; buf[i] != '\0'; i++) {
  2614. if (buf[i] == '\r' || buf[i] == '\n') {
  2615. buf[i] = '\0';
  2616. break;
  2617. }
  2618. }
  2619. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2620. clif_displaymessage(fd, buf);
  2621. else if (gm_level >= atoi(w1))
  2622. clif_displaymessage(fd, w2);
  2623. }
  2624. fclose(fp);
  2625. } else {
  2626. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2627. return -1;
  2628. }
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. * @help2 - Char commands [Kayla]
  2633. *------------------------------------------
  2634. */
  2635. int atcommand_help2(
  2636. const int fd, struct map_session_data* sd,
  2637. const char* command, const char* message)
  2638. {
  2639. char buf[2048], w1[2048], w2[2048];
  2640. int i, gm_level;
  2641. FILE* fp;
  2642. nullpo_retr(-1, sd);
  2643. malloc_tsetdword(buf, '\0', sizeof(buf));
  2644. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2645. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2646. gm_level = pc_isGM(sd);
  2647. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2648. if (buf[0] == '/' && buf[1] == '/')
  2649. continue;
  2650. for (i = 0; buf[i] != '\0'; i++) {
  2651. if (buf[i] == '\r' || buf[i] == '\n') {
  2652. buf[i] = '\0';
  2653. break;
  2654. }
  2655. }
  2656. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2657. clif_displaymessage(fd, buf);
  2658. else if (gm_level >= atoi(w1))
  2659. clif_displaymessage(fd, w2);
  2660. }
  2661. fclose(fp);
  2662. } else {
  2663. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2664. return -1;
  2665. }
  2666. return 0;
  2667. }
  2668. /*==========================================
  2669. * @gm
  2670. *------------------------------------------
  2671. */
  2672. int atcommand_gm(
  2673. const int fd, struct map_session_data* sd,
  2674. const char* command, const char* message)
  2675. {
  2676. char password[100];
  2677. nullpo_retr(-1, sd);
  2678. malloc_tsetdword(password, '\0', sizeof(password));
  2679. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2680. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2681. return -1;
  2682. }
  2683. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2684. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2685. return -1;
  2686. } else
  2687. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2688. return 0;
  2689. }
  2690. /*==========================================
  2691. *
  2692. *------------------------------------------
  2693. */
  2694. int atcommand_pvpoff(
  2695. const int fd, struct map_session_data* sd,
  2696. const char* command, const char* message)
  2697. {
  2698. struct map_session_data *pl_sd, **pl_allsd;
  2699. int i, users;
  2700. nullpo_retr(-1, sd);
  2701. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2702. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2703. return -1;
  2704. }
  2705. if (map[sd->bl.m].flag.pvp) {
  2706. map[sd->bl.m].flag.pvp = 0;
  2707. clif_send0199(sd->bl.m, 0);
  2708. pl_allsd = map_getallusers(&users);
  2709. for (i = 0; i < users; i++) { //人数分ループ
  2710. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2711. clif_pvpset(pl_sd, 0, 0, 2);
  2712. if (pl_sd->pvp_timer != -1) {
  2713. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2714. pl_sd->pvp_timer = -1;
  2715. }
  2716. }
  2717. }
  2718. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2719. } else {
  2720. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2721. return -1;
  2722. }
  2723. return 0;
  2724. }
  2725. /*==========================================
  2726. *
  2727. *------------------------------------------
  2728. */
  2729. int atcommand_pvpon(
  2730. const int fd, struct map_session_data* sd,
  2731. const char* command, const char* message)
  2732. {
  2733. struct map_session_data *pl_sd, **pl_allsd;
  2734. int i, users;
  2735. nullpo_retr(-1, sd);
  2736. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2737. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2738. return -1;
  2739. }
  2740. if (!map[sd->bl.m].flag.pvp) {
  2741. map[sd->bl.m].flag.pvp = 1;
  2742. clif_send0199(sd->bl.m, 1);
  2743. pl_allsd = map_getallusers(&users);
  2744. for (i = 0; i < users; i++) {
  2745. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2746. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2747. pl_sd->pvp_rank = 0;
  2748. pl_sd->pvp_lastusers = 0;
  2749. pl_sd->pvp_point = 5;
  2750. pl_sd->pvp_won = 0;
  2751. pl_sd->pvp_lost = 0;
  2752. }
  2753. }
  2754. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2755. } else {
  2756. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2757. return -1;
  2758. }
  2759. return 0;
  2760. }
  2761. /*==========================================
  2762. *
  2763. *------------------------------------------
  2764. */
  2765. int atcommand_gvgoff(
  2766. const int fd, struct map_session_data* sd,
  2767. const char* command, const char* message)
  2768. {
  2769. nullpo_retr(-1, sd);
  2770. if (map[sd->bl.m].flag.gvg) {
  2771. map[sd->bl.m].flag.gvg = 0;
  2772. clif_send0199(sd->bl.m, 0);
  2773. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2774. } else {
  2775. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2776. return -1;
  2777. }
  2778. return 0;
  2779. }
  2780. /*==========================================
  2781. *
  2782. *------------------------------------------
  2783. */
  2784. int atcommand_gvgon(
  2785. const int fd, struct map_session_data* sd,
  2786. const char* command, const char* message)
  2787. {
  2788. nullpo_retr(-1, sd);
  2789. if (!map[sd->bl.m].flag.gvg) {
  2790. map[sd->bl.m].flag.gvg = 1;
  2791. clif_send0199(sd->bl.m, 3);
  2792. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2793. } else {
  2794. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2795. return -1;
  2796. }
  2797. return 0;
  2798. }
  2799. /*==========================================
  2800. *
  2801. *------------------------------------------
  2802. */
  2803. int atcommand_model(
  2804. const int fd, struct map_session_data* sd,
  2805. const char* command, const char* message)
  2806. {
  2807. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2808. nullpo_retr(-1, sd);
  2809. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2810. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2811. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2812. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2813. clif_displaymessage(fd, atcmd_output);
  2814. return -1;
  2815. }
  2816. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2817. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2818. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2819. /* Removed because this check is TOO strange. [Skotlex]
  2820. //秒フ色変更
  2821. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2822. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2823. //秒フ色未実装職の判定
  2824. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2825. return -1;
  2826. } else {
  2827. */
  2828. pc_changelook(sd, LOOK_HAIR, hair_style);
  2829. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2830. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2831. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2832. // }
  2833. } else {
  2834. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2835. return -1;
  2836. }
  2837. return 0;
  2838. }
  2839. /*==========================================
  2840. * @dye && @ccolor
  2841. *------------------------------------------
  2842. */
  2843. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2844. {
  2845. int cloth_color = 0;
  2846. nullpo_retr(-1, sd);
  2847. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2848. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2849. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2850. clif_displaymessage(fd, atcmd_output);
  2851. return -1;
  2852. }
  2853. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2854. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2855. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2856. } else {
  2857. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2858. return -1;
  2859. }
  2860. return 0;
  2861. }
  2862. /*==========================================
  2863. * @hairstyle && @hstyle
  2864. *------------------------------------------
  2865. */
  2866. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2867. {
  2868. int hair_style = 0;
  2869. nullpo_retr(-1, sd);
  2870. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2871. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2872. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2873. clif_displaymessage(fd, atcmd_output);
  2874. return -1;
  2875. }
  2876. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2877. /* Removed because this check is TOO strange. [Skotlex]
  2878. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2879. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2880. return -1;
  2881. } else {
  2882. */
  2883. pc_changelook(sd, LOOK_HAIR, hair_style);
  2884. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2885. // }
  2886. } else {
  2887. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2888. return -1;
  2889. }
  2890. return 0;
  2891. }
  2892. /*==========================================
  2893. * @charhairstyle by [MouseJstr]
  2894. *------------------------------------------
  2895. */
  2896. int
  2897. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2898. const char* command, const char* message)
  2899. {
  2900. nullpo_retr(-1, sd);
  2901. return 0;
  2902. }
  2903. /*==========================================
  2904. * @haircolor && @hcolor
  2905. *------------------------------------------
  2906. */
  2907. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2908. {
  2909. int hair_color = 0;
  2910. nullpo_retr(-1, sd);
  2911. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2912. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2913. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2914. clif_displaymessage(fd, atcmd_output);
  2915. return -1;
  2916. }
  2917. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2918. /* Removed for being such a strange check. [Skotlex]
  2919. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2920. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2921. return -1;
  2922. } else {
  2923. */
  2924. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2925. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2926. // }
  2927. } else {
  2928. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2929. return -1;
  2930. }
  2931. return 0;
  2932. }
  2933. /*==========================================
  2934. * @go [city_number or city_name] - Updated by Harbin
  2935. *------------------------------------------
  2936. */
  2937. int atcommand_go(
  2938. const int fd, struct map_session_data* sd,
  2939. const char* command, const char* message)
  2940. {
  2941. int i;
  2942. int town;
  2943. char map_name[MAP_NAME_LENGTH];
  2944. int m;
  2945. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2946. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2947. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2948. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2949. { MAP_PAYON, 162, 233 }, // 3=Payon
  2950. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2951. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2952. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2953. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2954. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2955. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2956. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2957. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2958. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2959. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2960. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2961. { "new_zone01.gat", 53, 111 }, // 15=Training Grounds
  2962. { MAP_JAIL, 23, 61 }, // 16=Prison
  2963. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2964. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2965. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2966. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2967. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2968. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2969. };
  2970. nullpo_retr(-1, sd);
  2971. if(map[sd->bl.m].flag.nogo) {
  2972. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2973. return 0;
  2974. }
  2975. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  2976. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  2977. // get the number
  2978. town = atoi(message);
  2979. // if no value, display all value
  2980. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2981. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2982. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2983. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2984. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2985. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2986. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2987. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2988. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2989. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2990. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2991. return -1;
  2992. } else {
  2993. // get possible name of the city and add .gat if not in the name
  2994. map_name[MAP_NAME_LENGTH-1] = '\0';
  2995. for (i = 0; map_name[i]; i++)
  2996. map_name[i] = tolower(map_name[i]);
  2997. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2998. strcat(map_name, ".gat");
  2999. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  3000. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  3001. town = 0;
  3002. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  3003. town = 1;
  3004. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  3005. town = 2;
  3006. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  3007. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  3008. town = 3;
  3009. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  3010. town = 4;
  3011. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  3012. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  3013. town = 5;
  3014. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  3015. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  3016. town = 6;
  3017. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  3018. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  3019. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  3020. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  3021. town = 7;
  3022. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  3023. town = 8;
  3024. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  3025. town = 9;
  3026. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  3027. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  3028. town = 10;
  3029. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  3030. town = 11;
  3031. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  3032. town = 12;
  3033. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  3034. town = 13;
  3035. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  3036. town = 14;
  3037. } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
  3038. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  3039. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  3040. town = 15;
  3041. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  3042. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  3043. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  3044. town = 16;
  3045. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  3046. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  3047. town = 17;
  3048. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  3049. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  3050. town = 18;
  3051. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  3052. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  3053. town = 19;
  3054. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  3055. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  3056. town = 20;
  3057. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  3058. town = 21;
  3059. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  3060. town = 22;
  3061. }
  3062. if (town >= -3 && town <= -1) {
  3063. if (sd->status.memo_point[-town-1].map) {
  3064. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  3065. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3066. clif_displaymessage(fd, msg_txt(247));
  3067. return -1;
  3068. }
  3069. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3070. clif_displaymessage(fd, msg_txt(248));
  3071. return -1;
  3072. }
  3073. if (pc_setpos(sd, sd->status.memo_point[-town-1].map, sd->status.memo_point[-town-1].x, sd->status.memo_point[-town-1].y, 3) == 0) {
  3074. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3075. } else {
  3076. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3077. return -1;
  3078. }
  3079. } else {
  3080. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  3081. clif_displaymessage(fd, atcmd_output);
  3082. return -1;
  3083. }
  3084. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3085. m = map_mapname2mapid((char *)data[town].map);
  3086. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3087. clif_displaymessage(fd, msg_txt(247));
  3088. return -1;
  3089. }
  3090. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3091. clif_displaymessage(fd, msg_txt(248));
  3092. return -1;
  3093. }
  3094. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3095. clif_displaymessage(fd, msg_txt(0)); // Warped.
  3096. } else {
  3097. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3098. return -1;
  3099. }
  3100. } else { // if you arrive here, you have an error in town variable when reading of names
  3101. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  3102. return -1;
  3103. }
  3104. }
  3105. return 0;
  3106. }
  3107. /*==========================================
  3108. *
  3109. *------------------------------------------
  3110. */
  3111. int atcommand_monster(
  3112. const int fd, struct map_session_data* sd,
  3113. const char* command, const char* message)
  3114. {
  3115. char name[NAME_LENGTH];
  3116. char monster[NAME_LENGTH];
  3117. int mob_id;
  3118. int number = 0;
  3119. int count;
  3120. int i, k, range;
  3121. short mx, my;
  3122. nullpo_retr(-1, sd);
  3123. malloc_tsetdword(name, '\0', sizeof(name));
  3124. malloc_tsetdword(monster, '\0', sizeof(monster));
  3125. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3126. if (!message || !*message) {
  3127. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3128. return -1;
  3129. }
  3130. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3131. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3132. //All data can be left as it is.
  3133. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3134. //Here, it is possible name was not given and we are using monster for it.
  3135. if (count < 3) //Blank mob's name.
  3136. name[0] = '\0';
  3137. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3138. //All data can be left as it is.
  3139. } else if (sscanf(message, "%23s", monster) > 0) {
  3140. //As before, name may be already filled.
  3141. name[0] = '\0';
  3142. } else {
  3143. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3144. return -1;
  3145. }
  3146. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3147. mob_id = mobdb_checkid(atoi(monster));
  3148. if (mob_id == 0) {
  3149. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3150. return -1;
  3151. }
  3152. if (mob_id == MOBID_EMPERIUM) {
  3153. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3154. return -1;
  3155. }
  3156. if (number <= 0)
  3157. number = 1;
  3158. if (strlen(name) < 1)
  3159. strcpy(name, "--ja--");
  3160. // 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
  3161. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3162. number = battle_config.atc_spawn_quantity_limit;
  3163. if (battle_config.etc_log)
  3164. 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);
  3165. count = 0;
  3166. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3167. for (i = 0; i < number; i++) {
  3168. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3169. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3170. count += (k != 0) ? 1 : 0;
  3171. }
  3172. if (count != 0)
  3173. if (number == count)
  3174. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3175. else {
  3176. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3177. clif_displaymessage(fd, atcmd_output);
  3178. }
  3179. else {
  3180. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3181. return -1;
  3182. }
  3183. return 0;
  3184. }
  3185. // small monster spawning [Valaris]
  3186. int atcommand_monstersmall(
  3187. const int fd, struct map_session_data* sd,
  3188. const char* command, const char* message) {
  3189. char name[NAME_LENGTH] = "";
  3190. char monster[NAME_LENGTH] = "";
  3191. int mob_id = 0;
  3192. int number = 0;
  3193. int x = 0;
  3194. int y = 0;
  3195. int count;
  3196. int i;
  3197. nullpo_retr(-1, sd);
  3198. if (!message || !*message) {
  3199. clif_displaymessage(fd, "Give a monster name/id please.");
  3200. return -1;
  3201. }
  3202. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3203. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3204. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3205. clif_displaymessage(fd, "Give a monster name/id please.");
  3206. return -1;
  3207. }
  3208. // If monster identifier/name argument is a name
  3209. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3210. mob_id = atoi(monster);
  3211. if (mob_id == 0) {
  3212. clif_displaymessage(fd, msg_txt(40));
  3213. return -1;
  3214. }
  3215. if (mob_id == MOBID_EMPERIUM) {
  3216. clif_displaymessage(fd, msg_txt(83));
  3217. return -1;
  3218. }
  3219. if (mobdb_checkid(mob_id) == 0) {
  3220. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3221. return -1;
  3222. }
  3223. if (number <= 0)
  3224. number = 1;
  3225. if (strlen(name) < 1)
  3226. strcpy(name, "--ja--");
  3227. // 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
  3228. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3229. number = battle_config.atc_spawn_quantity_limit;
  3230. count = 0;
  3231. for (i = 0; i < number; i++) {
  3232. int mx, my;
  3233. if (x <= 0)
  3234. mx = sd->bl.x + (rand() % 11 - 5);
  3235. else
  3236. mx = x;
  3237. if (y <= 0)
  3238. my = sd->bl.y + (rand() % 11 - 5);
  3239. else
  3240. my = y;
  3241. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3242. }
  3243. if (count != 0)
  3244. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3245. else
  3246. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3247. return 0;
  3248. }
  3249. // big monster spawning [Valaris]
  3250. int atcommand_monsterbig(
  3251. const int fd, struct map_session_data* sd,
  3252. const char* command, const char* message) {
  3253. char name[NAME_LENGTH] = "";
  3254. char monster[NAME_LENGTH] = "";
  3255. int mob_id = 0;
  3256. int number = 0;
  3257. int x = 0;
  3258. int y = 0;
  3259. int count;
  3260. int i;
  3261. nullpo_retr(-1, sd);
  3262. if (!message || !*message) {
  3263. clif_displaymessage(fd, "Give a monster name/id please.");
  3264. return -1;
  3265. }
  3266. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3267. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3268. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3269. clif_displaymessage(fd, "Give a monster name/id please.");
  3270. return -1;
  3271. }
  3272. // If monster identifier/name argument is a name
  3273. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3274. mob_id = atoi(monster);
  3275. if (mob_id == 0) {
  3276. clif_displaymessage(fd, msg_txt(40));
  3277. return -1;
  3278. }
  3279. if (mob_id == MOBID_EMPERIUM) {
  3280. clif_displaymessage(fd, msg_txt(83));
  3281. return -1;
  3282. }
  3283. if (mobdb_checkid(mob_id) == 0) {
  3284. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3285. return -1;
  3286. }
  3287. if (number <= 0)
  3288. number = 1;
  3289. if (strlen(name) < 1)
  3290. strcpy(name, "--ja--");
  3291. // 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
  3292. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3293. number = battle_config.atc_spawn_quantity_limit;
  3294. count = 0;
  3295. for (i = 0; i < number; i++) {
  3296. int mx, my;
  3297. if (x <= 0)
  3298. mx = sd->bl.x + (rand() % 11 - 5);
  3299. else
  3300. mx = x;
  3301. if (y <= 0)
  3302. my = sd->bl.y + (rand() % 11 - 5);
  3303. else
  3304. my = y;
  3305. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3306. }
  3307. if (count != 0)
  3308. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3309. else
  3310. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. *
  3315. *------------------------------------------
  3316. */
  3317. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3318. struct mob_data *md;
  3319. int flag;
  3320. nullpo_retr(0, ap);
  3321. nullpo_retr(0, md=(struct mob_data *)bl);
  3322. flag = va_arg(ap, int);
  3323. if (md->guardian_data)
  3324. return 0; //Do not touch WoE mobs!
  3325. if (flag)
  3326. status_zap(bl,md->status.hp, 0);
  3327. else
  3328. status_kill(bl);
  3329. return 1;
  3330. }
  3331. void atcommand_killmonster_sub(
  3332. const int fd, struct map_session_data* sd, const char* message,
  3333. const int drop)
  3334. {
  3335. int map_id;
  3336. char map_name[MAP_NAME_LENGTH];
  3337. if (!sd) return;
  3338. malloc_tsetdword(map_name, '\0', sizeof(map_name));
  3339. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3340. map_id = sd->bl.m;
  3341. else {
  3342. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3343. strcat(map_name, ".gat");
  3344. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3345. map_id = sd->bl.m;
  3346. }
  3347. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3348. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3349. return;
  3350. }
  3351. /*==========================================
  3352. *
  3353. *------------------------------------------
  3354. */
  3355. int atcommand_killmonster(
  3356. const int fd, struct map_session_data* sd,
  3357. const char* command, const char* message)
  3358. {
  3359. if (!sd) return 0;
  3360. atcommand_killmonster_sub(fd, sd, message, 1);
  3361. return 0;
  3362. }
  3363. /*==========================================
  3364. *
  3365. *------------------------------------------
  3366. */
  3367. int atcommand_killmonster2(
  3368. const int fd, struct map_session_data* sd,
  3369. const char* command, const char* message)
  3370. {
  3371. if (!sd) return 0;
  3372. atcommand_killmonster_sub(fd, sd, message, 0);
  3373. return 0;
  3374. }
  3375. /*==========================================
  3376. *
  3377. *------------------------------------------
  3378. */
  3379. int atcommand_refine(
  3380. const int fd, struct map_session_data* sd,
  3381. const char* command, const char* message)
  3382. {
  3383. int i,j, position = 0, refine = 0, current_position, final_refine;
  3384. int count;
  3385. nullpo_retr(-1, sd);
  3386. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3387. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3388. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3389. return -1;
  3390. }
  3391. if (refine < -MAX_REFINE)
  3392. refine = -MAX_REFINE;
  3393. else if (refine > MAX_REFINE)
  3394. refine = MAX_REFINE;
  3395. else if (refine == 0)
  3396. refine = 1;
  3397. count = 0;
  3398. for (j = 0; j < EQI_MAX-1; j++) {
  3399. if ((i = sd->equip_index[j]) < 0)
  3400. continue;
  3401. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3402. continue;
  3403. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3404. continue;
  3405. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3406. continue;
  3407. if(position && !(sd->status.inventory[i].equip & position))
  3408. continue;
  3409. final_refine = sd->status.inventory[i].refine + refine;
  3410. if (final_refine > MAX_REFINE)
  3411. final_refine = MAX_REFINE;
  3412. else if (final_refine < 0)
  3413. final_refine = 0;
  3414. if (sd->status.inventory[i].refine != final_refine) {
  3415. sd->status.inventory[i].refine = final_refine;
  3416. current_position = sd->status.inventory[i].equip;
  3417. pc_unequipitem(sd, i, 3);
  3418. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3419. clif_delitem(sd, i, 1);
  3420. clif_additem(sd, i, 1, 0);
  3421. pc_equipitem(sd, i, current_position);
  3422. clif_misceffect(&sd->bl, 3);
  3423. count++;
  3424. }
  3425. }
  3426. if (count == 0)
  3427. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3428. else if (count == 1)
  3429. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3430. else {
  3431. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3432. clif_displaymessage(fd, atcmd_output);
  3433. }
  3434. return 0;
  3435. }
  3436. /*==========================================
  3437. *
  3438. *------------------------------------------
  3439. */
  3440. int atcommand_produce(
  3441. const int fd, struct map_session_data* sd,
  3442. const char* command, const char* message)
  3443. {
  3444. char item_name[100];
  3445. int item_id, attribute = 0, star = 0;
  3446. int flag = 0;
  3447. struct item_data *item_data;
  3448. struct item tmp_item;
  3449. nullpo_retr(-1, sd);
  3450. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3451. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  3452. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3453. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3454. return -1;
  3455. }
  3456. item_id = 0;
  3457. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3458. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3459. {
  3460. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3461. clif_displaymessage(fd, atcmd_output);
  3462. return -1;
  3463. }
  3464. item_id = item_data->nameid;
  3465. if (itemdb_isequip2(item_data)) {
  3466. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3467. attribute = ATTRIBUTE_NORMAL;
  3468. if (star < MIN_STAR || star > MAX_STAR)
  3469. star = 0;
  3470. malloc_set(&tmp_item, 0, sizeof tmp_item);
  3471. tmp_item.nameid = item_id;
  3472. tmp_item.amount = 1;
  3473. tmp_item.identify = 1;
  3474. tmp_item.card[0] = CARD0_FORGE;
  3475. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3476. ((star*5) << 8) + attribute:0;
  3477. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3478. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3479. clif_produceeffect(sd, 0, item_id);
  3480. clif_misceffect(&sd->bl, 3);
  3481. //Logs (A)dmins items [Lupus]
  3482. if(log_config.enable_logs&0x400)
  3483. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3484. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3485. clif_additem(sd, 0, 0, flag);
  3486. } else {
  3487. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3488. clif_displaymessage(fd, atcmd_output);
  3489. return -1;
  3490. }
  3491. return 0;
  3492. }
  3493. /*==========================================
  3494. * Sub-function to display actual memo points
  3495. *------------------------------------------
  3496. */
  3497. void atcommand_memo_sub(struct map_session_data* sd) {
  3498. int i;
  3499. if (!sd) return;
  3500. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3501. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3502. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3503. if (sd->status.memo_point[i].map)
  3504. 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);
  3505. else
  3506. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3507. clif_displaymessage(sd->fd, atcmd_output);
  3508. }
  3509. return;
  3510. }
  3511. /*==========================================
  3512. *
  3513. *------------------------------------------
  3514. */
  3515. int atcommand_memo(
  3516. const int fd, struct map_session_data* sd,
  3517. const char* command, const char* message)
  3518. {
  3519. int position = 0;
  3520. nullpo_retr(-1, sd);
  3521. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3522. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3523. atcommand_memo_sub(sd);
  3524. else {
  3525. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3526. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3527. clif_displaymessage(fd, msg_txt(253));
  3528. return -1;
  3529. }
  3530. if (sd->status.memo_point[position].map) {
  3531. sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3532. clif_displaymessage(fd, atcmd_output);
  3533. }
  3534. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3535. sd->status.memo_point[position].x = sd->bl.x;
  3536. sd->status.memo_point[position].y = sd->bl.y;
  3537. clif_skill_memo(sd, 0);
  3538. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3539. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3540. atcommand_memo_sub(sd);
  3541. } else {
  3542. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3543. clif_displaymessage(fd, atcmd_output);
  3544. atcommand_memo_sub(sd);
  3545. return -1;
  3546. }
  3547. }
  3548. return 0;
  3549. }
  3550. /*==========================================
  3551. *
  3552. *------------------------------------------
  3553. */
  3554. int atcommand_gat(
  3555. const int fd, struct map_session_data* sd,
  3556. const char* command, const char* message)
  3557. {
  3558. int y;
  3559. nullpo_retr(-1, sd);
  3560. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3561. for (y = 2; y >= -2; y--) {
  3562. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3563. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3564. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3565. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3566. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3567. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3568. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3569. clif_displaymessage(fd, atcmd_output);
  3570. }
  3571. return 0;
  3572. }
  3573. /*==========================================
  3574. *
  3575. *------------------------------------------
  3576. */
  3577. int atcommand_packet(
  3578. const int fd, struct map_session_data* sd,
  3579. const char* command, const char* message)
  3580. {
  3581. static int packet_mode = 0;
  3582. int i, x = 0, y = 0;
  3583. nullpo_retr(-1, sd);
  3584. if (strstr(command, "packetmode")) {
  3585. packet_mode = atoi(message);
  3586. clif_displaymessage(fd, "Packet mode changed.");
  3587. return 0;
  3588. }
  3589. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3590. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3591. return -1;
  3592. }
  3593. if (i == 1) y = 1;
  3594. switch (packet_mode)
  3595. {
  3596. case 0:
  3597. clif_status_change(&sd->bl, x, y);
  3598. break;
  3599. case 1:
  3600. sd->status.skill[sd->cloneskill_id].id=0;
  3601. sd->status.skill[sd->cloneskill_id].lv=0;
  3602. sd->status.skill[sd->cloneskill_id].flag=0;
  3603. sd->cloneskill_id = x;
  3604. sd->status.skill[x].id = x;
  3605. sd->status.skill[x].lv = skill_get_max(x);
  3606. sd->status.skill[x].flag = 13;//cloneskill flag
  3607. clif_skillinfoblock(sd);
  3608. break;
  3609. case 2:
  3610. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3611. case 3:
  3612. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3613. default:
  3614. break;
  3615. //added later
  3616. }
  3617. return 0;
  3618. }
  3619. /*==========================================
  3620. * @waterlevel [Skotlex]
  3621. *------------------------------------------
  3622. */
  3623. int atcommand_waterlevel(
  3624. const int fd, struct map_session_data* sd,
  3625. const char* command, const char* message)
  3626. {
  3627. int newlevel;
  3628. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3629. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3630. clif_displaymessage(fd, atcmd_output);
  3631. return 0;
  3632. }
  3633. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3634. if (newlevel > 0)
  3635. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3636. else
  3637. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3638. clif_displaymessage(fd, atcmd_output);
  3639. } else {
  3640. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3641. clif_displaymessage(fd, atcmd_output);
  3642. }
  3643. return 0;
  3644. }
  3645. /*==========================================
  3646. * @stpoint (Rewritten by [Yor])
  3647. *------------------------------------------
  3648. */
  3649. int atcommand_statuspoint(
  3650. const int fd, struct map_session_data* sd,
  3651. const char* command, const char* message)
  3652. {
  3653. int point, new_status_point;
  3654. if (!message || !*message || (point = atoi(message)) == 0) {
  3655. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3656. return -1;
  3657. }
  3658. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3659. new_status_point = USHRT_MAX;
  3660. else
  3661. if (point < 0 && sd->status.status_point < -point)
  3662. new_status_point = 0;
  3663. else
  3664. new_status_point = sd->status.status_point + point;
  3665. if (new_status_point != (int)sd->status.status_point) {
  3666. sd->status.status_point = (unsigned short)new_status_point;
  3667. clif_updatestatus(sd, SP_STATUSPOINT);
  3668. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3669. } else {
  3670. if (point < 0)
  3671. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3672. else
  3673. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3674. return -1;
  3675. }
  3676. return 0;
  3677. }
  3678. /*==========================================
  3679. * @skpoint (Rewritten by [Yor])
  3680. *------------------------------------------
  3681. */
  3682. int atcommand_skillpoint(
  3683. const int fd, struct map_session_data* sd,
  3684. const char* command, const char* message)
  3685. {
  3686. int point, new_skill_point;
  3687. nullpo_retr(-1, sd);
  3688. if (!message || !*message || (point = atoi(message)) == 0) {
  3689. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3690. return -1;
  3691. }
  3692. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3693. new_skill_point = USHRT_MAX;
  3694. else if (point < 0 && sd->status.skill_point < -point)
  3695. new_skill_point = 0;
  3696. else
  3697. new_skill_point = sd->status.skill_point + point;
  3698. if (new_skill_point != (int)sd->status.skill_point) {
  3699. sd->status.skill_point = (unsigned short)new_skill_point;
  3700. clif_updatestatus(sd, SP_SKILLPOINT);
  3701. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3702. } else {
  3703. if (point < 0)
  3704. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3705. else
  3706. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3707. return -1;
  3708. }
  3709. return 0;
  3710. }
  3711. /*==========================================
  3712. * @zeny (Rewritten by [Yor])
  3713. *------------------------------------------
  3714. */
  3715. int atcommand_zeny(
  3716. const int fd, struct map_session_data* sd,
  3717. const char* command, const char* message)
  3718. {
  3719. int zeny, new_zeny;
  3720. nullpo_retr(-1, sd);
  3721. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3722. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3723. return -1;
  3724. }
  3725. new_zeny = sd->status.zeny + zeny;
  3726. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3727. new_zeny = MAX_ZENY;
  3728. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3729. new_zeny = 0;
  3730. if (new_zeny != sd->status.zeny) {
  3731. sd->status.zeny = new_zeny;
  3732. clif_updatestatus(sd, SP_ZENY);
  3733. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3734. } else {
  3735. if (zeny < 0)
  3736. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3737. else
  3738. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3739. return -1;
  3740. }
  3741. return 0;
  3742. }
  3743. /*==========================================
  3744. *
  3745. *------------------------------------------
  3746. */
  3747. int atcommand_param(
  3748. const int fd, struct map_session_data* sd,
  3749. const char* command, const char* message)
  3750. {
  3751. int index, value = 0, new_value, max;
  3752. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3753. short* status[6];
  3754. //we don't use direct initialization because it isn't part of the c standard.
  3755. nullpo_retr(-1, sd);
  3756. status[0] = &sd->status.str;
  3757. status[1] = &sd->status.agi;
  3758. status[2] = &sd->status.vit;
  3759. status[3] = &sd->status.int_;
  3760. status[4] = &sd->status.dex;
  3761. status[5] = &sd->status.luk;
  3762. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  3763. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3764. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3765. clif_displaymessage(fd, atcmd_output);
  3766. return -1;
  3767. }
  3768. index = -1;
  3769. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3770. if (strcmpi(command, param[index]) == 0)
  3771. break;
  3772. }
  3773. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3774. // normaly impossible...
  3775. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3776. clif_displaymessage(fd, atcmd_output);
  3777. return -1;
  3778. }
  3779. max = pc_maxparameter(sd);
  3780. if (value > 0 && *status[index] > max - value)
  3781. new_value = max;
  3782. else if (value < 0 && *status[index] <= -value)
  3783. new_value = 1;
  3784. else
  3785. new_value = *status[index] + value;
  3786. if (new_value != (int)*status[index]) {
  3787. *status[index] = new_value;
  3788. clif_updatestatus(sd, SP_STR + index);
  3789. clif_updatestatus(sd, SP_USTR + index);
  3790. status_calc_pc(sd, 0);
  3791. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3792. } else {
  3793. if (value < 0)
  3794. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3795. else
  3796. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3797. return -1;
  3798. }
  3799. return 0;
  3800. }
  3801. /*==========================================
  3802. *
  3803. *------------------------------------------
  3804. */
  3805. //** Stat all by fritz (rewritten by [Yor])
  3806. int atcommand_stat_all(
  3807. const int fd, struct map_session_data* sd,
  3808. const char* command, const char* message)
  3809. {
  3810. int index, count, value = 0, max, new_value;
  3811. short* status[6];
  3812. //we don't use direct initialization because it isn't part of the c standard.
  3813. nullpo_retr(-1, sd);
  3814. status[0] = &sd->status.str;
  3815. status[1] = &sd->status.agi;
  3816. status[2] = &sd->status.vit;
  3817. status[3] = &sd->status.int_;
  3818. status[4] = &sd->status.dex;
  3819. status[5] = &sd->status.luk;
  3820. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3821. value = pc_maxparameter(sd);
  3822. count = 0;
  3823. max = pc_maxparameter(sd);
  3824. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3825. if (value > 0 && *status[index] > max - value)
  3826. new_value = max;
  3827. else if (value < 0 && *status[index] <= -value)
  3828. new_value = 1;
  3829. else
  3830. new_value = *status[index] +value;
  3831. if (new_value != (int)*status[index]) {
  3832. *status[index] = new_value;
  3833. clif_updatestatus(sd, SP_STR + index);
  3834. clif_updatestatus(sd, SP_USTR + index);
  3835. status_calc_pc(sd, 0);
  3836. count++;
  3837. }
  3838. }
  3839. if (count > 0) // if at least 1 stat modified
  3840. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3841. else {
  3842. if (value < 0)
  3843. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3844. else
  3845. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3846. return -1;
  3847. }
  3848. return 0;
  3849. }
  3850. /*==========================================
  3851. *
  3852. *------------------------------------------
  3853. */
  3854. int atcommand_guildlevelup(
  3855. const int fd, struct map_session_data* sd,
  3856. const char* command, const char* message)
  3857. {
  3858. int level = 0;
  3859. short added_level;
  3860. struct guild *guild_info;
  3861. nullpo_retr(-1, sd);
  3862. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3863. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3864. return -1;
  3865. }
  3866. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3867. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3868. return -1;
  3869. }
  3870. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3871. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3872. return -1;
  3873. }
  3874. added_level = (short)level;
  3875. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3876. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3877. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3878. added_level = 1 - guild_info->guild_lv;
  3879. if (added_level != 0) {
  3880. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3881. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3882. } else {
  3883. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3884. return -1;
  3885. }
  3886. return 0;
  3887. }
  3888. /*==========================================
  3889. *
  3890. *------------------------------------------
  3891. */
  3892. int atcommand_makeegg(
  3893. const int fd, struct map_session_data* sd,
  3894. const char* command, const char* message)
  3895. {
  3896. struct item_data *item_data;
  3897. int id, pet_id;
  3898. nullpo_retr(-1, sd);
  3899. if (!message || !*message) {
  3900. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3901. return -1;
  3902. }
  3903. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3904. id = item_data->nameid;
  3905. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3906. id = atoi(message);
  3907. pet_id = search_petDB_index(id, PET_CLASS);
  3908. if (pet_id < 0)
  3909. pet_id = search_petDB_index(id, PET_EGG);
  3910. if (pet_id >= 0) {
  3911. sd->catch_target_class = pet_db[pet_id].class_;
  3912. intif_create_pet(
  3913. sd->status.account_id, sd->status.char_id,
  3914. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3915. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3916. 100, 0, 1, pet_db[pet_id].jname);
  3917. } else {
  3918. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3919. return -1;
  3920. }
  3921. return 0;
  3922. }
  3923. /*==========================================
  3924. *
  3925. *------------------------------------------
  3926. */
  3927. int atcommand_hatch(
  3928. const int fd, struct map_session_data* sd,
  3929. const char* command, const char* message)
  3930. {
  3931. nullpo_retr(-1, sd);
  3932. if (sd->status.pet_id <= 0)
  3933. clif_sendegg(sd);
  3934. else {
  3935. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3936. return -1;
  3937. }
  3938. return 0;
  3939. }
  3940. /*==========================================
  3941. *
  3942. *------------------------------------------
  3943. */
  3944. int atcommand_petfriendly(
  3945. const int fd, struct map_session_data* sd,
  3946. const char* command, const char* message)
  3947. {
  3948. int friendly;
  3949. struct pet_data *pd;
  3950. nullpo_retr(-1, sd);
  3951. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3952. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3953. return -1;
  3954. }
  3955. pd = sd->pd;
  3956. if (!pd) {
  3957. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3958. return -1;
  3959. }
  3960. if (friendly < 0 || friendly > 1000)
  3961. {
  3962. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3963. return -1;
  3964. }
  3965. if (friendly == pd->pet.intimate) {
  3966. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3967. return -1;
  3968. }
  3969. pd->pet.intimate = friendly;
  3970. clif_send_petstatus(sd);
  3971. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3972. return 0;
  3973. }
  3974. /*==========================================
  3975. *
  3976. *------------------------------------------
  3977. */
  3978. int atcommand_pethungry(
  3979. const int fd, struct map_session_data* sd,
  3980. const char* command, const char* message)
  3981. {
  3982. int hungry;
  3983. struct pet_data *pd;
  3984. nullpo_retr(-1, sd);
  3985. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3986. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3987. return -1;
  3988. }
  3989. pd = sd->pd;
  3990. if (!sd->status.pet_id || !pd) {
  3991. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3992. return -1;
  3993. }
  3994. if (hungry < 0 || hungry > 100) {
  3995. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3996. return -1;
  3997. }
  3998. if (hungry == pd->pet.hungry) {
  3999. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  4000. return -1;
  4001. }
  4002. pd->pet.hungry = hungry;
  4003. clif_send_petstatus(sd);
  4004. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  4005. return 0;
  4006. }
  4007. /*==========================================
  4008. *
  4009. *------------------------------------------
  4010. */
  4011. int atcommand_petrename(
  4012. const int fd, struct map_session_data* sd,
  4013. const char* command, const char* message)
  4014. {
  4015. struct pet_data *pd;
  4016. nullpo_retr(-1, sd);
  4017. if (!sd->status.pet_id || !sd->pd) {
  4018. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  4019. return -1;
  4020. }
  4021. pd = sd->pd;
  4022. if (!pd->pet.rename_flag) {
  4023. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  4024. return -1;
  4025. }
  4026. pd->pet.rename_flag = 0;
  4027. intif_save_petdata(sd->status.account_id, &pd->pet);
  4028. clif_send_petstatus(sd);
  4029. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  4030. return 0;
  4031. }
  4032. /*==========================================
  4033. *
  4034. *------------------------------------------
  4035. */
  4036. int
  4037. atcommand_recall(
  4038. const int fd, struct map_session_data* sd,
  4039. const char* command, const char* message)
  4040. {
  4041. struct map_session_data *pl_sd = NULL;
  4042. nullpo_retr(-1, sd);
  4043. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4044. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  4045. return -1;
  4046. }
  4047. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4048. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  4049. return -1;
  4050. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  4051. return -1;
  4052. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4053. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4054. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4055. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4056. return -1;
  4057. }
  4058. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4059. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  4060. return -1;
  4061. }
  4062. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4063. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  4064. clif_displaymessage(fd, atcmd_output);
  4065. } else {
  4066. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4067. return -1;
  4068. }
  4069. } else {
  4070. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4071. return -1;
  4072. }
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. *
  4077. *------------------------------------------
  4078. */
  4079. int atcommand_revive(
  4080. const int fd, struct map_session_data* sd,
  4081. const char* command, const char* message)
  4082. {
  4083. struct map_session_data *pl_sd;
  4084. nullpo_retr(-1, sd);
  4085. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4086. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4087. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4088. return -1;
  4089. }
  4090. pl_sd = map_nick2sd(atcmd_player_name);
  4091. if (!pl_sd) {
  4092. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4093. return -1;
  4094. }
  4095. if (!status_revive(&sd->bl, 100, 0))
  4096. return -1;
  4097. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4098. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  4099. return 0;
  4100. }
  4101. /*==========================================
  4102. * charblock command (usage: charblock <player_name>)
  4103. * This command do a definitiv ban on a player
  4104. *------------------------------------------
  4105. */
  4106. int atcommand_char_block(
  4107. const int fd, struct map_session_data* sd,
  4108. const char* command, const char* message)
  4109. {
  4110. nullpo_retr(-1, sd);
  4111. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4112. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4113. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4114. return -1;
  4115. }
  4116. // check player name
  4117. if (strlen(atcmd_player_name) < 4) {
  4118. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4119. return -1;
  4120. } else if (strlen(atcmd_player_name) > 23) {
  4121. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4122. return -1;
  4123. } else {
  4124. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4125. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4126. }
  4127. return 0;
  4128. }
  4129. /*==========================================
  4130. * charban command (usage: charban <time> <player_name>)
  4131. * This command do a limited ban on a player
  4132. * Time is done as follows:
  4133. * Adjustment value (-1, 1, +1, etc...)
  4134. * Modified element:
  4135. * a or y: year
  4136. * m: month
  4137. * j or d: day
  4138. * h: hour
  4139. * mn: minute
  4140. * s: second
  4141. * <example> @ban +1m-2mn1s-6y test_player
  4142. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4143. *------------------------------------------
  4144. */
  4145. int atcommand_char_ban(
  4146. const int fd, struct map_session_data* sd,
  4147. const char* command, const char* message)
  4148. {
  4149. char * modif_p;
  4150. int year, month, day, hour, minute, second, value;
  4151. nullpo_retr(-1, sd);
  4152. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4153. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4154. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4155. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4156. return -1;
  4157. }
  4158. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4159. modif_p = atcmd_output;
  4160. year = month = day = hour = minute = second = 0;
  4161. while (modif_p[0] != '\0') {
  4162. value = atoi(modif_p);
  4163. if (value == 0)
  4164. modif_p++;
  4165. else {
  4166. if (modif_p[0] == '-' || modif_p[0] == '+')
  4167. modif_p++;
  4168. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4169. modif_p++;
  4170. if (modif_p[0] == 's') {
  4171. second = value;
  4172. modif_p++;
  4173. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4174. minute = value;
  4175. modif_p = modif_p + 2;
  4176. } else if (modif_p[0] == 'h') {
  4177. hour = value;
  4178. modif_p++;
  4179. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4180. day = value;
  4181. modif_p++;
  4182. } else if (modif_p[0] == 'm') {
  4183. month = value;
  4184. modif_p++;
  4185. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4186. year = value;
  4187. modif_p++;
  4188. } else if (modif_p[0] != '\0') {
  4189. modif_p++;
  4190. }
  4191. }
  4192. }
  4193. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4194. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4195. return -1;
  4196. }
  4197. // check player name
  4198. if (strlen(atcmd_player_name) < 4) {
  4199. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4200. return -1;
  4201. } else if (strlen(atcmd_player_name) > 23) {
  4202. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4203. return -1;
  4204. } else {
  4205. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4206. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4207. }
  4208. return 0;
  4209. }
  4210. /*==========================================
  4211. * charunblock command (usage: charunblock <player_name>)
  4212. *------------------------------------------
  4213. */
  4214. int atcommand_char_unblock(
  4215. const int fd, struct map_session_data* sd,
  4216. const char* command, const char* message)
  4217. {
  4218. nullpo_retr(-1, sd);
  4219. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4220. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4221. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4222. return -1;
  4223. }
  4224. // check player name
  4225. if (strlen(atcmd_player_name) < 4) {
  4226. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4227. return -1;
  4228. } else if (strlen(atcmd_player_name) > 23) {
  4229. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4230. return -1;
  4231. } else {
  4232. // send answer to login server via char-server
  4233. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4234. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4235. }
  4236. return 0;
  4237. }
  4238. /*==========================================
  4239. * charunban command (usage: charunban <player_name>)
  4240. *------------------------------------------
  4241. */
  4242. int atcommand_char_unban(
  4243. const int fd, struct map_session_data* sd,
  4244. const char* command, const char* message)
  4245. {
  4246. nullpo_retr(-1, sd);
  4247. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4248. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4249. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4250. return -1;
  4251. }
  4252. // check player name
  4253. if (strlen(atcmd_player_name) < 4) {
  4254. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4255. return -1;
  4256. } else if (strlen(atcmd_player_name) > 23) {
  4257. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4258. return -1;
  4259. } else {
  4260. // send answer to login server via char-server
  4261. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4262. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4263. }
  4264. return 0;
  4265. }
  4266. /*==========================================
  4267. *
  4268. *------------------------------------------
  4269. */
  4270. int atcommand_night(
  4271. const int fd, struct map_session_data* sd,
  4272. const char* command, const char* message)
  4273. {
  4274. nullpo_retr(-1, sd);
  4275. if (night_flag != 1) {
  4276. map_night_timer(night_timer_tid, 0, 0, 1);
  4277. } else {
  4278. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4279. return -1;
  4280. }
  4281. return 0;
  4282. }
  4283. /*==========================================
  4284. *
  4285. *------------------------------------------
  4286. */
  4287. int atcommand_day(
  4288. const int fd, struct map_session_data* sd,
  4289. const char* command, const char* message)
  4290. {
  4291. nullpo_retr(-1, sd);
  4292. if (night_flag != 0) {
  4293. map_day_timer(day_timer_tid, 0, 0, 1);
  4294. } else {
  4295. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4296. return -1;
  4297. }
  4298. return 0;
  4299. }
  4300. /*==========================================
  4301. *
  4302. *------------------------------------------
  4303. */
  4304. int atcommand_doom(
  4305. const int fd, struct map_session_data* sd,
  4306. const char* command, const char* message)
  4307. {
  4308. struct map_session_data *pl_sd, **pl_allsd;
  4309. int i, users;
  4310. nullpo_retr(-1, sd);
  4311. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4312. pl_allsd = map_getallusers(&users);
  4313. for(i = 0; i < users; i++) {
  4314. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4315. status_kill(&pl_sd->bl);
  4316. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4317. }
  4318. }
  4319. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4320. return 0;
  4321. }
  4322. /*==========================================
  4323. *
  4324. *------------------------------------------
  4325. */
  4326. int atcommand_doommap(
  4327. const int fd, struct map_session_data* sd,
  4328. const char* command, const char* message)
  4329. {
  4330. struct map_session_data *pl_sd, **pl_allsd;
  4331. int i, users;
  4332. nullpo_retr(-1, sd);
  4333. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4334. pl_allsd = map_getallusers(&users);
  4335. for (i = 0; i < users; i++) {
  4336. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4337. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4338. {
  4339. status_kill(&pl_sd->bl);
  4340. // clif_specialeffect(&pl_sd->bl,450,1);
  4341. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4342. }
  4343. }
  4344. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4345. return 0;
  4346. }
  4347. /*==========================================
  4348. *
  4349. *------------------------------------------
  4350. */
  4351. static void atcommand_raise_sub(struct map_session_data* sd)
  4352. {
  4353. if (!sd->state.auth || !status_isdead(&sd->bl))
  4354. return;
  4355. if(!status_revive(&sd->bl, 100, 100))
  4356. return;
  4357. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4358. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4359. }
  4360. /*==========================================
  4361. *
  4362. *------------------------------------------
  4363. */
  4364. int atcommand_raise(
  4365. const int fd, struct map_session_data* sd,
  4366. const char* command, const char* message)
  4367. {
  4368. int i, users;
  4369. struct map_session_data **all_sd;
  4370. nullpo_retr(-1, sd);
  4371. all_sd = map_getallusers(&users);
  4372. for (i = 0; i < users; i++) {
  4373. atcommand_raise_sub(all_sd[i]);
  4374. }
  4375. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4376. return 0;
  4377. }
  4378. /*==========================================
  4379. *
  4380. *------------------------------------------
  4381. */
  4382. int atcommand_raisemap(
  4383. const int fd, struct map_session_data* sd,
  4384. const char* command, const char* message)
  4385. {
  4386. struct map_session_data **pl_allsd;
  4387. int i, users;
  4388. nullpo_retr(-1, sd);
  4389. pl_allsd = map_getallusers(&users);
  4390. for (i = 0; i < users; i++) {
  4391. if (sd->bl.m == pl_allsd[i]->bl.m)
  4392. atcommand_raise_sub(pl_allsd[i]);
  4393. }
  4394. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4395. return 0;
  4396. }
  4397. /*==========================================
  4398. *
  4399. *------------------------------------------
  4400. */
  4401. int atcommand_kick(
  4402. const int fd, struct map_session_data* sd,
  4403. const char* command, const char* message)
  4404. {
  4405. struct map_session_data *pl_sd;
  4406. nullpo_retr(-1, sd);
  4407. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4408. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4409. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4410. return -1;
  4411. }
  4412. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4413. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4414. clif_GM_kick(sd, pl_sd, 1);
  4415. else {
  4416. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4417. return -1;
  4418. }
  4419. } else {
  4420. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4421. return -1;
  4422. }
  4423. return 0;
  4424. }
  4425. /*==========================================
  4426. *
  4427. *------------------------------------------
  4428. */
  4429. int atcommand_kickall(
  4430. const int fd, struct map_session_data* sd,
  4431. const char* command, const char* message)
  4432. {
  4433. struct map_session_data *pl_sd, **pl_allsd;
  4434. int i, users;
  4435. nullpo_retr(-1, sd);
  4436. pl_allsd = map_getallusers(&users);
  4437. for (i = 0; i < users; i++) {
  4438. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4439. if (sd->status.account_id != pl_sd->status.account_id)
  4440. clif_GM_kick(sd, pl_sd, 0);
  4441. }
  4442. }
  4443. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4444. return 0;
  4445. }
  4446. /*==========================================
  4447. *
  4448. *------------------------------------------
  4449. */
  4450. int atcommand_allskill(
  4451. const int fd, struct map_session_data* sd,
  4452. const char* command, const char* message)
  4453. {
  4454. nullpo_retr(-1, sd);
  4455. pc_allskillup(sd); // all skills
  4456. sd->status.skill_point = 0; // 0 skill points
  4457. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4458. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4459. return 0;
  4460. }
  4461. /*==========================================
  4462. *
  4463. *------------------------------------------
  4464. */
  4465. int atcommand_questskill(
  4466. const int fd, struct map_session_data* sd,
  4467. const char* command, const char* message)
  4468. {
  4469. int skill_id;
  4470. nullpo_retr(-1, sd);
  4471. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4472. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4473. return -1;
  4474. }
  4475. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4476. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4477. if (pc_checkskill(sd, skill_id) == 0) {
  4478. pc_skill(sd, skill_id, 1, 0);
  4479. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4480. } else {
  4481. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4482. return -1;
  4483. }
  4484. } else {
  4485. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4486. return -1;
  4487. }
  4488. } else {
  4489. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4490. return -1;
  4491. }
  4492. return 0;
  4493. }
  4494. /*==========================================
  4495. *
  4496. *------------------------------------------
  4497. */
  4498. int atcommand_lostskill(
  4499. const int fd, struct map_session_data* sd,
  4500. const char* command, const char* message)
  4501. {
  4502. int skill_id;
  4503. nullpo_retr(-1, sd);
  4504. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4505. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4506. return -1;
  4507. }
  4508. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4509. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4510. if (pc_checkskill(sd, skill_id) > 0) {
  4511. sd->status.skill[skill_id].lv = 0;
  4512. sd->status.skill[skill_id].flag = 0;
  4513. clif_skillinfoblock(sd);
  4514. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4515. } else {
  4516. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4517. return -1;
  4518. }
  4519. } else {
  4520. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4521. return -1;
  4522. }
  4523. } else {
  4524. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4525. return -1;
  4526. }
  4527. return 0;
  4528. }
  4529. /*==========================================
  4530. *
  4531. *------------------------------------------
  4532. */
  4533. int atcommand_spiritball(
  4534. const int fd, struct map_session_data* sd,
  4535. const char* command, const char* message)
  4536. {
  4537. int number;
  4538. nullpo_retr(-1, sd);
  4539. if (!message || !*message || (number = atoi(message)) < 0) {
  4540. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4541. return -1;
  4542. }
  4543. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4544. if (number > 500)
  4545. number = 500;
  4546. if (number >= 0 && number <= 0x7FFF) {
  4547. if (sd->spiritball != number || number > 499) {
  4548. if (sd->spiritball > 0)
  4549. pc_delspiritball(sd, sd->spiritball, 1);
  4550. sd->spiritball = number;
  4551. clif_spiritball(sd);
  4552. // no message, player can look the difference
  4553. if (number > 1000)
  4554. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4555. } else {
  4556. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4557. return -1;
  4558. }
  4559. } else {
  4560. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4561. return -1;
  4562. }
  4563. return 0;
  4564. }
  4565. /*==========================================
  4566. *
  4567. *------------------------------------------
  4568. */
  4569. int atcommand_party(
  4570. const int fd, struct map_session_data* sd,
  4571. const char* command, const char* message)
  4572. {
  4573. char party[NAME_LENGTH];
  4574. nullpo_retr(-1, sd);
  4575. malloc_tsetdword(party, '\0', sizeof(party));
  4576. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4577. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4578. return -1;
  4579. }
  4580. party_create(sd, party, 0, 0);
  4581. return 0;
  4582. }
  4583. /*==========================================
  4584. *
  4585. *------------------------------------------
  4586. */
  4587. int atcommand_guild(
  4588. const int fd, struct map_session_data* sd,
  4589. const char* command, const char* message)
  4590. {
  4591. char guild[NAME_LENGTH];
  4592. int prev;
  4593. nullpo_retr(-1, sd);
  4594. malloc_tsetdword(guild, '\0', sizeof(guild));
  4595. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4596. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4597. return -1;
  4598. }
  4599. prev = battle_config.guild_emperium_check;
  4600. battle_config.guild_emperium_check = 0;
  4601. guild_create(sd, guild);
  4602. battle_config.guild_emperium_check = prev;
  4603. return 0;
  4604. }
  4605. /*==========================================
  4606. *
  4607. *------------------------------------------
  4608. */
  4609. int atcommand_agitstart(
  4610. const int fd, struct map_session_data* sd,
  4611. const char* command, const char* message)
  4612. {
  4613. nullpo_retr(-1, sd);
  4614. if (agit_flag == 1) {
  4615. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4616. return -1;
  4617. }
  4618. agit_flag = 1;
  4619. guild_agit_start();
  4620. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4621. return 0;
  4622. }
  4623. /*==========================================
  4624. *
  4625. *------------------------------------------
  4626. */
  4627. int atcommand_agitend(
  4628. const int fd, struct map_session_data* sd,
  4629. const char* command, const char* message)
  4630. {
  4631. nullpo_retr(-1, sd);
  4632. if (agit_flag == 0) {
  4633. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4634. return -1;
  4635. }
  4636. agit_flag = 0;
  4637. guild_agit_end();
  4638. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4639. return 0;
  4640. }
  4641. /*==========================================
  4642. * @mapexitでマップサーバーを終了させる
  4643. *------------------------------------------
  4644. */
  4645. int atcommand_mapexit(
  4646. const int fd, struct map_session_data* sd,
  4647. const char* command, const char* message)
  4648. {
  4649. struct map_session_data *pl_sd, **pl_allsd;
  4650. int i, users;
  4651. nullpo_retr(-1, sd);
  4652. pl_allsd = map_getallusers(&users);
  4653. for (i = 0; i < users; i++) {
  4654. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4655. clif_GM_kick(sd, pl_sd, 0);
  4656. }
  4657. clif_GM_kick(sd, sd, 0);
  4658. flush_fifos();
  4659. runflag = 0;
  4660. return 0;
  4661. }
  4662. /*==========================================
  4663. * idsearch <part_of_name>: revrited by [Yor]
  4664. *------------------------------------------
  4665. */
  4666. int atcommand_idsearch(
  4667. const int fd, struct map_session_data* sd,
  4668. const char* command, const char* message)
  4669. {
  4670. char item_name[100];
  4671. unsigned int i, match;
  4672. struct item_data *item_array[MAX_SEARCH];
  4673. nullpo_retr(-1, sd);
  4674. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  4675. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4676. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4677. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4678. return -1;
  4679. }
  4680. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4681. clif_displaymessage(fd, atcmd_output);
  4682. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4683. if (match > MAX_SEARCH) {
  4684. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4685. clif_displaymessage(fd, atcmd_output);
  4686. match = MAX_SEARCH;
  4687. }
  4688. for(i = 0; i < match; i++) {
  4689. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4690. clif_displaymessage(fd, atcmd_output);
  4691. }
  4692. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4693. clif_displaymessage(fd, atcmd_output);
  4694. return 0;
  4695. }
  4696. /*==========================================
  4697. * Recall All Characters Online To Your Location
  4698. *------------------------------------------
  4699. */
  4700. int atcommand_recallall(
  4701. const int fd, struct map_session_data* sd,
  4702. const char* command, const char* message)
  4703. {
  4704. struct map_session_data *pl_sd, **pl_allsd;
  4705. int i;
  4706. int count, users;
  4707. nullpo_retr(-1, sd);
  4708. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4709. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4710. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4711. return -1;
  4712. }
  4713. count = 0;
  4714. pl_allsd = map_getallusers(&users);
  4715. for (i = 0; i < users; i++) {
  4716. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4717. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4718. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4719. count++;
  4720. else {
  4721. if (pc_isdead(pl_sd)) { //Wake them up
  4722. pc_setstand(pl_sd);
  4723. pc_setrestartvalue(pl_sd,1);
  4724. }
  4725. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4726. }
  4727. }
  4728. }
  4729. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4730. if (count) {
  4731. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4732. clif_displaymessage(fd, atcmd_output);
  4733. }
  4734. return 0;
  4735. }
  4736. /*==========================================
  4737. * Recall online characters of a guild to your location
  4738. *------------------------------------------
  4739. */
  4740. int atcommand_guildrecall(
  4741. const int fd, struct map_session_data* sd,
  4742. const char* command, const char* message)
  4743. {
  4744. struct map_session_data *pl_sd, **pl_allsd;
  4745. int i, users, count;
  4746. char guild_name[NAME_LENGTH];
  4747. struct guild *g;
  4748. nullpo_retr(-1, sd);
  4749. malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
  4750. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4751. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4752. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4753. return -1;
  4754. }
  4755. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4756. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4757. return -1;
  4758. }
  4759. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4760. (g = guild_search(atoi(message))) != NULL) {
  4761. count = 0;
  4762. pl_allsd = map_getallusers(&users);
  4763. for (i = 0; i < users; i++) {
  4764. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4765. pl_sd->status.guild_id == g->guild_id) {
  4766. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4767. continue; //Skip GMs greater than you.
  4768. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4769. count++;
  4770. else
  4771. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4772. }
  4773. }
  4774. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4775. clif_displaymessage(fd, atcmd_output);
  4776. if (count) {
  4777. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4778. clif_displaymessage(fd, atcmd_output);
  4779. }
  4780. } else {
  4781. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4782. return -1;
  4783. }
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. * Recall online characters of a party to your location
  4788. *------------------------------------------
  4789. */
  4790. int atcommand_partyrecall(
  4791. const int fd, struct map_session_data* sd,
  4792. const char* command, const char* message)
  4793. {
  4794. int i;
  4795. struct map_session_data *pl_sd, **pl_allsd;
  4796. char party_name[NAME_LENGTH];
  4797. struct party_data *p;
  4798. int count, users;
  4799. nullpo_retr(-1, sd);
  4800. malloc_tsetdword(party_name, '\0', sizeof(party_name));
  4801. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  4802. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4803. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4804. return -1;
  4805. }
  4806. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4807. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4808. return -1;
  4809. }
  4810. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4811. (p = party_search(atoi(message))) != NULL) {
  4812. count = 0;
  4813. pl_allsd = map_getallusers(&users);
  4814. for (i = 0; i < users; i++) {
  4815. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4816. pl_sd->status.party_id == p->party.party_id) {
  4817. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4818. continue; //Skip GMs greater than you.
  4819. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4820. count++;
  4821. else
  4822. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4823. }
  4824. }
  4825. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4826. clif_displaymessage(fd, atcmd_output);
  4827. if (count) {
  4828. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4829. clif_displaymessage(fd, atcmd_output);
  4830. }
  4831. } else {
  4832. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4833. return -1;
  4834. }
  4835. return 0;
  4836. }
  4837. /*==========================================
  4838. *
  4839. *------------------------------------------
  4840. */
  4841. int atcommand_reloaditemdb(
  4842. const int fd, struct map_session_data* sd,
  4843. const char* command, const char* message)
  4844. {
  4845. nullpo_retr(-1, sd);
  4846. itemdb_reload();
  4847. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4848. return 0;
  4849. }
  4850. /*==========================================
  4851. *
  4852. *------------------------------------------
  4853. */
  4854. int atcommand_reloadmobdb(
  4855. const int fd, struct map_session_data* sd,
  4856. const char* command, const char* message)
  4857. {
  4858. nullpo_retr(-1, sd);
  4859. mob_reload();
  4860. read_petdb();
  4861. merc_reload();
  4862. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4863. return 0;
  4864. }
  4865. /*==========================================
  4866. *
  4867. *------------------------------------------
  4868. */
  4869. int atcommand_reloadskilldb(
  4870. const int fd, struct map_session_data* sd,
  4871. const char* command, const char* message)
  4872. {
  4873. nullpo_retr(-1, sd);
  4874. skill_reload();
  4875. merc_skill_reload();
  4876. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4877. return 0;
  4878. }
  4879. /*==========================================
  4880. * @reloadatcommand
  4881. * atcommand_athena.conf のリロード
  4882. *------------------------------------------
  4883. */
  4884. int
  4885. atcommand_reloadatcommand(
  4886. const int fd, struct map_session_data* sd,
  4887. const char* command, const char* message)
  4888. {
  4889. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4890. clif_displaymessage(fd, msg_txt(254));
  4891. return 0;
  4892. }
  4893. /*==========================================
  4894. * @reloadbattleconf
  4895. * battle_athena.conf のリロード
  4896. *------------------------------------------
  4897. */
  4898. int
  4899. atcommand_reloadbattleconf(
  4900. const int fd, struct map_session_data* sd,
  4901. const char* command, const char* message)
  4902. {
  4903. struct Battle_Config prev_config;
  4904. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4905. battle_config_read(BATTLE_CONF_FILENAME);
  4906. if (memcmp(&prev_config.item_rate_mvp,
  4907. &battle_config.item_rate_mvp,
  4908. sizeof(battle_config.item_rate_mvp)+
  4909. sizeof(battle_config.item_rate_common)+
  4910. sizeof(battle_config.item_rate_common_boss)+
  4911. sizeof(battle_config.item_rate_card)+
  4912. sizeof(battle_config.item_rate_card_boss)+
  4913. sizeof(battle_config.item_rate_equip)+
  4914. sizeof(battle_config.item_rate_equip_boss)+
  4915. sizeof(battle_config.item_rate_heal)+
  4916. sizeof(battle_config.item_rate_heal_boss)+
  4917. sizeof(battle_config.item_rate_use)+
  4918. sizeof(battle_config.item_rate_use_boss)+
  4919. sizeof(battle_config.item_rate_treasure)+
  4920. sizeof(battle_config.item_rate_adddrop)+
  4921. sizeof(battle_config.logarithmic_drops)+
  4922. sizeof(battle_config.item_drop_common_min)+
  4923. sizeof(battle_config.item_drop_common_max)+
  4924. sizeof(battle_config.item_drop_card_min)+
  4925. sizeof(battle_config.item_drop_card_max)+
  4926. sizeof(battle_config.item_drop_equip_min)+
  4927. sizeof(battle_config.item_drop_equip_max)+
  4928. sizeof(battle_config.item_drop_mvp_min)+
  4929. sizeof(battle_config.item_drop_mvp_max)+
  4930. sizeof(battle_config.item_drop_heal_min)+
  4931. sizeof(battle_config.item_drop_heal_max)+
  4932. sizeof(battle_config.item_drop_use_min)+
  4933. sizeof(battle_config.item_drop_use_max)+
  4934. sizeof(battle_config.item_drop_treasure_min)+
  4935. sizeof(battle_config.item_drop_treasure_max)
  4936. ) != 0)
  4937. { //Drop rates changed.
  4938. mob_reload(); //Needed as well so rate changes take effect.
  4939. #ifndef TXT_ONLY
  4940. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4941. #endif
  4942. }
  4943. clif_displaymessage(fd, msg_txt(255));
  4944. return 0;
  4945. }
  4946. /*==========================================
  4947. * @reloadstatusdb
  4948. * job_db1.txt job_db2.txt job_db2-2.txt
  4949. * refine_db.txt size_fix.txt
  4950. * のリロード
  4951. *------------------------------------------
  4952. */
  4953. int
  4954. atcommand_reloadstatusdb(
  4955. const int fd, struct map_session_data* sd,
  4956. const char* command, const char* message)
  4957. {
  4958. status_readdb();
  4959. clif_displaymessage(fd, msg_txt(256));
  4960. return 0;
  4961. }
  4962. /*==========================================
  4963. * @reloadpcdb
  4964. * exp.txt skill_tree.txt attr_fix.txt
  4965. * のリロード
  4966. *------------------------------------------
  4967. */
  4968. int
  4969. atcommand_reloadpcdb(
  4970. const int fd, struct map_session_data* sd,
  4971. const char* command, const char* message)
  4972. {
  4973. pc_readdb();
  4974. clif_displaymessage(fd, msg_txt(257));
  4975. return 0;
  4976. }
  4977. /*==========================================
  4978. * @reloadmotd [Valaris]
  4979. * Reloads motd.txt
  4980. *------------------------------------------
  4981. */
  4982. int
  4983. atcommand_reloadmotd(
  4984. const int fd, struct map_session_data* sd,
  4985. const char* command, const char* message)
  4986. {
  4987. pc_read_motd();
  4988. clif_displaymessage(fd, msg_txt(268));
  4989. return 0;
  4990. }
  4991. /*==========================================
  4992. *
  4993. *------------------------------------------
  4994. */
  4995. int atcommand_reloadscript(
  4996. const int fd, struct map_session_data* sd,
  4997. const char* command, const char* message)
  4998. {
  4999. nullpo_retr(-1, sd);
  5000. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  5001. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5002. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5003. flush_fifos();
  5004. //do_init_npc();
  5005. script_reload();
  5006. npc_reload();
  5007. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  5008. return 0;
  5009. }
  5010. /*==========================================
  5011. *
  5012. *------------------------------------------
  5013. */
  5014. int atcommand_reloadgmdb( // by [Yor]
  5015. const int fd, struct map_session_data* sd,
  5016. const char* command, const char* message)
  5017. {
  5018. nullpo_retr(-1, sd);
  5019. chrif_reloadGMdb();
  5020. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  5021. return 0;
  5022. }
  5023. /*==========================================
  5024. * @mapinfo <map name> [0-3] by MC_Cameri
  5025. * => Shows information about the map [map name]
  5026. * 0 = no additional information
  5027. * 1 = Show users in that map and their location
  5028. * 2 = Shows NPCs in that map
  5029. * 3 = Shows the shops/chats in that map (not implemented)
  5030. *------------------------------------------
  5031. */
  5032. int atcommand_mapinfo(
  5033. const int fd, struct map_session_data* sd,
  5034. const char* command, const char* message)
  5035. {
  5036. struct map_session_data *pl_sd, **pl_allsd;
  5037. struct npc_data *nd = NULL;
  5038. struct chat_data *cd = NULL;
  5039. char direction[12];
  5040. int m_id, i, chat_num, users, list = 0;
  5041. unsigned short m_index;
  5042. nullpo_retr(-1, sd);
  5043. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5044. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5045. malloc_tsetdword(direction, '\0', sizeof(direction));
  5046. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  5047. if (list < 0 || list > 3) {
  5048. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5049. return -1;
  5050. }
  5051. if (atcmd_player_name[0] == '\0') {
  5052. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  5053. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  5054. m_id = map_mapindex2mapid(sd->mapindex);
  5055. } else {
  5056. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  5057. strcat(atcmd_player_name, ".gat");
  5058. m_id = map_mapname2mapid(atcmd_player_name);
  5059. }
  5060. if (m_id < 0) {
  5061. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5062. return -1;
  5063. }
  5064. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  5065. clif_displaymessage(fd, "------ Map Info ------");
  5066. chat_num = 0;
  5067. pl_allsd = map_getallusers(&users);
  5068. for (i = 0; i < users; i++) {
  5069. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5070. chat_num++;
  5071. }
  5072. }
  5073. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  5074. clif_displaymessage(fd, atcmd_output);
  5075. if (map[m_id].flag.alias)
  5076. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  5077. clif_displaymessage(fd, "------ Map Flags ------");
  5078. strcpy(atcmd_output,"PvP Flags: ");
  5079. if (map[m_id].flag.pvp)
  5080. strcat(atcmd_output, "Pvp ON | ");
  5081. if (map[m_id].flag.pvp_noguild)
  5082. strcat(atcmd_output, "NoGuild | ");
  5083. if (map[m_id].flag.pvp_noparty)
  5084. strcat(atcmd_output, "NoParty | ");
  5085. if (map[m_id].flag.pvp_nightmaredrop)
  5086. strcat(atcmd_output, "NightmareDrop | ");
  5087. if (map[m_id].flag.pvp_nocalcrank)
  5088. strcat(atcmd_output, "NoCalcRank | ");
  5089. clif_displaymessage(fd, atcmd_output);
  5090. strcpy(atcmd_output,"GvG Flags: ");
  5091. if (map[m_id].flag.gvg)
  5092. strcat(atcmd_output, "GvG ON | ");
  5093. if (map[m_id].flag.gvg_dungeon)
  5094. strcat(atcmd_output, "GvG Dungeon | ");
  5095. if (map[m_id].flag.gvg_castle)
  5096. strcat(atcmd_output, "GvG Castle | ");
  5097. if (map[m_id].flag.gvg_noparty)
  5098. strcat(atcmd_output, "NoParty | ");
  5099. clif_displaymessage(fd, atcmd_output);
  5100. strcpy(atcmd_output,"Teleport Flags: ");
  5101. if (map[m_id].flag.noteleport)
  5102. strcat(atcmd_output, "NoTeleport | ");
  5103. if (map[m_id].flag.monster_noteleport)
  5104. strcat(atcmd_output, "Monster NoTeleport | ");
  5105. if (map[m_id].flag.nowarp)
  5106. strcat(atcmd_output, "NoWarp | ");
  5107. if (map[m_id].flag.nowarpto)
  5108. strcat(atcmd_output, "NoWarpTo | ");
  5109. if (map[m_id].flag.noreturn)
  5110. strcat(atcmd_output, "NoReturn | ");
  5111. if (map[m_id].flag.nogo)
  5112. strcat(atcmd_output, "NoGo | ");
  5113. if (map[m_id].flag.nomemo)
  5114. strcat(atcmd_output, "NoMemo | ");
  5115. clif_displaymessage(fd, atcmd_output);
  5116. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5117. clif_displaymessage(fd, atcmd_output);
  5118. if (map[m_id].flag.nosave) {
  5119. if (!map[m_id].save.map)
  5120. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  5121. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5122. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5123. else
  5124. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5125. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5126. clif_displaymessage(fd, atcmd_output);
  5127. }
  5128. strcpy(atcmd_output,"Weather Flags: ");
  5129. if (map[m_id].flag.snow)
  5130. strcat(atcmd_output, "Snow | ");
  5131. if (map[m_id].flag.fog)
  5132. strcat(atcmd_output, "Fog | ");
  5133. if (map[m_id].flag.sakura)
  5134. strcat(atcmd_output, "Sakura | ");
  5135. if (map[m_id].flag.clouds)
  5136. strcat(atcmd_output, "Clouds | ");
  5137. if (map[m_id].flag.clouds2)
  5138. strcat(atcmd_output, "Clouds2 | ");
  5139. if (map[m_id].flag.fireworks)
  5140. strcat(atcmd_output, "Fireworks | ");
  5141. if (map[m_id].flag.leaves)
  5142. strcat(atcmd_output, "Leaves | ");
  5143. if (map[m_id].flag.rain)
  5144. strcat(atcmd_output, "Rain | ");
  5145. if (map[m_id].flag.indoors)
  5146. strcat(atcmd_output, "Indoors | ");
  5147. if (map[m_id].flag.nightenabled)
  5148. strcat(atcmd_output, "Displays Night | ");
  5149. clif_displaymessage(fd, atcmd_output);
  5150. strcpy(atcmd_output,"Other Flags: ");
  5151. if (map[m_id].flag.nobranch)
  5152. strcat(atcmd_output, "NoBranch | ");
  5153. if (map[m_id].flag.notrade)
  5154. strcat(atcmd_output, "NoTrade | ");
  5155. if (map[m_id].flag.novending)
  5156. strcat(atcmd_output, "NoVending | ");
  5157. if (map[m_id].flag.nodrop)
  5158. strcat(atcmd_output, "NoDrop | ");
  5159. if (map[m_id].flag.noskill)
  5160. strcat(atcmd_output, "NoSkill | ");
  5161. if (map[m_id].flag.noicewall)
  5162. strcat(atcmd_output, "NoIcewall | ");
  5163. clif_displaymessage(fd, atcmd_output);
  5164. strcpy(atcmd_output,"Other Flags: ");
  5165. if (map[m_id].nocommand)
  5166. strcat(atcmd_output, "NoCommand | ");
  5167. if (map[m_id].flag.nobaseexp)
  5168. strcat(atcmd_output, "NoBaseEXP | ");
  5169. if (map[m_id].flag.nojobexp)
  5170. strcat(atcmd_output, "NoJobEXP | ");
  5171. if (map[m_id].flag.nomobloot)
  5172. strcat(atcmd_output, "NoMobLoot | ");
  5173. if (map[m_id].flag.nomvploot)
  5174. strcat(atcmd_output, "NoMVPLoot | ");
  5175. if (map[m_id].flag.partylock)
  5176. strcat(atcmd_output, "PartyLock | ");
  5177. if (map[m_id].flag.guildlock)
  5178. strcat(atcmd_output, "GuildLock | ");
  5179. clif_displaymessage(fd, atcmd_output);
  5180. switch (list) {
  5181. case 0:
  5182. // Do nothing. It's list 0, no additional display.
  5183. break;
  5184. case 1:
  5185. clif_displaymessage(fd, "----- Players in Map -----");
  5186. for (i = 0; i < users; i++) {
  5187. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5188. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5189. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5190. clif_displaymessage(fd, atcmd_output);
  5191. }
  5192. }
  5193. break;
  5194. case 2:
  5195. clif_displaymessage(fd, "----- NPCs in Map -----");
  5196. for (i = 0; i < map[m_id].npc_num;) {
  5197. nd = map[m_id].npc[i];
  5198. switch(nd->ud.dir) {
  5199. case 0: strcpy(direction, "North"); break;
  5200. case 1: strcpy(direction, "North West"); break;
  5201. case 2: strcpy(direction, "West"); break;
  5202. case 3: strcpy(direction, "South West"); break;
  5203. case 4: strcpy(direction, "South"); break;
  5204. case 5: strcpy(direction, "South East"); break;
  5205. case 6: strcpy(direction, "East"); break;
  5206. case 7: strcpy(direction, "North East"); break;
  5207. case 9: strcpy(direction, "North"); break;
  5208. default: strcpy(direction, "Unknown"); break;
  5209. }
  5210. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5211. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5212. clif_displaymessage(fd, atcmd_output);
  5213. }
  5214. break;
  5215. case 3:
  5216. clif_displaymessage(fd, "----- Chats in Map -----");
  5217. for (i = 0; i < users; i++) {
  5218. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5219. pl_sd->mapindex == m_index &&
  5220. cd->usersd[0] == pl_sd) {
  5221. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5222. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5223. clif_displaymessage(fd, atcmd_output);
  5224. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5225. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5226. clif_displaymessage(fd, atcmd_output);
  5227. }
  5228. }
  5229. break;
  5230. default: // normally impossible to arrive here
  5231. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5232. return -1;
  5233. break;
  5234. }
  5235. return 0;
  5236. }
  5237. /*==========================================
  5238. *
  5239. *------------------------------------------
  5240. */
  5241. int atcommand_mount_peco(
  5242. const int fd, struct map_session_data* sd,
  5243. const char* command, const char* message)
  5244. {
  5245. nullpo_retr(-1, sd);
  5246. if (!pc_isriding(sd)) { // if actually no peco
  5247. if (pc_checkskill(sd, KN_RIDING)) {
  5248. pc_setoption(sd, sd->sc.option | 0x0020);
  5249. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  5250. } else {
  5251. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  5252. return -1;
  5253. }
  5254. } else { //Dismount
  5255. pc_setoption(sd, sd->sc.option & ~0x0020);
  5256. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5257. }
  5258. return 0;
  5259. }
  5260. /*==========================================
  5261. *
  5262. *------------------------------------------
  5263. */
  5264. int atcommand_char_mount_peco(
  5265. const int fd, struct map_session_data* sd,
  5266. const char* command, const char* message)
  5267. {
  5268. struct map_session_data *pl_sd;
  5269. nullpo_retr(-1, sd);
  5270. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5271. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5272. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5273. return -1;
  5274. }
  5275. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5276. if (!pc_isriding(pl_sd)) { // if actually no peco
  5277. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5278. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5279. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5280. } else {
  5281. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5282. return -1;
  5283. }
  5284. } else { //Dismount
  5285. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5286. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5287. }
  5288. } else {
  5289. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5290. return -1;
  5291. }
  5292. return 0;
  5293. }
  5294. /*==========================================
  5295. *Spy Commands by Syrus22
  5296. *------------------------------------------
  5297. */
  5298. int atcommand_guildspy(
  5299. const int fd, struct map_session_data* sd,
  5300. const char* command, const char* message)
  5301. {
  5302. char guild_name[NAME_LENGTH];
  5303. struct guild *g;
  5304. nullpo_retr(-1, sd);
  5305. malloc_tsetdword(guild_name, '\0', sizeof(guild_name));
  5306. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5307. if (!enable_spy)
  5308. {
  5309. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5310. return -1;
  5311. }
  5312. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5313. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5314. return -1;
  5315. }
  5316. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5317. (g = guild_search(atoi(message))) != NULL) {
  5318. if (sd->guildspy == g->guild_id) {
  5319. sd->guildspy = 0;
  5320. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5321. clif_displaymessage(fd, atcmd_output);
  5322. } else {
  5323. sd->guildspy = g->guild_id;
  5324. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5325. clif_displaymessage(fd, atcmd_output);
  5326. }
  5327. } else {
  5328. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5329. return -1;
  5330. }
  5331. return 0;
  5332. }
  5333. /*==========================================
  5334. *
  5335. *------------------------------------------
  5336. */
  5337. int atcommand_partyspy(
  5338. const int fd, struct map_session_data* sd,
  5339. const char* command, const char* message)
  5340. {
  5341. char party_name[NAME_LENGTH];
  5342. struct party_data *p;
  5343. nullpo_retr(-1, sd);
  5344. malloc_tsetdword(party_name, '\0', sizeof(party_name));
  5345. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5346. if (!enable_spy)
  5347. {
  5348. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5349. return -1;
  5350. }
  5351. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5352. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5353. return -1;
  5354. }
  5355. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5356. (p = party_search(atoi(message))) != NULL) {
  5357. if (sd->partyspy == p->party.party_id) {
  5358. sd->partyspy = 0;
  5359. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5360. clif_displaymessage(fd, atcmd_output);
  5361. } else {
  5362. sd->partyspy = p->party.party_id;
  5363. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5364. clif_displaymessage(fd, atcmd_output);
  5365. }
  5366. } else {
  5367. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5368. return -1;
  5369. }
  5370. return 0;
  5371. }
  5372. /*==========================================
  5373. * @repairall [Valaris]
  5374. *------------------------------------------
  5375. */
  5376. int atcommand_repairall(
  5377. const int fd, struct map_session_data* sd,
  5378. const char* command, const char* message)
  5379. {
  5380. int count, i;
  5381. nullpo_retr(-1, sd);
  5382. count = 0;
  5383. for (i = 0; i < MAX_INVENTORY; i++) {
  5384. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5385. sd->status.inventory[i].attribute = 0;
  5386. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5387. count++;
  5388. }
  5389. }
  5390. if (count > 0) {
  5391. clif_misceffect(&sd->bl, 3);
  5392. clif_equiplist(sd);
  5393. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5394. } else {
  5395. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5396. return -1;
  5397. }
  5398. return 0;
  5399. }
  5400. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5401. int atcommand_nuke(
  5402. const int fd, struct map_session_data* sd,
  5403. const char* command, const char* message)
  5404. {
  5405. struct map_session_data *pl_sd;
  5406. nullpo_retr(-1, sd);
  5407. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5408. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5409. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5410. return -1;
  5411. }
  5412. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5413. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5414. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5415. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5416. } else {
  5417. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5418. return -1;
  5419. }
  5420. } else {
  5421. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5422. return -1;
  5423. }
  5424. return 0;
  5425. }
  5426. /*==========================================
  5427. * @tonpc
  5428. *------------------------------------------
  5429. */
  5430. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5431. const char* command, const char* message)
  5432. {
  5433. char npcname[NAME_LENGTH];
  5434. struct npc_data *nd;
  5435. nullpo_retr(-1, sd);
  5436. malloc_tsetdword(npcname, 0, sizeof(npcname));
  5437. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5438. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5439. return -1;
  5440. }
  5441. if ((nd = npc_name2id(npcname)) != NULL) {
  5442. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5443. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5444. else
  5445. return -1;
  5446. } else {
  5447. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5448. return -1;
  5449. }
  5450. return 0;
  5451. }
  5452. /*==========================================
  5453. *
  5454. *------------------------------------------
  5455. */
  5456. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5457. const char* command, const char* message)
  5458. {
  5459. char NPCname[NAME_LENGTH];
  5460. nullpo_retr(-1, sd);
  5461. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5462. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5463. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5464. return -1;
  5465. }
  5466. if (npc_name2id(NPCname) != NULL) {
  5467. npc_enable(NPCname, 1);
  5468. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5469. } else {
  5470. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5471. return -1;
  5472. }
  5473. return 0;
  5474. }
  5475. /*==========================================
  5476. *
  5477. *------------------------------------------
  5478. */
  5479. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5480. const char* command, const char* message)
  5481. {
  5482. char NPCname[NAME_LENGTH];
  5483. nullpo_retr(-1, sd);
  5484. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5485. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5486. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5487. return -1;
  5488. }
  5489. if (npc_name2id(NPCname) != NULL) {
  5490. npc_enable(NPCname, 0);
  5491. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5492. } else {
  5493. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5494. return -1;
  5495. }
  5496. return 0;
  5497. }
  5498. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5499. const char* command, const char* message)
  5500. {
  5501. FILE *fp;
  5502. if (!message || !*message) {
  5503. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5504. return -1;
  5505. }
  5506. // check if script file exists
  5507. if ((fp = fopen(message, "r")) == NULL) {
  5508. clif_displaymessage(fd, msg_txt(261));
  5509. return -1;
  5510. }
  5511. fclose(fp);
  5512. // add to list of script sources and run it
  5513. npc_addsrcfile((char *)message);
  5514. npc_parsesrcfile((char *)message);
  5515. clif_displaymessage(fd, msg_txt(262));
  5516. return 0;
  5517. }
  5518. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5519. const char* command, const char* message)
  5520. {
  5521. struct npc_data *nd;
  5522. char NPCname[NAME_LENGTH];
  5523. nullpo_retr(-1, sd);
  5524. malloc_tsetdword(NPCname, '\0', sizeof(NPCname));
  5525. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5526. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5527. return -1;
  5528. }
  5529. if ((nd = npc_name2id(NPCname)) != NULL) {
  5530. npc_unload_duplicates(nd);
  5531. npc_unload(nd);
  5532. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5533. } else {
  5534. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5535. return -1;
  5536. }
  5537. return 0;
  5538. }
  5539. /*==========================================
  5540. * time in txt for time command (by [Yor])
  5541. *------------------------------------------
  5542. */
  5543. char * txt_time(unsigned int duration) {
  5544. int days, hours, minutes, seconds;
  5545. char temp[256];
  5546. static char temp1[256];
  5547. malloc_tsetdword(temp, '\0', sizeof(temp));
  5548. malloc_tsetdword(temp1, '\0', sizeof(temp1));
  5549. days = duration / (60 * 60 * 24);
  5550. duration = duration - (60 * 60 * 24 * days);
  5551. hours = duration / (60 * 60);
  5552. duration = duration - (60 * 60 * hours);
  5553. minutes = duration / 60;
  5554. seconds = duration - (60 * minutes);
  5555. if (days < 2)
  5556. sprintf(temp, msg_txt(219), days); // %d day
  5557. else
  5558. sprintf(temp, msg_txt(220), days); // %d days
  5559. if (hours < 2)
  5560. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5561. else
  5562. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5563. if (minutes < 2)
  5564. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5565. else
  5566. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5567. if (seconds < 2)
  5568. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5569. else
  5570. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5571. return temp1;
  5572. }
  5573. /*==========================================
  5574. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5575. * Calculation management of GM modification (@day/@night GM commands) is done
  5576. *------------------------------------------
  5577. */
  5578. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5579. const char* command, const char* message)
  5580. {
  5581. struct TimerData * timer_data;
  5582. struct TimerData * timer_data2;
  5583. time_t time_server; // variable for number of seconds (used with time() function)
  5584. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5585. char temp[256];
  5586. nullpo_retr(-1, sd);
  5587. malloc_tsetdword(temp, '\0', sizeof(temp));
  5588. time(&time_server); // get time in seconds since 1/1/1970
  5589. datetime = localtime(&time_server); // convert seconds in structure
  5590. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5591. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5592. clif_displaymessage(fd, temp);
  5593. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5594. if (night_flag == 0)
  5595. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5596. else
  5597. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5598. } else if (battle_config.night_duration == 0)
  5599. if (night_flag == 1) { // we start with night
  5600. timer_data = get_timer(day_timer_tid);
  5601. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5602. clif_displaymessage(fd, temp);
  5603. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5604. } else
  5605. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5606. else if (battle_config.day_duration == 0)
  5607. if (night_flag == 0) { // we start with day
  5608. timer_data = get_timer(night_timer_tid);
  5609. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5610. clif_displaymessage(fd, temp);
  5611. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5612. } else
  5613. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5614. else {
  5615. if (night_flag == 0) {
  5616. timer_data = get_timer(night_timer_tid);
  5617. timer_data2 = get_timer(day_timer_tid);
  5618. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5619. clif_displaymessage(fd, temp);
  5620. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5621. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5622. else
  5623. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5624. clif_displaymessage(fd, temp);
  5625. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5626. clif_displaymessage(fd, temp);
  5627. } else {
  5628. timer_data = get_timer(day_timer_tid);
  5629. timer_data2 = get_timer(night_timer_tid);
  5630. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5631. clif_displaymessage(fd, temp);
  5632. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5633. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5634. else
  5635. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5636. clif_displaymessage(fd, temp);
  5637. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5638. clif_displaymessage(fd, temp);
  5639. }
  5640. }
  5641. return 0;
  5642. }
  5643. /*==========================================
  5644. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5645. * removes <quantity> item from a character
  5646. * item can be equiped or not.
  5647. * Inspired from a old command created by RoVeRT
  5648. *------------------------------------------
  5649. */
  5650. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5651. const char* command, const char* message)
  5652. {
  5653. struct map_session_data *pl_sd;
  5654. char item_name[100];
  5655. int i, number = 0, item_id, item_position, count;
  5656. struct item_data *item_data;
  5657. nullpo_retr(-1, sd);
  5658. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5659. malloc_tsetdword(item_name, '\0', sizeof(item_name));
  5660. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  5661. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5662. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5663. return -1;
  5664. }
  5665. item_id = 0;
  5666. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5667. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5668. item_id = item_data->nameid;
  5669. if (item_id > 500) {
  5670. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5671. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5672. item_position = pc_search_inventory(pl_sd, item_id);
  5673. if (item_position >= 0) {
  5674. count = 0;
  5675. for(i = 0; i < number && item_position >= 0; i++) {
  5676. //Logs (A)dmins items [Lupus]
  5677. if(log_config.enable_logs&0x400)
  5678. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5679. pc_delitem(pl_sd, item_position, 1, 0);
  5680. count++;
  5681. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5682. }
  5683. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5684. clif_displaymessage(pl_sd->fd, atcmd_output);
  5685. if (number == count)
  5686. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5687. else
  5688. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5689. clif_displaymessage(fd, atcmd_output);
  5690. } else {
  5691. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5692. return -1;
  5693. }
  5694. } else {
  5695. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5696. return -1;
  5697. }
  5698. } else {
  5699. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5700. return -1;
  5701. }
  5702. } else {
  5703. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5704. return -1;
  5705. }
  5706. return 0;
  5707. }
  5708. //Added by Coltaro
  5709. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  5710. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5711. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) {
  5712. const int factor_year = 518400; //12*30*24*60 = 518400
  5713. const int factor_month = 43200; //30*24*60 = 43200
  5714. const int factor_day = 1440; //24*60 = 1440
  5715. const int factor_hour = 60;
  5716. *year = jailtime/factor_year;
  5717. jailtime -= *year*factor_year;
  5718. *month = jailtime/factor_month;
  5719. jailtime -= *month*factor_month;
  5720. *day = jailtime/factor_day;
  5721. jailtime -= *day*factor_day;
  5722. *hour = jailtime/factor_hour;
  5723. jailtime -= *hour*factor_hour;
  5724. *minute = jailtime;
  5725. *year = *year > 0? *year : 0;
  5726. *month = *month > 0? *month : 0;
  5727. *day = *day > 0? *day : 0;
  5728. *hour = *hour > 0? *hour : 0;
  5729. *minute = *minute > 0? *minute : 0;
  5730. return;
  5731. }
  5732. /*==========================================
  5733. * @jail <char_name> by [Yor]
  5734. * Special warp! No check with nowarp and nowarpto flag
  5735. *------------------------------------------
  5736. */
  5737. int atcommand_jail(
  5738. const int fd, struct map_session_data* sd,
  5739. const char* command, const char* message)
  5740. {
  5741. struct map_session_data *pl_sd;
  5742. int x, y;
  5743. unsigned short m_index;
  5744. nullpo_retr(-1, sd);
  5745. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5746. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5747. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5748. return -1;
  5749. }
  5750. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5751. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5752. return -1;
  5753. }
  5754. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5755. { // you can jail only lower or same GM
  5756. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5757. return -1;
  5758. }
  5759. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5760. { //Already jailed
  5761. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5762. return -1;
  5763. }
  5764. switch(rand() % 2) { //Jail Locations
  5765. case 0:
  5766. m_index = mapindex_name2id(MAP_JAIL);
  5767. x = 24;
  5768. y = 75;
  5769. break;
  5770. default:
  5771. m_index = mapindex_name2id(MAP_JAIL);
  5772. x = 49;
  5773. y = 75;
  5774. break;
  5775. }
  5776. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5777. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5778. return -1;
  5779. }
  5780. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5781. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5782. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5783. return 0;
  5784. }
  5785. /*==========================================
  5786. * @unjail/@discharge <char_name> by [Yor]
  5787. * Special warp! No check with nowarp and nowarpto flag
  5788. *------------------------------------------
  5789. */
  5790. int atcommand_unjail(
  5791. const int fd, struct map_session_data* sd,
  5792. const char* command, const char* message)
  5793. {
  5794. struct map_session_data *pl_sd;
  5795. unsigned short m_index;
  5796. int x=0, y=0;
  5797. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5798. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5799. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5800. return -1;
  5801. }
  5802. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5803. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5804. return -1;
  5805. }
  5806. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5807. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5808. return -1;
  5809. }
  5810. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5811. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5812. return -1;
  5813. }
  5814. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5815. { //Retrieve return map.
  5816. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5817. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5818. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5819. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5820. } else
  5821. m_index = mapindex_name2id(MAP_PRONTERA);
  5822. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5823. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5824. ) { //Send to Prontera is saved SC map fails.
  5825. pc_setsavepoint(pl_sd, m_index, x, y);
  5826. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5827. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5828. } else {
  5829. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5830. return -1;
  5831. }
  5832. return 0;
  5833. }
  5834. int atcommand_jailfor(
  5835. const int fd, struct map_session_data* sd,
  5836. const char* command, const char* message)
  5837. {
  5838. struct map_session_data *pl_sd = NULL;
  5839. int year, month, day, hour, minute, value;
  5840. char * modif_p;
  5841. int jailtime = 0,x,y;
  5842. short m_index = 0;
  5843. nullpo_retr(-1, sd);
  5844. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5845. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5846. return -1;
  5847. }
  5848. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5849. modif_p = atcmd_output;
  5850. year = month = day = hour = minute = 0;
  5851. while (modif_p[0] != '\0') {
  5852. value = atoi(modif_p);
  5853. if (value == 0)
  5854. modif_p++;
  5855. else {
  5856. if (modif_p[0] == '-' || modif_p[0] == '+')
  5857. modif_p++;
  5858. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5859. modif_p++;
  5860. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5861. minute = value;
  5862. modif_p = modif_p + 2;
  5863. } else if (modif_p[0] == 'h') {
  5864. hour = value;
  5865. modif_p++;
  5866. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5867. day = value;
  5868. modif_p++;
  5869. } else if (modif_p[0] == 'm') {
  5870. month = value;
  5871. modif_p++;
  5872. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5873. year = value;
  5874. modif_p++;
  5875. } else if (modif_p[0] != '\0') {
  5876. modif_p++;
  5877. }
  5878. }
  5879. }
  5880. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5881. clif_displaymessage(fd, "Invalid time for jail command.");
  5882. return -1;
  5883. }
  5884. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5885. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5886. return -1;
  5887. }
  5888. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5889. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5890. return -1;
  5891. }
  5892. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5893. if(jailtime==0) {
  5894. clif_displaymessage(fd, "Invalid time for jail command.");
  5895. return -1;
  5896. }
  5897. //Added by Coltaro
  5898. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5899. { //Update the player's jail time
  5900. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5901. if (jailtime <= 0) {
  5902. jailtime = 0;
  5903. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5904. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5905. } else {
  5906. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5907. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5908. clif_displaymessage(pl_sd->fd, atcmd_output);
  5909. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5910. clif_displaymessage(fd, atcmd_output);
  5911. }
  5912. } else if (jailtime < 0) {
  5913. clif_displaymessage(fd, "Invalid time for jail command.");
  5914. return -1;
  5915. }
  5916. //Jail locations, add more as you wish.
  5917. switch(rand()%2)
  5918. {
  5919. case 1: //Jail #1
  5920. m_index = mapindex_name2id(MAP_JAIL);
  5921. x = 49; y = 75;
  5922. break;
  5923. default: //Default Jail
  5924. m_index = mapindex_name2id(MAP_JAIL);
  5925. x = 24; y = 75;
  5926. break;
  5927. }
  5928. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  5929. return 0;
  5930. }
  5931. //By Coltaro
  5932. int atcommand_jailtime(
  5933. const int fd, struct map_session_data* sd,
  5934. const char* command, const char* message)
  5935. {
  5936. int year, month, day, hour, minute;
  5937. nullpo_retr(-1, sd);
  5938. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5939. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5940. return -1;
  5941. }
  5942. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5943. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5944. return -1;
  5945. }
  5946. //Get remaining jail time
  5947. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5948. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5949. clif_displaymessage(fd, atcmd_output);
  5950. return 0;
  5951. }
  5952. //By Coltaro
  5953. int atcommand_charjailtime(
  5954. const int fd, struct map_session_data* sd,
  5955. const char* command, const char* message)
  5956. {
  5957. struct map_session_data* pl_sd;
  5958. int year, month, day, hour, minute;
  5959. nullpo_retr(-1, sd);
  5960. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5961. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5962. return -1;
  5963. }
  5964. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5965. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5966. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5967. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5968. return -1;
  5969. }
  5970. if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
  5971. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5972. return -1;
  5973. }
  5974. //Get remaining jail time
  5975. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5976. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5977. clif_displaymessage(fd, atcmd_output);
  5978. } else {
  5979. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5980. return -1;
  5981. }
  5982. } else {
  5983. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5984. return -1;
  5985. }
  5986. return 0;
  5987. }
  5988. /*==========================================
  5989. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5990. *------------------------------------------
  5991. */
  5992. int atcommand_disguise(
  5993. const int fd, struct map_session_data* sd,
  5994. const char* command, const char* message)
  5995. {
  5996. int id = 0;
  5997. nullpo_retr(-1, sd);
  5998. if (!message || !*message) {
  5999. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  6000. return -1;
  6001. }
  6002. if ((id = atoi(message)) > 0)
  6003. { //Acquired an ID
  6004. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  6005. id = 0; //Invalid id for either mobs or npcs.
  6006. } else { //Acquired a Name
  6007. if ((id = mobdb_searchname(message)) == 0)
  6008. {
  6009. struct npc_data* nd = npc_name2id(message);
  6010. if (nd != NULL)
  6011. id = nd->n;
  6012. }
  6013. }
  6014. if (id == 0)
  6015. { // Monster/NPC name/id hasn't been found.
  6016. clif_displaymessage(fd, msg_txt(123));
  6017. return -1;
  6018. }
  6019. pc_disguise(sd, id);
  6020. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  6021. return 0;
  6022. }
  6023. /*==========================================
  6024. * DisguiseAll
  6025. *------------------------------------------
  6026. */
  6027. int atcommand_disguiseall(
  6028. const int fd, struct map_session_data* sd,
  6029. const char* command, const char* message)
  6030. {
  6031. int mob_id=0, i=0, users;
  6032. struct map_session_data *pl_sd, **pl_allsd;
  6033. nullpo_retr(-1, sd);
  6034. if (!message || !*message) {
  6035. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  6036. return -1;
  6037. }
  6038. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  6039. mob_id = atoi(message);
  6040. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  6041. pl_allsd = map_getallusers(&users);
  6042. for(i=0; i < users; i++) {
  6043. if((pl_sd = pl_allsd[i]))
  6044. pc_disguise(pl_sd, mob_id);
  6045. }
  6046. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  6047. } else {
  6048. return -1;
  6049. }
  6050. return 0;
  6051. }
  6052. /*==========================================
  6053. * @undisguise by [Yor]
  6054. *------------------------------------------
  6055. */
  6056. int atcommand_undisguise(
  6057. const int fd, struct map_session_data* sd,
  6058. const char* command, const char* message)
  6059. {
  6060. nullpo_retr(-1, sd);
  6061. if (sd->disguise) {
  6062. pc_disguise(sd, 0);
  6063. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6064. } else {
  6065. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  6066. return -1;
  6067. }
  6068. return 0;
  6069. }
  6070. /*==========================================
  6071. * UndisguiseAll
  6072. *------------------------------------------
  6073. */
  6074. int atcommand_undisguiseall(
  6075. const int fd, struct map_session_data* sd,
  6076. const char* command, const char* message)
  6077. {
  6078. struct map_session_data *pl_sd, **pl_allsd;
  6079. int i, users;
  6080. nullpo_retr(-1, sd);
  6081. pl_allsd = map_getallusers(&users);
  6082. for(i=0; i < users; i++) {
  6083. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  6084. pc_disguise(pl_sd, 0);
  6085. }
  6086. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  6087. return 0;
  6088. }
  6089. /*==========================================
  6090. * @exp by [Skotlex]
  6091. *------------------------------------------
  6092. */
  6093. int atcommand_exp(
  6094. const int fd, struct map_session_data* sd,
  6095. const char* command, const char* message)
  6096. {
  6097. char output[200];
  6098. double nextb, nextj;
  6099. nullpo_retr(-1, sd);
  6100. malloc_tsetdword(output, '\0', sizeof(output));
  6101. nextb = pc_nextbaseexp(sd);
  6102. if (nextb)
  6103. nextb = sd->status.base_exp*100.0/nextb;
  6104. nextj = pc_nextjobexp(sd);
  6105. if (nextj)
  6106. nextj = sd->status.job_exp*100.0/nextj;
  6107. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  6108. clif_displaymessage(fd, output);
  6109. return 0;
  6110. }
  6111. /*==========================================
  6112. * @broadcast by [Valaris]
  6113. *------------------------------------------
  6114. */
  6115. int atcommand_broadcast(
  6116. const int fd, struct map_session_data* sd,
  6117. const char* command, const char* message)
  6118. {
  6119. nullpo_retr(-1, sd);
  6120. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6121. if (!message || !*message) {
  6122. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  6123. return -1;
  6124. }
  6125. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6126. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  6127. return 0;
  6128. }
  6129. /*==========================================
  6130. * @localbroadcast by [Valaris]
  6131. *------------------------------------------
  6132. */
  6133. int atcommand_localbroadcast(
  6134. const int fd, struct map_session_data* sd,
  6135. const char* command, const char* message)
  6136. {
  6137. nullpo_retr(-1, sd);
  6138. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6139. if (!message || !*message) {
  6140. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  6141. return -1;
  6142. }
  6143. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  6144. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  6145. return 0;
  6146. }
  6147. /*==========================================
  6148. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  6149. *------------------------------------------
  6150. */
  6151. int atcommand_chardisguise(
  6152. const int fd, struct map_session_data* sd,
  6153. const char* command, const char* message)
  6154. {
  6155. int mob_id;
  6156. char mob_name[NAME_LENGTH];
  6157. struct map_session_data* pl_sd;
  6158. nullpo_retr(-1, sd);
  6159. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6160. malloc_tsetdword(mob_name, '\0', sizeof(mob_name));
  6161. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  6162. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  6163. return -1;
  6164. }
  6165. if ((mob_id = atoi(mob_name)) > 0)
  6166. { //Acquired an ID
  6167. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  6168. mob_id = 0; //Invalid id for either mobs or npcs.
  6169. } else { //Acquired a Name
  6170. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  6171. {
  6172. struct npc_data* nd = npc_name2id(mob_name);
  6173. if (nd != NULL)
  6174. mob_id = nd->n;
  6175. }
  6176. }
  6177. if (mob_id == 0)
  6178. {
  6179. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  6180. return -1;
  6181. }
  6182. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6183. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  6184. pc_disguise(pl_sd, mob_id);
  6185. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  6186. } else {
  6187. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6188. return -1;
  6189. }
  6190. } else {
  6191. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6192. return -1;
  6193. }
  6194. return 0;
  6195. }
  6196. /*==========================================
  6197. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  6198. *------------------------------------------
  6199. */
  6200. int atcommand_charundisguise(
  6201. const int fd, struct map_session_data* sd,
  6202. const char* command, const char* message)
  6203. {
  6204. struct map_session_data* pl_sd;
  6205. nullpo_retr(-1, sd);
  6206. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6207. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6208. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  6209. return -1;
  6210. }
  6211. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6212. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  6213. if (pl_sd->disguise)
  6214. pc_disguise(pl_sd, 0);
  6215. else {
  6216. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  6217. return -1;
  6218. }
  6219. } else {
  6220. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6221. return -1;
  6222. }
  6223. } else {
  6224. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6225. return -1;
  6226. }
  6227. return 0;
  6228. }
  6229. /*==========================================
  6230. * @email <actual@email> <new@email> by [Yor]
  6231. *------------------------------------------
  6232. */
  6233. int atcommand_email(
  6234. const int fd, struct map_session_data* sd,
  6235. const char* command, const char* message)
  6236. {
  6237. char actual_email[100];
  6238. char new_email[100];
  6239. nullpo_retr(-1, sd);
  6240. malloc_tsetdword(actual_email, '\0', sizeof(actual_email));
  6241. malloc_tsetdword(new_email, '\0', sizeof(new_email));
  6242. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  6243. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  6244. return -1;
  6245. }
  6246. if (e_mail_check(actual_email) == 0) {
  6247. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  6248. return -1;
  6249. } else if (e_mail_check(new_email) == 0) {
  6250. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  6251. return -1;
  6252. } else if (strcmpi(new_email, "a@a.com") == 0) {
  6253. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  6254. return -1;
  6255. } else if (strcmpi(actual_email, new_email) == 0) {
  6256. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  6257. return -1;
  6258. } else {
  6259. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  6260. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  6261. }
  6262. return 0;
  6263. }
  6264. /*==========================================
  6265. *@effect
  6266. *------------------------------------------
  6267. */
  6268. int atcommand_effect(
  6269. const int fd, struct map_session_data* sd,
  6270. const char* command, const char* message)
  6271. {
  6272. int type = 0, flag = 0;
  6273. nullpo_retr(-1, sd);
  6274. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  6275. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  6276. return -1;
  6277. }
  6278. clif_specialeffect(&sd->bl, type, flag);
  6279. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  6280. return 0;
  6281. }
  6282. /*==========================================
  6283. * @charcartlist <character>: Displays the items list of a player's cart.
  6284. *------------------------------------------
  6285. */
  6286. int
  6287. atcommand_character_cart_list(
  6288. const int fd, struct map_session_data* sd,
  6289. const char* command, const char* message)
  6290. {
  6291. char outputtmp[200];
  6292. struct map_session_data *pl_sd;
  6293. struct item_data *item_data, *item_temp;
  6294. int i, j, count, counter, counter2;
  6295. nullpo_retr(-1, sd);
  6296. malloc_tsetdword(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6297. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6298. malloc_tsetdword(outputtmp, '\0', sizeof(outputtmp));
  6299. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6300. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6301. return -1;
  6302. }
  6303. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6304. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6305. counter = 0;
  6306. count = 0;
  6307. for (i = 0; i < MAX_CART; i++) {
  6308. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6309. counter = counter + pl_sd->status.cart[i].amount;
  6310. count++;
  6311. if (count == 1) {
  6312. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6313. clif_displaymessage(fd, atcmd_output);
  6314. }
  6315. if (pl_sd->status.cart[i].refine)
  6316. sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  6317. else
  6318. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6319. clif_displaymessage(fd, atcmd_output);
  6320. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  6321. counter2 = 0;
  6322. for (j = 0; j < item_data->slot; j++) {
  6323. if (pl_sd->status.cart[i].card[j]) {
  6324. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6325. if (atcmd_output[0] == '\0')
  6326. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6327. else
  6328. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6329. strcat(atcmd_output, outputtmp);
  6330. }
  6331. }
  6332. }
  6333. if (atcmd_output[0] != '\0') {
  6334. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6335. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6336. clif_displaymessage(fd, atcmd_output);
  6337. }
  6338. }
  6339. }
  6340. if (count == 0)
  6341. clif_displaymessage(fd, "No item found in the cart of this player.");
  6342. else {
  6343. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6344. clif_displaymessage(fd, atcmd_output);
  6345. }
  6346. } else {
  6347. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6348. return -1;
  6349. }
  6350. } else {
  6351. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6352. return -1;
  6353. }
  6354. return 0;
  6355. }
  6356. /*==========================================
  6357. * @killer by MouseJstr
  6358. * enable killing players even when not in pvp
  6359. *------------------------------------------
  6360. */
  6361. int
  6362. atcommand_killer(
  6363. const int fd, struct map_session_data* sd,
  6364. const char* command, const char* message)
  6365. {
  6366. nullpo_retr(-1, sd);
  6367. sd->state.killer = !sd->state.killer;
  6368. if(sd->state.killer)
  6369. clif_displaymessage(fd, msg_txt(241));
  6370. else
  6371. clif_displaymessage(fd, msg_txt(287));
  6372. return 0;
  6373. }
  6374. /*==========================================
  6375. * @killable by MouseJstr
  6376. * enable other people killing you
  6377. *------------------------------------------
  6378. */
  6379. int
  6380. atcommand_killable(
  6381. const int fd, struct map_session_data* sd,
  6382. const char* command, const char* message)
  6383. {
  6384. nullpo_retr(-1, sd);
  6385. sd->state.killable = !sd->state.killable;
  6386. if(sd->state.killable)
  6387. clif_displaymessage(fd, msg_txt(242));
  6388. else
  6389. clif_displaymessage(fd, msg_txt(288));
  6390. return 0;
  6391. }
  6392. /*==========================================
  6393. * @charkillable by MouseJstr
  6394. * enable another player to be killed
  6395. *------------------------------------------
  6396. */
  6397. int
  6398. atcommand_charkillable(
  6399. const int fd, struct map_session_data* sd,
  6400. const char* command, const char* message)
  6401. {
  6402. struct map_session_data *pl_sd = NULL;
  6403. nullpo_retr(-1, sd);
  6404. if (!message || !*message)
  6405. return -1;
  6406. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6407. return -1;
  6408. pl_sd->state.killable = !pl_sd->state.killable;
  6409. if(pl_sd->state.killable)
  6410. clif_displaymessage(fd, msg_txt(289));
  6411. else
  6412. clif_displaymessage(fd, msg_txt(290));
  6413. return 0;
  6414. }
  6415. /*==========================================
  6416. * @skillon by MouseJstr
  6417. * turn skills on for the map
  6418. *------------------------------------------
  6419. */
  6420. int
  6421. atcommand_skillon(
  6422. const int fd, struct map_session_data* sd,
  6423. const char* command, const char* message)
  6424. {
  6425. nullpo_retr(-1, sd);
  6426. map[sd->bl.m].flag.noskill = 0;
  6427. clif_displaymessage(fd, msg_txt(244));
  6428. return 0;
  6429. }
  6430. /*==========================================
  6431. * @skilloff by MouseJstr
  6432. * Turn skills off on the map
  6433. *------------------------------------------
  6434. */
  6435. int
  6436. atcommand_skilloff(
  6437. const int fd, struct map_session_data* sd,
  6438. const char* command, const char* message)
  6439. {
  6440. nullpo_retr(-1, sd);
  6441. map[sd->bl.m].flag.noskill = 1;
  6442. clif_displaymessage(fd, msg_txt(243));
  6443. return 0;
  6444. }
  6445. /*==========================================
  6446. * @npcmove by MouseJstr
  6447. *
  6448. * move a npc
  6449. *------------------------------------------
  6450. */
  6451. int
  6452. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6453. const char* command, const char* message)
  6454. {
  6455. int x = 0, y = 0, m;
  6456. struct npc_data *nd = 0;
  6457. nullpo_retr(-1, sd);
  6458. if (!message || !*message)
  6459. return -1;
  6460. malloc_tsetdword(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6461. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6462. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6463. return -1;
  6464. }
  6465. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6466. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6467. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6468. return -1;
  6469. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6470. return -1; //Not on a map.
  6471. if (x < 0) x = 0;
  6472. else if (x >= map[m].xs) x = map[m].xs-1;
  6473. if (y < 0) y = 0;
  6474. else if (y >= map[m].ys) y = map[m].ys-1;
  6475. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6476. map_moveblock(&nd->bl, x, y, gettick());
  6477. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6478. return 0;
  6479. }
  6480. /*==========================================
  6481. * @addwarp by MouseJstr
  6482. *
  6483. * Create a new static warp point.
  6484. *------------------------------------------
  6485. */
  6486. int
  6487. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6488. const char* command, const char* message)
  6489. {
  6490. char w1[64], w3[64], w4[64];
  6491. int x,y,ret;
  6492. nullpo_retr(-1, sd);
  6493. if (!message || !*message)
  6494. return -1;
  6495. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6496. return -1;
  6497. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6498. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6499. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6500. ret = npc_parse_warp(w1, "warp", w3, w4);
  6501. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6502. clif_displaymessage(fd, atcmd_output);
  6503. return ret;
  6504. }
  6505. /*==========================================
  6506. * @follow by [MouseJstr]
  6507. *
  6508. * Follow a player .. staying no more then 5 spaces away
  6509. *------------------------------------------
  6510. */
  6511. int
  6512. atcommand_follow(const int fd, struct map_session_data* sd,
  6513. const char* command, const char* message)
  6514. {
  6515. struct map_session_data *pl_sd = NULL;
  6516. nullpo_retr(-1, sd);
  6517. if (!message || !*message) {
  6518. if (sd->followtarget == -1)
  6519. return -1;
  6520. pc_stop_following (sd);
  6521. clif_displaymessage(fd, "Follow mode OFF.");
  6522. return 0;
  6523. }
  6524. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6525. if (sd->followtarget == pl_sd->bl.id) {
  6526. pc_stop_following (sd);
  6527. clif_displaymessage(fd, "Follow mode OFF.");
  6528. } else {
  6529. pc_follow(sd, pl_sd->bl.id);
  6530. clif_displaymessage(fd, "Follow mode ON.");
  6531. }
  6532. return 0;
  6533. } else {
  6534. clif_displaymessage(fd, "Character not found.");
  6535. return -1;
  6536. }
  6537. return 1;
  6538. }
  6539. /*==========================================
  6540. * @dropall by [MouseJstr]
  6541. *
  6542. * Drop all your possession on the ground
  6543. *------------------------------------------
  6544. */
  6545. int
  6546. atcommand_dropall(const int fd, struct map_session_data* sd,
  6547. const char* command, const char* message)
  6548. {
  6549. int i;
  6550. nullpo_retr(-1, sd);
  6551. for (i = 0; i < MAX_INVENTORY; i++) {
  6552. if (sd->status.inventory[i].amount) {
  6553. if(sd->status.inventory[i].equip != 0)
  6554. pc_unequipitem(sd, i, 3);
  6555. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6556. }
  6557. }
  6558. return 0;
  6559. }
  6560. /*==========================================
  6561. * @chardropall by [MouseJstr]
  6562. *
  6563. * Throw all the characters possessions on the ground. Normally
  6564. * done in response to them being disrespectful of a GM
  6565. *------------------------------------------
  6566. */
  6567. int
  6568. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6569. const char* command, const char* message)
  6570. {
  6571. int i;
  6572. struct map_session_data *pl_sd = NULL;
  6573. nullpo_retr(-1, sd);
  6574. if (!message || !*message)
  6575. return -1;
  6576. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6577. return -1;
  6578. for (i = 0; i < MAX_INVENTORY; i++) {
  6579. if (pl_sd->status.inventory[i].amount) {
  6580. if(pl_sd->status.inventory[i].equip != 0)
  6581. pc_unequipitem(pl_sd, i, 3);
  6582. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6583. }
  6584. }
  6585. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6586. clif_displaymessage(fd, "It is done");
  6587. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6588. return 0;
  6589. }
  6590. /*==========================================
  6591. * @storeall by [MouseJstr]
  6592. *
  6593. * Put everything into storage to simplify your inventory to make
  6594. * debugging easie
  6595. *------------------------------------------
  6596. */
  6597. int
  6598. atcommand_storeall(const int fd, struct map_session_data* sd,
  6599. const char* command, const char* message)
  6600. {
  6601. int i;
  6602. nullpo_retr(-1, sd);
  6603. if (sd->state.storage_flag != 1)
  6604. { //Open storage.
  6605. switch (storage_storageopen(sd)) {
  6606. case 2: //Try again
  6607. clif_displaymessage(fd, "run this command again..");
  6608. return 0;
  6609. case 1: //Failure
  6610. clif_displaymessage(fd, "You can't open the storage currently.");
  6611. return -1;
  6612. }
  6613. }
  6614. for (i = 0; i < MAX_INVENTORY; i++) {
  6615. if (sd->status.inventory[i].amount) {
  6616. if(sd->status.inventory[i].equip != 0)
  6617. pc_unequipitem(sd, i, 3);
  6618. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6619. }
  6620. }
  6621. storage_storageclose(sd);
  6622. clif_displaymessage(fd, "It is done");
  6623. return 0;
  6624. }
  6625. /*==========================================
  6626. * @charstoreall by [MouseJstr]
  6627. *
  6628. * A way to screw with players who piss you off
  6629. *------------------------------------------
  6630. */
  6631. int
  6632. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6633. const char* command, const char* message)
  6634. {
  6635. int i;
  6636. struct map_session_data *pl_sd = NULL;
  6637. nullpo_retr(-1, sd);
  6638. if (!message || !*message)
  6639. return -1;
  6640. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6641. return -1;
  6642. if (pl_sd->state.storage_flag != 1)
  6643. { //Open storage.
  6644. switch (storage_storageopen(pl_sd)) {
  6645. case 2: //Try again
  6646. clif_displaymessage(fd, "Had to open the characters storage window...");
  6647. clif_displaymessage(fd, "run this command again..");
  6648. return 0;
  6649. case 1: //Failure
  6650. clif_displaymessage(fd, "The character currently can't use the storage.");
  6651. return 1;
  6652. }
  6653. }
  6654. for (i = 0; i < MAX_INVENTORY; i++) {
  6655. if (pl_sd->status.inventory[i].amount) {
  6656. if(pl_sd->status.inventory[i].equip != 0)
  6657. pc_unequipitem(pl_sd, i, 3);
  6658. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6659. }
  6660. }
  6661. storage_storageclose(pl_sd);
  6662. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6663. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6664. clif_displaymessage(pl_sd->fd, " -- the management");
  6665. clif_displaymessage(fd, "It is done");
  6666. return 0;
  6667. }
  6668. /*==========================================
  6669. * @skillid by [MouseJstr]
  6670. *
  6671. * lookup a skill by name
  6672. *------------------------------------------
  6673. */
  6674. int
  6675. atcommand_skillid(const int fd, struct map_session_data* sd,
  6676. const char* command, const char* message)
  6677. {
  6678. int skillen, idx;
  6679. nullpo_retr(-1, sd);
  6680. if (!message || !*message)
  6681. return -1;
  6682. skillen = strlen(message);
  6683. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6684. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6685. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6686. {
  6687. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6688. clif_displaymessage(fd, atcmd_output);
  6689. }
  6690. }
  6691. return 0;
  6692. }
  6693. /*==========================================
  6694. * @useskill by [MouseJstr]
  6695. *
  6696. * A way of using skills without having to find them in the skills menu
  6697. *------------------------------------------
  6698. */
  6699. int
  6700. atcommand_useskill(const int fd, struct map_session_data* sd,
  6701. const char* command, const char* message)
  6702. {
  6703. struct map_session_data *pl_sd = NULL;
  6704. struct block_list *bl;
  6705. int skillnum;
  6706. int skilllv;
  6707. char target[255];
  6708. nullpo_retr(-1, sd);
  6709. if (!message || !*message)
  6710. return -1;
  6711. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6712. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6713. return -1;
  6714. }
  6715. if((pl_sd=map_nick2sd(target)) == NULL) {
  6716. return -1;
  6717. }
  6718. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6719. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6720. bl = &sd->hd->bl;
  6721. else
  6722. bl = &sd->bl;
  6723. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6724. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6725. else
  6726. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6727. return 0;
  6728. }
  6729. /*==========================================
  6730. * @skilltree by [MouseJstr]
  6731. *
  6732. * prints the skill tree for a player required to get to a skill
  6733. *------------------------------------------
  6734. */
  6735. int
  6736. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6737. const char* command, const char* message)
  6738. {
  6739. struct map_session_data *pl_sd = NULL;
  6740. int skillnum, skillidx = -1;
  6741. int meets = 1, j, c=0;
  6742. char target[NAME_LENGTH], *tbl;
  6743. struct skill_tree_entry *ent;
  6744. nullpo_retr(-1, sd);
  6745. if (!message || !*message)
  6746. return -1;
  6747. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6748. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6749. return -1;
  6750. }
  6751. if((pl_sd=map_nick2sd(target)) == NULL)
  6752. return -1;
  6753. c = pc_calc_skilltree_normalize_job(pl_sd);
  6754. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6755. tbl = job_name(c);
  6756. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6757. tbl, pc_checkskill(pl_sd, 1));
  6758. clif_displaymessage(fd, atcmd_output);
  6759. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6760. if (skill_tree[c][j].id == skillnum) {
  6761. skillidx = j;
  6762. break;
  6763. }
  6764. }
  6765. if (skillidx == -1) {
  6766. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6767. clif_displaymessage(fd, atcmd_output);
  6768. return 0;
  6769. }
  6770. ent = &skill_tree[c][skillidx];
  6771. for(j=0;j<5;j++)
  6772. if( ent->need[j].id &&
  6773. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6774. {
  6775. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6776. sprintf(atcmd_output, "player requires level %d of skill %s",
  6777. ent->need[j].lv, desc);
  6778. clif_displaymessage(fd, atcmd_output);
  6779. meets = 0;
  6780. }
  6781. if (meets == 1) {
  6782. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6783. clif_displaymessage(fd, atcmd_output);
  6784. }
  6785. return 0;
  6786. }
  6787. // Hand a ring with partners name on it to this char
  6788. void getring (struct map_session_data *sd)
  6789. {
  6790. int flag,item_id = 0;
  6791. struct item item_tmp;
  6792. if(sd->status.sex==0)
  6793. item_id = 2635;
  6794. else
  6795. item_id = 2634;
  6796. malloc_set(&item_tmp,0,sizeof(item_tmp));
  6797. item_tmp.nameid=item_id;
  6798. item_tmp.identify=1;
  6799. item_tmp.card[0]=255;
  6800. item_tmp.card[2]=sd->status.partner_id;
  6801. item_tmp.card[3]=sd->status.partner_id >> 16;
  6802. //Logs (A)dmins items [Lupus]
  6803. if(log_config.enable_logs&0x400)
  6804. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  6805. if((flag = pc_additem(sd,&item_tmp,1))) {
  6806. clif_additem(sd,0,0,flag);
  6807. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6808. }
  6809. }
  6810. /*==========================================
  6811. * @marry by [MouseJstr], fixed by Lupus
  6812. *
  6813. * Marry two players
  6814. *------------------------------------------
  6815. */
  6816. int
  6817. atcommand_marry(const int fd, struct map_session_data* sd,
  6818. const char* command, const char* message)
  6819. {
  6820. struct map_session_data *pl_sd1 = NULL;
  6821. struct map_session_data *pl_sd2 = NULL;
  6822. char player1[128], player2[128]; //Length used for return error msgs
  6823. nullpo_retr(-1, sd);
  6824. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6825. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6826. return -1;
  6827. }
  6828. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6829. sprintf(player2, "Cannot find player '%s' online", player1);
  6830. clif_displaymessage(fd, player2);
  6831. return -1;
  6832. }
  6833. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6834. sprintf(player1, "Cannot find player '%s' online", player2);
  6835. clif_displaymessage(fd, player1);
  6836. return -1;
  6837. }
  6838. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6839. clif_displaymessage(fd, "They are married.. wish them well");
  6840. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6841. // Auto-give named rings (Aru)
  6842. getring (pl_sd1);
  6843. getring (pl_sd2);
  6844. return 0;
  6845. }
  6846. return -1;
  6847. }
  6848. /*==========================================
  6849. * @divorce by [MouseJstr], fixed by [Lupus]
  6850. *
  6851. * divorce two players
  6852. *------------------------------------------
  6853. */
  6854. int
  6855. atcommand_divorce(const int fd, struct map_session_data* sd,
  6856. const char* command, const char* message)
  6857. {
  6858. struct map_session_data *pl_sd = NULL;
  6859. nullpo_retr(-1, sd);
  6860. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6861. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6862. return -1;
  6863. }
  6864. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6865. if (pc_divorce(pl_sd) != 0) {
  6866. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6867. clif_displaymessage(fd, atcmd_output);
  6868. return -1;
  6869. } else {
  6870. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6871. clif_displaymessage(fd, atcmd_output);
  6872. return 0;
  6873. }
  6874. }
  6875. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6876. clif_displaymessage(fd, atcmd_output);
  6877. return -1;
  6878. }
  6879. #ifdef DMALLOC
  6880. unsigned long dmark_;
  6881. int
  6882. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6883. const char* command, const char* message)
  6884. {
  6885. dmark_ = dmalloc_mark();
  6886. clif_displaymessage(fd, "debug mark set");
  6887. return 0;
  6888. }
  6889. int
  6890. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6891. const char* command, const char* message)
  6892. {
  6893. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6894. dmark_ = dmalloc_mark();
  6895. clif_displaymessage(fd, "malloc changes logged");
  6896. return 0;
  6897. }
  6898. #endif
  6899. /*==========================================
  6900. * @grind by [MouseJstr]
  6901. *------------------------------------------
  6902. */
  6903. int
  6904. atcommand_grind(const int fd, struct map_session_data* sd,
  6905. const char* command, const char* message)
  6906. {
  6907. struct map_session_data *pl_sd = NULL;
  6908. int skillnum;
  6909. int inf;
  6910. char target[NAME_LENGTH];
  6911. nullpo_retr(-1, sd);
  6912. if (!message || !*message)
  6913. return -1;
  6914. if(sscanf(message, "%23s", target) != 1) {
  6915. clif_displaymessage(fd, "Usage: @grind <target>");
  6916. return -1;
  6917. }
  6918. if((pl_sd=map_nick2sd(target)) == NULL)
  6919. return -1;
  6920. for (skillnum = 1; skillnum < 500; skillnum++) {
  6921. sd->status.sp = sd->status.max_sp;
  6922. atcommand_alive(fd, sd, command, message);
  6923. inf = skill_get_inf(skillnum);
  6924. if (inf & INF_GROUND_SKILL)
  6925. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6926. else if (!(inf & INF_SUPPORT_SKILL))
  6927. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6928. }
  6929. return 0;
  6930. }
  6931. /*==========================================
  6932. * @grind2 by [MouseJstr]
  6933. *------------------------------------------
  6934. */
  6935. int
  6936. atcommand_grind2(const int fd, struct map_session_data* sd,
  6937. const char* command, const char* message)
  6938. {
  6939. int i;
  6940. short x, y;
  6941. for (i = 1000; i < MAX_MOB_DB; i++) {
  6942. if (!mobdb_checkid(i))
  6943. continue;
  6944. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6945. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6946. }
  6947. return 0;
  6948. }
  6949. /*==========================================
  6950. * @changelook by [Celest]
  6951. *------------------------------------------
  6952. */
  6953. int
  6954. atcommand_changelook(const int fd, struct map_session_data* sd,
  6955. const char* command, const char* message)
  6956. {
  6957. int i, j = 0, k = 0;
  6958. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6959. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6960. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6961. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6962. return -1;
  6963. } else if (i == 2) {
  6964. if (j < 1) j = 1;
  6965. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6966. j = pos[j - 1];
  6967. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6968. k = j; // swap
  6969. j = LOOK_HEAD_TOP;
  6970. }
  6971. clif_changelook(&sd->bl,j,k);
  6972. return 0;
  6973. }
  6974. /*==========================================
  6975. *Turns on/off Autotrade for a specific player
  6976. *------------------------------------------
  6977. *by durf (changed by Lupus)
  6978. */
  6979. int
  6980. atcommand_autotrade(
  6981. const int fd, struct map_session_data* sd,
  6982. const char* command, const char* message)
  6983. {
  6984. nullpo_retr(-1, sd);
  6985. if (sd->vender_id) //check if player's vending
  6986. {
  6987. sd->state.autotrade = 1;
  6988. clif_authfail_fd(fd, 15);
  6989. }
  6990. else
  6991. {
  6992. //"You should be vending to use @Autotrade."
  6993. clif_displaymessage(fd, msg_txt(549));
  6994. }
  6995. return 0;
  6996. }
  6997. /*==========================================
  6998. * Changes Master of your Guild to a specified guild member
  6999. *------------------------------------------
  7000. *by durf (changed by Lupus)
  7001. */
  7002. int
  7003. atcommand_changegm(
  7004. const int fd, struct map_session_data* sd,
  7005. const char* command, const char* message)
  7006. {
  7007. struct guild *g;
  7008. struct map_session_data *pl_sd;
  7009. nullpo_retr(-1, sd);
  7010. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  7011. {
  7012. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  7013. return -1;
  7014. }
  7015. if (strlen(message)==0)
  7016. {
  7017. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  7018. return -1;
  7019. }
  7020. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  7021. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  7022. return -1;
  7023. }
  7024. guild_gm_change(sd->status.guild_id, pl_sd);
  7025. return 0;
  7026. }
  7027. /*==========================================
  7028. *Changes the leader of a party.
  7029. *------------------------------------------
  7030. *by Skotlex
  7031. */
  7032. int
  7033. atcommand_changeleader(
  7034. const int fd, struct map_session_data* sd,
  7035. const char* command, const char* message)
  7036. {
  7037. struct party_data *p;
  7038. struct map_session_data *pl_sd;
  7039. int mi, pl_mi;
  7040. nullpo_retr(-1, sd);
  7041. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7042. { //Need to be a party leader.
  7043. clif_displaymessage(fd, msg_txt(282));
  7044. return -1;
  7045. }
  7046. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7047. if (mi == MAX_PARTY)
  7048. return -1; //Shouldn't happen
  7049. if (!p->party.member[mi].leader)
  7050. { //Need to be a party leader.
  7051. clif_displaymessage(fd, msg_txt(282));
  7052. return -1;
  7053. }
  7054. if (strlen(message)==0)
  7055. {
  7056. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  7057. return -1;
  7058. }
  7059. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  7060. clif_displaymessage(fd, msg_txt(283));
  7061. return -1;
  7062. }
  7063. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  7064. if (pl_mi == MAX_PARTY)
  7065. return -1; //Shouldn't happen
  7066. //Change leadership.
  7067. p->party.member[mi].leader = 0;
  7068. if (p->data[mi].sd->fd)
  7069. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  7070. p->party.member[pl_mi].leader = 1;
  7071. if (p->data[pl_mi].sd->fd)
  7072. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  7073. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  7074. //Update info.
  7075. clif_party_main_info(p,-1);
  7076. clif_party_info(p,-1);
  7077. return 0;
  7078. }
  7079. /*==========================================
  7080. * Used to change the item share setting of a party.
  7081. *------------------------------------------
  7082. *by Skotlex
  7083. */
  7084. int
  7085. atcommand_partyoption(
  7086. const int fd, struct map_session_data* sd,
  7087. const char* command, const char* message)
  7088. {
  7089. struct party_data *p;
  7090. int mi, option;
  7091. char w1[15], w2[15];
  7092. nullpo_retr(-1, sd);
  7093. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  7094. {
  7095. clif_displaymessage(fd, msg_txt(282));
  7096. return -1;
  7097. }
  7098. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  7099. if (mi == MAX_PARTY)
  7100. return -1; //Shouldn't happen
  7101. if (!p->party.member[mi].leader)
  7102. {
  7103. clif_displaymessage(fd, msg_txt(282));
  7104. return -1;
  7105. }
  7106. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  7107. {
  7108. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  7109. return -1;
  7110. }
  7111. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  7112. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  7113. //Change item share type.
  7114. if (option != p->party.item)
  7115. party_changeoption(sd, p->party.exp, option);
  7116. else
  7117. clif_displaymessage(fd, msg_txt(286));
  7118. return 0;
  7119. }
  7120. /*==========================================
  7121. *Turns on/off AutoLoot for a specific player
  7122. *------------------------------------------
  7123. *by Upa-Kun
  7124. */
  7125. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7126. {
  7127. // autoloot command with value
  7128. int rate;
  7129. nullpo_retr(-1, sd);
  7130. // autoloot command without value
  7131. if(!message || !*message)
  7132. {
  7133. // autoloot on -> off
  7134. if(sd->state.autoloot)
  7135. {
  7136. clif_displaymessage(fd, "Autoloot is now off.");
  7137. sd->state.autoloot = 0;
  7138. return 0;
  7139. // autoloot off -> on
  7140. } else {
  7141. clif_displaymessage(fd, "Autoloot is now on.");
  7142. sd->state.autoloot = 10000;
  7143. return 0;
  7144. }
  7145. }
  7146. // get maximum droprate limit
  7147. rate = (int)(atof(message) * 100.);
  7148. // check for invalid value
  7149. if(rate > 10000)
  7150. {
  7151. clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
  7152. return 0;
  7153. }
  7154. // autoloot value is 0, turn autoloot off
  7155. if(rate == 0)
  7156. {
  7157. if(sd->state.autoloot == 0)
  7158. clif_displaymessage(fd, "Autoloot is already off.");
  7159. else {
  7160. clif_displaymessage(fd, "Autoloot is now off.");
  7161. sd->state.autoloot = 0;
  7162. }
  7163. return 0;
  7164. }
  7165. // autoloot value is 100, turn autoloot on
  7166. if(rate == 10000)
  7167. {
  7168. if(sd->state.autoloot == 10000)
  7169. clif_displaymessage(fd, "Autoloot is already on.");
  7170. else {
  7171. clif_displaymessage(fd, "Autoloot is now on.");
  7172. sd->state.autoloot = 10000;
  7173. }
  7174. return 0;
  7175. }
  7176. // autoloot value is between 0 and 100
  7177. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
  7178. clif_displaymessage(fd, atcmd_output);
  7179. sd->state.autoloot = rate;
  7180. return 0;
  7181. }
  7182. /*==========================================
  7183. * It is made to rain.
  7184. *------------------------------------------
  7185. */
  7186. int
  7187. atcommand_rain(
  7188. const int fd, struct map_session_data* sd,
  7189. const char* command, const char* message)
  7190. {
  7191. nullpo_retr(-1, sd);
  7192. if (map[sd->bl.m].flag.rain) {
  7193. map[sd->bl.m].flag.rain=0;
  7194. clif_weather(sd->bl.m);
  7195. clif_displaymessage(fd, "The rain has stopped.");
  7196. } else {
  7197. map[sd->bl.m].flag.rain=1;
  7198. clif_weather(sd->bl.m);
  7199. clif_displaymessage(fd, "It is made to rain.");
  7200. }
  7201. return 0;
  7202. }
  7203. /*==========================================
  7204. * It is made to snow.
  7205. *------------------------------------------
  7206. */
  7207. int
  7208. atcommand_snow(
  7209. const int fd, struct map_session_data* sd,
  7210. const char* command, const char* message)
  7211. {
  7212. nullpo_retr(-1, sd);
  7213. if (map[sd->bl.m].flag.snow) {
  7214. map[sd->bl.m].flag.snow=0;
  7215. clif_weather(sd->bl.m);
  7216. clif_displaymessage(fd, "Snow has stopped falling.");
  7217. } else {
  7218. map[sd->bl.m].flag.snow=1;
  7219. clif_weather(sd->bl.m);
  7220. clif_displaymessage(fd, "It is made to snow.");
  7221. }
  7222. return 0;
  7223. }
  7224. /*==========================================
  7225. * Cherry tree snowstorm is made to fall. (Sakura)
  7226. *------------------------------------------
  7227. */
  7228. int
  7229. atcommand_sakura(
  7230. const int fd, struct map_session_data* sd,
  7231. const char* command, const char* message)
  7232. {
  7233. nullpo_retr(-1, sd);
  7234. if (map[sd->bl.m].flag.sakura) {
  7235. map[sd->bl.m].flag.sakura=0;
  7236. clif_weather(sd->bl.m);
  7237. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  7238. } else {
  7239. map[sd->bl.m].flag.sakura=1;
  7240. clif_weather(sd->bl.m);
  7241. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  7242. }
  7243. return 0;
  7244. }
  7245. /*==========================================
  7246. * Clouds appear.
  7247. *------------------------------------------
  7248. */
  7249. int
  7250. atcommand_clouds(
  7251. const int fd, struct map_session_data* sd,
  7252. const char* command, const char* message)
  7253. {
  7254. nullpo_retr(-1, sd);
  7255. if (map[sd->bl.m].flag.clouds) {
  7256. map[sd->bl.m].flag.clouds=0;
  7257. clif_weather(sd->bl.m);
  7258. clif_displaymessage(fd, "The clouds has disappear.");
  7259. } else {
  7260. map[sd->bl.m].flag.clouds=1;
  7261. clif_weather(sd->bl.m);
  7262. clif_displaymessage(fd, "Clouds appear.");
  7263. }
  7264. return 0;
  7265. }
  7266. /*==========================================
  7267. * Different type of clouds using effect 516
  7268. *------------------------------------------
  7269. */
  7270. int
  7271. atcommand_clouds2(
  7272. const int fd, struct map_session_data* sd,
  7273. const char* command, const char* message)
  7274. {
  7275. nullpo_retr(-1, sd);
  7276. if (map[sd->bl.m].flag.clouds2) {
  7277. map[sd->bl.m].flag.clouds2=0;
  7278. clif_weather(sd->bl.m);
  7279. clif_displaymessage(fd, "The alternative clouds disappear.");
  7280. } else {
  7281. map[sd->bl.m].flag.clouds2=1;
  7282. clif_weather(sd->bl.m);
  7283. clif_displaymessage(fd, "Alternative clouds appear.");
  7284. }
  7285. return 0;
  7286. }
  7287. /*==========================================
  7288. * Fog hangs over.
  7289. *------------------------------------------
  7290. */
  7291. int
  7292. atcommand_fog(
  7293. const int fd, struct map_session_data* sd,
  7294. const char* command, const char* message)
  7295. {
  7296. nullpo_retr(-1, sd);
  7297. if (map[sd->bl.m].flag.fog) {
  7298. map[sd->bl.m].flag.fog=0;
  7299. clif_weather(sd->bl.m);
  7300. clif_displaymessage(fd, "The fog has gone.");
  7301. } else {
  7302. map[sd->bl.m].flag.fog=1;
  7303. clif_weather(sd->bl.m);
  7304. clif_displaymessage(fd, "Fog hangs over.");
  7305. }
  7306. return 0;
  7307. }
  7308. /*==========================================
  7309. * Fallen leaves fall.
  7310. *------------------------------------------
  7311. */
  7312. int
  7313. atcommand_leaves(
  7314. const int fd, struct map_session_data* sd,
  7315. const char* command, const char* message)
  7316. {
  7317. nullpo_retr(-1, sd);
  7318. if (map[sd->bl.m].flag.leaves) {
  7319. map[sd->bl.m].flag.leaves=0;
  7320. clif_weather(sd->bl.m);
  7321. clif_displaymessage(fd, "Leaves no longer fall.");
  7322. } else {
  7323. map[sd->bl.m].flag.leaves=1;
  7324. clif_weather(sd->bl.m);
  7325. clif_displaymessage(fd, "Fallen leaves fall.");
  7326. }
  7327. return 0;
  7328. }
  7329. /*==========================================
  7330. * Fireworks appear.
  7331. *------------------------------------------
  7332. */
  7333. int
  7334. atcommand_fireworks(
  7335. const int fd, struct map_session_data* sd,
  7336. const char* command, const char* message)
  7337. {
  7338. nullpo_retr(-1, sd);
  7339. if (map[sd->bl.m].flag.fireworks) {
  7340. map[sd->bl.m].flag.fireworks=0;
  7341. clif_weather(sd->bl.m);
  7342. clif_displaymessage(fd, "Fireworks are ended.");
  7343. } else {
  7344. map[sd->bl.m].flag.fireworks=1;
  7345. clif_weather(sd->bl.m);
  7346. clif_displaymessage(fd, "Fireworks are launched.");
  7347. }
  7348. return 0;
  7349. }
  7350. /*==========================================
  7351. * Clearing Weather Effects by Dexity
  7352. *------------------------------------------
  7353. */
  7354. int
  7355. atcommand_clearweather(
  7356. const int fd, struct map_session_data* sd,
  7357. const char* command, const char* message)
  7358. {
  7359. nullpo_retr(-1, sd);
  7360. map[sd->bl.m].flag.rain=0;
  7361. map[sd->bl.m].flag.snow=0;
  7362. map[sd->bl.m].flag.sakura=0;
  7363. map[sd->bl.m].flag.clouds=0;
  7364. map[sd->bl.m].flag.clouds2=0;
  7365. map[sd->bl.m].flag.fog=0;
  7366. map[sd->bl.m].flag.fireworks=0;
  7367. map[sd->bl.m].flag.leaves=0;
  7368. clif_weather(sd->bl.m);
  7369. clif_displaymessage(fd, msg_txt(291));
  7370. return 0;
  7371. }
  7372. /*===============================================================
  7373. * Sound Command - plays a sound for everyone! [Codemaster]
  7374. *---------------------------------------------------------------
  7375. */
  7376. int
  7377. atcommand_sound(
  7378. const int fd, struct map_session_data *sd,
  7379. const char *command, const char *message)
  7380. {
  7381. char sound_file[100];
  7382. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7383. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7384. return -1;
  7385. }
  7386. malloc_tsetdword(sound_file, '\0', sizeof(sound_file));
  7387. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7388. return -1;
  7389. if(strstr(sound_file, ".wav") == NULL)
  7390. strcat(sound_file, ".wav");
  7391. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7392. return 0;
  7393. }
  7394. /*==========================================
  7395. * MOB Search
  7396. *------------------------------------------
  7397. */
  7398. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7399. {
  7400. int mob_id,fd;
  7401. static int number=0;
  7402. struct mob_data *md;
  7403. nullpo_retr(0, bl);
  7404. if(!ap){
  7405. number=0;
  7406. return 0;
  7407. }
  7408. mob_id = va_arg(ap,int);
  7409. fd = va_arg(ap,int);
  7410. md = (struct mob_data *)bl;
  7411. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7412. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7413. ++number,bl->x, bl->y,md->name);
  7414. clif_displaymessage(fd, atcmd_output);
  7415. }
  7416. return 0;
  7417. }
  7418. int atcommand_mobsearch(
  7419. const int fd, struct map_session_data* sd,
  7420. const char* command, const char* message)
  7421. {
  7422. char mob_name[100];
  7423. int mob_id,map_id = 0;
  7424. nullpo_retr(-1, sd);
  7425. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7426. return -1;
  7427. if ((mob_id = atoi(mob_name)) == 0)
  7428. mob_id = mobdb_searchname(mob_name);
  7429. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7430. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7431. clif_displaymessage(fd, atcmd_output);
  7432. return 0;
  7433. }
  7434. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7435. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7436. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7437. map_id = sd->bl.m;
  7438. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7439. mob_name, mapindex_id2name(sd->mapindex));
  7440. clif_displaymessage(fd, atcmd_output);
  7441. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7442. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7443. return 0;
  7444. }
  7445. /*==========================================
  7446. * ドロップアイテムの掃除
  7447. *------------------------------------------
  7448. */
  7449. /*==========================================
  7450. * cleanmap
  7451. *------------------------------------------
  7452. */
  7453. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7454. {
  7455. nullpo_retr(0, bl);
  7456. map_clearflooritem(bl->id);
  7457. return 0;
  7458. }
  7459. int
  7460. atcommand_cleanmap(
  7461. const int fd, struct map_session_data* sd,
  7462. const char* command, const char* message)
  7463. {
  7464. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7465. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7466. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7467. BL_ITEM);
  7468. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7469. return 0;
  7470. }
  7471. /*==========================================
  7472. * NPC/PETに話させる
  7473. *------------------------------------------
  7474. */
  7475. int
  7476. atcommand_npctalk(
  7477. const int fd, struct map_session_data* sd,
  7478. const char* command, const char* message)
  7479. {
  7480. char name[NAME_LENGTH],mes[100],temp[100];
  7481. struct npc_data *nd;
  7482. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7483. return -1;
  7484. if (!(nd = npc_name2id(name)))
  7485. return -1;
  7486. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7487. clif_message(&nd->bl, temp);
  7488. return 0;
  7489. }
  7490. int
  7491. atcommand_pettalk(
  7492. const int fd, struct map_session_data* sd,
  7493. const char* command, const char* message)
  7494. {
  7495. char mes[100],temp[100];
  7496. struct pet_data *pd;
  7497. nullpo_retr(-1, sd);
  7498. if(!sd->status.pet_id || !(pd=sd->pd))
  7499. return -1;
  7500. if (sd->sc.count && //no "chatting" while muted.
  7501. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7502. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7503. return -1;
  7504. if (sscanf(message, "%99[^\n]", mes) < 1)
  7505. return -1;
  7506. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7507. clif_message(&pd->bl, temp);
  7508. return 0;
  7509. }
  7510. /*==========================================
  7511. * @users
  7512. * サーバー内の人数マップを表示させる
  7513. * 手抜きのため汚くなっているのは仕様です。
  7514. *------------------------------------------
  7515. */
  7516. static struct dbt *users_db = NULL;
  7517. static int users_all;
  7518. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7519. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7520. users_all++;
  7521. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7522. return 0;
  7523. }
  7524. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7525. char buf[256];
  7526. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7527. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7528. clif_displaymessage(sd->fd,buf);
  7529. return 0;
  7530. }
  7531. int
  7532. atcommand_users(
  7533. const int fd, struct map_session_data* sd,
  7534. const char* command, const char* message)
  7535. {
  7536. char buf[256];
  7537. users_all = 0;
  7538. users_db->clear(users_db, NULL);
  7539. clif_foreachclient(atcommand_users_sub1);
  7540. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7541. sprintf(buf,"all : %d",users_all);
  7542. clif_displaymessage(fd,buf);
  7543. return 0;
  7544. }
  7545. int
  7546. atcommand_reset(
  7547. const int fd, struct map_session_data* sd,
  7548. const char* command, const char* message)
  7549. {
  7550. pc_resetstate(sd);
  7551. pc_resetskill(sd,1);
  7552. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7553. clif_displaymessage(fd, atcmd_output);
  7554. return 0;
  7555. }
  7556. /*==========================================
  7557. *
  7558. *------------------------------------------
  7559. */
  7560. int
  7561. atcommand_summon(
  7562. const int fd, struct map_session_data* sd,
  7563. const char* command, const char* message)
  7564. {
  7565. char name[NAME_LENGTH];
  7566. int mob_id = 0;
  7567. int duration = 0;
  7568. struct mob_data *md;
  7569. unsigned int tick=gettick();
  7570. nullpo_retr(-1, sd);
  7571. if (!message || !*message)
  7572. return -1;
  7573. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7574. return -1;
  7575. if (duration < 1)
  7576. duration =1;
  7577. else if (duration > 60)
  7578. duration =60;
  7579. if ((mob_id = atoi(name)) == 0)
  7580. mob_id = mobdb_searchname(name);
  7581. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7582. return -1;
  7583. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7584. if(md){
  7585. md->master_id=sd->bl.id;
  7586. md->special_state.ai=1;
  7587. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7588. clif_misceffect2(&md->bl,344);
  7589. mob_spawn(md);
  7590. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7591. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7592. }
  7593. return 0;
  7594. }
  7595. /*==========================================
  7596. * @adjcmdlvl by [MouseJstr]
  7597. *
  7598. * Temp adjust the GM level required to use a GM command
  7599. *
  7600. * Used during beta testing to allow players to use GM commands
  7601. * for short periods of time
  7602. *------------------------------------------
  7603. */
  7604. int
  7605. atcommand_adjcmdlvl(
  7606. const int fd, struct map_session_data* sd,
  7607. const char* command, const char* message)
  7608. {
  7609. int i, newlev;
  7610. char cmd[100];
  7611. nullpo_retr(-1, sd);
  7612. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7613. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7614. return -1;
  7615. }
  7616. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7617. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7618. atcommand_info[i].level = newlev;
  7619. clif_displaymessage(fd, "@command level changed.");
  7620. return 0;
  7621. }
  7622. clif_displaymessage(fd, "@command not found.");
  7623. return -1;
  7624. }
  7625. /*==========================================
  7626. * @adjgmlvl by [MouseJstr]
  7627. *
  7628. * Create a temp GM
  7629. *
  7630. * Used during beta testing to allow players to use GM commands
  7631. * for short periods of time
  7632. *------------------------------------------
  7633. */
  7634. int
  7635. atcommand_adjgmlvl(
  7636. const int fd, struct map_session_data* sd,
  7637. const char* command, const char* message)
  7638. {
  7639. int newlev;
  7640. char user[NAME_LENGTH];
  7641. struct map_session_data *pl_sd;
  7642. nullpo_retr(-1, sd);
  7643. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7644. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7645. return -1;
  7646. }
  7647. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7648. return -1;
  7649. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7650. return 0;
  7651. }
  7652. /*==========================================
  7653. * @trade by [MouseJstr]
  7654. *
  7655. * Open a trade window with a remote player
  7656. *
  7657. * If I have to jump to a remote player one more time, I am
  7658. * gonna scream!
  7659. *------------------------------------------
  7660. */
  7661. int
  7662. atcommand_trade(
  7663. const int fd, struct map_session_data* sd,
  7664. const char* command, const char* message)
  7665. {
  7666. struct map_session_data *pl_sd = NULL;
  7667. nullpo_retr(-1, sd);
  7668. if (!message || !*message)
  7669. return -1;
  7670. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7671. trade_traderequest(sd, pl_sd);
  7672. return 0;
  7673. }
  7674. return -1;
  7675. }
  7676. /*==========================================
  7677. * @setbattleflag by [MouseJstr]
  7678. *
  7679. * set a battle_config flag without having to reboot
  7680. */
  7681. int
  7682. atcommand_setbattleflag(
  7683. const int fd, struct map_session_data* sd,
  7684. const char* command, const char* message)
  7685. {
  7686. char flag[128], value[128];
  7687. nullpo_retr(-1, sd);
  7688. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7689. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7690. return -1;
  7691. }
  7692. if (battle_set_value(flag, value) == 0)
  7693. clif_displaymessage(fd, "unknown battle_config flag");
  7694. else
  7695. clif_displaymessage(fd, "battle_config set as requested");
  7696. return 0;
  7697. }
  7698. /*===========================
  7699. * @unmute [Valaris]
  7700. *===========================
  7701. */
  7702. int atcommand_unmute(
  7703. const int fd, struct map_session_data* sd,
  7704. const char* command, const char* message)
  7705. {
  7706. struct map_session_data *pl_sd = NULL;
  7707. nullpo_retr(-1, sd);
  7708. if (!message || !*message)
  7709. return -1;
  7710. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7711. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7712. pl_sd->status.manner = 0;
  7713. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7714. clif_displaymessage(sd->fd,"Player unmuted");
  7715. }
  7716. else
  7717. clif_displaymessage(sd->fd,"Player is not muted");
  7718. }
  7719. return 0;
  7720. }
  7721. /*==========================================
  7722. * @uptime by MC Cameri
  7723. *------------------------------------------
  7724. */
  7725. int
  7726. atcommand_uptime(
  7727. const int fd, struct map_session_data* sd,
  7728. const char* command, const char* message)
  7729. {
  7730. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7731. minute = 60, days = 0, hours = 0, minutes = 0;
  7732. nullpo_retr(-1, sd);
  7733. seconds = get_uptime();
  7734. days = seconds/day;
  7735. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7736. hours = seconds/hour;
  7737. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7738. minutes = seconds/minute;
  7739. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7740. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7741. clif_displaymessage(fd, atcmd_output);
  7742. return 0;
  7743. }
  7744. /*==========================================
  7745. * @changesex <sex>
  7746. * => Changes one's sex. Argument sex can be
  7747. * 0 or 1, m or f, male or female.
  7748. *------------------------------------------
  7749. */
  7750. int
  7751. atcommand_changesex(
  7752. const int fd, struct map_session_data* sd,
  7753. const char* command, const char* message)
  7754. {
  7755. nullpo_retr(-1, sd);
  7756. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7757. return 0;
  7758. }
  7759. /*================================================
  7760. * @mute - Mutes a player for a set amount of time
  7761. *------------------------------------------------
  7762. */
  7763. int atcommand_mute(
  7764. const int fd, struct map_session_data* sd,
  7765. const char* command, const char* message)
  7766. {
  7767. struct map_session_data *pl_sd = NULL;
  7768. int manner;
  7769. nullpo_retr(-1, sd);
  7770. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7771. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7772. return -1;
  7773. }
  7774. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7775. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7776. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7777. return -1;
  7778. }
  7779. clif_GM_silence(sd, pl_sd, 0);
  7780. pl_sd->status.manner -= manner;
  7781. if(pl_sd->status.manner < 0)
  7782. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7783. }
  7784. else {
  7785. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7786. return -1;
  7787. }
  7788. return 0;
  7789. }
  7790. /*==========================================
  7791. * @refresh (like @jumpto <<yourself>>)
  7792. *------------------------------------------
  7793. */
  7794. int atcommand_refresh(
  7795. const int fd, struct map_session_data* sd,
  7796. const char* command, const char* message)
  7797. {
  7798. nullpo_retr(-1, sd);
  7799. clif_refresh(sd);
  7800. return 0;
  7801. }
  7802. /*==========================================
  7803. * @petid <part of pet name>
  7804. * => Displays a list of matching pets.
  7805. *------------------------------------------
  7806. */
  7807. int
  7808. atcommand_petid(const int fd, struct map_session_data* sd,
  7809. const char* command, const char* message)
  7810. {
  7811. char searchtext[100];
  7812. char temp0[100];
  7813. char temp1[100];
  7814. int cnt = 0, i = 0;
  7815. nullpo_retr(-1, sd);
  7816. if (!message || !*message)
  7817. return -1;
  7818. if (sscanf(message, "%99s", searchtext) < 1)
  7819. return -1;
  7820. estr_lower(searchtext);
  7821. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7822. clif_displaymessage(fd,temp0);
  7823. while (i < MAX_PET_DB) {
  7824. strcpy(temp1,pet_db[i].name);
  7825. strcpy(temp1, estr_lower(temp1));
  7826. strcpy(temp0,pet_db[i].jname);
  7827. strcpy(temp0, estr_lower(temp1));
  7828. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7829. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7830. pet_db[i].jname);
  7831. if (cnt >= 100) { // Only if there are custom pets
  7832. clif_displaymessage(fd, "Be more specific, can't send more than"
  7833. " 100 results.");
  7834. } else {
  7835. clif_displaymessage(fd, temp0);
  7836. }
  7837. cnt++;
  7838. }
  7839. i++;
  7840. }
  7841. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7842. clif_displaymessage(fd, temp0);
  7843. return 0;
  7844. }
  7845. /*==========================================
  7846. * @identify
  7847. * => GM's magnifier.
  7848. *------------------------------------------
  7849. */
  7850. int
  7851. atcommand_identify(
  7852. const int fd, struct map_session_data* sd,
  7853. const char* command, const char* message)
  7854. {
  7855. int i,num;
  7856. nullpo_retr(-1, sd);
  7857. for(i=num=0;i<MAX_INVENTORY;i++){
  7858. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7859. num++;
  7860. }
  7861. }
  7862. if (num > 0) {
  7863. clif_item_identify_list(sd);
  7864. } else {
  7865. clif_displaymessage(fd,"There are no items to appraise.");
  7866. }
  7867. return 0;
  7868. }
  7869. /*==========================================
  7870. * @gmotd (Global MOTD)
  7871. * by davidsiaw :P
  7872. *------------------------------------------
  7873. */
  7874. int
  7875. atcommand_gmotd(
  7876. const int fd, struct map_session_data* sd,
  7877. const char* command, const char* message)
  7878. {
  7879. char buf[256];
  7880. FILE *fp;
  7881. nullpo_retr(-1, sd);
  7882. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7883. while (fgets(buf, 250, fp) != NULL){
  7884. int i;
  7885. for( i=0; buf[i]; i++){
  7886. if( buf[i]=='\r' || buf[i]=='\n'){
  7887. buf[i]=0;
  7888. break;
  7889. }
  7890. }
  7891. intif_GMmessage(buf,strlen(buf)+1,8);
  7892. }
  7893. fclose(fp);
  7894. }
  7895. return 0;
  7896. }
  7897. int atcommand_misceffect(
  7898. const int fd, struct map_session_data* sd,
  7899. const char* command, const char* message)
  7900. {
  7901. int effect = 0;
  7902. nullpo_retr(-1, sd);
  7903. if (!message || !*message)
  7904. return -1;
  7905. if (sscanf(message, "%d", &effect) < 1)
  7906. return -1;
  7907. clif_misceffect(&sd->bl,effect);
  7908. return 0;
  7909. }
  7910. /*==========================================
  7911. * Jump to a player by PID number
  7912. * Original by Dino9021
  7913. * Added in by nsstrunks
  7914. *------------------------------------------
  7915. */
  7916. int atcommand_jumptoid(
  7917. const int fd, struct map_session_data* sd,
  7918. const char* command, const char* message)
  7919. {
  7920. int cid=0;
  7921. struct map_session_data *pl_sd;
  7922. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  7923. if (!message || (cid = atoi(message)) == 0) {
  7924. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7925. return -1;
  7926. }
  7927. pl_sd = map_charid2sd(cid);
  7928. if (!pl_sd) {
  7929. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7930. return -1;
  7931. }
  7932. if (map[pl_sd->bl.m].flag.nowarpto &&
  7933. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7934. {
  7935. clif_displaymessage(fd, msg_txt(247));
  7936. return -1;
  7937. }
  7938. if (map[sd->bl.m].flag.nowarp &&
  7939. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7940. {
  7941. clif_displaymessage(fd, msg_txt(248));
  7942. return -1;
  7943. }
  7944. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7945. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7946. clif_displaymessage(fd, atcmd_output);
  7947. return 0;
  7948. }
  7949. /*==========================================
  7950. * Jump to a player by PID number
  7951. * Original by Dino9021
  7952. * Added in by nsstrunks
  7953. *------------------------------------------
  7954. */
  7955. int atcommand_jumptoid2(
  7956. const int fd, struct map_session_data* sd,
  7957. const char* command, const char* message)
  7958. {
  7959. int aid=0;
  7960. struct map_session_data *pl_sd;
  7961. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  7962. if (!message || (aid = atoi(message)) == 0) {
  7963. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7964. return -1;
  7965. }
  7966. pl_sd = map_id2sd(aid);
  7967. if (!pl_sd) {
  7968. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7969. return -1;
  7970. }
  7971. if (map[pl_sd->bl.m].flag.nowarpto &&
  7972. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7973. {
  7974. clif_displaymessage(fd, msg_txt(247));
  7975. return -1;
  7976. }
  7977. if (map[sd->bl.m].flag.nowarp &&
  7978. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7979. {
  7980. clif_displaymessage(fd, msg_txt(248));
  7981. return -1;
  7982. }
  7983. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7984. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7985. clif_displaymessage(fd, atcmd_output);
  7986. return 0;
  7987. }
  7988. /*==========================================
  7989. * Recall a player by PID number
  7990. * Original by Dino9021
  7991. * Added in by nsstrunks
  7992. *------------------------------------------
  7993. */
  7994. int atcommand_recallid(
  7995. const int fd, struct map_session_data* sd,
  7996. const char* command, const char* message)
  7997. {
  7998. int cid=0;
  7999. struct map_session_data *pl_sd;
  8000. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8001. if (!message || (cid = atoi(message)) == 0) {
  8002. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  8003. return -1;
  8004. }
  8005. pl_sd = map_charid2sd(cid);
  8006. if (!pl_sd) {
  8007. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8008. return -1;
  8009. }
  8010. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
  8011. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8012. return -1;
  8013. }
  8014. if (map[pl_sd->bl.m].flag.nowarpto &&
  8015. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8016. {
  8017. clif_displaymessage(fd, msg_txt(247));
  8018. return -1;
  8019. }
  8020. if (map[sd->bl.m].flag.nowarp &&
  8021. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8022. {
  8023. clif_displaymessage(fd, msg_txt(248));
  8024. return -1;
  8025. }
  8026. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8027. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8028. clif_displaymessage(fd, atcmd_output);
  8029. return 0;
  8030. }
  8031. /*==========================================
  8032. * Recall a player by PID number
  8033. * Original by Dino9021
  8034. * Added in by nsstrunks
  8035. *------------------------------------------
  8036. */
  8037. int atcommand_recallid2(
  8038. const int fd, struct map_session_data* sd,
  8039. const char* command, const char* message)
  8040. {
  8041. int aid=0;
  8042. struct map_session_data *pl_sd;
  8043. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8044. if (!message || (aid = atoi(message)) == 0) {
  8045. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  8046. return -1;
  8047. }
  8048. pl_sd = map_id2sd(aid);
  8049. if (!pl_sd) {
  8050. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  8051. return -1;
  8052. }
  8053. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8054. { // you can recall only lower or same level
  8055. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8056. return -1;
  8057. }
  8058. if (map[pl_sd->bl.m].flag.nowarpto &&
  8059. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8060. {
  8061. clif_displaymessage(fd, msg_txt(247));
  8062. return -1;
  8063. }
  8064. if (map[sd->bl.m].flag.nowarp &&
  8065. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  8066. {
  8067. clif_displaymessage(fd, msg_txt(248));
  8068. return -1;
  8069. }
  8070. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  8071. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  8072. clif_displaymessage(fd, atcmd_output);
  8073. return 0;
  8074. }
  8075. /*==========================================
  8076. * Kick a player by PID number
  8077. * Original by Dino9021
  8078. * Added in by nsstrunks
  8079. *------------------------------------------
  8080. */
  8081. int atcommand_kickid(
  8082. const int fd, struct map_session_data* sd,
  8083. const char* command, const char* message)
  8084. {
  8085. struct map_session_data *pl_sd;
  8086. int cid=0;
  8087. if (!message || (cid = atoi(message)) == 0) {
  8088. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  8089. return -1;
  8090. }
  8091. pl_sd = map_charid2sd(cid);
  8092. if (!pl_sd) {
  8093. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8094. return -1;
  8095. }
  8096. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8097. { // you can kick only lower or same gm level
  8098. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8099. return -1;
  8100. }
  8101. clif_GM_kick(sd, pl_sd, 1);
  8102. return 0;
  8103. }
  8104. /*==========================================
  8105. * Kick a player by PID number
  8106. * Original by Dino9021
  8107. * Added in by nsstrunks
  8108. *------------------------------------------
  8109. */
  8110. int atcommand_kickid2(
  8111. const int fd, struct map_session_data* sd,
  8112. const char* command, const char* message)
  8113. {
  8114. struct map_session_data *pl_sd;
  8115. int aid=0;
  8116. if (!message || (aid = atoi(message)) == 0) {
  8117. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  8118. return -1;
  8119. }
  8120. pl_sd = map_id2sd(aid);
  8121. if (!pl_sd) {
  8122. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8123. return -1;
  8124. }
  8125. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8126. { // you can kick only lower or same gm level
  8127. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8128. return -1;
  8129. }
  8130. clif_GM_kick(sd, pl_sd, 1);
  8131. return 0;
  8132. }
  8133. /*==========================================
  8134. * Revive a player by PID number
  8135. * Original by Dino9021
  8136. * Added in by nsstrunks
  8137. *------------------------------------------
  8138. */
  8139. int atcommand_reviveid(
  8140. const int fd, struct map_session_data* sd,
  8141. const char* command, const char* message)
  8142. {
  8143. int cid=0;
  8144. struct map_session_data *pl_sd;
  8145. if (!message || (cid = atoi(message)) == 0) {
  8146. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  8147. return -1;
  8148. }
  8149. pl_sd = map_charid2sd(cid);
  8150. if (!pl_sd) {
  8151. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8152. return -1;
  8153. }
  8154. if(!status_revive(&pl_sd->bl, 100, 100))
  8155. return -1;
  8156. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  8157. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8158. return 0;
  8159. }
  8160. /*==========================================
  8161. * Revive a player by PID number
  8162. * Original by Dino9021
  8163. * Added in by nsstrunks
  8164. *------------------------------------------
  8165. */
  8166. int atcommand_reviveid2(
  8167. const int fd, struct map_session_data* sd,
  8168. const char* command, const char* message)
  8169. {
  8170. int aid=0;
  8171. struct map_session_data *pl_sd;
  8172. if (!message || (aid = atoi(message)) == 0) {
  8173. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  8174. return -1;
  8175. }
  8176. pl_sd = map_id2sd(aid);
  8177. if(!pl_sd) {
  8178. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8179. return -1;
  8180. }
  8181. if(!status_revive(&pl_sd->bl, 100, 100))
  8182. return -1;
  8183. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  8184. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  8185. return 0;
  8186. }
  8187. /*==========================================
  8188. * Kill a player by PID number
  8189. * Original by Dino9021
  8190. * Added in by nsstrunks
  8191. *------------------------------------------
  8192. */
  8193. int atcommand_killid(
  8194. const int fd, struct map_session_data* sd,
  8195. const char* command, const char* message)
  8196. {
  8197. int cid=0;
  8198. struct map_session_data *pl_sd;
  8199. if (!message || (cid = atoi(message)) == 0) {
  8200. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  8201. return -1;
  8202. }
  8203. pl_sd = map_charid2sd(cid);
  8204. if (!pl_sd) {
  8205. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8206. return -1;
  8207. }
  8208. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8209. { // you can kill only lower or same level
  8210. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8211. return -1;
  8212. }
  8213. status_kill(&pl_sd->bl);
  8214. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8215. return 0;
  8216. }
  8217. /*==========================================
  8218. * Kill a player by PID number
  8219. * Original by Dino9021
  8220. * Added in by nsstrunks
  8221. *------------------------------------------
  8222. */
  8223. int atcommand_killid2(
  8224. const int fd, struct map_session_data* sd,
  8225. const char* command, const char* message)
  8226. {
  8227. int aid=0;
  8228. struct map_session_data *pl_sd;
  8229. if (!message || (aid = atoi(message)) == 0) {
  8230. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  8231. return -1;
  8232. }
  8233. pl_sd = map_id2sd(aid);
  8234. if (!pl_sd) {
  8235. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8236. return -1;
  8237. }
  8238. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8239. { // you can kill only lower or same level
  8240. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8241. return -1;
  8242. }
  8243. status_kill(&pl_sd->bl);
  8244. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  8245. return 0;
  8246. }
  8247. /*==========================================
  8248. * Make a player killable, by PID
  8249. * Original by Dino9021
  8250. * Added in by nsstrunks
  8251. *------------------------------------------
  8252. */
  8253. int
  8254. atcommand_charkillableid(
  8255. const int fd, struct map_session_data* sd,
  8256. const char* command, const char* message)
  8257. {
  8258. struct map_session_data *pl_sd = NULL;
  8259. int cid=0;
  8260. if (!message || (cid = atoi(message)) == 0) {
  8261. clif_displaymessage(fd, "Please, enter a player CID.");
  8262. return -1;
  8263. }
  8264. pl_sd = map_charid2sd(cid);
  8265. if (!pl_sd) {
  8266. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8267. return -1;
  8268. }
  8269. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8270. {
  8271. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8272. return -1;
  8273. }
  8274. pl_sd->state.killable = !pl_sd->state.killable;
  8275. if(pl_sd->state.killable)
  8276. clif_displaymessage(fd, msg_txt(289));
  8277. else
  8278. clif_displaymessage(fd, msg_txt(290));
  8279. return 0;
  8280. }
  8281. /*==========================================
  8282. * Make a player killable, by PID
  8283. * Original by Dino9021
  8284. * Added in by nsstrunks
  8285. *------------------------------------------
  8286. */
  8287. int
  8288. atcommand_charkillableid2(
  8289. const int fd, struct map_session_data* sd,
  8290. const char* command, const char* message)
  8291. {
  8292. struct map_session_data *pl_sd = NULL;
  8293. int aid=0;
  8294. if (!message || (aid = atoi(message)) == 0) {
  8295. clif_displaymessage(fd, "Please, enter a player AID.");
  8296. return -1;
  8297. }
  8298. pl_sd = map_id2sd(aid);
  8299. if (!pl_sd) {
  8300. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8301. return -1;
  8302. }
  8303. if (pc_isGM(sd) < pc_isGM(pl_sd))
  8304. {
  8305. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8306. return -1;
  8307. }
  8308. pl_sd->state.killable = !pl_sd->state.killable;
  8309. if(pl_sd->state.killable)
  8310. clif_displaymessage(fd, msg_txt(289));
  8311. else
  8312. clif_displaymessage(fd, msg_txt(290));
  8313. return 0;
  8314. }
  8315. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8316. /*==========================================
  8317. * Mail System commands by [Valaris]
  8318. *------------------------------------------
  8319. */
  8320. int atcommand_listmail(
  8321. const int fd, struct map_session_data* sd,
  8322. const char* command, const char* message)
  8323. {
  8324. if(!mail_server_enable)
  8325. return 0;
  8326. nullpo_retr(-1, sd);
  8327. if(strlen(command)==12)
  8328. mail_check(sd,3);
  8329. else if(strlen(command)==9)
  8330. mail_check(sd,2);
  8331. else
  8332. mail_check(sd,1);
  8333. return 0;
  8334. }
  8335. int atcommand_readmail(
  8336. const int fd, struct map_session_data* sd,
  8337. const char* command, const char* message)
  8338. {
  8339. int index;
  8340. if(!mail_server_enable)
  8341. return 0;
  8342. nullpo_retr(-1, sd);
  8343. if (!message || !*message) {
  8344. clif_displaymessage(sd->fd,"You must specify a message number.");
  8345. return 0;
  8346. }
  8347. index = atoi(message);
  8348. if (index < 1) {
  8349. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8350. return 0;
  8351. }
  8352. if(strlen(command)==11)
  8353. mail_delete(sd,index);
  8354. else
  8355. mail_read(sd,index);
  8356. return 0;
  8357. }
  8358. int atcommand_sendmail(
  8359. const int fd, struct map_session_data* sd,
  8360. const char* command, const char* message)
  8361. {
  8362. char name[NAME_LENGTH],text[80];
  8363. if(!mail_server_enable)
  8364. return 0;
  8365. nullpo_retr(-1, sd);
  8366. if (!message || !*message) {
  8367. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8368. return 0;
  8369. }
  8370. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8371. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8372. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8373. return 0;
  8374. }
  8375. if(strlen(command)==17)
  8376. mail_send(sd,name,text,1);
  8377. else
  8378. mail_send(sd,name,text,0);
  8379. return 0;
  8380. }
  8381. /*==========================================
  8382. * Refresh online command for SQL [Valaris]
  8383. * Will refresh and check online column of
  8384. * players and set correctly.
  8385. *------------------------------------------
  8386. */
  8387. int atcommand_refreshonline(
  8388. const int fd, struct map_session_data* sd,
  8389. const char* command, const char* message)
  8390. {
  8391. send_users_tochar(-1, gettick(), 0, 0);
  8392. return 0;
  8393. }
  8394. #endif /* end sql only */
  8395. /*==========================================
  8396. * Show Monster DB Info v 1.0
  8397. * originally by [Lupus] eAthena
  8398. *------------------------------------------
  8399. */
  8400. int atcommand_mobinfo(
  8401. const int fd, struct map_session_data* sd,
  8402. const char* command, const char* message)
  8403. {
  8404. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8405. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8406. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8407. char atcmd_output2[200];
  8408. struct item_data *item_data;
  8409. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8410. int count;
  8411. int i, j, k;
  8412. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8413. malloc_tsetdword(atcmd_output2, '\0', sizeof(atcmd_output2));
  8414. if (!message || !*message) {
  8415. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8416. return -1;
  8417. }
  8418. // If monster identifier/name argument is a name
  8419. if ((i = mobdb_checkid(atoi(message))))
  8420. {
  8421. mob_array[0] = mob_db(i);
  8422. count = 1;
  8423. } else
  8424. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8425. if (!count) {
  8426. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  8427. return -1;
  8428. }
  8429. if (count > MAX_SEARCH) {
  8430. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8431. clif_displaymessage(fd, atcmd_output);
  8432. count = MAX_SEARCH;
  8433. }
  8434. for (k = 0; k < count; k++) {
  8435. mob = mob_array[k];
  8436. // stats
  8437. if (mob->mexp)
  8438. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8439. else
  8440. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  8441. clif_displaymessage(fd, atcmd_output);
  8442. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  8443. clif_displaymessage(fd, atcmd_output);
  8444. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8445. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8446. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8447. clif_displaymessage(fd, atcmd_output);
  8448. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8449. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8450. mob->range2 , mob->range3, msize[mob->status.size],
  8451. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8452. clif_displaymessage(fd, atcmd_output);
  8453. // drops
  8454. clif_displaymessage(fd, " Drops:");
  8455. strcpy(atcmd_output, " ");
  8456. j = 0;
  8457. for (i = 0; i < MAX_MOB_DROP; i++) {
  8458. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8459. continue;
  8460. if (item_data->slot)
  8461. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  8462. else
  8463. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8464. strcat(atcmd_output, atcmd_output2);
  8465. if (++j % 3 == 0) {
  8466. clif_displaymessage(fd, atcmd_output);
  8467. strcpy(atcmd_output, " ");
  8468. }
  8469. }
  8470. if (j == 0)
  8471. clif_displaymessage(fd, "This monster has no drops.");
  8472. else if (j % 3 != 0)
  8473. clif_displaymessage(fd, atcmd_output);
  8474. // mvp
  8475. if (mob->mexp) {
  8476. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8477. clif_displaymessage(fd, atcmd_output);
  8478. strcpy(atcmd_output, " MVP Items:");
  8479. j = 0;
  8480. for (i = 0; i < 3; i++) {
  8481. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8482. continue;
  8483. if (mob->mvpitem[i].p > 0) {
  8484. j++;
  8485. if (j == 1)
  8486. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8487. else
  8488. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8489. strcat(atcmd_output, atcmd_output2);
  8490. }
  8491. }
  8492. if (j == 0)
  8493. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8494. else
  8495. clif_displaymessage(fd, atcmd_output);
  8496. }
  8497. }
  8498. return 0;
  8499. }
  8500. /*=========================================
  8501. * @showmobs by KarLaeda
  8502. * => For 5 sec displays the mobs on minimap
  8503. *------------------------------------------
  8504. */
  8505. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  8506. {
  8507. struct map_session_data *sd;
  8508. if (!session[id] || (sd = session[id]->session_data) == NULL)
  8509. return 0;
  8510. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  8511. return 1;
  8512. }
  8513. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  8514. {
  8515. int mob_id,fd;
  8516. struct map_session_data* sd;
  8517. static int number=0;
  8518. struct mob_data *md;
  8519. if(!ap){
  8520. number=0;
  8521. return 0;
  8522. }
  8523. mob_id = va_arg(ap,int);
  8524. fd = va_arg(ap,int);
  8525. sd = va_arg(ap,struct map_session_data*);
  8526. md = (struct mob_data *)bl;
  8527. if(md->special_state.ai || md->master_id)
  8528. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  8529. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  8530. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  8531. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  8532. }
  8533. return 0;
  8534. }
  8535. int atcommand_showmobs(
  8536. const int fd, struct map_session_data* sd,
  8537. const char* command, const char* message)
  8538. {
  8539. char mob_name[100];
  8540. int mob_id,map_id = 0;
  8541. nullpo_retr(-1, sd);
  8542. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  8543. return -1;
  8544. if ((mob_id = atoi(mob_name)) == 0)
  8545. mob_id = mobdb_searchname(mob_name);
  8546. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  8547. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  8548. clif_displaymessage(fd, atcmd_output);
  8549. return 0;
  8550. }
  8551. // Uncomment the following line to show mini-bosses & MVP.
  8552. //#define SHOW_MVP
  8553. #ifndef SHOW_MVP
  8554. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8555. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8556. clif_displaymessage(fd, atcmd_output);
  8557. return 0;
  8558. }
  8559. #endif
  8560. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8561. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8562. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8563. map_id = sd->bl.m;
  8564. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8565. mob_name, mapindex_id2name(sd->mapindex));
  8566. clif_displaymessage(fd, atcmd_output);
  8567. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8568. atshowmobs_sub(&sd->bl,0);
  8569. return 0;
  8570. }
  8571. /*==========================================
  8572. * homunculus level up [orn]
  8573. *------------------------------------------
  8574. */
  8575. int atcommand_homlevel(
  8576. const int fd, struct map_session_data* sd,
  8577. const char* command, const char* message)
  8578. {
  8579. TBL_HOM * hd;
  8580. int level = 0, i = 0;
  8581. nullpo_retr(-1, sd);
  8582. if (!message || !*message)
  8583. return -1;
  8584. if ( !merc_is_hom_active(sd->hd) )
  8585. return 1 ;
  8586. level = atoi(message);
  8587. hd = sd->hd;
  8588. for (i = 1; i <= level && hd->exp_next; i++){
  8589. hd->homunculus.exp += hd->exp_next;
  8590. merc_hom_levelup(hd);
  8591. }
  8592. status_calc_homunculus(hd,0);
  8593. status_percent_heal(&hd->bl, 100, 100);
  8594. clif_misceffect2(&hd->bl,568);
  8595. return 0;
  8596. }
  8597. /*==========================================
  8598. * homunculus evolution H [orn]
  8599. *------------------------------------------
  8600. */
  8601. int atcommand_homevolution(
  8602. const int fd, struct map_session_data* sd,
  8603. const char* command, const char* message)
  8604. {
  8605. nullpo_retr(-1, sd);
  8606. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8607. {
  8608. merc_hom_evolution(sd->hd) ;
  8609. }
  8610. return 0;
  8611. }
  8612. /*==========================================
  8613. * call choosen homunculus [orn]
  8614. *------------------------------------------
  8615. */
  8616. int
  8617. atcommand_makehomun(
  8618. const int fd, struct map_session_data* sd,
  8619. const char* command, const char* message)
  8620. {
  8621. int homunid;
  8622. nullpo_retr(-1, sd);
  8623. if(sscanf(message, "%d", &homunid)<1)
  8624. return -1;
  8625. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8626. return -1;
  8627. if(sd->status.hom_id == 0)
  8628. {
  8629. merc_create_homunculus_request(sd,homunid);
  8630. }
  8631. else
  8632. {
  8633. clif_displaymessage(fd,msg_txt(450));
  8634. }
  8635. return 0;
  8636. }
  8637. /*==========================================
  8638. * modify homunculus intimacy [orn]
  8639. *------------------------------------------
  8640. */
  8641. int atcommand_homfriendly(
  8642. const int fd, struct map_session_data* sd,
  8643. const char* command, const char* message)
  8644. {
  8645. int friendly = 0;
  8646. nullpo_retr(-1, sd);
  8647. if (!message || !*message)
  8648. return -1;
  8649. friendly = atoi(message);
  8650. if (merc_is_hom_active(sd->hd)) {
  8651. if (friendly > 0 && friendly <= 1000) {
  8652. sd->hd->homunculus.intimacy = friendly * 100 ;
  8653. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8654. } else {
  8655. return -1;
  8656. }
  8657. }
  8658. return 0;
  8659. }
  8660. /*==========================================
  8661. * modify homunculus hunger [orn]
  8662. *------------------------------------------
  8663. */
  8664. int atcommand_homhungry(
  8665. const int fd, struct map_session_data* sd,
  8666. const char* command, const char* message)
  8667. {
  8668. int hungry = 0;
  8669. nullpo_retr(-1, sd);
  8670. if (!message || !*message)
  8671. return -1;
  8672. hungry = atoi(message);
  8673. if (sd->status.hom_id > 0 && sd->hd) {
  8674. struct homun_data *hd = sd->hd;
  8675. if (hungry >= 0 && hungry <= 100) {
  8676. hd->homunculus.hunger = hungry;
  8677. clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
  8678. } else {
  8679. return -1;
  8680. }
  8681. }
  8682. return 0;
  8683. }
  8684. /*==========================================
  8685. * modify homunculus hunger [orn]
  8686. *------------------------------------------
  8687. */
  8688. int atcommand_homtalk(
  8689. const int fd, struct map_session_data* sd,
  8690. const char* command, const char* message)
  8691. {
  8692. char mes[100],temp[100];
  8693. nullpo_retr(-1, sd);
  8694. if(!merc_is_hom_active(sd->hd))
  8695. return -1;
  8696. if (sscanf(message, "%99[^\n]", mes) < 1)
  8697. return -1;
  8698. snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
  8699. clif_message(&sd->hd->bl, temp);
  8700. return 0;
  8701. }
  8702. /*==========================================
  8703. * Show homunculus stats
  8704. *------------------------------------------
  8705. */
  8706. int atcommand_hominfo(
  8707. const int fd, struct map_session_data* sd,
  8708. const char* command, const char* message)
  8709. {
  8710. struct homun_data *hd;
  8711. struct status_data *status;
  8712. nullpo_retr(-1, sd);
  8713. if(!merc_is_hom_active(sd->hd))
  8714. return -1;
  8715. hd = sd->hd;
  8716. status = status_get_status_data(&hd->bl);
  8717. clif_displaymessage(fd, "Homunculus stats :");
  8718. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  8719. status->hp, status->max_hp, status->sp, status->max_sp);
  8720. clif_displaymessage(fd, atcmd_output);
  8721. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  8722. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  8723. clif_displaymessage(fd, atcmd_output);
  8724. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  8725. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  8726. clif_displaymessage(fd, atcmd_output);
  8727. return 0;
  8728. }
  8729. /*==========================================
  8730. * Show Items DB Info v 1.0
  8731. * originally by [Lupus] eAthena
  8732. *------------------------------------------
  8733. */
  8734. int atcommand_iteminfo(
  8735. const int fd, struct map_session_data* sd,
  8736. const char* command, const char* message)
  8737. {
  8738. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8739. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8740. struct item_data *item_data, *item_array[MAX_SEARCH];
  8741. int i, count = 1;
  8742. if (!message || !*message) {
  8743. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8744. return -1;
  8745. }
  8746. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8747. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8748. if (!count) {
  8749. clif_displaymessage(fd, "Item not found.");
  8750. return -1;
  8751. }
  8752. if (count > MAX_SEARCH) {
  8753. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8754. clif_displaymessage(fd, atcmd_output);
  8755. count = MAX_SEARCH;
  8756. }
  8757. for (i = 0; i < count; i++) {
  8758. item_data = item_array[i];
  8759. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8760. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8761. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8762. (item_data->script==NULL)? "None" : "With script"
  8763. );
  8764. clif_displaymessage(fd, atcmd_output);
  8765. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  8766. clif_displaymessage(fd, atcmd_output);
  8767. if (item_data->maxchance == 10000)
  8768. strcpy(atcmd_output, " - Available in the shops only");
  8769. else if (item_data->maxchance)
  8770. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8771. else
  8772. strcpy(atcmd_output, " - Monsters don't drop this item");
  8773. clif_displaymessage(fd, atcmd_output);
  8774. }
  8775. return 0;
  8776. }
  8777. /*==========================================
  8778. * Show who drops the item.
  8779. *------------------------------------------
  8780. */
  8781. int atcommand_whodrops(
  8782. const int fd, struct map_session_data* sd,
  8783. const char* command, const char* message)
  8784. {
  8785. struct item_data *item_data, *item_array[MAX_SEARCH];
  8786. int i,j, count = 1;
  8787. if (!message || !*message) {
  8788. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8789. return -1;
  8790. }
  8791. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8792. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8793. if (!count) {
  8794. clif_displaymessage(fd, "Item not found.");
  8795. return -1;
  8796. }
  8797. if (count > MAX_SEARCH) {
  8798. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8799. clif_displaymessage(fd, atcmd_output);
  8800. count = MAX_SEARCH;
  8801. }
  8802. for (i = 0; i < count; i++) {
  8803. item_data = item_array[i];
  8804. sprintf(atcmd_output, "Item: '%s'[%d]",
  8805. item_data->jname,item_data->slot);
  8806. clif_displaymessage(fd, atcmd_output);
  8807. if (item_data->mob[0].chance == 0) {
  8808. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8809. clif_displaymessage(fd, atcmd_output);
  8810. } else {
  8811. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8812. clif_displaymessage(fd, atcmd_output);
  8813. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8814. {
  8815. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8816. clif_displaymessage(fd, atcmd_output);
  8817. }
  8818. }
  8819. }
  8820. return 0;
  8821. }
  8822. /*==========================================
  8823. * @adopt by [Veider]
  8824. *
  8825. * adopt a novice
  8826. *------------------------------------------
  8827. */
  8828. int
  8829. atcommand_adopt(const int fd, struct map_session_data* sd,
  8830. const char* command, const char* message)
  8831. {
  8832. struct map_session_data *pl_sd1 = NULL;
  8833. struct map_session_data *pl_sd2 = NULL;
  8834. struct map_session_data *pl_sd3 = NULL;
  8835. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8836. nullpo_retr(-1, sd);
  8837. if (!message || !*message)
  8838. return -1;
  8839. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8840. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8841. return -1;
  8842. }
  8843. if (battle_config.etc_log)
  8844. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8845. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8846. sprintf(player2, "Cannot find player %s online", player1);
  8847. clif_displaymessage(fd, player2);
  8848. return -1;
  8849. }
  8850. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8851. sprintf(player1, "Cannot find player %s online", player2);
  8852. clif_displaymessage(fd, player1);
  8853. return -1;
  8854. }
  8855. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8856. sprintf(player1, "Cannot find player %s online", player3);
  8857. clif_displaymessage(fd, player1);
  8858. return -1;
  8859. }
  8860. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8861. clif_displaymessage(fd, "They are too young to be parents!");
  8862. return -1;
  8863. }
  8864. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8865. clif_displaymessage(fd, "They are family.. wish them luck");
  8866. return 0;
  8867. }
  8868. else
  8869. return -1;
  8870. }
  8871. int atcommand_version(
  8872. const int fd, struct map_session_data* sd,
  8873. const char* command, const char* message)
  8874. {
  8875. const char * revision;
  8876. if ((revision = get_svn_revision()) != 0) {
  8877. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8878. clif_displaymessage(fd,atcmd_output);
  8879. } else
  8880. clif_displaymessage(fd,"Cannot determine SVN revision");
  8881. return 0;
  8882. }
  8883. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8884. {
  8885. int time, id;
  8886. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8887. if (pl_sd == NULL)
  8888. return 0;
  8889. id = va_arg(ap, int);
  8890. time = va_arg(ap, int);
  8891. if (id != bl->id && !pc_isGM(pl_sd)) {
  8892. pl_sd->status.manner -= time;
  8893. if (pl_sd->status.manner < 0)
  8894. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8895. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8896. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8897. }
  8898. return 0;
  8899. }
  8900. /*==========================================
  8901. * @mutearea by MouseJstr
  8902. *------------------------------------------
  8903. */
  8904. int atcommand_mutearea(
  8905. const int fd, struct map_session_data* sd,
  8906. const char* command, const char* message)
  8907. {
  8908. int time;
  8909. nullpo_retr(0, sd);
  8910. time = atoi(message);
  8911. if (!time)
  8912. time = 15; // 15 minutes default
  8913. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8914. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8915. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8916. return 0;
  8917. }
  8918. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8919. {
  8920. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8921. if (bl == NULL)
  8922. return 0;
  8923. if (!pc_isGM(pl_sd))
  8924. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8925. return 0;
  8926. }
  8927. /*==========================================
  8928. * @shuffle by MouseJstr
  8929. *------------------------------------------
  8930. */
  8931. int atcommand_shuffle(
  8932. const int fd, struct map_session_data* sd,
  8933. const char* command, const char* message)
  8934. {
  8935. nullpo_retr(0, sd);
  8936. if (strcmp(message, "area")== 0) {
  8937. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8938. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8939. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8940. } else if (strcmp(message, "map")== 0) {
  8941. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8942. } else if (strcmp(message, "world") == 0) {
  8943. struct map_session_data **pl_allsd;
  8944. int i, users;
  8945. pl_allsd = map_getallusers(&users);
  8946. for (i = 0; i < users; i++)
  8947. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8948. } else
  8949. clif_displaymessage(fd, "options are area, map, or world");
  8950. return 0;
  8951. }
  8952. int atcommand_rates(
  8953. const int fd, struct map_session_data* sd,
  8954. const char* command, const char* message)
  8955. {
  8956. char buf[255];
  8957. nullpo_retr(0, sd);
  8958. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8959. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8960. clif_displaymessage(fd, buf);
  8961. return 0;
  8962. }
  8963. /*==========================================
  8964. * @me by lordalfa
  8965. * => Displays the OUTPUT string on top of
  8966. * the Visible players Heads.
  8967. *------------------------------------------
  8968. */
  8969. int atcommand_me(
  8970. const int fd, struct map_session_data* sd,
  8971. const char* command, const char* message)
  8972. {
  8973. char tempmes[200];
  8974. nullpo_retr(-1, sd);
  8975. malloc_tsetdword(tempmes, '\0', sizeof(tempmes));
  8976. malloc_tsetdword(atcmd_output, '\0', sizeof(atcmd_output));
  8977. if (sd->sc.count && //no "chatting" while muted.
  8978. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  8979. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  8980. return -1;
  8981. if (!message || !*message) {
  8982. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8983. return -1;
  8984. }
  8985. sscanf(message, "%199[^\n]", tempmes);
  8986. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8987. clif_disp_overhead(sd, atcmd_output);
  8988. return 0;
  8989. }
  8990. /*==========================================
  8991. * @size
  8992. * => Resize your character sprite. [Valaris]
  8993. *------------------------------------------
  8994. */
  8995. int atcommand_size(
  8996. const int fd, struct map_session_data* sd,
  8997. const char* command, const char* message)
  8998. {
  8999. int size=0;
  9000. nullpo_retr(-1, sd);
  9001. if (!message || !*message)
  9002. return -1;
  9003. if (sscanf(message,"%d", &size) < 1)
  9004. return -1;
  9005. if(sd->state.size) {
  9006. sd->state.size=0;
  9007. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  9008. }
  9009. if(size==1) {
  9010. sd->state.size=1;
  9011. clif_specialeffect(&sd->bl,420,AREA);
  9012. } else if(size==2) {
  9013. sd->state.size=2;
  9014. clif_specialeffect(&sd->bl,422,AREA);
  9015. }
  9016. return 0;
  9017. }
  9018. /*==========================================
  9019. * @monsterignore
  9020. * => Makes monsters ignore you. [Valaris]
  9021. *------------------------------------------
  9022. */
  9023. int atcommand_monsterignore(
  9024. const int fd, struct map_session_data* sd,
  9025. const char* command, const char* message)
  9026. {
  9027. nullpo_retr(-1, sd);
  9028. if (!sd->state.monster_ignore) {
  9029. sd->state.monster_ignore = 1;
  9030. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  9031. } else {
  9032. sd->state.monster_ignore = 0;
  9033. clif_displaymessage(sd->fd, "Returned to normal state.");
  9034. }
  9035. return 0;
  9036. }
  9037. /*==========================================
  9038. * @fakename
  9039. * => Gives your character a fake name. [Valaris]
  9040. *------------------------------------------
  9041. */
  9042. int atcommand_fakename(
  9043. const int fd, struct map_session_data* sd,
  9044. const char* command, const char* message)
  9045. {
  9046. char name[NAME_LENGTH];
  9047. nullpo_retr(-1, sd);
  9048. if((!message || !*message) && strlen(sd->fakename) > 1) {
  9049. sd->fakename[0]='\0';
  9050. clif_charnameack(0, &sd->bl);
  9051. clif_displaymessage(sd->fd,"Returned to real name.");
  9052. return 0;
  9053. }
  9054. if (!message || !*message) {
  9055. clif_displaymessage(sd->fd,"You must enter a name.");
  9056. return 0;
  9057. }
  9058. if (sscanf(message, "%23[^\n]", name) < 1) {
  9059. return 0;
  9060. }
  9061. if(strlen(name) < 2) {
  9062. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  9063. return 0;
  9064. }
  9065. memcpy(sd->fakename,name,NAME_LENGTH-1);
  9066. clif_charnameack(0, &sd->bl);
  9067. clif_displaymessage(sd->fd,"Fake name enabled.");
  9068. return 0;
  9069. }
  9070. /*==========================================
  9071. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  9072. * => Shows information about the map flags [map name]
  9073. * Also set flags
  9074. *------------------------------------------
  9075. */
  9076. int atcommand_mapflag(
  9077. const int fd, struct map_session_data* sd,
  9078. const char* command, const char* message)
  9079. {
  9080. // WIP
  9081. return 0;
  9082. }
  9083. /*===================================
  9084. * Remove some messages
  9085. *-----------------------------------
  9086. */
  9087. int atcommand_showexp(
  9088. const int fd, struct map_session_data* sd,
  9089. const char* command, const char* message)
  9090. {
  9091. if (sd->state.showexp) {
  9092. sd->state.showexp = 0;
  9093. clif_displaymessage(fd, "Gained exp will not be shown.");
  9094. return 0;
  9095. }
  9096. sd->state.showexp = 1;
  9097. clif_displaymessage(fd, "Gained exp is now shown");
  9098. return 0;
  9099. }
  9100. int atcommand_showzeny(
  9101. const int fd, struct map_session_data* sd,
  9102. const char* command, const char* message)
  9103. {
  9104. if (sd->state.showzeny) {
  9105. sd->state.showzeny = 0;
  9106. clif_displaymessage(fd, "Gained zeny will not be shown.");
  9107. return 0;
  9108. }
  9109. sd->state.showzeny = 1;
  9110. clif_displaymessage(fd, "Gained zeny is now shown");
  9111. return 0;
  9112. }
  9113. int atcommand_showdelay(
  9114. const int fd, struct map_session_data* sd,
  9115. const char* command, const char* message)
  9116. {
  9117. if (sd->state.showdelay) {
  9118. sd->state.showdelay = 0;
  9119. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  9120. return 0;
  9121. }
  9122. sd->state.showdelay = 1;
  9123. clif_displaymessage(fd, "Skill delay failures are shown now.");
  9124. return 0;
  9125. }
  9126. /*==========================================
  9127. * Duel organizing functions [LuzZza]
  9128. *
  9129. * @duel [limit|nick] - create a duel
  9130. * @invite <nick> - invite player
  9131. * @accept - accept invitation
  9132. * @reject - reject invitation
  9133. * @leave - leave duel
  9134. *------------------------------------------
  9135. */
  9136. int atcommand_invite(
  9137. const int fd, struct map_session_data* sd,
  9138. const char* command, const char* message)
  9139. {
  9140. unsigned int did = sd->duel_group;
  9141. struct map_session_data *target_sd = map_nick2sd((char *)message);
  9142. if(did <= 0) {
  9143. // "Duel: @invite without @duel."
  9144. clif_displaymessage(fd, msg_txt(350));
  9145. return 0;
  9146. }
  9147. if(duel_list[did].max_players_limit > 0 &&
  9148. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  9149. // "Duel: Limit of players is reached."
  9150. clif_displaymessage(fd, msg_txt(351));
  9151. return 0;
  9152. }
  9153. if(target_sd == NULL) {
  9154. // "Duel: Player not found."
  9155. clif_displaymessage(fd, msg_txt(352));
  9156. return 0;
  9157. }
  9158. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9159. // "Duel: Player already in duel."
  9160. clif_displaymessage(fd, msg_txt(353));
  9161. return 0;
  9162. }
  9163. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  9164. {
  9165. sprintf(atcmd_output, msg_txt(364), message);
  9166. clif_displaymessage(fd, atcmd_output);
  9167. return 0;
  9168. }
  9169. duel_invite(did, sd, target_sd);
  9170. // "Duel: Invitation has been sent."
  9171. clif_displaymessage(fd, msg_txt(354));
  9172. return 0;
  9173. }
  9174. int atcommand_duel(
  9175. const int fd, struct map_session_data* sd,
  9176. const char* command, const char* message)
  9177. {
  9178. char output[256];
  9179. unsigned int maxpl=0, newduel;
  9180. struct map_session_data *target_sd;
  9181. /* // Commnted because it can be disabled in at-comms conf.
  9182. if(!battle_config.duel_enable) {
  9183. clif_displaymessage(fd, "Duel: duel is disable.");
  9184. return 0;
  9185. }
  9186. */
  9187. if(sd->duel_group > 0) {
  9188. duel_showinfo(sd->duel_group, sd);
  9189. return 0;
  9190. }
  9191. if(sd->duel_invite > 0) {
  9192. // "Duel: @duel without @reject."
  9193. clif_displaymessage(fd, msg_txt(355));
  9194. return 0;
  9195. }
  9196. if(!duel_checktime(sd)) {
  9197. // "Duel: You can take part in duel only one time per %d minutes."
  9198. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9199. clif_displaymessage(fd, output);
  9200. return 0;
  9201. }
  9202. if(strlen(message) > 0) {
  9203. if(sscanf(message, "%d", &maxpl) >= 1) {
  9204. if(maxpl < 2 || maxpl > 65535) {
  9205. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  9206. return 0;
  9207. }
  9208. duel_create(sd, maxpl);
  9209. } else {
  9210. target_sd = map_nick2sd((char *)message);
  9211. if(target_sd != NULL) {
  9212. if((newduel = duel_create(sd, 2)) != -1) {
  9213. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  9214. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  9215. return 0;
  9216. }
  9217. duel_invite(newduel, sd, target_sd);
  9218. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  9219. }
  9220. } else {
  9221. // "Duel: Player not found."
  9222. clif_displaymessage(fd, msg_txt(352));
  9223. return 0;
  9224. }
  9225. }
  9226. } else
  9227. duel_create(sd, 0);
  9228. return 0;
  9229. }
  9230. int atcommand_leave(
  9231. const int fd, struct map_session_data* sd,
  9232. const char* command, const char* message)
  9233. {
  9234. if(sd->duel_group <= 0) {
  9235. // "Duel: @leave without @duel."
  9236. clif_displaymessage(fd, msg_txt(358));
  9237. return 0;
  9238. }
  9239. duel_leave(sd->duel_group, sd);
  9240. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  9241. return 0;
  9242. }
  9243. int atcommand_accept(
  9244. const int fd, struct map_session_data* sd,
  9245. const char* command, const char* message)
  9246. {
  9247. char output[256];
  9248. if(!duel_checktime(sd)) {
  9249. // "Duel: You can take part in duel only one time per %d minutes."
  9250. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  9251. clif_displaymessage(fd, output);
  9252. return 0;
  9253. }
  9254. if(sd->duel_invite <= 0) {
  9255. // "Duel: @accept without invititation."
  9256. clif_displaymessage(fd, msg_txt(360));
  9257. return 0;
  9258. }
  9259. duel_accept(sd->duel_invite, sd);
  9260. // "Duel: Invitation has been accepted."
  9261. clif_displaymessage(fd, msg_txt(361));
  9262. return 0;
  9263. }
  9264. int atcommand_reject(
  9265. const int fd, struct map_session_data* sd,
  9266. const char* command, const char* message)
  9267. {
  9268. if(sd->duel_invite <= 0) {
  9269. // "Duel: @reject without invititation."
  9270. clif_displaymessage(fd, msg_txt(362));
  9271. return 0;
  9272. }
  9273. duel_reject(sd->duel_invite, sd);
  9274. // "Duel: Invitation has been rejected."
  9275. clif_displaymessage(fd, msg_txt(363));
  9276. return 0;
  9277. }
  9278. /*===================================
  9279. * Away message (@away, @aw) [LuzZza]
  9280. *-----------------------------------
  9281. */
  9282. int atcommand_away(
  9283. const int fd, struct map_session_data* sd,
  9284. const char* command, const char* message)
  9285. {
  9286. if(strlen(message) > 0) {
  9287. if(strlen(message) > 128)
  9288. return -1;
  9289. strcpy(sd->away_message, message);
  9290. //"Away automessage has been activated."
  9291. clif_displaymessage(fd, msg_txt(546));
  9292. } else {
  9293. if(strlen(sd->away_message) > 0) {
  9294. sd->away_message[0] = 0;
  9295. //"Away automessage has been disabled."
  9296. clif_displaymessage(fd, msg_txt(547));
  9297. return 0;
  9298. }
  9299. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  9300. clif_displaymessage(fd, msg_txt(548));
  9301. }
  9302. return 0;
  9303. }
  9304. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  9305. int atcommand_clone(
  9306. const int fd, struct map_session_data* sd,
  9307. const char* command, const char* message)
  9308. {
  9309. int x=0,y=0,flag=0,master=0,i=0;
  9310. struct map_session_data *pl_sd=NULL;
  9311. if (!message || !*message) {
  9312. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  9313. return 0;
  9314. }
  9315. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  9316. clif_displaymessage(fd, msg_txt(3));
  9317. return 0;
  9318. }
  9319. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  9320. clif_displaymessage(fd, msg_txt(126));
  9321. return 0;
  9322. }
  9323. if (strcmpi(command, "@clone") == 0)
  9324. flag = 1;
  9325. else if (strcmpi(command, "@slaveclone") == 0) {
  9326. flag = 2;
  9327. master = sd->bl.id;
  9328. if (battle_config.atc_slave_clone_limit
  9329. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  9330. clif_displaymessage(fd, msg_txt(127));
  9331. return 0;
  9332. }
  9333. }
  9334. do {
  9335. x = sd->bl.x + (rand() % 10 - 5);
  9336. y = sd->bl.y + (rand() % 10 - 5);
  9337. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  9338. if (i >= 10) {
  9339. x = sd->bl.x;
  9340. y = sd->bl.y;
  9341. }
  9342. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  9343. clif_displaymessage(fd, msg_txt(128+flag*2));
  9344. return 0;
  9345. }
  9346. clif_displaymessage(fd, msg_txt(129+flag*2));
  9347. return 0;
  9348. }
  9349. /*===================================
  9350. * Main chat [LuzZza]
  9351. * Usage: @main <on|off|message>
  9352. *-----------------------------------
  9353. */
  9354. int atcommand_main(
  9355. const int fd, struct map_session_data* sd,
  9356. const char* command, const char* message)
  9357. {
  9358. if(strlen(message) > 0) {
  9359. if(strcmpi(message, "on") == 0) {
  9360. if(!sd->state.mainchat) {
  9361. sd->state.mainchat = 1;
  9362. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9363. } else {
  9364. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  9365. }
  9366. } else if(strcmpi(message, "off") == 0) {
  9367. if(sd->state.mainchat) {
  9368. sd->state.mainchat = 0;
  9369. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  9370. } else {
  9371. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  9372. }
  9373. } else {
  9374. if(!sd->state.mainchat) {
  9375. sd->state.mainchat = 1;
  9376. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  9377. }
  9378. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  9379. clif_displaymessage(fd, msg_txt(387));
  9380. return -1;
  9381. }
  9382. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  9383. // I use 0xFE000000 color for signalizing that this message is
  9384. // main chat message. 0xFE000000 is invalid color, same using
  9385. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  9386. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  9387. }
  9388. } else {
  9389. if(sd->state.mainchat)
  9390. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  9391. clif_displaymessage(fd, msg_txt(384));
  9392. else
  9393. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  9394. clif_displaymessage(fd, msg_txt(385));
  9395. }
  9396. return 0;
  9397. }
  9398. /*=====================================
  9399. * Autorejecting Invites/Deals [LuzZza]
  9400. * Usage: @noask
  9401. *-------------------------------------
  9402. */
  9403. int atcommand_noask(
  9404. const int fd, struct map_session_data* sd,
  9405. const char* command, const char* message)
  9406. {
  9407. if(sd->state.noask) {
  9408. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  9409. sd->state.noask = 0;
  9410. } else {
  9411. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  9412. sd->state.noask = 1;
  9413. }
  9414. return 0;
  9415. }
  9416. /*=====================================
  9417. * Send a @request message to all GMs of lowest_gm_level.
  9418. * Usage: @request <petition>
  9419. *-------------------------------------
  9420. */
  9421. int atcommand_request(
  9422. const int fd, struct map_session_data* sd,
  9423. const char* command, const char* message)
  9424. {
  9425. if (!message || !*message) {
  9426. clif_displaymessage(sd->fd,msg_txt(277));
  9427. return -1;
  9428. }
  9429. sprintf(atcmd_output, msg_txt(278), message);
  9430. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  9431. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  9432. clif_displaymessage(sd->fd,msg_txt(279));
  9433. return 0;
  9434. }
  9435. void do_init_atcommand() {
  9436. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  9437. duel_count = 0;
  9438. malloc_tsetdword(&duel_list[0], 0, sizeof(duel_list));
  9439. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  9440. return;
  9441. }
  9442. void do_final_atcommand() {
  9443. users_db->destroy(users_db,NULL);
  9444. }