atcommand.c 274 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114
  1. // $Id: atcommand.c 148 2004-09-30 14:05:37Z MouseJstr $
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <math.h>
  7. #include "../common/socket.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "../common/mmo.h"
  11. #include "../common/db.h"
  12. #include "log.h"
  13. #include "clif.h"
  14. #include "chrif.h"
  15. #include "intif.h"
  16. #include "itemdb.h"
  17. #include "map.h"
  18. #include "pc.h"
  19. #include "status.h"
  20. #include "skill.h"
  21. #include "mob.h"
  22. #include "pet.h"
  23. #include "battle.h"
  24. #include "party.h"
  25. #include "guild.h"
  26. #include "atcommand.h"
  27. #include "script.h"
  28. #include "npc.h"
  29. #include "trade.h"
  30. #include "core.h"
  31. #ifndef TXT_ONLY
  32. #include "mail.h"
  33. #endif
  34. #define STATE_BLIND 0x10
  35. static char command_symbol = '@'; // first char of the commands (by [Yor])
  36. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  37. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  38. ACMD_FUNC(broadcast);
  39. ACMD_FUNC(localbroadcast);
  40. ACMD_FUNC(rura);
  41. ACMD_FUNC(where);
  42. ACMD_FUNC(jumpto);
  43. ACMD_FUNC(jump);
  44. ACMD_FUNC(who);
  45. ACMD_FUNC(who2);
  46. ACMD_FUNC(who3);
  47. ACMD_FUNC(whomap);
  48. ACMD_FUNC(whomap2);
  49. ACMD_FUNC(whomap3);
  50. ACMD_FUNC(whogm); // by Yor
  51. ACMD_FUNC(whozeny); // [Valaris]
  52. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  53. ACMD_FUNC(save);
  54. ACMD_FUNC(load);
  55. ACMD_FUNC(speed);
  56. ACMD_FUNC(storage);
  57. ACMD_FUNC(guildstorage);
  58. ACMD_FUNC(option);
  59. ACMD_FUNC(hide);
  60. ACMD_FUNC(jobchange);
  61. ACMD_FUNC(die);
  62. ACMD_FUNC(kill);
  63. ACMD_FUNC(alive);
  64. ACMD_FUNC(kami);
  65. ACMD_FUNC(heal);
  66. ACMD_FUNC(item);
  67. ACMD_FUNC(item2);
  68. ACMD_FUNC(itemreset);
  69. ACMD_FUNC(itemcheck);
  70. ACMD_FUNC(baselevelup);
  71. ACMD_FUNC(joblevelup);
  72. ACMD_FUNC(help);
  73. ACMD_FUNC(gm);
  74. ACMD_FUNC(pvpoff);
  75. ACMD_FUNC(pvpon);
  76. ACMD_FUNC(gvgoff);
  77. ACMD_FUNC(gvgon);
  78. ACMD_FUNC(model);
  79. ACMD_FUNC(go);
  80. ACMD_FUNC(monster);
  81. ACMD_FUNC(monstersmall);
  82. ACMD_FUNC(monsterbig);
  83. ACMD_FUNC(spawn);
  84. ACMD_FUNC(killmonster);
  85. ACMD_FUNC(killmonster2);
  86. ACMD_FUNC(refine);
  87. ACMD_FUNC(produce);
  88. ACMD_FUNC(memo);
  89. ACMD_FUNC(gat);
  90. ACMD_FUNC(packet);
  91. ACMD_FUNC(statuspoint);
  92. ACMD_FUNC(skillpoint);
  93. ACMD_FUNC(zeny);
  94. ACMD_FUNC(param);
  95. ACMD_FUNC(guildlevelup);
  96. ACMD_FUNC(makeegg);
  97. ACMD_FUNC(hatch);
  98. ACMD_FUNC(petfriendly);
  99. ACMD_FUNC(pethungry);
  100. ACMD_FUNC(petrename);
  101. ACMD_FUNC(recall);
  102. ACMD_FUNC(recallall);
  103. ACMD_FUNC(revive);
  104. ACMD_FUNC(character_stats_all);
  105. ACMD_FUNC(character_save);
  106. ACMD_FUNC(night);
  107. ACMD_FUNC(day);
  108. ACMD_FUNC(doom);
  109. ACMD_FUNC(doommap);
  110. ACMD_FUNC(raise);
  111. ACMD_FUNC(raisemap);
  112. ACMD_FUNC(character_baselevel);
  113. ACMD_FUNC(character_joblevel);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(charquestskill);
  119. ACMD_FUNC(lostskill);
  120. ACMD_FUNC(charlostskill);
  121. ACMD_FUNC(spiritball);
  122. ACMD_FUNC(party);
  123. ACMD_FUNC(guild);
  124. ACMD_FUNC(charskreset);
  125. ACMD_FUNC(charstreset);
  126. ACMD_FUNC(charreset);
  127. ACMD_FUNC(charstpoint);
  128. ACMD_FUNC(charmodel);
  129. ACMD_FUNC(charskpoint);
  130. ACMD_FUNC(agitstart);
  131. ACMD_FUNC(agitend);
  132. ACMD_FUNC(reloaditemdb);
  133. ACMD_FUNC(reloadmobdb);
  134. ACMD_FUNC(reloadskilldb);
  135. ACMD_FUNC(reloadscript);
  136. ACMD_FUNC(reloadgmdb); // by Yor
  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_change_sex); // by Yor
  145. ACMD_FUNC(char_block); // by Yor
  146. ACMD_FUNC(char_ban); // by Yor
  147. ACMD_FUNC(char_unblock); // by Yor
  148. ACMD_FUNC(char_unban); // by Yor
  149. ACMD_FUNC(mount_peco); // by Valaris
  150. ACMD_FUNC(char_mount_peco); // by Yor
  151. ACMD_FUNC(guildspy); // [Syrus22]
  152. ACMD_FUNC(partyspy); // [Syrus22]
  153. ACMD_FUNC(repairall); // [Valaris]
  154. ACMD_FUNC(guildrecall); // by Yor
  155. ACMD_FUNC(partyrecall); // by Yor
  156. ACMD_FUNC(nuke); // [Valaris]
  157. ACMD_FUNC(enablenpc);
  158. ACMD_FUNC(disablenpc);
  159. ACMD_FUNC(servertime); // by Yor
  160. ACMD_FUNC(chardelitem); // by Yor
  161. ACMD_FUNC(jail); // by Yor
  162. ACMD_FUNC(unjail); // by Yor
  163. ACMD_FUNC(disguise); // [Valaris]
  164. ACMD_FUNC(undisguise); // by Yor
  165. ACMD_FUNC(chardisguise); // Kalaspuff
  166. ACMD_FUNC(charundisguise); // Kalaspuff
  167. ACMD_FUNC(email); // by Yor
  168. ACMD_FUNC(effect);//by Apple
  169. ACMD_FUNC(character_cart_list); // by Yor
  170. ACMD_FUNC(addwarp); // by MouseJstr
  171. ACMD_FUNC(follow); // by MouseJstr
  172. ACMD_FUNC(skillon); // by MouseJstr
  173. ACMD_FUNC(skilloff); // by MouseJstr
  174. ACMD_FUNC(killer); // by MouseJstr
  175. ACMD_FUNC(npcmove); // by MouseJstr
  176. ACMD_FUNC(killable); // by MouseJstr
  177. ACMD_FUNC(charkillable); // by MouseJstr
  178. ACMD_FUNC(dropall); // by MouseJstr
  179. ACMD_FUNC(chardropall); // by MouseJstr
  180. ACMD_FUNC(storeall); // by MouseJstr
  181. ACMD_FUNC(charstoreall); // by MouseJstr
  182. ACMD_FUNC(skillid); // by MouseJstr
  183. ACMD_FUNC(useskill); // by MouseJstr
  184. ACMD_FUNC(summon);
  185. ACMD_FUNC(rain);
  186. ACMD_FUNC(snow);
  187. ACMD_FUNC(sakura);
  188. ACMD_FUNC(fog);
  189. ACMD_FUNC(leaves);
  190. ACMD_FUNC(adjgmlvl); // by MouseJstr
  191. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  192. ACMD_FUNC(trade); // by MouseJstr
  193. ACMD_FUNC(send); // by davidsiaw
  194. ACMD_FUNC(setbattleflag); // by MouseJstr
  195. ACMD_FUNC(unmute); // [Valaris]
  196. ACMD_FUNC(clearweather); // Dexity
  197. ACMD_FUNC(uptime); // by MC Cameri
  198. ACMD_FUNC(changesex); // by MC Cameri
  199. ACMD_FUNC(mute); // celest
  200. ACMD_FUNC(refresh); // by MC Cameri
  201. ACMD_FUNC(petid); // by MC Cameri
  202. ACMD_FUNC(identify); // by MC Cameri
  203. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  204. ACMD_FUNC(misceffect); // by MC Cameri
  205. ACMD_FUNC(mobsearch);
  206. ACMD_FUNC(cleanmap);
  207. ACMD_FUNC(npctalk);
  208. ACMD_FUNC(pettalk);
  209. ACMD_FUNC(users);
  210. ACMD_FUNC(autoloot); // by Upa-Kun
  211. #ifndef TXT_ONLY
  212. ACMD_FUNC(checkmail); // [Valaris]
  213. ACMD_FUNC(listmail); // [Valaris]
  214. ACMD_FUNC(listnewmail); // [Valaris]
  215. ACMD_FUNC(readmail); // [Valaris]
  216. ACMD_FUNC(sendmail); // [Valaris]
  217. ACMD_FUNC(sendprioritymail); // [Valaris]
  218. ACMD_FUNC(deletemail); // [Valaris]
  219. //ACMD_FUNC(sound); // [Valaris]
  220. ACMD_FUNC(refreshonline); // [Valaris]
  221. #endif /* TXT_ONLY */
  222. ACMD_FUNC(skilltree); // by MouseJstr
  223. ACMD_FUNC(marry); // by MouseJstr
  224. ACMD_FUNC(divorce); // by MouseJstr
  225. ACMD_FUNC(rings); // by MouseJstr
  226. ACMD_FUNC(grind); // by MouseJstr
  227. ACMD_FUNC(grind2); // by MouseJstr
  228. #ifdef DMALLOC
  229. ACMD_FUNC(dmstart); // by MouseJstr
  230. ACMD_FUNC(dmtick); // by MouseJstr
  231. #endif
  232. ACMD_FUNC(jumptoid); // by Dino9021
  233. ACMD_FUNC(jumptoid2); // by Dino9021
  234. ACMD_FUNC(recallid); // by Dino9021
  235. ACMD_FUNC(recallid2); // by Dino9021
  236. ACMD_FUNC(kickid); // by Dino9021
  237. ACMD_FUNC(kickid2); // by Dino9021
  238. ACMD_FUNC(reviveid); // by Dino9021
  239. ACMD_FUNC(reviveid2); // by Dino9021
  240. ACMD_FUNC(killid); // by Dino9021
  241. ACMD_FUNC(killid2); // by Dino9021
  242. ACMD_FUNC(charkillableid); // by Dino9021
  243. ACMD_FUNC(charkillableid2); // by Dino9021
  244. ACMD_FUNC(sound);
  245. ACMD_FUNC(undisguiseall);
  246. ACMD_FUNC(disguiseall);
  247. ACMD_FUNC(changelook);
  248. ACMD_FUNC(mobinfo); //by Lupus
  249. /*==========================================
  250. *AtCommandInfo atcommand_info[]構造体の定義
  251. *------------------------------------------
  252. */
  253. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  254. // to set default level, read atcommand_athena.conf first please.
  255. static AtCommandInfo atcommand_info[] = {
  256. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  257. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  258. { AtCommand_Where, "@where", 1, atcommand_where },
  259. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  260. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  261. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  262. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  263. { AtCommand_Who, "@who", 20, atcommand_who },
  264. { AtCommand_Who, "@whois", 20, atcommand_who },
  265. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  266. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  267. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  268. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  269. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  270. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  271. { AtCommand_Save, "@save", 40, atcommand_save },
  272. { AtCommand_Load, "@return", 40, atcommand_load },
  273. { AtCommand_Load, "@load", 40, atcommand_load },
  274. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  275. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  276. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  277. { AtCommand_Option, "@option", 40, atcommand_option },
  278. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  279. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  280. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  281. { AtCommand_Die, "@die", 1, atcommand_die },
  282. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  283. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  284. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  285. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  286. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  287. { AtCommand_Item, "@item", 60, atcommand_item },
  288. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  289. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  290. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  291. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  292. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  293. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  294. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  295. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  296. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  297. { AtCommand_H, "@h", 20, atcommand_help },
  298. { AtCommand_Help, "@help", 20, atcommand_help },
  299. { AtCommand_GM, "@gm", 100, atcommand_gm },
  300. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  301. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  302. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  303. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  304. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  305. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  306. { AtCommand_Model, "@model", 20, atcommand_model },
  307. { AtCommand_Go, "@go", 10, atcommand_go },
  308. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  309. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  310. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  311. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  312. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  313. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  314. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  315. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  316. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  317. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  318. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  319. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  320. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  321. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  322. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  323. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  324. { AtCommand_Strength, "@str", 60, atcommand_param },
  325. { AtCommand_Agility, "@agi", 60, atcommand_param },
  326. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  327. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  328. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  329. { AtCommand_Luck, "@luk", 60, atcommand_param },
  330. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  331. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  332. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  333. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  334. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  335. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  336. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  337. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  338. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  339. { AtCommand_Night, "@night", 80, atcommand_night },
  340. { AtCommand_Day, "@day", 80, atcommand_day },
  341. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  342. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  343. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  344. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  345. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  346. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  347. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  348. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  349. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  350. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  351. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  352. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  353. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  354. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  355. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  356. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  357. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  358. { AtCommand_Party, "@party", 1, atcommand_party },
  359. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  360. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  361. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  362. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  363. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  364. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  365. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  366. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  367. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  368. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  369. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  370. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  371. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  372. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  373. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  374. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  375. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  376. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  377. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  378. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  379. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  380. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  381. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  382. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  383. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  384. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  385. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  386. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  387. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  388. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  389. // { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  390. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  391. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  392. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  393. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  394. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  395. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  396. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  397. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  398. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  399. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  400. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  401. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  402. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  403. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  404. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  405. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  406. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  407. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  408. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  409. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  410. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  411. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  412. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  413. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  414. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  415. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  416. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  417. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  418. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  419. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  420. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  421. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  422. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  423. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  424. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  425. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  426. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  427. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  428. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  429. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  430. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  431. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  432. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  433. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  434. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  435. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  436. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  437. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  438. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  439. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  440. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  441. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  442. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  443. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  444. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  445. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  446. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  447. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  448. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  449. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  450. /*
  451. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  452. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  453. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  454. */
  455. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  456. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  457. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  458. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  459. { AtCommand_Send, "@send", 60, atcommand_send },
  460. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  461. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  462. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  463. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  464. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  465. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  466. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  467. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  468. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  469. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  470. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  471. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  472. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  473. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  474. { AtCommand_MobSearch, "@mobsearch", 0, atcommand_mobsearch },
  475. { AtCommand_CleanMap, "@cleanmap", 0, atcommand_cleanmap },
  476. { AtCommand_NpcTalk, "@npctalk", 0, atcommand_npctalk },
  477. { AtCommand_PetTalk, "@pettalk", 0, atcommand_pettalk },
  478. { AtCommand_Users, "@users", 0, atcommand_users },
  479. { AtCommand_ResetState, "/reset", 40, NULL },
  480. #ifndef TXT_ONLY // sql-only commands
  481. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  482. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  483. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  484. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  485. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  486. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  487. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  488. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  489. #endif /* TXT_ONLY */
  490. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  491. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  492. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  493. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  494. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  495. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  496. #ifdef DMALLOC
  497. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  498. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  499. #endif
  500. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  501. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  502. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  503. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  504. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  505. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  506. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  507. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  508. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  509. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  510. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  511. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  512. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  513. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  514. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  515. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  516. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  517. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  518. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  519. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  520. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  521. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  522. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  523. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  524. // add new commands before this line
  525. { AtCommand_Unknown, NULL, 1, NULL }
  526. };
  527. /*====================================================
  528. * This function return the name of the job (by [Yor])
  529. *----------------------------------------------------
  530. */
  531. char * job_name(int class_) {
  532. switch (class_) {
  533. case 0: return "Novice";
  534. case 1: return "Swordsman";
  535. case 2: return "Mage";
  536. case 3: return "Archer";
  537. case 4: return "Acolyte";
  538. case 5: return "Merchant";
  539. case 6: return "Thief";
  540. case 7: return "Knight";
  541. case 8: return "Priest";
  542. case 9: return "Wizard";
  543. case 10: return "Blacksmith";
  544. case 11: return "Hunter";
  545. case 12: return "Assassin";
  546. case 13: return "Knight 2";
  547. case 14: return "Crusader";
  548. case 15: return "Monk";
  549. case 16: return "Sage";
  550. case 17: return "Rogue";
  551. case 18: return "Alchemist";
  552. case 19: return "Bard";
  553. case 20: return "Dancer";
  554. case 21: return "Crusader 2";
  555. case 22: return "Wedding";
  556. case 23: return "Super Novice";
  557. case 4001: return "Novice High";
  558. case 4002: return "Swordsman High";
  559. case 4003: return "Mage High";
  560. case 4004: return "Archer High";
  561. case 4005: return "Acolyte High";
  562. case 4006: return "Merchant High";
  563. case 4007: return "Thief High";
  564. case 4008: return "Lord Knight";
  565. case 4009: return "High Priest";
  566. case 4010: return "High Wizard";
  567. case 4011: return "Whitesmith";
  568. case 4012: return "Sniper";
  569. case 4013: return "Assassin Cross";
  570. case 4014: return "Peko Knight";
  571. case 4015: return "Paladin";
  572. case 4016: return "Champion";
  573. case 4017: return "Professor";
  574. case 4018: return "Stalker";
  575. case 4019: return "Creator";
  576. case 4020: return "Clown";
  577. case 4021: return "Gypsy";
  578. case 4022: return "Peko Paladin";
  579. case 4023: return "Baby Novice";
  580. case 4024: return "Baby Swordsman";
  581. case 4025: return "Baby Mage";
  582. case 4026: return "Baby Archer";
  583. case 4027: return "Baby Acolyte";
  584. case 4028: return "Baby Merchant";
  585. case 4029: return "Baby Thief";
  586. case 4030: return "Baby Knight";
  587. case 4031: return "Baby Priest";
  588. case 4032: return "Baby Wizard";
  589. case 4033: return "Baby Blacksmith";
  590. case 4034: return "Baby Hunter";
  591. case 4035: return "Baby Assassin";
  592. case 4036: return "Baby Peco Knight";
  593. case 4037: return "Baby Crusader";
  594. case 4038: return "Baby Monk";
  595. case 4039: return "Baby Sage";
  596. case 4040: return "Baby Rogue";
  597. case 4041: return "Baby Alchemist";
  598. case 4042: return "Baby Bard";
  599. case 4043: return "Baby Dancer";
  600. case 4044: return "Baby Peco Crusader";
  601. case 4045: return "Super Baby";
  602. }
  603. return "Unknown Job";
  604. }
  605. /*==========================================
  606. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  607. *------------------------------------------
  608. */
  609. char *estr_lower(char *str)
  610. {
  611. int i;
  612. for (i=0; str[i]; i++)
  613. if ((str[i] >= 65) && (str[i] <= 90))
  614. str[i] += 32;
  615. return str;
  616. }
  617. // compare function for sorting high to lowest
  618. int hightolow_compare (const void * a, const void * b)
  619. {
  620. return ( *(int*)b - *(int*)a );
  621. }
  622. // compare function for sorting lowest to highest
  623. int lowtohigh_compare (const void * a, const void * b)
  624. {
  625. return ( *(int*)a - *(int*)b );
  626. }
  627. //-----------------------------------------------------------
  628. // Return the message string of the specified number by [Yor]
  629. //-----------------------------------------------------------
  630. char * msg_txt(int msg_number) {
  631. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  632. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  633. return msg_table[msg_number];
  634. return "??";
  635. }
  636. //------------------------------------------------------------
  637. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  638. //------------------------------------------------------------
  639. int e_mail_check(unsigned char *email) {
  640. char ch;
  641. unsigned char* last_arobas;
  642. // athena limits
  643. if (strlen(email) < 3 || strlen(email) > 39)
  644. return 0;
  645. // part of RFC limits (official reference of e-mail description)
  646. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  647. return 0;
  648. if (email[strlen(email)-1] == '.')
  649. return 0;
  650. last_arobas = strrchr(email, '@');
  651. if (strstr(last_arobas, "@.") != NULL ||
  652. strstr(last_arobas, "..") != NULL)
  653. return 0;
  654. for(ch = 1; ch < 32; ch++) {
  655. if (strchr(last_arobas, ch) != NULL) {
  656. return 0;
  657. break;
  658. }
  659. }
  660. if (strchr(last_arobas, ' ') != NULL ||
  661. strchr(last_arobas, ';') != NULL)
  662. return 0;
  663. // all correct
  664. return 1;
  665. }
  666. /*==========================================
  667. * get_atcommand_level @コマンドの必要レベルを取得
  668. *------------------------------------------
  669. */
  670. int get_atcommand_level(const AtCommandType type) {
  671. int i;
  672. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  673. if (atcommand_info[i].type == type)
  674. return atcommand_info[i].level;
  675. return 100; // 100: command can not be used
  676. }
  677. /*==========================================
  678. *is_atcommand @コマンドに存在するかどうか確認する
  679. *------------------------------------------
  680. */
  681. AtCommandType
  682. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  683. const char* str = message;
  684. int s_flag = 0;
  685. AtCommandInfo info;
  686. AtCommandType type;
  687. nullpo_retr(AtCommand_None, sd);
  688. if (!battle_config.allow_atcommand_when_mute &&
  689. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  690. return AtCommand_Unknown;
  691. }
  692. if (!message || !*message)
  693. return AtCommand_None;
  694. memset(&info, 0, sizeof(info));
  695. str += strlen(sd->status.name);
  696. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  697. if (*str == ':')
  698. s_flag = 1;
  699. str++;
  700. }
  701. if (!*str)
  702. return AtCommand_None;
  703. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  704. if (type != AtCommand_None) {
  705. char command[100];
  706. char output[200];
  707. const char* p = str;
  708. memset(command, '\0', sizeof(command));
  709. memset(output, '\0', sizeof(output));
  710. while (*p && !isspace(*p))
  711. p++;
  712. if (p - str >= sizeof(command)) // too long
  713. return AtCommand_Unknown;
  714. strncpy(command, str, p - str);
  715. while (isspace(*p))
  716. p++;
  717. if (type == AtCommand_Unknown || info.proc == NULL) {
  718. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  719. clif_displaymessage(fd, output);
  720. } else {
  721. if (info.proc(fd, sd, command, p) != 0) {
  722. // Command can not be executed
  723. sprintf(output, msg_table[154], command); // %s failed.
  724. clif_displaymessage(fd, output);
  725. }
  726. }
  727. return info.type;
  728. }
  729. return AtCommand_None;
  730. }
  731. /*==========================================
  732. *
  733. *------------------------------------------
  734. */
  735. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  736. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  737. if (!info)
  738. return AtCommand_None;
  739. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  740. return AtCommand_None;
  741. if (!p || !*p) {
  742. fprintf(stderr, "at command message is empty\n");
  743. return AtCommand_None;
  744. }
  745. if (*p == command_symbol) { // check first char.
  746. char command[101];
  747. int i = 0;
  748. memset(info, 0, sizeof(AtCommandInfo));
  749. sscanf(p, "%100s", command);
  750. command[sizeof(command)-1] = '\0';
  751. while (atcommand_info[i].type != AtCommand_Unknown) {
  752. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  753. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  754. break;
  755. }
  756. i++;
  757. }
  758. if (atcommand_info[i].type == AtCommand_Unknown) {
  759. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  760. if (level == 0)
  761. return AtCommand_None;
  762. else
  763. return AtCommand_Unknown;
  764. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  765. log_atcommand(sd, message);
  766. }
  767. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  768. } else {
  769. return AtCommand_None;
  770. }
  771. return info->type;
  772. }
  773. /*==========================================
  774. *
  775. *------------------------------------------
  776. */
  777. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  778. int flag = va_arg(ap, int);
  779. nullpo_retr(0, bl);
  780. if (flag)
  781. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  782. else
  783. mob_delete((struct mob_data *)bl);
  784. return 0;
  785. }
  786. /*==========================================
  787. * Mob search
  788. *------------------------------------------
  789. */
  790. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  791. {
  792. int mob_id,fd;
  793. static int number=0;
  794. struct mob_data *md;
  795. char output[128];
  796. nullpo_retr(0, bl);
  797. if(!ap){
  798. number=0;
  799. return 0;
  800. }
  801. mob_id = va_arg(ap,int);
  802. fd = va_arg(ap,int);
  803. md = (struct mob_data *)bl;
  804. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  805. snprintf(output, sizeof output, "%2d[%3d:%3d] %s",
  806. ++number,bl->x, bl->y,md->name);
  807. clif_displaymessage(fd, output);
  808. }
  809. return 0;
  810. }
  811. /*==========================================
  812. * cleanmap
  813. *------------------------------------------
  814. */
  815. static int atcommand_cleanmap_sub(struct block_list *bl,va_list ap)
  816. {
  817. struct flooritem_data *fitem;
  818. nullpo_retr(0, bl);
  819. fitem = (struct flooritem_data *)bl;
  820. if(fitem==NULL || fitem->bl.type!=BL_ITEM){
  821. if(battle_config.error_log)
  822. printf("map_clearflooritem_timer : error\n");
  823. return 1;
  824. }
  825. delete_timer(fitem->cleartimer,map_clearflooritem_timer);
  826. if(fitem->item_data.card[0] == (short)0xff00)
  827. intif_delete_petdata(*((long *)(&fitem->item_data.card[1])));
  828. clif_clearflooritem(fitem,0);
  829. map_delobject(fitem->bl.id);
  830. return 0;
  831. }
  832. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  833. {
  834. int flag = va_arg(ap,int);
  835. nullpo_retr(0, bl);
  836. npc_delete((struct npc_data *)bl);
  837. flag = 0;
  838. return 0;
  839. }
  840. void rehash( const int fd, struct map_session_data* sd )
  841. {
  842. int map_id = 0;
  843. int LOADED_MAPS = map_num;
  844. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  845. if (map_id > LOADED_MAPS)
  846. break;
  847. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  848. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  849. }
  850. }
  851. /*==========================================
  852. * Read Message Data
  853. *------------------------------------------
  854. */
  855. int msg_config_read(const char *cfgName) {
  856. int msg_number;
  857. char line[1024], w1[1024], w2[1024];
  858. FILE *fp;
  859. if ((fp = fopen(cfgName, "r")) == NULL) {
  860. printf("Messages file not found: %s\n", cfgName);
  861. return 1;
  862. }
  863. while(fgets(line, sizeof(line)-1, fp)) {
  864. if (line[0] == '/' && line[1] == '/')
  865. continue;
  866. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  867. if (strcmpi(w1, "import") == 0) {
  868. msg_config_read(w2);
  869. } else {
  870. msg_number = atoi(w1);
  871. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  872. strcpy(msg_table[msg_number], w2);
  873. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  874. }
  875. }
  876. }
  877. fclose(fp);
  878. return 0;
  879. }
  880. /*==========================================
  881. *
  882. *------------------------------------------
  883. */
  884. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  885. int i;
  886. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  887. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  888. return &atcommand_info[i];
  889. return NULL;
  890. }
  891. /*==========================================
  892. *
  893. *------------------------------------------
  894. */
  895. int atcommand_config_read(const char *cfgName) {
  896. char line[1024], w1[1024], w2[1024];
  897. AtCommandInfo* p;
  898. FILE* fp;
  899. if ((fp = fopen(cfgName, "r")) == NULL) {
  900. printf("At commands configuration file not found: %s\n", cfgName);
  901. return 1;
  902. }
  903. while (fgets(line, sizeof(line)-1, fp)) {
  904. if (line[0] == '/' && line[1] == '/')
  905. continue;
  906. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  907. continue;
  908. p = get_atcommandinfo_byname(w1);
  909. if (p != NULL) {
  910. p->level = atoi(w2);
  911. if (p->level > 100)
  912. p->level = 100;
  913. else if (p->level < 0)
  914. p->level = 0;
  915. }
  916. if (strcmpi(w1, "import") == 0)
  917. atcommand_config_read(w2);
  918. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  919. w2[0] != '/' && // symbol of standard ragnarok GM commands
  920. w2[0] != '%' && // symbol of party chat speaking
  921. w2[0] != '#') // symbol of charcommand
  922. command_symbol = w2[0];
  923. }
  924. fclose(fp);
  925. return 0;
  926. }
  927. /*==========================================
  928. // @ command processing functions
  929. *------------------------------------------
  930. */
  931. /*==========================================
  932. * @send (used for testing packet sends from the client)
  933. *------------------------------------------
  934. */
  935. int atcommand_send(
  936. const int fd, struct map_session_data* sd,
  937. const char* command, const char* message)
  938. {
  939. int a = atoi(message);
  940. if (a)
  941. {
  942. unsigned char buf[1024];
  943. switch(a)
  944. {
  945. case 1:
  946. WBUFW(buf,0)=0x18d;
  947. case 2:
  948. WBUFW(buf,0)=0x18e;
  949. case 3:
  950. WBUFW(buf,0)=0x18f;
  951. case 4:
  952. WBUFW(buf,0)=0x190;
  953. }
  954. }
  955. return 0;
  956. }
  957. // @rura
  958. /*==========================================
  959. *
  960. *------------------------------------------
  961. */
  962. int atcommand_rura(
  963. const int fd, struct map_session_data* sd,
  964. const char* command, const char* message)
  965. {
  966. char map_name[100];
  967. int x = 0, y = 0;
  968. int m;
  969. nullpo_retr(-1, sd);
  970. memset(map_name, '\0', sizeof(map_name));
  971. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  972. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  973. return -1;
  974. }
  975. if (x <= 0)
  976. x = rand() % 399 + 1;
  977. if (y <= 0)
  978. y = rand() % 399 + 1;
  979. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  980. strcat(map_name, ".gat");
  981. if (x > 0 && x < 400 && y > 0 && y < 400) {
  982. m = map_mapname2mapid(map_name);
  983. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  984. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  985. return -1;
  986. }
  987. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  988. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  989. return -1;
  990. }
  991. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  992. clif_displaymessage(fd, msg_table[0]); // Warped.
  993. else {
  994. clif_displaymessage(fd, msg_table[1]); // Map not found.
  995. return -1;
  996. }
  997. } else {
  998. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  999. return -1;
  1000. }
  1001. return 0;
  1002. }
  1003. /*==========================================
  1004. *
  1005. *------------------------------------------
  1006. */
  1007. int atcommand_where(
  1008. const int fd, struct map_session_data* sd,
  1009. const char* command, const char* message)
  1010. {
  1011. char character[100];
  1012. char output[200];
  1013. struct map_session_data *pl_sd = NULL;
  1014. nullpo_retr(-1, sd);
  1015. if (!message || !*message)
  1016. return -1;
  1017. memset(character, '\0', sizeof character);
  1018. if (sscanf(message, "%99[^\n]", character) < 1)
  1019. return -1;
  1020. if(strncmp(sd->status.name,character,24)==0)
  1021. return -1;
  1022. if ((pl_sd = map_nick2sd(character)) == NULL) {
  1023. snprintf(output, sizeof output, "%s %d %d",
  1024. sd->mapname, sd->bl.x, sd->bl.y);
  1025. clif_displaymessage(fd, output);
  1026. return -1;
  1027. }
  1028. snprintf(output, sizeof output, "%s %s %d %d",
  1029. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1030. clif_displaymessage(fd, output);
  1031. return 0;
  1032. }
  1033. /*==========================================
  1034. *
  1035. *------------------------------------------
  1036. */
  1037. int atcommand_jumpto(
  1038. const int fd, struct map_session_data* sd,
  1039. const char* command, const char* message)
  1040. {
  1041. char character[100];
  1042. char output[200];
  1043. struct map_session_data *pl_sd = NULL;
  1044. nullpo_retr(-1, sd);
  1045. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1046. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1047. return -1;
  1048. }
  1049. memset(character, '\0', sizeof character);
  1050. if (sscanf(message, "%99[^\n]", character) < 1)
  1051. return -1;
  1052. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1053. return -1;
  1054. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1055. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1056. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1057. return -1;
  1058. }
  1059. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1060. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1061. return -1;
  1062. }
  1063. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1064. sprintf(output, msg_table[4], character); // Jump to %s
  1065. clif_displaymessage(fd, output);
  1066. } else {
  1067. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1068. return -1;
  1069. }
  1070. return 0;
  1071. }
  1072. /*==========================================
  1073. *
  1074. *------------------------------------------
  1075. */
  1076. int atcommand_jump(
  1077. const int fd, struct map_session_data* sd,
  1078. const char* command, const char* message)
  1079. {
  1080. char output[200];
  1081. int x = 0, y = 0;
  1082. nullpo_retr(-1, sd);
  1083. memset(output, '\0', sizeof(output));
  1084. sscanf(message, "%d %d", &x, &y);
  1085. if (x <= 0)
  1086. x = rand() % 399 + 1;
  1087. if (y <= 0)
  1088. y = rand() % 399 + 1;
  1089. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1090. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1091. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1092. return -1;
  1093. }
  1094. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1095. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1096. return -1;
  1097. }
  1098. pc_setpos(sd, sd->mapname, x, y, 3);
  1099. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1100. clif_displaymessage(fd, output);
  1101. } else {
  1102. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1103. return -1;
  1104. }
  1105. return 0;
  1106. }
  1107. /*==========================================
  1108. *
  1109. *------------------------------------------
  1110. */
  1111. int atcommand_who(
  1112. const int fd, struct map_session_data* sd,
  1113. const char* command, const char* message)
  1114. {
  1115. char output[200];
  1116. struct map_session_data *pl_sd;
  1117. int i, j, count;
  1118. int pl_GM_level, GM_level;
  1119. char match_text[100];
  1120. char player_name[24];
  1121. nullpo_retr(-1, sd);
  1122. memset(output, '\0', sizeof(output));
  1123. memset(match_text, '\0', sizeof(match_text));
  1124. memset(player_name, '\0', sizeof(player_name));
  1125. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1126. strcpy(match_text, "");
  1127. for (j = 0; match_text[j]; j++)
  1128. match_text[j] = tolower(match_text[j]);
  1129. count = 0;
  1130. GM_level = pc_isGM(sd);
  1131. for (i = 0; i < fd_max; i++) {
  1132. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1133. pl_GM_level = pc_isGM(pl_sd);
  1134. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1135. memcpy(player_name, pl_sd->status.name, 24);
  1136. for (j = 0; player_name[j]; j++)
  1137. player_name[j] = tolower(player_name[j]);
  1138. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1139. if (pl_GM_level > 0)
  1140. sprintf(output, "(CID:%d/AID:%d) Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1141. else
  1142. sprintf(output, "(CID:%d/AID:%d) Name: %s | Location: %s %d %d", pl_sd->status.char_id, pl_sd->status.account_id, pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1143. clif_displaymessage(fd, output);
  1144. count++;
  1145. }
  1146. }
  1147. }
  1148. }
  1149. if (count == 0)
  1150. clif_displaymessage(fd, msg_table[28]); // No player found.
  1151. else if (count == 1)
  1152. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1153. else {
  1154. sprintf(output, msg_table[30], count); // %d players found.
  1155. clif_displaymessage(fd, output);
  1156. }
  1157. return 0;
  1158. }
  1159. /*==========================================
  1160. *
  1161. *------------------------------------------
  1162. */
  1163. int atcommand_who2(
  1164. const int fd, struct map_session_data* sd,
  1165. const char* command, const char* message)
  1166. {
  1167. char output[200];
  1168. struct map_session_data *pl_sd;
  1169. int i, j, count;
  1170. int pl_GM_level, GM_level;
  1171. char match_text[100];
  1172. char player_name[24];
  1173. nullpo_retr(-1, sd);
  1174. memset(output, '\0', sizeof(output));
  1175. memset(match_text, '\0', sizeof(match_text));
  1176. memset(player_name, '\0', sizeof(player_name));
  1177. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1178. strcpy(match_text, "");
  1179. for (j = 0; match_text[j]; j++)
  1180. match_text[j] = tolower(match_text[j]);
  1181. count = 0;
  1182. GM_level = pc_isGM(sd);
  1183. for (i = 0; i < fd_max; i++) {
  1184. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1185. pl_GM_level = pc_isGM(pl_sd);
  1186. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1187. memcpy(player_name, pl_sd->status.name, 24);
  1188. for (j = 0; player_name[j]; j++)
  1189. player_name[j] = tolower(player_name[j]);
  1190. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1191. if (pl_GM_level > 0)
  1192. sprintf(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);
  1193. else
  1194. sprintf(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);
  1195. clif_displaymessage(fd, output);
  1196. count++;
  1197. }
  1198. }
  1199. }
  1200. }
  1201. if (count == 0)
  1202. clif_displaymessage(fd, msg_table[28]); // No player found.
  1203. else if (count == 1)
  1204. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1205. else {
  1206. sprintf(output, msg_table[30], count); // %d players found.
  1207. clif_displaymessage(fd, output);
  1208. }
  1209. return 0;
  1210. }
  1211. /*==========================================
  1212. *
  1213. *------------------------------------------
  1214. */
  1215. int atcommand_who3(
  1216. const int fd, struct map_session_data* sd,
  1217. const char* command, const char* message)
  1218. {
  1219. char temp0[100];
  1220. char temp1[100];
  1221. char output[200];
  1222. struct map_session_data *pl_sd;
  1223. int i, j, count;
  1224. int pl_GM_level, GM_level;
  1225. char match_text[100];
  1226. char player_name[24];
  1227. struct guild *g;
  1228. struct party *p;
  1229. nullpo_retr(-1, sd);
  1230. memset(temp0, '\0', sizeof(temp0));
  1231. memset(temp1, '\0', sizeof(temp1));
  1232. memset(output, '\0', sizeof(output));
  1233. memset(match_text, '\0', sizeof(match_text));
  1234. memset(player_name, '\0', sizeof(player_name));
  1235. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1236. strcpy(match_text, "");
  1237. for (j = 0; match_text[j]; j++)
  1238. match_text[j] = tolower(match_text[j]);
  1239. count = 0;
  1240. GM_level = pc_isGM(sd);
  1241. for (i = 0; i < fd_max; i++) {
  1242. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1243. pl_GM_level = pc_isGM(pl_sd);
  1244. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1245. memcpy(player_name, pl_sd->status.name, 24);
  1246. for (j = 0; player_name[j]; j++)
  1247. player_name[j] = tolower(player_name[j]);
  1248. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1249. g = guild_search(pl_sd->status.guild_id);
  1250. if (g == NULL)
  1251. sprintf(temp1, "None");
  1252. else
  1253. sprintf(temp1, "%s", g->name);
  1254. p = party_search(pl_sd->status.party_id);
  1255. if (p == NULL)
  1256. sprintf(temp0, "None");
  1257. else
  1258. sprintf(temp0, "%s", p->name);
  1259. if (pl_GM_level > 0)
  1260. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1261. else
  1262. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1263. clif_displaymessage(fd, output);
  1264. count++;
  1265. }
  1266. }
  1267. }
  1268. }
  1269. if (count == 0)
  1270. clif_displaymessage(fd, msg_table[28]); // No player found.
  1271. else if (count == 1)
  1272. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1273. else {
  1274. sprintf(output, msg_table[30], count); // %d players found.
  1275. clif_displaymessage(fd, output);
  1276. }
  1277. return 0;
  1278. }
  1279. /*==========================================
  1280. *
  1281. *------------------------------------------
  1282. */
  1283. int atcommand_whomap(
  1284. const int fd, struct map_session_data* sd,
  1285. const char* command, const char* message)
  1286. {
  1287. char output[200];
  1288. struct map_session_data *pl_sd;
  1289. int i, count;
  1290. int pl_GM_level, GM_level;
  1291. int map_id;
  1292. char map_name[100];
  1293. memset(output, '\0', sizeof(output));
  1294. memset(map_name, '\0', sizeof(map_name));
  1295. if (!message || !*message)
  1296. map_id = sd->bl.m;
  1297. else {
  1298. sscanf(message, "%99s", map_name);
  1299. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1300. strcat(map_name, ".gat");
  1301. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1302. map_id = sd->bl.m;
  1303. }
  1304. count = 0;
  1305. GM_level = pc_isGM(sd);
  1306. for (i = 0; i < fd_max; i++) {
  1307. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1308. pl_GM_level = pc_isGM(pl_sd);
  1309. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1310. if (pl_sd->bl.m == map_id) {
  1311. if (pl_GM_level > 0)
  1312. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1313. else
  1314. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1315. clif_displaymessage(fd, output);
  1316. count++;
  1317. }
  1318. }
  1319. }
  1320. }
  1321. if (count == 0)
  1322. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1323. else if (count == 1)
  1324. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1325. else {
  1326. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1327. }
  1328. clif_displaymessage(fd, output);
  1329. return 0;
  1330. }
  1331. /*==========================================
  1332. *
  1333. *------------------------------------------
  1334. */
  1335. int atcommand_whomap2(
  1336. const int fd, struct map_session_data* sd,
  1337. const char* command, const char* message)
  1338. {
  1339. char output[200];
  1340. struct map_session_data *pl_sd;
  1341. int i, count;
  1342. int pl_GM_level, GM_level;
  1343. int map_id = 0;
  1344. char map_name[100];
  1345. nullpo_retr(-1, sd);
  1346. memset(output, '\0', sizeof(output));
  1347. memset(map_name, '\0', sizeof(map_name));
  1348. if (!message || !*message)
  1349. map_id = sd->bl.m;
  1350. else {
  1351. sscanf(message, "%99s", map_name);
  1352. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1353. strcat(map_name, ".gat");
  1354. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1355. map_id = sd->bl.m;
  1356. }
  1357. count = 0;
  1358. GM_level = pc_isGM(sd);
  1359. for (i = 0; i < fd_max; i++) {
  1360. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1361. pl_GM_level = pc_isGM(pl_sd);
  1362. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1363. if (pl_sd->bl.m == map_id) {
  1364. if (pl_GM_level > 0)
  1365. sprintf(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);
  1366. else
  1367. sprintf(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);
  1368. clif_displaymessage(fd, output);
  1369. count++;
  1370. }
  1371. }
  1372. }
  1373. }
  1374. if (count == 0)
  1375. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1376. else if (count == 1)
  1377. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1378. else {
  1379. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1380. }
  1381. clif_displaymessage(fd, output);
  1382. return 0;
  1383. }
  1384. /*==========================================
  1385. *
  1386. *------------------------------------------
  1387. */
  1388. int atcommand_whomap3(
  1389. const int fd, struct map_session_data* sd,
  1390. const char* command, const char* message)
  1391. {
  1392. char temp0[100];
  1393. char temp1[100];
  1394. char output[200];
  1395. struct map_session_data *pl_sd;
  1396. int i, count;
  1397. int pl_GM_level, GM_level;
  1398. int map_id = 0;
  1399. char map_name[100];
  1400. struct guild *g;
  1401. struct party *p;
  1402. nullpo_retr(-1, sd);
  1403. memset(temp0, '\0', sizeof(temp0));
  1404. memset(temp1, '\0', sizeof(temp1));
  1405. memset(output, '\0', sizeof(output));
  1406. memset(map_name, '\0', sizeof(map_name));
  1407. if (!message || !*message)
  1408. map_id = sd->bl.m;
  1409. else {
  1410. sscanf(message, "%99s", map_name);
  1411. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1412. strcat(map_name, ".gat");
  1413. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1414. map_id = sd->bl.m;
  1415. }
  1416. count = 0;
  1417. GM_level = pc_isGM(sd);
  1418. for (i = 0; i < fd_max; i++) {
  1419. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1420. pl_GM_level = pc_isGM(pl_sd);
  1421. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1422. if (pl_sd->bl.m == map_id) {
  1423. g = guild_search(pl_sd->status.guild_id);
  1424. if (g == NULL)
  1425. sprintf(temp1, "None");
  1426. else
  1427. sprintf(temp1, "%s", g->name);
  1428. p = party_search(pl_sd->status.party_id);
  1429. if (p == NULL)
  1430. sprintf(temp0, "None");
  1431. else
  1432. sprintf(temp0, "%s", p->name);
  1433. if (pl_GM_level > 0)
  1434. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1435. else
  1436. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1437. clif_displaymessage(fd, output);
  1438. count++;
  1439. }
  1440. }
  1441. }
  1442. }
  1443. if (count == 0)
  1444. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1445. else if (count == 1)
  1446. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1447. else {
  1448. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1449. }
  1450. clif_displaymessage(fd, output);
  1451. return 0;
  1452. }
  1453. /*==========================================
  1454. *
  1455. *------------------------------------------
  1456. */
  1457. int atcommand_whogm(
  1458. const int fd, struct map_session_data* sd,
  1459. const char* command, const char* message)
  1460. {
  1461. char temp0[100];
  1462. char temp1[100];
  1463. char output[200];
  1464. struct map_session_data *pl_sd;
  1465. int i, j, count;
  1466. int pl_GM_level, GM_level;
  1467. char match_text[100];
  1468. char player_name[24];
  1469. struct guild *g;
  1470. struct party *p;
  1471. nullpo_retr(-1, sd);
  1472. memset(temp0, '\0', sizeof(temp0));
  1473. memset(temp1, '\0', sizeof(temp1));
  1474. memset(output, '\0', sizeof(output));
  1475. memset(match_text, '\0', sizeof(match_text));
  1476. memset(player_name, '\0', sizeof(player_name));
  1477. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1478. strcpy(match_text, "");
  1479. for (j = 0; match_text[j]; j++)
  1480. match_text[j] = tolower(match_text[j]);
  1481. count = 0;
  1482. GM_level = pc_isGM(sd);
  1483. for (i = 0; i < fd_max; i++) {
  1484. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1485. pl_GM_level = pc_isGM(pl_sd);
  1486. if (pl_GM_level > 0) {
  1487. if (!((battle_config.hide_GM_session || (pl_sd->status.option & OPTION_HIDE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1488. memcpy(player_name, pl_sd->status.name, 24);
  1489. for (j = 0; player_name[j]; j++)
  1490. player_name[j] = tolower(player_name[j]);
  1491. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1492. sprintf(output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1493. clif_displaymessage(fd, output);
  1494. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1495. clif_displaymessage(fd, output);
  1496. g = guild_search(pl_sd->status.guild_id);
  1497. if (g == NULL)
  1498. sprintf(temp1, "None");
  1499. else
  1500. sprintf(temp1, "%s", g->name);
  1501. p = party_search(pl_sd->status.party_id);
  1502. if (p == NULL)
  1503. sprintf(temp0, "None");
  1504. else
  1505. sprintf(temp0, "%s", p->name);
  1506. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1507. clif_displaymessage(fd, output);
  1508. count++;
  1509. }
  1510. }
  1511. }
  1512. }
  1513. }
  1514. if (count == 0)
  1515. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1516. else if (count == 1)
  1517. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1518. else {
  1519. sprintf(output, msg_table[152], count); // %d GMs found.
  1520. clif_displaymessage(fd, output);
  1521. }
  1522. return 0;
  1523. }
  1524. int atcommand_whozeny(
  1525. const int fd, struct map_session_data* sd,
  1526. const char* command, const char* message)
  1527. {
  1528. char output[200];
  1529. struct map_session_data *pl_sd;
  1530. int i, j, count,c;
  1531. char match_text[100];
  1532. char player_name[24];
  1533. //int zeny[clif_countusers()];
  1534. //int counted[clif_countusers()];
  1535. int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int));
  1536. int *counted = (int *)aCallocA(clif_countusers(), sizeof(int));
  1537. nullpo_retr(-1, sd);
  1538. memset(output, '\0', sizeof(output));
  1539. memset(match_text, '\0', sizeof(match_text));
  1540. memset(player_name, '\0', sizeof(player_name));
  1541. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1542. strcpy(match_text, "");
  1543. for (j = 0; match_text[j]; j++)
  1544. match_text[j] = tolower(match_text[j]);
  1545. count = 0;
  1546. for (i = 0; i < fd_max; i++) {
  1547. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1548. memcpy(player_name, pl_sd->status.name, 24);
  1549. for (j = 0; player_name[j]; j++)
  1550. player_name[j] = tolower(player_name[j]);
  1551. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1552. zeny[count]=pl_sd->status.zeny;
  1553. counted[i]=0;
  1554. count++;
  1555. }
  1556. }
  1557. }
  1558. qsort(zeny, count, sizeof(int), hightolow_compare);
  1559. for (c = 0; c < count && c < 50; c++) {
  1560. if(!zeny[c])
  1561. continue;
  1562. for (i = 0; i < fd_max; i++) {
  1563. if(!zeny[c])
  1564. continue;
  1565. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1566. if(pl_sd->status.zeny==zeny[c]) {
  1567. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1568. clif_displaymessage(fd, output);
  1569. zeny[c]=0;
  1570. counted[i]=1;
  1571. }
  1572. }
  1573. }
  1574. }
  1575. if (count == 0)
  1576. clif_displaymessage(fd, msg_table[28]); // No player found.
  1577. else if (count == 1)
  1578. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1579. else {
  1580. sprintf(output, msg_table[30], count); // %d players found.
  1581. clif_displaymessage(fd, output);
  1582. }
  1583. aFree(zeny);
  1584. aFree(counted);
  1585. return 0;
  1586. }
  1587. // cause random emote on all online players [Valaris]
  1588. int atcommand_happyhappyjoyjoy(
  1589. const int fd, struct map_session_data* sd,
  1590. const char* command, const char* message)
  1591. {
  1592. struct map_session_data *pl_sd;
  1593. int i,e;
  1594. nullpo_retr(-1, sd);
  1595. for (i = 0; i < fd_max; i++) {
  1596. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1597. e=rand()%40;
  1598. if(e==34)
  1599. e = 0;
  1600. clif_emotion(&pl_sd->bl,e);
  1601. }
  1602. }
  1603. return 0;
  1604. }
  1605. /*==========================================
  1606. *
  1607. *------------------------------------------
  1608. */
  1609. int atcommand_save(
  1610. const int fd, struct map_session_data* sd,
  1611. const char* command, const char* message)
  1612. {
  1613. nullpo_retr(-1, sd);
  1614. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1615. if (sd->status.pet_id > 0 && sd->pd)
  1616. intif_save_petdata(sd->status.account_id, &sd->pet);
  1617. pc_makesavestatus(sd);
  1618. chrif_save(sd);
  1619. storage_storage_save(sd);
  1620. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1621. return 0;
  1622. }
  1623. /*==========================================
  1624. *
  1625. *------------------------------------------
  1626. */
  1627. int atcommand_load(
  1628. const int fd, struct map_session_data* sd,
  1629. const char* command, const char* message)
  1630. {
  1631. int m;
  1632. nullpo_retr(-1, sd);
  1633. m = map_mapname2mapid(sd->status.save_point.map);
  1634. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1635. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1636. return -1;
  1637. }
  1638. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1639. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1640. return -1;
  1641. }
  1642. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1643. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1644. return 0;
  1645. }
  1646. /*==========================================
  1647. *
  1648. *------------------------------------------
  1649. */
  1650. int atcommand_speed(
  1651. const int fd, struct map_session_data* sd,
  1652. const char* command, const char* message)
  1653. {
  1654. char output[200];
  1655. int speed;
  1656. nullpo_retr(-1, sd);
  1657. memset(output, '\0', sizeof(output));
  1658. if (!message || !*message) {
  1659. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1660. clif_displaymessage(fd, output);
  1661. return -1;
  1662. }
  1663. speed = atoi(message);
  1664. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1665. sd->speed = speed;
  1666. //sd->walktimer = x;
  1667. //この文を追加 by れ�
  1668. clif_updatestatus(sd, SP_SPEED);
  1669. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1670. } else {
  1671. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1672. clif_displaymessage(fd, output);
  1673. return -1;
  1674. }
  1675. return 0;
  1676. }
  1677. /*==========================================
  1678. *
  1679. *------------------------------------------
  1680. */
  1681. int atcommand_storage(
  1682. const int fd, struct map_session_data* sd,
  1683. const char* command, const char* message)
  1684. {
  1685. nullpo_retr(-1, sd);
  1686. storage_storageopen(sd);
  1687. return 0;
  1688. }
  1689. /*==========================================
  1690. *
  1691. *------------------------------------------
  1692. */
  1693. int atcommand_guildstorage(
  1694. const int fd, struct map_session_data* sd,
  1695. const char* command, const char* message)
  1696. {
  1697. nullpo_retr(-1, sd);
  1698. if (sd->status.guild_id > 0)
  1699. storage_guild_storageopen(sd);
  1700. return 0;
  1701. }
  1702. /*==========================================
  1703. *
  1704. *------------------------------------------
  1705. */
  1706. int atcommand_option(
  1707. const int fd, struct map_session_data* sd,
  1708. const char* command, const char* message)
  1709. {
  1710. int param1 = 0, param2 = 0, param3 = 0;
  1711. nullpo_retr(-1, sd);
  1712. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1713. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1714. return -1;
  1715. }
  1716. sd->opt1 = param1;
  1717. sd->opt2 = param2;
  1718. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1719. clif_cart_itemlist(sd);
  1720. clif_cart_equiplist(sd);
  1721. clif_updatestatus(sd, SP_CARTINFO);
  1722. }
  1723. sd->status.option = param3;
  1724. // fix pecopeco display
  1725. if (sd->status.class_ == 13 || sd->status.class_ == 21 || sd->status.class_ == 4014 || sd->status.class_ == 4022) {
  1726. if (!pc_isriding(sd)) { // sd have the new value...
  1727. if (sd->status.class_ == 13)
  1728. sd->status.class_ = sd->view_class = 7;
  1729. else if (sd->status.class_ == 21)
  1730. sd->status.class_ = sd->view_class = 14;
  1731. else if (sd->status.class_ == 4014)
  1732. sd->status.class_ = sd->view_class = 4008;
  1733. else if (sd->status.class_ == 4022)
  1734. sd->status.class_ = sd->view_class = 4015;
  1735. }
  1736. } else {
  1737. if (pc_isriding(sd)) { // sd have the new value...
  1738. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1739. sd->status.option &= ~0x0020;
  1740. } else {
  1741. if (sd->status.class_ == 7)
  1742. sd->status.class_ = sd->view_class = 13;
  1743. else if (sd->status.class_ == 14)
  1744. sd->status.class_ = sd->view_class = 21;
  1745. else if (sd->status.class_ == 4008)
  1746. sd->status.class_ = sd->view_class = 4014;
  1747. else if (sd->status.class_ == 4015)
  1748. sd->status.class_ = sd->view_class = 4022;
  1749. else
  1750. sd->status.option &= ~0x0020;
  1751. }
  1752. }
  1753. }
  1754. clif_changeoption(&sd->bl);
  1755. status_calc_pc(sd, 0);
  1756. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1757. return 0;
  1758. }
  1759. /*==========================================
  1760. *
  1761. *------------------------------------------
  1762. */
  1763. int atcommand_hide(
  1764. const int fd, struct map_session_data* sd,
  1765. const char* command, const char* message)
  1766. {
  1767. nullpo_retr(-1, sd);
  1768. if (sd->status.option & OPTION_HIDE) {
  1769. sd->status.option &= ~OPTION_HIDE;
  1770. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1771. } else {
  1772. sd->status.option |= OPTION_HIDE;
  1773. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1774. }
  1775. clif_changeoption(&sd->bl);
  1776. return 0;
  1777. }
  1778. /*==========================================
  1779. * 転職する upperを指定すると転生や養子にもなれる
  1780. *------------------------------------------
  1781. */
  1782. int atcommand_jobchange(
  1783. const int fd, struct map_session_data* sd,
  1784. const char* command, const char* message)
  1785. {
  1786. int job = 0, upper = 0;
  1787. nullpo_retr(-1, sd);
  1788. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1789. int i, found = 0;
  1790. const struct { char name[16]; int id; } jobs[] = {
  1791. { "novice", 0 },
  1792. { "swordsman", 1 },
  1793. { "mage", 2 },
  1794. { "archer", 3 },
  1795. { "acolyte", 4 },
  1796. { "merchant", 5 },
  1797. { "thief", 6 },
  1798. { "knight", 7 },
  1799. { "priest", 8 },
  1800. { "priestess", 8 },
  1801. { "wizard", 9 },
  1802. { "blacksmith", 10 },
  1803. { "hunter", 11 },
  1804. { "assassin", 12 },
  1805. { "crusader", 14 },
  1806. { "monk", 15 },
  1807. { "sage", 16 },
  1808. { "rogue", 17 },
  1809. { "alchemist", 18 },
  1810. { "bard", 19 },
  1811. { "dancer", 20 },
  1812. { "super novice", 23 },
  1813. { "supernovice", 23 },
  1814. { "high novice", 4001 },
  1815. { "swordsman high", 4002 },
  1816. { "mage high", 4003 },
  1817. { "archer high", 4004 },
  1818. { "acolyte high", 4005 },
  1819. { "merchant high", 4006 },
  1820. { "thief high", 4007 },
  1821. { "lord knight", 4008 },
  1822. { "high priest", 4009 },
  1823. { "high priestess", 4009 },
  1824. { "high wizard", 4010 },
  1825. { "whitesmith", 4011 },
  1826. { "sniper", 4012 },
  1827. { "assassin cross", 4013 },
  1828. { "paladin", 4015 },
  1829. { "champion", 4016 },
  1830. { "professor", 4017 },
  1831. { "stalker", 4018 },
  1832. { "creator", 4019 },
  1833. { "clown", 4020 },
  1834. { "gypsy", 4021 },
  1835. { "baby novice", 4023 },
  1836. { "baby swordsman", 4024 },
  1837. { "baby mage", 4025 },
  1838. { "baby archer", 4026 },
  1839. { "baby acolyte", 4027 },
  1840. { "baby merchant", 4028 },
  1841. { "baby thief", 4029 },
  1842. { "baby knight", 4030 },
  1843. { "baby priest", 4031 },
  1844. { "baby priestess", 4031 },
  1845. { "baby wizard", 4032 },
  1846. { "baby blacksmith",4033 },
  1847. { "baby hunter", 4034 },
  1848. { "baby assassin", 4035 },
  1849. { "baby crusader", 4037 },
  1850. { "baby monk", 4038 },
  1851. { "baby sage", 4039 },
  1852. { "baby rogue", 4040 },
  1853. { "baby alchemist", 4041 },
  1854. { "baby bard", 4042 },
  1855. { "baby dancer", 4043 },
  1856. { "super baby", 4045 },
  1857. };
  1858. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1859. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1860. job = jobs[i].id;
  1861. upper = 0;
  1862. found = 1;
  1863. break;
  1864. }
  1865. }
  1866. if (!found) {
  1867. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1868. return -1;
  1869. }
  1870. }
  1871. if (job == 37 ||job == 45)
  1872. return 0;
  1873. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1874. int j;
  1875. // fix pecopeco display
  1876. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1877. if (pc_isriding(sd)) {
  1878. if (sd->status.class_ == 13)
  1879. sd->status.class_ = sd->view_class = 7;
  1880. if (sd->status.class_ == 21)
  1881. sd->status.class_ = sd->view_class = 14;
  1882. if (sd->status.class_ == 4014)
  1883. sd->status.class_ = sd->view_class = 4008;
  1884. if (sd->status.class_ == 4022)
  1885. sd->status.class_ = sd->view_class = 4015;
  1886. sd->status.option &= ~0x0020;
  1887. clif_changeoption(&sd->bl);
  1888. status_calc_pc(sd, 0);
  1889. }
  1890. } else {
  1891. if (!pc_isriding(sd)) {
  1892. if (job == 13)
  1893. job = 7;
  1894. if (job == 21)
  1895. job = 14;
  1896. if (job == 4014)
  1897. job = 4008;
  1898. if (job == 4022)
  1899. job = 4015;
  1900. }
  1901. }
  1902. for (j=0; j < MAX_INVENTORY; j++) {
  1903. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1904. pc_unequipitem(sd, j, 3);
  1905. }
  1906. if (pc_jobchange(sd, job, upper) == 0)
  1907. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1908. else {
  1909. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1910. return -1;
  1911. }
  1912. } else {
  1913. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1914. return -1;
  1915. }
  1916. return 0;
  1917. }
  1918. /*==========================================
  1919. *
  1920. *------------------------------------------
  1921. */
  1922. int atcommand_die(
  1923. const int fd, struct map_session_data* sd,
  1924. const char* command, const char* message)
  1925. {
  1926. nullpo_retr(-1, sd);
  1927. clif_specialeffect(&sd->bl,450,1);
  1928. pc_damage(NULL, sd, sd->status.hp + 1);
  1929. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1930. return 0;
  1931. }
  1932. /*==========================================
  1933. *
  1934. *------------------------------------------
  1935. */
  1936. int atcommand_kill(
  1937. const int fd, struct map_session_data* sd,
  1938. const char* command, const char* message)
  1939. {
  1940. char character[100];
  1941. struct map_session_data *pl_sd;
  1942. nullpo_retr(-1, sd);
  1943. memset(character, '\0', sizeof(character));
  1944. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1945. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1946. return -1;
  1947. }
  1948. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1949. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1950. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1951. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1952. } else {
  1953. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1954. return -1;
  1955. }
  1956. } else {
  1957. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1958. return -1;
  1959. }
  1960. return 0;
  1961. }
  1962. /*==========================================
  1963. *
  1964. *------------------------------------------
  1965. */
  1966. int atcommand_alive(
  1967. const int fd, struct map_session_data* sd,
  1968. const char* command, const char* message)
  1969. {
  1970. nullpo_retr(-1, sd);
  1971. if (pc_isdead(sd)) {
  1972. sd->status.hp = sd->status.max_hp;
  1973. sd->status.sp = sd->status.max_sp;
  1974. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1975. pc_setstand(sd);
  1976. if (battle_config.pc_invincible_time > 0)
  1977. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1978. clif_updatestatus(sd, SP_HP);
  1979. clif_updatestatus(sd, SP_SP);
  1980. clif_resurrection(&sd->bl, 1);
  1981. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1982. return 0;
  1983. }
  1984. return -1;
  1985. }
  1986. /*==========================================
  1987. *
  1988. *------------------------------------------
  1989. */
  1990. int atcommand_kami(
  1991. const int fd, struct map_session_data* sd,
  1992. const char* command, const char* message)
  1993. {
  1994. char output[200];
  1995. nullpo_retr(-1, sd);
  1996. memset(output, '\0', sizeof(output));
  1997. if (!message || !*message) {
  1998. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1999. return -1;
  2000. }
  2001. sscanf(message, "%199[^\n]", output);
  2002. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  2003. return 0;
  2004. }
  2005. /*==========================================
  2006. *
  2007. *------------------------------------------
  2008. */
  2009. int atcommand_heal(
  2010. const int fd, struct map_session_data* sd,
  2011. const char* command, const char* message)
  2012. {
  2013. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2014. nullpo_retr(-1, sd);
  2015. sscanf(message, "%d %d", &hp, &sp);
  2016. if (hp == 0 && sp == 0) {
  2017. hp = sd->status.max_hp - sd->status.hp;
  2018. sp = sd->status.max_sp - sd->status.sp;
  2019. } else {
  2020. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2021. hp = sd->status.max_hp - sd->status.hp;
  2022. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2023. hp = 1 - sd->status.hp;
  2024. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2025. sp = sd->status.max_sp - sd->status.sp;
  2026. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2027. sp = 1 - sd->status.sp;
  2028. }
  2029. if (hp > 0) // display like heal
  2030. clif_heal(fd, SP_HP, hp);
  2031. else if (hp < 0) // display like damage
  2032. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2033. if (sp > 0) // no display when we lost SP
  2034. clif_heal(fd, SP_SP, sp);
  2035. if (hp != 0 || sp != 0) {
  2036. pc_heal(sd, hp, sp);
  2037. if (hp >= 0 && sp >= 0)
  2038. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2039. else
  2040. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2041. } else {
  2042. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2043. return -1;
  2044. }
  2045. return 0;
  2046. }
  2047. /*==========================================
  2048. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2049. *------------------------------------------
  2050. */
  2051. int atcommand_item(
  2052. const int fd, struct map_session_data* sd,
  2053. const char* command, const char* message)
  2054. {
  2055. char item_name[100];
  2056. int number = 0, item_id, flag;
  2057. struct item item_tmp;
  2058. struct item_data *item_data;
  2059. int get_count, i, pet_id;
  2060. nullpo_retr(-1, sd);
  2061. memset(item_name, '\0', sizeof(item_name));
  2062. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2063. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2064. return -1;
  2065. }
  2066. if (number <= 0)
  2067. number = 1;
  2068. item_id = 0;
  2069. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2070. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2071. item_id = item_data->nameid;
  2072. if (item_id >= 500) {
  2073. get_count = number;
  2074. // check pet egg
  2075. pet_id = search_petDB_index(item_id, PET_EGG);
  2076. if (item_data->type == 4 || item_data->type == 5 ||
  2077. item_data->type == 7 || item_data->type == 8) {
  2078. get_count = 1;
  2079. }
  2080. for (i = 0; i < number; i += get_count) {
  2081. // if pet egg
  2082. if (pet_id >= 0) {
  2083. sd->catch_target_class = pet_db[pet_id].class_;
  2084. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2085. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  2086. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2087. 100, 0, 1, pet_db[pet_id].jname);
  2088. // if not pet egg
  2089. } else {
  2090. memset(&item_tmp, 0, sizeof(item_tmp));
  2091. item_tmp.nameid = item_id;
  2092. item_tmp.identify = 1;
  2093. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2094. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2095. }
  2096. }
  2097. clif_displaymessage(fd, msg_table[18]); // Item created.
  2098. } else {
  2099. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2100. return -1;
  2101. }
  2102. return 0;
  2103. }
  2104. /*==========================================
  2105. *
  2106. *------------------------------------------
  2107. */
  2108. int atcommand_item2(
  2109. const int fd, struct map_session_data* sd,
  2110. const char* command, const char* message)
  2111. {
  2112. struct item item_tmp;
  2113. struct item_data *item_data;
  2114. char item_name[100];
  2115. int item_id, number = 0;
  2116. int identify = 0, refine = 0, attr = 0;
  2117. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2118. int flag;
  2119. int loop, get_count, i;
  2120. nullpo_retr(-1, sd);
  2121. memset(item_name, '\0', sizeof(item_name));
  2122. 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) {
  2123. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2124. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2125. return -1;
  2126. }
  2127. if (number <= 0)
  2128. number = 1;
  2129. item_id = 0;
  2130. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2131. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2132. item_id = item_data->nameid;
  2133. if (item_id > 500) {
  2134. loop = 1;
  2135. get_count = number;
  2136. if (item_data->type == 4 || item_data->type == 5 ||
  2137. item_data->type == 7 || item_data->type == 8) {
  2138. loop = number;
  2139. get_count = 1;
  2140. if (item_data->type == 7) {
  2141. identify = 1;
  2142. refine = 0;
  2143. }
  2144. if (item_data->type == 8)
  2145. refine = 0;
  2146. if (refine > 10)
  2147. refine = 10;
  2148. } else {
  2149. identify = 1;
  2150. refine = attr = 0;
  2151. }
  2152. for (i = 0; i < loop; i++) {
  2153. memset(&item_tmp, 0, sizeof(item_tmp));
  2154. item_tmp.nameid = item_id;
  2155. item_tmp.identify = identify;
  2156. item_tmp.refine = refine;
  2157. item_tmp.attribute = attr;
  2158. item_tmp.card[0] = c1;
  2159. item_tmp.card[1] = c2;
  2160. item_tmp.card[2] = c3;
  2161. item_tmp.card[3] = c4;
  2162. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2163. clif_additem(sd, 0, 0, flag);
  2164. }
  2165. clif_displaymessage(fd, msg_table[18]); // Item created.
  2166. } else {
  2167. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2168. return -1;
  2169. }
  2170. return 0;
  2171. }
  2172. /*==========================================
  2173. *
  2174. *------------------------------------------
  2175. */
  2176. int atcommand_itemreset(
  2177. const int fd, struct map_session_data* sd,
  2178. const char* command, const char* message)
  2179. {
  2180. int i;
  2181. nullpo_retr(-1, sd);
  2182. for (i = 0; i < MAX_INVENTORY; i++) {
  2183. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2184. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2185. }
  2186. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2187. return 0;
  2188. }
  2189. /*==========================================
  2190. *
  2191. *------------------------------------------
  2192. */
  2193. int atcommand_itemcheck(
  2194. const int fd, struct map_session_data* sd,
  2195. const char* command, const char* message)
  2196. {
  2197. nullpo_retr(-1, sd);
  2198. pc_checkitem(sd);
  2199. return 0;
  2200. }
  2201. /*==========================================
  2202. *
  2203. *------------------------------------------
  2204. */
  2205. int atcommand_baselevelup(
  2206. const int fd, struct map_session_data* sd,
  2207. const char* command, const char* message)
  2208. {
  2209. int level, i;
  2210. nullpo_retr(-1, sd);
  2211. if (!message || !*message || (level = atoi(message)) == 0) {
  2212. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2213. return -1;
  2214. }
  2215. if (level > 0) {
  2216. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2217. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2218. return -1;
  2219. } // End Addition
  2220. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2221. level = battle_config.maximum_level - sd->status.base_level;
  2222. for (i = 1; i <= level; i++)
  2223. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2224. sd->status.base_level += level;
  2225. clif_updatestatus(sd, SP_BASELEVEL);
  2226. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2227. clif_updatestatus(sd, SP_STATUSPOINT);
  2228. status_calc_pc(sd, 0);
  2229. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2230. clif_misceffect(&sd->bl, 0);
  2231. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2232. } else {
  2233. if (sd->status.base_level == 1) {
  2234. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2235. return -1;
  2236. }
  2237. if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow
  2238. level = 1 - sd->status.base_level;
  2239. if (sd->status.status_point > 0) {
  2240. for (i = 0; i > level; i--)
  2241. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2242. if (sd->status.status_point < 0)
  2243. sd->status.status_point = 0;
  2244. clif_updatestatus(sd, SP_STATUSPOINT);
  2245. } // to add: remove status points from stats
  2246. sd->status.base_level += level;
  2247. clif_updatestatus(sd, SP_BASELEVEL);
  2248. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2249. status_calc_pc(sd, 0);
  2250. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2251. }
  2252. return 0;
  2253. }
  2254. /*==========================================
  2255. *
  2256. *------------------------------------------
  2257. */
  2258. int atcommand_joblevelup(
  2259. const int fd, struct map_session_data* sd,
  2260. const char* command, const char* message)
  2261. {
  2262. unsigned int up_level = 50;
  2263. int level;
  2264. struct pc_base_job s_class;
  2265. nullpo_retr(-1, sd);
  2266. s_class = pc_calc_base_job(sd->status.class_);
  2267. if (!message || !*message || (level = atoi(message)) == 0) {
  2268. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2269. return -1;
  2270. }
  2271. if (s_class.job == 0)
  2272. up_level -= 40;
  2273. // super novices can go up to 99 [celest]
  2274. else if (s_class.job == 23)
  2275. up_level += 49;
  2276. else if (sd->status.class_ > 4007 && sd->status.class_ < 4023)
  2277. up_level += 20;
  2278. if (level > 0) {
  2279. if (sd->status.job_level == up_level) {
  2280. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2281. return -1;
  2282. }
  2283. if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow
  2284. level = up_level - sd->status.job_level;
  2285. sd->status.job_level += level;
  2286. clif_updatestatus(sd, SP_JOBLEVEL);
  2287. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2288. sd->status.skill_point += level;
  2289. clif_updatestatus(sd, SP_SKILLPOINT);
  2290. status_calc_pc(sd, 0);
  2291. clif_misceffect(&sd->bl, 1);
  2292. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2293. } else {
  2294. if (sd->status.job_level == 1) {
  2295. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2296. return -1;
  2297. }
  2298. if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow
  2299. level = 1 - sd->status.job_level;
  2300. sd->status.job_level += level;
  2301. clif_updatestatus(sd, SP_JOBLEVEL);
  2302. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2303. if (sd->status.skill_point > 0) {
  2304. sd->status.skill_point += level;
  2305. if (sd->status.skill_point < 0)
  2306. sd->status.skill_point = 0;
  2307. clif_updatestatus(sd, SP_SKILLPOINT);
  2308. } // to add: remove status points from skills
  2309. status_calc_pc(sd, 0);
  2310. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2311. }
  2312. return 0;
  2313. }
  2314. /*==========================================
  2315. *
  2316. *------------------------------------------
  2317. */
  2318. int atcommand_help(
  2319. const int fd, struct map_session_data* sd,
  2320. const char* command, const char* message)
  2321. {
  2322. char buf[2048], w1[2048], w2[2048];
  2323. int i, gm_level;
  2324. FILE* fp;
  2325. nullpo_retr(-1, sd);
  2326. memset(buf, '\0', sizeof(buf));
  2327. if ((fp = fopen(help_txt, "r")) != NULL) {
  2328. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2329. gm_level = pc_isGM(sd);
  2330. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2331. if (buf[0] == '/' && buf[1] == '/')
  2332. continue;
  2333. for (i = 0; buf[i] != '\0'; i++) {
  2334. if (buf[i] == '\r' || buf[i] == '\n') {
  2335. buf[i] = '\0';
  2336. break;
  2337. }
  2338. }
  2339. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2340. clif_displaymessage(fd, buf);
  2341. else if (gm_level >= atoi(w1))
  2342. clif_displaymessage(fd, w2);
  2343. }
  2344. fclose(fp);
  2345. } else {
  2346. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2347. return -1;
  2348. }
  2349. return 0;
  2350. }
  2351. /*==========================================
  2352. *
  2353. *------------------------------------------
  2354. */
  2355. int atcommand_gm(
  2356. const int fd, struct map_session_data* sd,
  2357. const char* command, const char* message)
  2358. {
  2359. char password[100];
  2360. nullpo_retr(-1, sd);
  2361. memset(password, '\0', sizeof(password));
  2362. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2363. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2364. return -1;
  2365. }
  2366. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2367. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2368. return -1;
  2369. } else
  2370. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2371. return 0;
  2372. }
  2373. /*==========================================
  2374. *
  2375. *------------------------------------------
  2376. */
  2377. int atcommand_pvpoff(
  2378. const int fd, struct map_session_data* sd,
  2379. const char* command, const char* message)
  2380. {
  2381. struct map_session_data *pl_sd;
  2382. int i;
  2383. nullpo_retr(-1, sd);
  2384. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2385. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2386. return -1;
  2387. }
  2388. if (map[sd->bl.m].flag.pvp) {
  2389. map[sd->bl.m].flag.pvp = 0;
  2390. clif_send0199(sd->bl.m, 0);
  2391. for (i = 0; i < fd_max; i++) { //人数分ループ
  2392. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2393. if (sd->bl.m == pl_sd->bl.m) {
  2394. clif_pvpset(pl_sd, 0, 0, 2);
  2395. if (pl_sd->pvp_timer != -1) {
  2396. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2397. pl_sd->pvp_timer = -1;
  2398. }
  2399. }
  2400. }
  2401. }
  2402. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2403. } else {
  2404. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2405. return -1;
  2406. }
  2407. return 0;
  2408. }
  2409. /*==========================================
  2410. *
  2411. *------------------------------------------
  2412. */
  2413. int atcommand_pvpon(
  2414. const int fd, struct map_session_data* sd,
  2415. const char* command, const char* message)
  2416. {
  2417. struct map_session_data *pl_sd;
  2418. int i;
  2419. nullpo_retr(-1, sd);
  2420. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2421. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2422. return -1;
  2423. }
  2424. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2425. map[sd->bl.m].flag.pvp = 1;
  2426. clif_send0199(sd->bl.m, 1);
  2427. for (i = 0; i < fd_max; i++) {
  2428. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2429. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2430. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2431. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2432. pl_sd->pvp_rank = 0;
  2433. pl_sd->pvp_lastusers = 0;
  2434. pl_sd->pvp_point = 5;
  2435. }
  2436. }
  2437. }
  2438. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2439. } else {
  2440. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2441. return -1;
  2442. }
  2443. return 0;
  2444. }
  2445. /*==========================================
  2446. *
  2447. *------------------------------------------
  2448. */
  2449. int atcommand_gvgoff(
  2450. const int fd, struct map_session_data* sd,
  2451. const char* command, const char* message)
  2452. {
  2453. nullpo_retr(-1, sd);
  2454. if (map[sd->bl.m].flag.gvg) {
  2455. map[sd->bl.m].flag.gvg = 0;
  2456. clif_send0199(sd->bl.m, 0);
  2457. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2458. } else {
  2459. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2460. return -1;
  2461. }
  2462. return 0;
  2463. }
  2464. /*==========================================
  2465. *
  2466. *------------------------------------------
  2467. */
  2468. int atcommand_gvgon(
  2469. const int fd, struct map_session_data* sd,
  2470. const char* command, const char* message)
  2471. {
  2472. nullpo_retr(-1, sd);
  2473. if (!map[sd->bl.m].flag.gvg) {
  2474. map[sd->bl.m].flag.gvg = 1;
  2475. clif_send0199(sd->bl.m, 3);
  2476. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2477. } else {
  2478. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2479. return -1;
  2480. }
  2481. return 0;
  2482. }
  2483. /*==========================================
  2484. *
  2485. *------------------------------------------
  2486. */
  2487. int atcommand_model(
  2488. const int fd, struct map_session_data* sd,
  2489. const char* command, const char* message)
  2490. {
  2491. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2492. char output[200];
  2493. nullpo_retr(-1, sd);
  2494. memset(output, '\0', sizeof(output));
  2495. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2496. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2497. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2498. clif_displaymessage(fd, output);
  2499. return -1;
  2500. }
  2501. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2502. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2503. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2504. //服の色変更
  2505. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2506. //服の色未実装職の判定
  2507. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2508. return -1;
  2509. } else {
  2510. pc_changelook(sd, LOOK_HAIR, hair_style);
  2511. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2512. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2513. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2514. }
  2515. } else {
  2516. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2517. return -1;
  2518. }
  2519. return 0;
  2520. }
  2521. /*==========================================
  2522. * @dye && @ccolor
  2523. *------------------------------------------
  2524. */
  2525. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2526. {
  2527. int cloth_color = 0;
  2528. char output[200];
  2529. nullpo_retr(-1, sd);
  2530. memset(output, '\0', sizeof(output));
  2531. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2532. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2533. clif_displaymessage(fd, output);
  2534. return -1;
  2535. }
  2536. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2537. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2538. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2539. } else {
  2540. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2541. return -1;
  2542. }
  2543. return 0;
  2544. }
  2545. /*==========================================
  2546. * @hairstyle && @hstyle
  2547. *------------------------------------------
  2548. */
  2549. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2550. {
  2551. int hair_style = 0;
  2552. char output[200];
  2553. nullpo_retr(-1, sd);
  2554. memset(output, '\0', sizeof(output));
  2555. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2556. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2557. clif_displaymessage(fd, output);
  2558. return -1;
  2559. }
  2560. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2561. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2562. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2563. return -1;
  2564. } else {
  2565. pc_changelook(sd, LOOK_HAIR, hair_style);
  2566. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2567. }
  2568. } else {
  2569. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2570. return -1;
  2571. }
  2572. return 0;
  2573. }
  2574. /*==========================================
  2575. * @charhairstyle by [MouseJstr]
  2576. *------------------------------------------
  2577. */
  2578. int
  2579. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2580. const char* command, const char* message)
  2581. {
  2582. nullpo_retr(-1, sd);
  2583. return 0;
  2584. }
  2585. /*==========================================
  2586. * @haircolor && @hcolor
  2587. *------------------------------------------
  2588. */
  2589. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2590. {
  2591. int hair_color = 0;
  2592. char output[200];
  2593. nullpo_retr(-1, sd);
  2594. memset(output, '\0', sizeof(output));
  2595. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2596. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2597. clif_displaymessage(fd, output);
  2598. return -1;
  2599. }
  2600. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2601. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2602. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2603. return -1;
  2604. } else {
  2605. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2606. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2607. }
  2608. } else {
  2609. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2610. return -1;
  2611. }
  2612. return 0;
  2613. }
  2614. /*==========================================
  2615. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2616. *------------------------------------------
  2617. */
  2618. int atcommand_go(
  2619. const int fd, struct map_session_data* sd,
  2620. const char* command, const char* message)
  2621. {
  2622. int i;
  2623. int town;
  2624. char map_name[100];
  2625. char output[200];
  2626. int m;
  2627. const struct { char map[16]; int x, y; } data[] = {
  2628. { "prontera.gat", 156, 191 }, // 0=Prontera
  2629. { "morocc.gat", 156, 93 }, // 1=Morroc
  2630. { "geffen.gat", 119, 59 }, // 2=Geffen
  2631. { "payon.gat", 162, 233 }, // 3=Payon
  2632. { "alberta.gat", 192, 147 }, // 4=Alberta
  2633. { "izlude.gat", 128, 114 }, // 5=Izlude
  2634. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2635. { "xmas.gat", 147, 134 }, // 7=Lutie
  2636. { "comodo.gat", 209, 143 }, // 8=Comodo
  2637. { "yuno.gat", 157, 51 }, // 9=Yuno
  2638. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2639. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2640. { "umbala.gat", 89, 157 }, // 12=Umbala
  2641. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2642. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2643. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2644. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2645. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2646. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2647. };
  2648. nullpo_retr(-1, sd);
  2649. if(map[sd->bl.m].flag.nogo) {
  2650. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2651. return 0;
  2652. }
  2653. memset(map_name, '\0', sizeof(map_name));
  2654. memset(output, '\0', sizeof(output));
  2655. // get the number
  2656. town = atoi(message);
  2657. // if no value, display all value
  2658. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2659. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2660. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2661. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2662. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2663. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2664. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2665. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2666. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2667. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2668. clif_displaymessage(fd, " 18=Ayothaya");
  2669. return -1;
  2670. } else {
  2671. // get possible name of the city and add .gat if not in the name
  2672. map_name[sizeof(map_name)-1] = '\0';
  2673. for (i = 0; map_name[i]; i++)
  2674. map_name[i] = tolower(map_name[i]);
  2675. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2676. strcat(map_name, ".gat");
  2677. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2678. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2679. town = 0;
  2680. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2681. town = 1;
  2682. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2683. town = 2;
  2684. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2685. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2686. town = 3;
  2687. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2688. town = 4;
  2689. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2690. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2691. town = 5;
  2692. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2693. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2694. town = 6;
  2695. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2696. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2697. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2698. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2699. town = 7;
  2700. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2701. town = 8;
  2702. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2703. town = 9;
  2704. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2705. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2706. town = 10;
  2707. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2708. town = 11;
  2709. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2710. town = 12;
  2711. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2712. town = 13;
  2713. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2714. town = 14;
  2715. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2716. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2717. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2718. town = 15;
  2719. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2720. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2721. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2722. town = 16;
  2723. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2724. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2725. town = 17;
  2726. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2727. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2728. town = 18;
  2729. }
  2730. if (town >= -3 && town <= -1) {
  2731. if (sd->status.memo_point[-town-1].map[0]) {
  2732. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2733. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2734. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2735. return -1;
  2736. }
  2737. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2738. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2739. return -1;
  2740. }
  2741. 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) {
  2742. clif_displaymessage(fd, msg_table[0]); // Warped.
  2743. } else {
  2744. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2745. return -1;
  2746. }
  2747. } else {
  2748. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2749. clif_displaymessage(fd, output);
  2750. return -1;
  2751. }
  2752. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2753. m = map_mapname2mapid((char *)data[town].map);
  2754. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2755. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2756. return -1;
  2757. }
  2758. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2759. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2760. return -1;
  2761. }
  2762. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2763. clif_displaymessage(fd, msg_table[0]); // Warped.
  2764. } else {
  2765. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2766. return -1;
  2767. }
  2768. } else { // if you arrive here, you have an error in town variable when reading of names
  2769. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2770. return -1;
  2771. }
  2772. }
  2773. return 0;
  2774. }
  2775. /*==========================================
  2776. *
  2777. *------------------------------------------
  2778. */
  2779. int atcommand_monster(
  2780. const int fd, struct map_session_data* sd,
  2781. const char* command, const char* message)
  2782. {
  2783. char name[100];
  2784. char monster[100];
  2785. char output[200];
  2786. int mob_id;
  2787. int number = 0;
  2788. int x = 0, y = 0;
  2789. int count;
  2790. int i, j, k;
  2791. int mx, my, range;
  2792. nullpo_retr(-1, sd);
  2793. memset(name, '\0', sizeof(name));
  2794. memset(monster, '\0', sizeof(monster));
  2795. memset(output, '\0', sizeof(output));
  2796. if (!message || !*message ||
  2797. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2798. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2799. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2800. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2801. return -1;
  2802. }
  2803. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2804. mob_id = mobdb_checkid(atoi(monster));
  2805. if (mob_id == 0) {
  2806. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2807. return -1;
  2808. }
  2809. if (mob_id == 1288) {
  2810. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2811. return -1;
  2812. }
  2813. if (number <= 0)
  2814. number = 1;
  2815. if (strlen(name) < 1)
  2816. strcpy(name, "--ja--");
  2817. // 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
  2818. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2819. number = battle_config.atc_spawn_quantity_limit;
  2820. if (battle_config.etc_log)
  2821. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2822. count = 0;
  2823. range = (int)sqrt(number) / 2;
  2824. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2825. for (i = 0; i < number; i++) {
  2826. j = 0;
  2827. k = 0;
  2828. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2829. if (x <= 0)
  2830. mx = sd->bl.x + (rand() % range - (range / 2));
  2831. else
  2832. mx = x;
  2833. if (y <= 0)
  2834. my = sd->bl.y + (rand() % range - (range / 2));
  2835. else
  2836. my = y;
  2837. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2838. }
  2839. count += (k != 0) ? 1 : 0;
  2840. }
  2841. if (count != 0)
  2842. if (number == count)
  2843. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2844. else {
  2845. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2846. clif_displaymessage(fd, output);
  2847. }
  2848. else {
  2849. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2850. return -1;
  2851. }
  2852. return 0;
  2853. }
  2854. /*==========================================
  2855. *
  2856. *------------------------------------------
  2857. */
  2858. int atcommand_spawn(
  2859. const int fd, struct map_session_data* sd,
  2860. const char* command, const char* message) {
  2861. char name[100];
  2862. char monster[100];
  2863. char output[200];
  2864. int mob_id;
  2865. int number = 0;
  2866. int x = 0, y = 0;
  2867. int count;
  2868. int i, j, k;
  2869. int mx, my, range;
  2870. nullpo_retr(-1, sd);
  2871. memset(name, '\0', sizeof(name));
  2872. memset(monster, '\0', sizeof(monster));
  2873. memset(output, '\0', sizeof(output));
  2874. if (!message || !*message ||
  2875. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2876. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2877. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2878. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2879. return -1;
  2880. }
  2881. // If monster identifier/name argument is a name
  2882. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2883. mob_id = mobdb_checkid(atoi(monster));
  2884. if (mob_id == 0) {
  2885. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2886. return -1;
  2887. }
  2888. if (mob_id == 1288) {
  2889. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2890. return -1;
  2891. }
  2892. if (number <= 0)
  2893. number = 1;
  2894. if (strlen(name) < 1)
  2895. strcpy(name, "--ja--");
  2896. // 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
  2897. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2898. number = battle_config.atc_spawn_quantity_limit;
  2899. if (battle_config.etc_log)
  2900. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2901. count = 0;
  2902. range = (int)sqrt(number) / 2;
  2903. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2904. for (i = 0; i < number; i++) {
  2905. j = 0;
  2906. k = 0;
  2907. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2908. if (x <= 0)
  2909. mx = sd->bl.x + (rand() % range - (range / 2));
  2910. else
  2911. mx = x;
  2912. if (y <= 0)
  2913. my = sd->bl.y + (rand() % range - (range / 2));
  2914. else
  2915. my = y;
  2916. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2917. }
  2918. count += (k != 0) ? 1 : 0;
  2919. }
  2920. if (count != 0)
  2921. if (number == count)
  2922. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2923. else {
  2924. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2925. clif_displaymessage(fd, output);
  2926. }
  2927. else {
  2928. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2929. return -1;
  2930. }
  2931. return 0;
  2932. }
  2933. // small monster spawning [Valaris]
  2934. int atcommand_monstersmall(
  2935. const int fd, struct map_session_data* sd,
  2936. const char* command, const char* message) {
  2937. char name[100] = "";
  2938. char monster[100] = "";
  2939. int mob_id = 0;
  2940. int number = 0;
  2941. int x = 0;
  2942. int y = 0;
  2943. int count;
  2944. int i;
  2945. nullpo_retr(-1, sd);
  2946. if (!message || !*message) {
  2947. clif_displaymessage(fd, "Give a monster name/id please.");
  2948. return 0;
  2949. }
  2950. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2951. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2952. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2953. clif_displaymessage(fd, "Give a monster name/id please.");
  2954. return 0;
  2955. }
  2956. // If monster identifier/name argument is a name
  2957. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2958. mob_id = atoi(monster);
  2959. if (mob_id == 0) {
  2960. clif_displaymessage(fd, "Monster name hasn't been found.");
  2961. return 0;
  2962. }
  2963. if (mob_id == 1288) {
  2964. clif_displaymessage(fd, "Cannot spawn emperium.");
  2965. return 0;
  2966. }
  2967. if (mob_id > 2000) {
  2968. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2969. return 0;
  2970. }
  2971. if (number <= 0)
  2972. number = 1;
  2973. if (strlen(name) < 1)
  2974. strcpy(name, "--ja--");
  2975. // 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
  2976. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2977. number = battle_config.atc_spawn_quantity_limit;
  2978. count = 0;
  2979. for (i = 0; i < number; i++) {
  2980. int mx, my;
  2981. if (x <= 0)
  2982. mx = sd->bl.x + (rand() % 11 - 5);
  2983. else
  2984. mx = x;
  2985. if (y <= 0)
  2986. my = sd->bl.y + (rand() % 11 - 5);
  2987. else
  2988. my = y;
  2989. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2990. }
  2991. if (count != 0)
  2992. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2993. else
  2994. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2995. return 0;
  2996. }
  2997. // big monster spawning [Valaris]
  2998. int atcommand_monsterbig(
  2999. const int fd, struct map_session_data* sd,
  3000. const char* command, const char* message) {
  3001. char name[100] = "";
  3002. char monster[100] = "";
  3003. int mob_id = 0;
  3004. int number = 0;
  3005. int x = 0;
  3006. int y = 0;
  3007. int count;
  3008. int i;
  3009. nullpo_retr(-1, sd);
  3010. if (!message || !*message) {
  3011. clif_displaymessage(fd, "Give a monster name/id please.");
  3012. return 0;
  3013. }
  3014. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3015. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3016. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  3017. clif_displaymessage(fd, "Give a monster name/id please.");
  3018. return 0;
  3019. }
  3020. // If monster identifier/name argument is a name
  3021. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3022. mob_id = atoi(monster);
  3023. if (mob_id == 0) {
  3024. clif_displaymessage(fd, "Monster name hasn't been found.");
  3025. return 0;
  3026. }
  3027. if (mob_id == 1288) {
  3028. clif_displaymessage(fd, "Cannot spawn emperium.");
  3029. return 0;
  3030. }
  3031. if (mob_id > 2000) {
  3032. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3033. return 0;
  3034. }
  3035. if (number <= 0)
  3036. number = 1;
  3037. if (strlen(name) < 1)
  3038. strcpy(name, "--ja--");
  3039. // 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
  3040. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3041. number = battle_config.atc_spawn_quantity_limit;
  3042. count = 0;
  3043. for (i = 0; i < number; i++) {
  3044. int mx, my;
  3045. if (x <= 0)
  3046. mx = sd->bl.x + (rand() % 11 - 5);
  3047. else
  3048. mx = x;
  3049. if (y <= 0)
  3050. my = sd->bl.y + (rand() % 11 - 5);
  3051. else
  3052. my = y;
  3053. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  3054. }
  3055. if (count != 0)
  3056. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3057. else
  3058. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3059. return 0;
  3060. }
  3061. /*==========================================
  3062. *
  3063. *------------------------------------------
  3064. */
  3065. void atcommand_killmonster_sub(
  3066. const int fd, struct map_session_data* sd, const char* message,
  3067. const int drop)
  3068. {
  3069. int map_id;
  3070. char map_name[100];
  3071. if (!sd) return;
  3072. memset(map_name, '\0', sizeof(map_name));
  3073. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3074. map_id = sd->bl.m;
  3075. else {
  3076. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3077. strcat(map_name, ".gat");
  3078. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3079. map_id = sd->bl.m;
  3080. }
  3081. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3082. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3083. return;
  3084. }
  3085. /*==========================================
  3086. *
  3087. *------------------------------------------
  3088. */
  3089. int atcommand_killmonster(
  3090. const int fd, struct map_session_data* sd,
  3091. const char* command, const char* message)
  3092. {
  3093. if (!sd) return 0;
  3094. atcommand_killmonster_sub(fd, sd, message, 1);
  3095. return 0;
  3096. }
  3097. /*==========================================
  3098. *
  3099. *------------------------------------------
  3100. */
  3101. int atcommand_killmonster2(
  3102. const int fd, struct map_session_data* sd,
  3103. const char* command, const char* message)
  3104. {
  3105. if (!sd) return 0;
  3106. atcommand_killmonster_sub(fd, sd, message, 0);
  3107. return 0;
  3108. }
  3109. /*==========================================
  3110. *
  3111. *------------------------------------------
  3112. */
  3113. int atcommand_refine(
  3114. const int fd, struct map_session_data* sd,
  3115. const char* command, const char* message)
  3116. {
  3117. int i, position = 0, refine = 0, current_position, final_refine;
  3118. int count;
  3119. char output[200];
  3120. nullpo_retr(-1, sd);
  3121. memset(output, '\0', sizeof(output));
  3122. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3123. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3124. return -1;
  3125. }
  3126. if (refine < -10)
  3127. refine = -10;
  3128. else if (refine > 10)
  3129. refine = 10;
  3130. else if (refine == 0)
  3131. refine = 1;
  3132. count = 0;
  3133. for (i = 0; i < MAX_INVENTORY; i++) {
  3134. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3135. (sd->status.inventory[i].equip & position ||
  3136. (sd->status.inventory[i].equip && !position))) {
  3137. final_refine = sd->status.inventory[i].refine + refine;
  3138. if (final_refine > 10)
  3139. final_refine = 10;
  3140. else if (final_refine < 0)
  3141. final_refine = 0;
  3142. if (sd->status.inventory[i].refine != final_refine) {
  3143. sd->status.inventory[i].refine = final_refine;
  3144. current_position = sd->status.inventory[i].equip;
  3145. pc_unequipitem(sd, i, 3);
  3146. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3147. clif_delitem(sd, i, 1);
  3148. clif_additem(sd, i, 1, 0);
  3149. pc_equipitem(sd, i, current_position);
  3150. clif_misceffect((struct block_list*)&sd->bl, 3);
  3151. count++;
  3152. }
  3153. }
  3154. }
  3155. if (count == 0)
  3156. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3157. else if (count == 1)
  3158. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3159. else {
  3160. sprintf(output, msg_table[168], count); // %d items have been refined!
  3161. clif_displaymessage(fd, output);
  3162. }
  3163. return 0;
  3164. }
  3165. /*==========================================
  3166. *
  3167. *------------------------------------------
  3168. */
  3169. int atcommand_produce(
  3170. const int fd, struct map_session_data* sd,
  3171. const char* command, const char* message)
  3172. {
  3173. char item_name[100];
  3174. int item_id, attribute = 0, star = 0;
  3175. int flag = 0;
  3176. struct item_data *item_data;
  3177. struct item tmp_item;
  3178. char output[200];
  3179. nullpo_retr(-1, sd);
  3180. memset(output, '\0', sizeof(output));
  3181. memset(item_name, '\0', sizeof(item_name));
  3182. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3183. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3184. return -1;
  3185. }
  3186. item_id = 0;
  3187. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3188. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3189. item_id = item_data->nameid;
  3190. if (itemdb_exists(item_id) &&
  3191. (item_id <= 500 || item_id > 1099) &&
  3192. (item_id < 4001 || item_id > 4148) &&
  3193. (item_id < 7001 || item_id > 10019) &&
  3194. itemdb_isequip(item_id)) {
  3195. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3196. attribute = ATTRIBUTE_NORMAL;
  3197. if (star < MIN_STAR || star > MAX_STAR)
  3198. star = 0;
  3199. memset(&tmp_item, 0, sizeof tmp_item);
  3200. tmp_item.nameid = item_id;
  3201. tmp_item.amount = 1;
  3202. tmp_item.identify = 1;
  3203. tmp_item.card[0] = 0x00ff;
  3204. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3205. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3206. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3207. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3208. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3209. clif_additem(sd, 0, 0, flag);
  3210. } else {
  3211. if (battle_config.error_log)
  3212. printf("@produce NOT WEAPON [%d]\n", item_id);
  3213. if (item_id != 0 && itemdb_exists(item_id))
  3214. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3215. else
  3216. sprintf(output, msg_table[170]); // This item is not an equipment.
  3217. clif_displaymessage(fd, output);
  3218. return -1;
  3219. }
  3220. return 0;
  3221. }
  3222. /*==========================================
  3223. * Sub-function to display actual memo points
  3224. *------------------------------------------
  3225. */
  3226. void atcommand_memo_sub(struct map_session_data* sd) {
  3227. int i;
  3228. char output[200];
  3229. if (!sd) return;
  3230. memset(output, '\0', sizeof(output));
  3231. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3232. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3233. if (sd->status.memo_point[i].map[0])
  3234. sprintf(output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3235. else
  3236. sprintf(output, msg_table[171], i); // %d - void
  3237. clif_displaymessage(sd->fd, output);
  3238. }
  3239. return;
  3240. }
  3241. /*==========================================
  3242. *
  3243. *------------------------------------------
  3244. */
  3245. int atcommand_memo(
  3246. const int fd, struct map_session_data* sd,
  3247. const char* command, const char* message)
  3248. {
  3249. int position = 0;
  3250. char output[200];
  3251. nullpo_retr(-1, sd);
  3252. memset(output, '\0', sizeof(output));
  3253. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3254. atcommand_memo_sub(sd);
  3255. else {
  3256. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3257. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3258. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3259. return -1;
  3260. }
  3261. if (sd->status.memo_point[position].map[0]) {
  3262. sprintf(output, msg_table[172], position, 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).
  3263. clif_displaymessage(fd, output);
  3264. }
  3265. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3266. sd->status.memo_point[position].x = sd->bl.x;
  3267. sd->status.memo_point[position].y = sd->bl.y;
  3268. clif_skill_memo(sd, 0);
  3269. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3270. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3271. atcommand_memo_sub(sd);
  3272. } else {
  3273. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3274. clif_displaymessage(fd, output);
  3275. atcommand_memo_sub(sd);
  3276. return -1;
  3277. }
  3278. }
  3279. return 0;
  3280. }
  3281. /*==========================================
  3282. *
  3283. *------------------------------------------
  3284. */
  3285. int atcommand_gat(
  3286. const int fd, struct map_session_data* sd,
  3287. const char* command, const char* message)
  3288. {
  3289. char output[200];
  3290. int y;
  3291. nullpo_retr(-1, sd);
  3292. memset(output, '\0', sizeof(output));
  3293. for (y = 2; y >= -2; y--) {
  3294. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3295. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3296. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3297. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3298. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3299. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3300. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3301. clif_displaymessage(fd, output);
  3302. }
  3303. return 0;
  3304. }
  3305. /*==========================================
  3306. *
  3307. *------------------------------------------
  3308. */
  3309. int atcommand_packet(
  3310. const int fd, struct map_session_data* sd,
  3311. const char* command, const char* message)
  3312. {
  3313. int x = 0, y = 0;
  3314. nullpo_retr(-1, sd);
  3315. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3316. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3317. return -1;
  3318. }
  3319. clif_status_change(&sd->bl, x, y);
  3320. return 0;
  3321. }
  3322. /*==========================================
  3323. * @stpoint (Rewritten by [Yor])
  3324. *------------------------------------------
  3325. */
  3326. int atcommand_statuspoint(
  3327. const int fd, struct map_session_data* sd,
  3328. const char* command, const char* message)
  3329. {
  3330. int point, new_status_point;
  3331. if (!message || !*message || (point = atoi(message)) == 0) {
  3332. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3333. return -1;
  3334. }
  3335. new_status_point = (int)sd->status.status_point + point;
  3336. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3337. new_status_point = 0x7FFF;
  3338. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3339. new_status_point = 0;
  3340. if (new_status_point != (int)sd->status.status_point) {
  3341. sd->status.status_point = (short)new_status_point;
  3342. clif_updatestatus(sd, SP_STATUSPOINT);
  3343. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3344. } else {
  3345. if (point < 0)
  3346. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3347. else
  3348. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3349. return -1;
  3350. }
  3351. return 0;
  3352. }
  3353. /*==========================================
  3354. * @skpoint (Rewritten by [Yor])
  3355. *------------------------------------------
  3356. */
  3357. int atcommand_skillpoint(
  3358. const int fd, struct map_session_data* sd,
  3359. const char* command, const char* message)
  3360. {
  3361. int point, new_skill_point;
  3362. nullpo_retr(-1, sd);
  3363. if (!message || !*message || (point = atoi(message)) == 0) {
  3364. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3365. return -1;
  3366. }
  3367. new_skill_point = (int)sd->status.skill_point + point;
  3368. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3369. new_skill_point = 0x7FFF;
  3370. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3371. new_skill_point = 0;
  3372. if (new_skill_point != (int)sd->status.skill_point) {
  3373. sd->status.skill_point = (short)new_skill_point;
  3374. clif_updatestatus(sd, SP_SKILLPOINT);
  3375. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3376. } else {
  3377. if (point < 0)
  3378. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3379. else
  3380. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3381. return -1;
  3382. }
  3383. return 0;
  3384. }
  3385. /*==========================================
  3386. * @zeny (Rewritten by [Yor])
  3387. *------------------------------------------
  3388. */
  3389. int atcommand_zeny(
  3390. const int fd, struct map_session_data* sd,
  3391. const char* command, const char* message)
  3392. {
  3393. int zeny, new_zeny;
  3394. nullpo_retr(-1, sd);
  3395. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3396. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3397. return -1;
  3398. }
  3399. new_zeny = sd->status.zeny + zeny;
  3400. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3401. new_zeny = MAX_ZENY;
  3402. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3403. new_zeny = 0;
  3404. if (new_zeny != sd->status.zeny) {
  3405. sd->status.zeny = new_zeny;
  3406. clif_updatestatus(sd, SP_ZENY);
  3407. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3408. } else {
  3409. if (zeny < 0)
  3410. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3411. else
  3412. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3413. return -1;
  3414. }
  3415. return 0;
  3416. }
  3417. /*==========================================
  3418. *
  3419. *------------------------------------------
  3420. */
  3421. int atcommand_param(
  3422. const int fd, struct map_session_data* sd,
  3423. const char* command, const char* message)
  3424. {
  3425. int i, index, value = 0, new_value;
  3426. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3427. short* status[] = {
  3428. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3429. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3430. };
  3431. char output[200];
  3432. nullpo_retr(-1, sd);
  3433. memset(output, '\0', sizeof(output));
  3434. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3435. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3436. clif_displaymessage(fd, output);
  3437. return -1;
  3438. }
  3439. index = -1;
  3440. for (i = 0; param[i] != NULL; i++) {
  3441. if (strcmpi(command, param[i]) == 0) {
  3442. index = i;
  3443. break;
  3444. }
  3445. }
  3446. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3447. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3448. clif_displaymessage(fd, output);
  3449. return -1;
  3450. }
  3451. new_value = (int)*status[index] + value;
  3452. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3453. new_value = battle_config.max_parameter;
  3454. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3455. new_value = 1;
  3456. if (new_value != (int)*status[index]) {
  3457. *status[index] = new_value;
  3458. clif_updatestatus(sd, SP_STR + index);
  3459. clif_updatestatus(sd, SP_USTR + index);
  3460. status_calc_pc(sd, 0);
  3461. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3462. } else {
  3463. if (value < 0)
  3464. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3465. else
  3466. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3467. return -1;
  3468. }
  3469. return 0;
  3470. }
  3471. /*==========================================
  3472. *
  3473. *------------------------------------------
  3474. */
  3475. //** Stat all by fritz (rewritten by [Yor])
  3476. int atcommand_stat_all(
  3477. const int fd, struct map_session_data* sd,
  3478. const char* command, const char* message)
  3479. {
  3480. int index, count, value = 0, new_value;
  3481. short* status[] = {
  3482. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3483. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3484. };
  3485. nullpo_retr(-1, sd);
  3486. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3487. value = battle_config.max_parameter;
  3488. count = 0;
  3489. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3490. new_value = (int)*status[index] + value;
  3491. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3492. new_value = battle_config.max_parameter;
  3493. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3494. new_value = 1;
  3495. if (new_value != (int)*status[index]) {
  3496. *status[index] = new_value;
  3497. clif_updatestatus(sd, SP_STR + index);
  3498. clif_updatestatus(sd, SP_USTR + index);
  3499. status_calc_pc(sd, 0);
  3500. count++;
  3501. }
  3502. }
  3503. if (count > 0) // if at least 1 stat modified
  3504. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3505. else {
  3506. if (value < 0)
  3507. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3508. else
  3509. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3510. return -1;
  3511. }
  3512. return 0;
  3513. }
  3514. /*==========================================
  3515. *
  3516. *------------------------------------------
  3517. */
  3518. int atcommand_guildlevelup(
  3519. const int fd, struct map_session_data* sd,
  3520. const char* command, const char* message)
  3521. {
  3522. int level = 0;
  3523. short added_level;
  3524. struct guild *guild_info;
  3525. nullpo_retr(-1, sd);
  3526. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3527. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3528. return -1;
  3529. }
  3530. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3531. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3532. return -1;
  3533. }
  3534. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3535. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3536. return -1;
  3537. }
  3538. added_level = (short)level;
  3539. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3540. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3541. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3542. added_level = 1 - guild_info->guild_lv;
  3543. if (added_level != 0) {
  3544. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3545. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3546. } else {
  3547. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3548. return -1;
  3549. }
  3550. return 0;
  3551. }
  3552. /*==========================================
  3553. *
  3554. *------------------------------------------
  3555. */
  3556. int atcommand_makeegg(
  3557. const int fd, struct map_session_data* sd,
  3558. const char* command, const char* message)
  3559. {
  3560. struct item_data *item_data;
  3561. int id, pet_id;
  3562. nullpo_retr(-1, sd);
  3563. if (!message || !*message) {
  3564. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3565. return -1;
  3566. }
  3567. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3568. id = item_data->nameid;
  3569. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3570. id = atoi(message);
  3571. pet_id = search_petDB_index(id, PET_CLASS);
  3572. if (pet_id < 0)
  3573. pet_id = search_petDB_index(id, PET_EGG);
  3574. if (pet_id >= 0) {
  3575. sd->catch_target_class = pet_db[pet_id].class_;
  3576. intif_create_pet(
  3577. sd->status.account_id, sd->status.char_id,
  3578. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  3579. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3580. 100, 0, 1, pet_db[pet_id].jname);
  3581. } else {
  3582. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3583. return -1;
  3584. }
  3585. return 0;
  3586. }
  3587. /*==========================================
  3588. *
  3589. *------------------------------------------
  3590. */
  3591. int atcommand_hatch(
  3592. const int fd, struct map_session_data* sd,
  3593. const char* command, const char* message)
  3594. {
  3595. nullpo_retr(-1, sd);
  3596. if (sd->status.pet_id <= 0)
  3597. clif_sendegg(sd);
  3598. else {
  3599. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3600. return -1;
  3601. }
  3602. return 0;
  3603. }
  3604. /*==========================================
  3605. *
  3606. *------------------------------------------
  3607. */
  3608. int atcommand_petfriendly(
  3609. const int fd, struct map_session_data* sd,
  3610. const char* command, const char* message)
  3611. {
  3612. int friendly;
  3613. int t;
  3614. nullpo_retr(-1, sd);
  3615. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3616. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3617. return -1;
  3618. }
  3619. if (sd->status.pet_id > 0 && sd->pd) {
  3620. if (friendly >= 0 && friendly <= 1000) {
  3621. if (friendly != sd->pet.intimate) {
  3622. t = sd->pet.intimate;
  3623. sd->pet.intimate = friendly;
  3624. clif_send_petstatus(sd);
  3625. if (battle_config.pet_status_support) {
  3626. if ((sd->pet.intimate > 0 && t <= 0) ||
  3627. (sd->pet.intimate <= 0 && t > 0)) {
  3628. if (sd->bl.prev != NULL)
  3629. status_calc_pc(sd, 0);
  3630. else
  3631. status_calc_pc(sd, 2);
  3632. }
  3633. }
  3634. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3635. } else {
  3636. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3637. return -1;
  3638. }
  3639. } else {
  3640. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3641. return -1;
  3642. }
  3643. } else {
  3644. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3645. return -1;
  3646. }
  3647. return 0;
  3648. }
  3649. /*==========================================
  3650. *
  3651. *------------------------------------------
  3652. */
  3653. int atcommand_pethungry(
  3654. const int fd, struct map_session_data* sd,
  3655. const char* command, const char* message)
  3656. {
  3657. int hungry;
  3658. nullpo_retr(-1, sd);
  3659. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3660. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3661. return -1;
  3662. }
  3663. if (sd->status.pet_id > 0 && sd->pd) {
  3664. if (hungry >= 0 && hungry <= 100) {
  3665. if (hungry != sd->pet.hungry) {
  3666. sd->pet.hungry = hungry;
  3667. clif_send_petstatus(sd);
  3668. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3669. } else {
  3670. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3671. return -1;
  3672. }
  3673. } else {
  3674. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3675. return -1;
  3676. }
  3677. } else {
  3678. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3679. return -1;
  3680. }
  3681. return 0;
  3682. }
  3683. /*==========================================
  3684. *
  3685. *------------------------------------------
  3686. */
  3687. int atcommand_petrename(
  3688. const int fd, struct map_session_data* sd,
  3689. const char* command, const char* message)
  3690. {
  3691. nullpo_retr(-1, sd);
  3692. if (sd->status.pet_id > 0 && sd->pd) {
  3693. if (sd->pet.rename_flag != 0) {
  3694. sd->pet.rename_flag = 0;
  3695. intif_save_petdata(sd->status.account_id, &sd->pet);
  3696. clif_send_petstatus(sd);
  3697. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3698. } else {
  3699. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3700. return -1;
  3701. }
  3702. } else {
  3703. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3704. return -1;
  3705. }
  3706. return 0;
  3707. }
  3708. /*==========================================
  3709. *
  3710. *------------------------------------------
  3711. */
  3712. int
  3713. atcommand_recall(
  3714. const int fd, struct map_session_data* sd,
  3715. const char* command, const char* message)
  3716. {
  3717. char character[100];
  3718. char output[200];
  3719. struct map_session_data *pl_sd = NULL;
  3720. nullpo_retr(-1, sd);
  3721. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3722. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3723. return -1;
  3724. }
  3725. memset(character, '\0', sizeof character);
  3726. if(sscanf(message, "%99[^\n]", character) < 1)
  3727. return -1;
  3728. if(strncmp(sd->status.name,character,24)==0)
  3729. return -1;
  3730. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3731. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3732. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3733. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3734. return -1;
  3735. }
  3736. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3737. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3738. return -1;
  3739. }
  3740. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3741. sprintf(output, msg_table[46], character); // %s recalled!
  3742. clif_displaymessage(fd, output);
  3743. } else {
  3744. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3745. return -1;
  3746. }
  3747. } else {
  3748. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3749. return -1;
  3750. }
  3751. return 0;
  3752. }
  3753. /*==========================================
  3754. *
  3755. *------------------------------------------
  3756. */
  3757. int atcommand_revive(
  3758. const int fd, struct map_session_data* sd,
  3759. const char* command, const char* message)
  3760. {
  3761. char character[100];
  3762. struct map_session_data *pl_sd;
  3763. nullpo_retr(-1, sd);
  3764. memset(character, '\0', sizeof(character));
  3765. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3766. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3767. return -1;
  3768. }
  3769. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3770. if (pc_isdead(pl_sd)) {
  3771. pl_sd->status.hp = pl_sd->status.max_hp;
  3772. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3773. pc_setstand(pl_sd);
  3774. if (battle_config.pc_invincible_time > 0)
  3775. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3776. clif_updatestatus(pl_sd, SP_HP);
  3777. clif_updatestatus(pl_sd, SP_SP);
  3778. clif_resurrection(&pl_sd->bl, 1);
  3779. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3780. return 0;
  3781. }
  3782. return -1;
  3783. } else {
  3784. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3785. return -1;
  3786. }
  3787. return 0;
  3788. }
  3789. /*==========================================
  3790. * charchangesex command (usage: charchangesex <player_name>)
  3791. *------------------------------------------
  3792. */
  3793. int atcommand_char_change_sex(
  3794. const int fd, struct map_session_data* sd,
  3795. const char* command, const char* message)
  3796. {
  3797. char character[100];
  3798. nullpo_retr(-1, sd);
  3799. memset(character, '\0', sizeof(character));
  3800. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3801. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3802. return -1;
  3803. }
  3804. // check player name
  3805. if (strlen(character) < 4) {
  3806. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3807. return -1;
  3808. } else if (strlen(character) > 23) {
  3809. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3810. return -1;
  3811. } else {
  3812. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3813. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3814. }
  3815. return 0;
  3816. }
  3817. /*==========================================
  3818. * charblock command (usage: charblock <player_name>)
  3819. * This command do a definitiv ban on a player
  3820. *------------------------------------------
  3821. */
  3822. int atcommand_char_block(
  3823. const int fd, struct map_session_data* sd,
  3824. const char* command, const char* message)
  3825. {
  3826. char character[100];
  3827. nullpo_retr(-1, sd);
  3828. memset(character, '\0', sizeof(character));
  3829. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3830. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3831. return -1;
  3832. }
  3833. // check player name
  3834. if (strlen(character) < 4) {
  3835. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3836. return -1;
  3837. } else if (strlen(character) > 23) {
  3838. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3839. return -1;
  3840. } else {
  3841. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3842. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3843. }
  3844. return 0;
  3845. }
  3846. /*==========================================
  3847. * charban command (usage: charban <time> <player_name>)
  3848. * This command do a limited ban on a player
  3849. * Time is done as follows:
  3850. * Adjustment value (-1, 1, +1, etc...)
  3851. * Modified element:
  3852. * a or y: year
  3853. * m: month
  3854. * j or d: day
  3855. * h: hour
  3856. * mn: minute
  3857. * s: second
  3858. * <example> @ban +1m-2mn1s-6y test_player
  3859. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3860. *------------------------------------------
  3861. */
  3862. int atcommand_char_ban(
  3863. const int fd, struct map_session_data* sd,
  3864. const char* command, const char* message)
  3865. {
  3866. char modif[100], character[100];
  3867. char * modif_p;
  3868. int year, month, day, hour, minute, second, value;
  3869. nullpo_retr(-1, sd);
  3870. memset(modif, '\0', sizeof(modif));
  3871. memset(character, '\0', sizeof(character));
  3872. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3873. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3874. return -1;
  3875. }
  3876. modif[sizeof(modif)-1] = '\0';
  3877. character[sizeof(character)-1] = '\0';
  3878. modif_p = modif;
  3879. year = month = day = hour = minute = second = 0;
  3880. while (modif_p[0] != '\0') {
  3881. value = atoi(modif_p);
  3882. if (value == 0)
  3883. modif_p++;
  3884. else {
  3885. if (modif_p[0] == '-' || modif_p[0] == '+')
  3886. modif_p++;
  3887. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3888. modif_p++;
  3889. if (modif_p[0] == 's') {
  3890. second = value;
  3891. modif_p++;
  3892. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3893. minute = value;
  3894. modif_p = modif_p + 2;
  3895. } else if (modif_p[0] == 'h') {
  3896. hour = value;
  3897. modif_p++;
  3898. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3899. day = value;
  3900. modif_p++;
  3901. } else if (modif_p[0] == 'm') {
  3902. month = value;
  3903. modif_p++;
  3904. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3905. year = value;
  3906. modif_p++;
  3907. } else if (modif_p[0] != '\0') {
  3908. modif_p++;
  3909. }
  3910. }
  3911. }
  3912. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3913. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3914. return -1;
  3915. }
  3916. // check player name
  3917. if (strlen(character) < 4) {
  3918. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3919. return -1;
  3920. } else if (strlen(character) > 23) {
  3921. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3922. return -1;
  3923. } else {
  3924. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3925. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3926. }
  3927. return 0;
  3928. }
  3929. /*==========================================
  3930. * charunblock command (usage: charunblock <player_name>)
  3931. *------------------------------------------
  3932. */
  3933. int atcommand_char_unblock(
  3934. const int fd, struct map_session_data* sd,
  3935. const char* command, const char* message)
  3936. {
  3937. char character[100];
  3938. nullpo_retr(-1, sd);
  3939. memset(character, '\0', sizeof(character));
  3940. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3941. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3942. return -1;
  3943. }
  3944. // check player name
  3945. if (strlen(character) < 4) {
  3946. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3947. return -1;
  3948. } else if (strlen(character) > 23) {
  3949. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3950. return -1;
  3951. } else {
  3952. // send answer to login server via char-server
  3953. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3954. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3955. }
  3956. return 0;
  3957. }
  3958. /*==========================================
  3959. * charunban command (usage: charunban <player_name>)
  3960. *------------------------------------------
  3961. */
  3962. int atcommand_char_unban(
  3963. const int fd, struct map_session_data* sd,
  3964. const char* command, const char* message)
  3965. {
  3966. char character[100];
  3967. nullpo_retr(-1, sd);
  3968. memset(character, '\0', sizeof(character));
  3969. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3970. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3971. return -1;
  3972. }
  3973. // check player name
  3974. if (strlen(character) < 4) {
  3975. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3976. return -1;
  3977. } else if (strlen(character) > 23) {
  3978. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3979. return -1;
  3980. } else {
  3981. // send answer to login server via char-server
  3982. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3983. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3984. }
  3985. return 0;
  3986. }
  3987. /*==========================================
  3988. *
  3989. *------------------------------------------
  3990. */
  3991. int atcommand_night(
  3992. const int fd, struct map_session_data* sd,
  3993. const char* command, const char* message)
  3994. {
  3995. struct map_session_data *pl_sd;
  3996. int i;
  3997. nullpo_retr(-1, sd);
  3998. if (night_flag != 1) {
  3999. night_flag = 1; // 0=day, 1=night [Yor]
  4000. for(i = 0; i < fd_max; i++) {
  4001. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  4002. //pl_sd->opt2 |= STATE_BLIND;
  4003. //clif_changeoption(&pl_sd->bl);
  4004. if (battle_config.night_darkness_level > 0)
  4005. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  4006. else {
  4007. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  4008. pl_sd->opt2 |= STATE_BLIND;
  4009. clif_changeoption(&pl_sd->bl);
  4010. }
  4011. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  4012. }
  4013. }
  4014. } else {
  4015. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4016. return -1;
  4017. }
  4018. return 0;
  4019. }
  4020. /*==========================================
  4021. *
  4022. *------------------------------------------
  4023. */
  4024. int atcommand_day(
  4025. const int fd, struct map_session_data* sd,
  4026. const char* command, const char* message)
  4027. {
  4028. struct map_session_data *pl_sd;
  4029. int i;
  4030. nullpo_retr(-1, sd);
  4031. if (night_flag != 0) {
  4032. night_flag = 0; // 0=day, 1=night [Yor]
  4033. for(i = 0; i < fd_max; i++) {
  4034. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4035. pl_sd->opt2 &= ~STATE_BLIND;
  4036. clif_changeoption(&pl_sd->bl);
  4037. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4038. }
  4039. }
  4040. } else {
  4041. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4042. return -1;
  4043. }
  4044. return 0;
  4045. }
  4046. /*==========================================
  4047. *
  4048. *------------------------------------------
  4049. */
  4050. int atcommand_doom(
  4051. const int fd, struct map_session_data* sd,
  4052. const char* command, const char* message)
  4053. {
  4054. struct map_session_data *pl_sd;
  4055. int i;
  4056. nullpo_retr(-1, sd);
  4057. clif_specialeffect(&sd->bl,450,2);
  4058. for(i = 0; i < fd_max; i++) {
  4059. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4060. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4061. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4062. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4063. }
  4064. }
  4065. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4066. return 0;
  4067. }
  4068. /*==========================================
  4069. *
  4070. *------------------------------------------
  4071. */
  4072. int atcommand_doommap(
  4073. const int fd, struct map_session_data* sd,
  4074. const char* command, const char* message)
  4075. {
  4076. struct map_session_data *pl_sd;
  4077. int i;
  4078. nullpo_retr(-1, sd);
  4079. clif_specialeffect(&sd->bl,450,3);
  4080. for (i = 0; i < fd_max; i++) {
  4081. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4082. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4083. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4084. // clif_specialeffect(&pl_sd->bl,450,1);
  4085. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4086. }
  4087. }
  4088. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4089. return 0;
  4090. }
  4091. /*==========================================
  4092. *
  4093. *------------------------------------------
  4094. */
  4095. static void atcommand_raise_sub(struct map_session_data* sd)
  4096. {
  4097. if (sd && sd->state.auth && pc_isdead(sd)) {
  4098. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4099. sd->status.hp = sd->status.max_hp;
  4100. sd->status.sp = sd->status.max_sp;
  4101. pc_setstand(sd);
  4102. clif_updatestatus(sd, SP_HP);
  4103. clif_updatestatus(sd, SP_SP);
  4104. clif_resurrection(&sd->bl, 1);
  4105. if (battle_config.pc_invincible_time > 0)
  4106. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4107. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4108. }
  4109. }
  4110. /*==========================================
  4111. *
  4112. *------------------------------------------
  4113. */
  4114. int atcommand_raise(
  4115. const int fd, struct map_session_data* sd,
  4116. const char* command, const char* message)
  4117. {
  4118. int i;
  4119. nullpo_retr(-1, sd);
  4120. for (i = 0; i < fd_max; i++) {
  4121. if (session[i])
  4122. atcommand_raise_sub(session[i]->session_data);
  4123. }
  4124. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4125. return 0;
  4126. }
  4127. /*==========================================
  4128. *
  4129. *------------------------------------------
  4130. */
  4131. int atcommand_raisemap(
  4132. const int fd, struct map_session_data* sd,
  4133. const char* command, const char* message)
  4134. {
  4135. struct map_session_data *pl_sd;
  4136. int i;
  4137. nullpo_retr(-1, sd);
  4138. for (i = 0; i < fd_max; i++) {
  4139. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4140. atcommand_raise_sub(pl_sd);
  4141. }
  4142. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4143. return 0;
  4144. }
  4145. /*==========================================
  4146. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4147. *------------------------------------------
  4148. */
  4149. int atcommand_character_baselevel(
  4150. const int fd, struct map_session_data* sd,
  4151. const char* command, const char* message)
  4152. {
  4153. struct map_session_data *pl_sd;
  4154. char character[100];
  4155. int level = 0, i;
  4156. nullpo_retr(-1, sd);
  4157. memset(character, '\0', sizeof(character));
  4158. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4159. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4160. return -1;
  4161. }
  4162. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4163. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4164. if (level > 0) {
  4165. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4166. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4167. return 0;
  4168. } // End Addition
  4169. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4170. level = battle_config.maximum_level - pl_sd->status.base_level;
  4171. for (i = 1; i <= level; i++)
  4172. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4173. pl_sd->status.base_level += level;
  4174. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4175. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4176. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4177. status_calc_pc(pl_sd, 0);
  4178. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4179. clif_misceffect(&pl_sd->bl, 0);
  4180. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4181. } else {
  4182. if (pl_sd->status.base_level == 1) {
  4183. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4184. return -1;
  4185. }
  4186. if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow
  4187. level = 1 - pl_sd->status.base_level;
  4188. if (pl_sd->status.status_point > 0) {
  4189. for (i = 0; i > level; i--)
  4190. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4191. if (pl_sd->status.status_point < 0)
  4192. pl_sd->status.status_point = 0;
  4193. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4194. } // to add: remove status points from stats
  4195. pl_sd->status.base_level += level;
  4196. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4197. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4198. status_calc_pc(pl_sd, 0);
  4199. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4200. }
  4201. } else {
  4202. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4203. return -1;
  4204. }
  4205. } else {
  4206. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4207. return -1;
  4208. }
  4209. return 0; //正常終了
  4210. }
  4211. /*==========================================
  4212. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4213. *------------------------------------------
  4214. */
  4215. int atcommand_character_joblevel(
  4216. const int fd, struct map_session_data* sd,
  4217. const char* command, const char* message)
  4218. {
  4219. struct map_session_data *pl_sd;
  4220. char character[100];
  4221. unsigned int max_level = 50;
  4222. int level = 0;
  4223. //転生や養子の場合の元の職業を算出する
  4224. struct pc_base_job pl_s_class;
  4225. nullpo_retr(-1, sd);
  4226. memset(character, '\0', sizeof(character));
  4227. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4228. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4229. return -1;
  4230. }
  4231. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4232. pl_s_class = pc_calc_base_job(pl_sd->status.class_);
  4233. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4234. if (pl_s_class.job == 0)
  4235. max_level -= 40;
  4236. // super novices can go up to 99 [celest]
  4237. else if (pl_s_class.job == 23)
  4238. max_level += 49;
  4239. else if (pl_sd->status.class_ > 4007 && pl_sd->status.class_ < 4023)
  4240. max_level += 20;
  4241. if (level > 0) {
  4242. if (pl_sd->status.job_level == max_level) {
  4243. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4244. return -1;
  4245. }
  4246. if (pl_sd->status.job_level + level > max_level)
  4247. level = max_level - pl_sd->status.job_level;
  4248. pl_sd->status.job_level += level;
  4249. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4250. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4251. pl_sd->status.skill_point += level;
  4252. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4253. status_calc_pc(pl_sd, 0);
  4254. clif_misceffect(&pl_sd->bl, 1);
  4255. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4256. } else {
  4257. if (pl_sd->status.job_level == 1) {
  4258. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4259. return -1;
  4260. }
  4261. if (pl_sd->status.job_level + level < 1)
  4262. level = 1 - pl_sd->status.job_level;
  4263. pl_sd->status.job_level += level;
  4264. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4265. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4266. if (pl_sd->status.skill_point > 0) {
  4267. pl_sd->status.skill_point += level;
  4268. if (pl_sd->status.skill_point < 0)
  4269. pl_sd->status.skill_point = 0;
  4270. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4271. } // to add: remove status points from skills
  4272. status_calc_pc(pl_sd, 0);
  4273. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4274. }
  4275. } else {
  4276. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4277. return -1;
  4278. }
  4279. } else {
  4280. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4281. return -1;
  4282. }
  4283. return 0;
  4284. }
  4285. /*==========================================
  4286. *
  4287. *------------------------------------------
  4288. */
  4289. int atcommand_kick(
  4290. const int fd, struct map_session_data* sd,
  4291. const char* command, const char* message)
  4292. {
  4293. struct map_session_data *pl_sd;
  4294. char character[100];
  4295. nullpo_retr(-1, sd);
  4296. memset(character, '\0', sizeof(character));
  4297. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4298. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4299. return -1;
  4300. }
  4301. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4302. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4303. clif_GM_kick(sd, pl_sd, 1);
  4304. else {
  4305. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4306. return -1;
  4307. }
  4308. } else {
  4309. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4310. return -1;
  4311. }
  4312. return 0;
  4313. }
  4314. /*==========================================
  4315. *
  4316. *------------------------------------------
  4317. */
  4318. int atcommand_kickall(
  4319. const int fd, struct map_session_data* sd,
  4320. const char* command, const char* message)
  4321. {
  4322. struct map_session_data *pl_sd;
  4323. int i;
  4324. nullpo_retr(-1, sd);
  4325. for (i = 0; i < fd_max; i++) {
  4326. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4327. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4328. if (sd->status.account_id != pl_sd->status.account_id)
  4329. clif_GM_kick(sd, pl_sd, 0);
  4330. }
  4331. }
  4332. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4333. return 0;
  4334. }
  4335. /*==========================================
  4336. *
  4337. *------------------------------------------
  4338. */
  4339. int atcommand_allskill(
  4340. const int fd, struct map_session_data* sd,
  4341. const char* command, const char* message)
  4342. {
  4343. nullpo_retr(-1, sd);
  4344. pc_allskillup(sd); // all skills
  4345. sd->status.skill_point = 0; // 0 skill points
  4346. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4347. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4348. return 0;
  4349. }
  4350. /*==========================================
  4351. *
  4352. *------------------------------------------
  4353. */
  4354. int atcommand_questskill(
  4355. const int fd, struct map_session_data* sd,
  4356. const char* command, const char* message)
  4357. {
  4358. int skill_id;
  4359. nullpo_retr(-1, sd);
  4360. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4361. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4362. return -1;
  4363. }
  4364. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4365. if (skill_get_inf2(skill_id) & 0x01) {
  4366. if (pc_checkskill(sd, skill_id) == 0) {
  4367. pc_skill(sd, skill_id, 1, 0);
  4368. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4369. } else {
  4370. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4371. return -1;
  4372. }
  4373. } else {
  4374. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4375. return -1;
  4376. }
  4377. } else {
  4378. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4379. return -1;
  4380. }
  4381. return 0;
  4382. }
  4383. /*==========================================
  4384. *
  4385. *------------------------------------------
  4386. */
  4387. int atcommand_charquestskill(
  4388. const int fd, struct map_session_data* sd,
  4389. const char* command, const char* message)
  4390. {
  4391. char character[100];
  4392. struct map_session_data *pl_sd;
  4393. int skill_id = 0;
  4394. nullpo_retr(-1, sd);
  4395. memset(character, '\0', sizeof(character));
  4396. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4397. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4398. return -1;
  4399. }
  4400. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4401. if (skill_get_inf2(skill_id) & 0x01) {
  4402. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4403. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4404. pc_skill(pl_sd, skill_id, 1, 0);
  4405. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4406. } else {
  4407. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4408. return -1;
  4409. }
  4410. } else {
  4411. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4412. return -1;
  4413. }
  4414. } else {
  4415. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4416. return -1;
  4417. }
  4418. } else {
  4419. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4420. return -1;
  4421. }
  4422. return 0;
  4423. }
  4424. /*==========================================
  4425. *
  4426. *------------------------------------------
  4427. */
  4428. int atcommand_lostskill(
  4429. const int fd, struct map_session_data* sd,
  4430. const char* command, const char* message)
  4431. {
  4432. int skill_id;
  4433. nullpo_retr(-1, sd);
  4434. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4435. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4436. return -1;
  4437. }
  4438. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4439. if (skill_get_inf2(skill_id) & 0x01) {
  4440. if (pc_checkskill(sd, skill_id) > 0) {
  4441. sd->status.skill[skill_id].lv = 0;
  4442. sd->status.skill[skill_id].flag = 0;
  4443. clif_skillinfoblock(sd);
  4444. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4445. } else {
  4446. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4447. return -1;
  4448. }
  4449. } else {
  4450. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4451. return -1;
  4452. }
  4453. } else {
  4454. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4455. return -1;
  4456. }
  4457. return 0;
  4458. }
  4459. /*==========================================
  4460. *
  4461. *------------------------------------------
  4462. */
  4463. int atcommand_charlostskill(
  4464. const int fd, struct map_session_data* sd,
  4465. const char* command, const char* message)
  4466. {
  4467. char character[100];
  4468. struct map_session_data *pl_sd;
  4469. int skill_id = 0;
  4470. nullpo_retr(-1, sd);
  4471. memset(character, '\0', sizeof(character));
  4472. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4473. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4474. return -1;
  4475. }
  4476. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4477. if (skill_get_inf2(skill_id) & 0x01) {
  4478. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4479. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4480. pl_sd->status.skill[skill_id].lv = 0;
  4481. pl_sd->status.skill[skill_id].flag = 0;
  4482. clif_skillinfoblock(pl_sd);
  4483. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4484. } else {
  4485. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4486. return -1;
  4487. }
  4488. } else {
  4489. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4490. return -1;
  4491. }
  4492. } else {
  4493. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4494. return -1;
  4495. }
  4496. } else {
  4497. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4498. return -1;
  4499. }
  4500. return 0;
  4501. }
  4502. /*==========================================
  4503. *
  4504. *------------------------------------------
  4505. */
  4506. int atcommand_spiritball(
  4507. const int fd, struct map_session_data* sd,
  4508. const char* command, const char* message)
  4509. {
  4510. int number;
  4511. nullpo_retr(-1, sd);
  4512. if (!message || !*message || (number = atoi(message)) < 0) {
  4513. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4514. return -1;
  4515. }
  4516. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4517. if (number > 500)
  4518. number = 500;
  4519. if (number >= 0 && number <= 0x7FFF) {
  4520. if (sd->spiritball != number || number > 499) {
  4521. if (sd->spiritball > 0)
  4522. pc_delspiritball(sd, sd->spiritball, 1);
  4523. sd->spiritball = number;
  4524. clif_spiritball(sd);
  4525. // no message, player can look the difference
  4526. if (number > 1000)
  4527. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4528. } else {
  4529. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4530. return -1;
  4531. }
  4532. } else {
  4533. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4534. return -1;
  4535. }
  4536. return 0;
  4537. }
  4538. /*==========================================
  4539. *
  4540. *------------------------------------------
  4541. */
  4542. int atcommand_party(
  4543. const int fd, struct map_session_data* sd,
  4544. const char* command, const char* message)
  4545. {
  4546. char party[100];
  4547. nullpo_retr(-1, sd);
  4548. memset(party, '\0', sizeof(party));
  4549. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4550. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4551. return -1;
  4552. }
  4553. party_create(sd, party, 0, 0);
  4554. return 0;
  4555. }
  4556. /*==========================================
  4557. *
  4558. *------------------------------------------
  4559. */
  4560. int atcommand_guild(
  4561. const int fd, struct map_session_data* sd,
  4562. const char* command, const char* message)
  4563. {
  4564. char guild[100];
  4565. int prev;
  4566. nullpo_retr(-1, sd);
  4567. memset(guild, '\0', sizeof(guild));
  4568. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4569. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4570. return -1;
  4571. }
  4572. prev = battle_config.guild_emperium_check;
  4573. battle_config.guild_emperium_check = 0;
  4574. guild_create(sd, guild);
  4575. battle_config.guild_emperium_check = prev;
  4576. return 0;
  4577. }
  4578. /*==========================================
  4579. *
  4580. *------------------------------------------
  4581. */
  4582. int atcommand_agitstart(
  4583. const int fd, struct map_session_data* sd,
  4584. const char* command, const char* message)
  4585. {
  4586. nullpo_retr(-1, sd);
  4587. if (agit_flag == 1) {
  4588. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4589. return -1;
  4590. }
  4591. agit_flag = 1;
  4592. guild_agit_start();
  4593. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4594. return 0;
  4595. }
  4596. /*==========================================
  4597. *
  4598. *------------------------------------------
  4599. */
  4600. int atcommand_agitend(
  4601. const int fd, struct map_session_data* sd,
  4602. const char* command, const char* message)
  4603. {
  4604. nullpo_retr(-1, sd);
  4605. if (agit_flag == 0) {
  4606. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4607. return -1;
  4608. }
  4609. agit_flag = 0;
  4610. guild_agit_end();
  4611. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4612. return 0;
  4613. }
  4614. /*==========================================
  4615. * @mapexitでマップサーバーを終了させる
  4616. *------------------------------------------
  4617. */
  4618. int atcommand_mapexit(
  4619. const int fd, struct map_session_data* sd,
  4620. const char* command, const char* message)
  4621. {
  4622. struct map_session_data *pl_sd;
  4623. int i;
  4624. nullpo_retr(-1, sd);
  4625. for (i = 0; i < fd_max; i++) {
  4626. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4627. if (sd->status.account_id != pl_sd->status.account_id)
  4628. clif_GM_kick(sd, pl_sd, 0);
  4629. }
  4630. }
  4631. clif_GM_kick(sd, sd, 0);
  4632. runflag = 0;
  4633. return 0;
  4634. }
  4635. /*==========================================
  4636. * idsearch <part_of_name>: revrited by [Yor]
  4637. *------------------------------------------
  4638. */
  4639. int atcommand_idsearch(
  4640. const int fd, struct map_session_data* sd,
  4641. const char* command, const char* message)
  4642. {
  4643. char item_name[100];
  4644. char output[200];
  4645. unsigned int i, match;
  4646. struct item_data *item;
  4647. nullpo_retr(-1, sd);
  4648. memset(item_name, '\0', sizeof(item_name));
  4649. memset(output, '\0', sizeof(output));
  4650. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4651. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4652. return -1;
  4653. }
  4654. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4655. clif_displaymessage(fd, output);
  4656. match = 0;
  4657. for(i = 0; i < 20000; i++) {
  4658. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4659. match++;
  4660. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4661. clif_displaymessage(fd, output);
  4662. }
  4663. }
  4664. sprintf(output, msg_table[79], match); // It is %d affair above.
  4665. clif_displaymessage(fd, output);
  4666. return 0;
  4667. }
  4668. /*==========================================
  4669. * Character Skill Reset
  4670. *------------------------------------------
  4671. */
  4672. int atcommand_charskreset(
  4673. const int fd, struct map_session_data* sd,
  4674. const char* command, const char* message)
  4675. {
  4676. char character[100];
  4677. char output[200];
  4678. struct map_session_data *pl_sd;
  4679. nullpo_retr(-1, sd);
  4680. memset(character, '\0', sizeof(character));
  4681. memset(output, '\0', sizeof(output));
  4682. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4683. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4684. return -1;
  4685. }
  4686. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4687. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4688. pc_resetskill(pl_sd);
  4689. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4690. clif_displaymessage(fd, output);
  4691. } else {
  4692. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4693. return -1;
  4694. }
  4695. } else {
  4696. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4697. return -1;
  4698. }
  4699. return 0;
  4700. }
  4701. /*==========================================
  4702. * Character Stat Reset
  4703. *------------------------------------------
  4704. */
  4705. int atcommand_charstreset(
  4706. const int fd, struct map_session_data* sd,
  4707. const char* command, const char* message)
  4708. {
  4709. char character[100];
  4710. char output[200];
  4711. struct map_session_data *pl_sd;
  4712. nullpo_retr(-1, sd);
  4713. memset(character, '\0', sizeof(character));
  4714. memset(output, '\0', sizeof(output));
  4715. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4716. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4717. return -1;
  4718. }
  4719. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4720. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4721. pc_resetstate(pl_sd);
  4722. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4723. clif_displaymessage(fd, output);
  4724. } else {
  4725. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4726. return -1;
  4727. }
  4728. } else {
  4729. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4730. return -1;
  4731. }
  4732. return 0;
  4733. }
  4734. /*==========================================
  4735. * Character Model by chbrules
  4736. *------------------------------------------
  4737. */
  4738. int atcommand_charmodel(
  4739. const int fd, struct map_session_data* sd,
  4740. const char* command, const char* message)
  4741. {
  4742. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4743. struct map_session_data *pl_sd;
  4744. char character[100];
  4745. char output[200];
  4746. nullpo_retr(-1, sd);
  4747. memset(character, '\0', sizeof(character));
  4748. memset(output, '\0', sizeof(output));
  4749. if (!message || !*message || sscanf(message, "%d %d %d %99[^\n]", &hair_style, &hair_color, &cloth_color, character) < 4 || hair_style < 0 || hair_color < 0 || cloth_color < 0) {
  4750. sprintf(output, "Please, enter a valid model and a player name (usage: @charmodel <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d> <name>).",
  4751. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4752. clif_displaymessage(fd, output);
  4753. return -1;
  4754. }
  4755. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4756. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4757. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4758. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4759. if (cloth_color != 0 &&
  4760. pl_sd->status.sex == 1 &&
  4761. (pl_sd->status.class_ == 12 || pl_sd->status.class_ == 17)) {
  4762. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4763. return -1;
  4764. } else {
  4765. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4766. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4767. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4768. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4769. }
  4770. } else {
  4771. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4772. return -1;
  4773. }
  4774. } else {
  4775. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4776. return -1;
  4777. }
  4778. return 0;
  4779. }
  4780. /*==========================================
  4781. * Character Skill Point (Rewritten by [Yor])
  4782. *------------------------------------------
  4783. */
  4784. int atcommand_charskpoint(
  4785. const int fd, struct map_session_data* sd,
  4786. const char* command, const char* message)
  4787. {
  4788. struct map_session_data *pl_sd;
  4789. char character[100];
  4790. int new_skill_point;
  4791. int point = 0;
  4792. nullpo_retr(-1, sd);
  4793. memset(character, '\0', sizeof(character));
  4794. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4795. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4796. return -1;
  4797. }
  4798. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4799. new_skill_point = (int)pl_sd->status.skill_point + point;
  4800. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4801. new_skill_point = 0x7FFF;
  4802. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4803. new_skill_point = 0;
  4804. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4805. pl_sd->status.skill_point = new_skill_point;
  4806. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4807. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4808. } else {
  4809. if (point < 0)
  4810. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4811. else
  4812. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4813. return -1;
  4814. }
  4815. } else {
  4816. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4817. return -1;
  4818. }
  4819. return 0;
  4820. }
  4821. /*==========================================
  4822. * Character Status Point (rewritten by [Yor])
  4823. *------------------------------------------
  4824. */
  4825. int atcommand_charstpoint(
  4826. const int fd, struct map_session_data* sd,
  4827. const char* command, const char* message)
  4828. {
  4829. struct map_session_data *pl_sd;
  4830. char character[100];
  4831. int new_status_point;
  4832. int point = 0;
  4833. nullpo_retr(-1, sd);
  4834. memset(character, '\0', sizeof(character));
  4835. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4836. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4837. return -1;
  4838. }
  4839. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4840. new_status_point = (int)pl_sd->status.status_point + point;
  4841. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4842. new_status_point = 0x7FFF;
  4843. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4844. new_status_point = 0;
  4845. if (new_status_point != (int)pl_sd->status.status_point) {
  4846. pl_sd->status.status_point = new_status_point;
  4847. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4848. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4849. } else {
  4850. if (point < 0)
  4851. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4852. else
  4853. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4854. return -1;
  4855. }
  4856. } else {
  4857. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4858. return -1;
  4859. }
  4860. return 0;
  4861. }
  4862. /*==========================================
  4863. * Recall All Characters Online To Your Location
  4864. *------------------------------------------
  4865. */
  4866. int atcommand_recallall(
  4867. const int fd, struct map_session_data* sd,
  4868. const char* command, const char* message)
  4869. {
  4870. struct map_session_data *pl_sd;
  4871. int i;
  4872. int count;
  4873. char output[200];
  4874. nullpo_retr(-1, sd);
  4875. memset(output, '\0', sizeof(output));
  4876. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4877. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4878. return -1;
  4879. }
  4880. count = 0;
  4881. for (i = 0; i < fd_max; i++) {
  4882. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4883. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4884. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4885. count++;
  4886. else
  4887. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4888. }
  4889. }
  4890. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4891. if (count) {
  4892. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4893. clif_displaymessage(fd, output);
  4894. }
  4895. return 0;
  4896. }
  4897. /*==========================================
  4898. * Recall online characters of a guild to your location
  4899. *------------------------------------------
  4900. */
  4901. int atcommand_guildrecall(
  4902. const int fd, struct map_session_data* sd,
  4903. const char* command, const char* message)
  4904. {
  4905. struct map_session_data *pl_sd;
  4906. int i;
  4907. char guild_name[100];
  4908. char output[200];
  4909. struct guild *g;
  4910. int count;
  4911. nullpo_retr(-1, sd);
  4912. memset(guild_name, '\0', sizeof(guild_name));
  4913. memset(output, '\0', sizeof(output));
  4914. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4915. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4916. return -1;
  4917. }
  4918. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4919. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4920. return -1;
  4921. }
  4922. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4923. (g = guild_search(atoi(message))) != NULL) {
  4924. count = 0;
  4925. for (i = 0; i < fd_max; i++) {
  4926. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4927. sd->status.account_id != pl_sd->status.account_id &&
  4928. pl_sd->status.guild_id == g->guild_id) {
  4929. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4930. count++;
  4931. else
  4932. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4933. }
  4934. }
  4935. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4936. clif_displaymessage(fd, output);
  4937. if (count) {
  4938. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4939. clif_displaymessage(fd, output);
  4940. }
  4941. } else {
  4942. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4943. return -1;
  4944. }
  4945. return 0;
  4946. }
  4947. /*==========================================
  4948. * Recall online characters of a party to your location
  4949. *------------------------------------------
  4950. */
  4951. int atcommand_partyrecall(
  4952. const int fd, struct map_session_data* sd,
  4953. const char* command, const char* message)
  4954. {
  4955. int i;
  4956. struct map_session_data *pl_sd;
  4957. char party_name[100];
  4958. char output[200];
  4959. struct party *p;
  4960. int count;
  4961. nullpo_retr(-1, sd);
  4962. memset(party_name, '\0', sizeof(party_name));
  4963. memset(output, '\0', sizeof(output));
  4964. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4965. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4966. return -1;
  4967. }
  4968. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4969. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4970. return -1;
  4971. }
  4972. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4973. (p = party_search(atoi(message))) != NULL) {
  4974. count = 0;
  4975. for (i = 0; i < fd_max; i++) {
  4976. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4977. sd->status.account_id != pl_sd->status.account_id &&
  4978. pl_sd->status.party_id == p->party_id) {
  4979. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4980. count++;
  4981. else
  4982. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4983. }
  4984. }
  4985. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4986. clif_displaymessage(fd, output);
  4987. if (count) {
  4988. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4989. clif_displaymessage(fd, output);
  4990. }
  4991. } else {
  4992. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4993. return -1;
  4994. }
  4995. return 0;
  4996. }
  4997. /*==========================================
  4998. *
  4999. *------------------------------------------
  5000. */
  5001. int atcommand_reloaditemdb(
  5002. const int fd, struct map_session_data* sd,
  5003. const char* command, const char* message)
  5004. {
  5005. nullpo_retr(-1, sd);
  5006. itemdb_reload();
  5007. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  5008. return 0;
  5009. }
  5010. /*==========================================
  5011. *
  5012. *------------------------------------------
  5013. */
  5014. int atcommand_reloadmobdb(
  5015. const int fd, struct map_session_data* sd,
  5016. const char* command, const char* message)
  5017. {
  5018. nullpo_retr(-1, sd);
  5019. mob_reload();
  5020. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  5021. return 0;
  5022. }
  5023. /*==========================================
  5024. *
  5025. *------------------------------------------
  5026. */
  5027. int atcommand_reloadskilldb(
  5028. const int fd, struct map_session_data* sd,
  5029. const char* command, const char* message)
  5030. {
  5031. nullpo_retr(-1, sd);
  5032. skill_reload();
  5033. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  5034. return 0;
  5035. }
  5036. /*==========================================
  5037. *
  5038. *------------------------------------------
  5039. */
  5040. int atcommand_reloadscript(
  5041. const int fd, struct map_session_data* sd,
  5042. const char* command, const char* message)
  5043. {
  5044. nullpo_retr(-1, sd);
  5045. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5046. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5047. rehash( fd, sd );
  5048. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5049. do_init_npc();
  5050. do_init_script();
  5051. npc_event_do_oninit();
  5052. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5053. return 0;
  5054. }
  5055. /*==========================================
  5056. *
  5057. *------------------------------------------
  5058. */
  5059. int atcommand_reloadgmdb( // by [Yor]
  5060. const int fd, struct map_session_data* sd,
  5061. const char* command, const char* message)
  5062. {
  5063. nullpo_retr(-1, sd);
  5064. chrif_reloadGMdb();
  5065. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5066. return 0;
  5067. }
  5068. /*==========================================
  5069. * @mapinfo <map name> [0-3] by MC_Cameri
  5070. * => Shows information about the map [map name]
  5071. * 0 = no additional information
  5072. * 1 = Show users in that map and their location
  5073. * 2 = Shows NPCs in that map
  5074. * 3 = Shows the shops/chats in that map (not implemented)
  5075. *------------------------------------------
  5076. */
  5077. int atcommand_mapinfo(
  5078. const int fd, struct map_session_data* sd,
  5079. const char* command, const char* message)
  5080. {
  5081. struct map_session_data *pl_sd;
  5082. struct npc_data *nd = NULL;
  5083. struct chat_data *cd = NULL;
  5084. char output[200], map_name[100];
  5085. char direction[12];
  5086. int m_id, i, chat_num, list = 0;
  5087. nullpo_retr(-1, sd);
  5088. memset(output, '\0', sizeof(output));
  5089. memset(map_name, '\0', sizeof(map_name));
  5090. memset(direction, '\0', sizeof(direction));
  5091. sscanf(message, "%d %99[^\n]", &list, map_name);
  5092. if (list < 0 || list > 3) {
  5093. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5094. return -1;
  5095. }
  5096. if (map_name[0] == '\0')
  5097. strcpy(map_name, sd->mapname);
  5098. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5099. strcat(map_name, ".gat");
  5100. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5101. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5102. return -1;
  5103. }
  5104. clif_displaymessage(fd, "------ Map Info ------");
  5105. sprintf(output, "Map Name: %s", map_name);
  5106. clif_displaymessage(fd, output);
  5107. sprintf(output, "Players In Map: %d", map[m_id].users);
  5108. clif_displaymessage(fd, output);
  5109. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5110. clif_displaymessage(fd, output);
  5111. chat_num = 0;
  5112. for (i = 0; i < fd_max; i++) {
  5113. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5114. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5115. chat_num++;
  5116. }
  5117. }
  5118. sprintf(output, "Chats In Map: %d", chat_num);
  5119. clif_displaymessage(fd, output);
  5120. clif_displaymessage(fd, "------ Map Flags ------");
  5121. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5122. (map[m_id].flag.pvp) ? "True" : "False",
  5123. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5124. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5125. clif_displaymessage(fd, output);
  5126. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5127. clif_displaymessage(fd, output);
  5128. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5129. clif_displaymessage(fd, output);
  5130. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5131. clif_displaymessage(fd, output);
  5132. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5133. clif_displaymessage(fd, output);
  5134. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5135. clif_displaymessage(fd, output);
  5136. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5137. clif_displaymessage(fd, output);
  5138. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5139. clif_displaymessage(fd, output);
  5140. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5141. clif_displaymessage(fd, output);
  5142. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5143. clif_displaymessage(fd, output);
  5144. switch (list) {
  5145. case 0:
  5146. // Do nothing. It's list 0, no additional display.
  5147. break;
  5148. case 1:
  5149. clif_displaymessage(fd, "----- Players in Map -----");
  5150. for (i = 0; i < fd_max; i++) {
  5151. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5152. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5153. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5154. clif_displaymessage(fd, output);
  5155. }
  5156. }
  5157. break;
  5158. case 2:
  5159. clif_displaymessage(fd, "----- NPCs in Map -----");
  5160. for (i = 0; i < map[m_id].npc_num;) {
  5161. nd = map[m_id].npc[i];
  5162. switch(nd->dir) {
  5163. case 0: strcpy(direction, "North"); break;
  5164. case 1: strcpy(direction, "North West"); break;
  5165. case 2: strcpy(direction, "West"); break;
  5166. case 3: strcpy(direction, "South West"); break;
  5167. case 4: strcpy(direction, "South"); break;
  5168. case 5: strcpy(direction, "South East"); break;
  5169. case 6: strcpy(direction, "East"); break;
  5170. case 7: strcpy(direction, "North East"); break;
  5171. case 9: strcpy(direction, "North"); break;
  5172. default: strcpy(direction, "Unknown"); break;
  5173. }
  5174. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5175. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5176. clif_displaymessage(fd, output);
  5177. }
  5178. break;
  5179. case 3:
  5180. clif_displaymessage(fd, "----- Chats in Map -----");
  5181. for (i = 0; i < fd_max; i++) {
  5182. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5183. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5184. strcmp(pl_sd->mapname, map_name) == 0 &&
  5185. cd->usersd[0] == pl_sd) {
  5186. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5187. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5188. clif_displaymessage(fd, output);
  5189. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5190. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5191. clif_displaymessage(fd, output);
  5192. }
  5193. }
  5194. break;
  5195. default: // normally impossible to arrive here
  5196. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5197. return -1;
  5198. break;
  5199. }
  5200. return 0;
  5201. }
  5202. /*==========================================
  5203. *
  5204. *------------------------------------------
  5205. */
  5206. int atcommand_mount_peco(
  5207. const int fd, struct map_session_data* sd,
  5208. const char* command, const char* message)
  5209. {
  5210. nullpo_retr(-1, sd);
  5211. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5212. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5213. return -1;
  5214. }
  5215. if (!pc_isriding(sd)) { // if actually no peco
  5216. if (sd->status.class_ == 7 || sd->status.class_ == 14 || sd->status.class_ == 4008 || sd->status.class_ == 4015) {
  5217. if (sd->status.class_ == 7)
  5218. sd->status.class_ = sd->view_class = 13;
  5219. else if (sd->status.class_ == 14)
  5220. sd->status.class_ = sd->view_class = 21;
  5221. else if (sd->status.class_ == 4008)
  5222. sd->status.class_ = sd->view_class = 4014;
  5223. else if (sd->status.class_ == 4015)
  5224. sd->status.class_ = sd->view_class = 4022;
  5225. pc_setoption(sd, sd->status.option | 0x0020);
  5226. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5227. } else {
  5228. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5229. return -1;
  5230. }
  5231. } else {
  5232. if (sd->status.class_ == 13)
  5233. sd->status.class_ = sd->view_class = 7;
  5234. else if (sd->status.class_ == 21)
  5235. sd->status.class_ = sd->view_class = 14;
  5236. else if (sd->status.class_ == 4014)
  5237. sd->status.class_ = sd->view_class = 4008;
  5238. else if (sd->status.class_ == 4022)
  5239. sd->status.class_ = sd->view_class = 4015;
  5240. pc_setoption(sd, sd->status.option & ~0x0020);
  5241. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5242. }
  5243. return 0;
  5244. }
  5245. /*==========================================
  5246. *
  5247. *------------------------------------------
  5248. */
  5249. int atcommand_char_mount_peco(
  5250. const int fd, struct map_session_data* sd,
  5251. const char* command, const char* message)
  5252. {
  5253. char character[100];
  5254. struct map_session_data *pl_sd;
  5255. nullpo_retr(-1, sd);
  5256. memset(character, '\0', sizeof(character));
  5257. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5258. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5259. return -1;
  5260. }
  5261. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5262. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5263. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5264. return -1;
  5265. }
  5266. if (!pc_isriding(pl_sd)) { // if actually no peco
  5267. if (pl_sd->status.class_ == 7 || pl_sd->status.class_ == 14 || pl_sd->status.class_ == 4008 || pl_sd->status.class_ == 4015) {
  5268. if (pl_sd->status.class_ == 7)
  5269. pl_sd->status.class_ = pl_sd->view_class = 13;
  5270. else if (pl_sd->status.class_ == 14)
  5271. pl_sd->status.class_ = pl_sd->view_class = 21;
  5272. else if (pl_sd->status.class_ == 4008)
  5273. pl_sd->status.class_ = pl_sd->view_class = 4014;
  5274. else if (pl_sd->status.class_ == 4015)
  5275. pl_sd->status.class_ = pl_sd->view_class = 4022;
  5276. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5277. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5278. } else {
  5279. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5280. return -1;
  5281. }
  5282. } else {
  5283. if (pl_sd->status.class_ == 13)
  5284. pl_sd->status.class_ = pl_sd->view_class = 7;
  5285. else if (pl_sd->status.class_ == 21)
  5286. pl_sd->status.class_ = pl_sd->view_class = 14;
  5287. else if (pl_sd->status.class_ == 4014)
  5288. pl_sd->status.class_ = pl_sd->view_class = 4008;
  5289. else if (pl_sd->status.class_ == 4022)
  5290. pl_sd->status.class_ = pl_sd->view_class = 4015;
  5291. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5292. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5293. }
  5294. } else {
  5295. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5296. return -1;
  5297. }
  5298. return 0;
  5299. }
  5300. /*==========================================
  5301. *Spy Commands by Syrus22
  5302. *------------------------------------------
  5303. */
  5304. int atcommand_guildspy(
  5305. const int fd, struct map_session_data* sd,
  5306. const char* command, const char* message)
  5307. {
  5308. char guild_name[100];
  5309. char output[200];
  5310. struct guild *g;
  5311. nullpo_retr(-1, sd);
  5312. memset(guild_name, '\0', sizeof(guild_name));
  5313. memset(output, '\0', sizeof(output));
  5314. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5315. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5316. return -1;
  5317. }
  5318. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5319. (g = guild_search(atoi(message))) != NULL) {
  5320. if (sd->guildspy == g->guild_id) {
  5321. sd->guildspy = 0;
  5322. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5323. clif_displaymessage(fd, output);
  5324. } else {
  5325. sd->guildspy = g->guild_id;
  5326. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5327. clif_displaymessage(fd, output);
  5328. }
  5329. } else {
  5330. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5331. return -1;
  5332. }
  5333. return 0;
  5334. }
  5335. /*==========================================
  5336. *
  5337. *------------------------------------------
  5338. */
  5339. int atcommand_partyspy(
  5340. const int fd, struct map_session_data* sd,
  5341. const char* command, const char* message)
  5342. {
  5343. char party_name[100];
  5344. char output[200];
  5345. struct party *p;
  5346. nullpo_retr(-1, sd);
  5347. memset(party_name, '\0', sizeof(party_name));
  5348. memset(output, '\0', sizeof(output));
  5349. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5350. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5351. return -1;
  5352. }
  5353. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5354. (p = party_search(atoi(message))) != NULL) {
  5355. if (sd->partyspy == p->party_id) {
  5356. sd->partyspy = 0;
  5357. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5358. clif_displaymessage(fd, output);
  5359. } else {
  5360. sd->partyspy = p->party_id;
  5361. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5362. clif_displaymessage(fd, output);
  5363. }
  5364. } else {
  5365. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5366. return -1;
  5367. }
  5368. return 0;
  5369. }
  5370. /*==========================================
  5371. * @repairall [Valaris]
  5372. *------------------------------------------
  5373. */
  5374. int atcommand_repairall(
  5375. const int fd, struct map_session_data* sd,
  5376. const char* command, const char* message)
  5377. {
  5378. int count, i;
  5379. nullpo_retr(-1, sd);
  5380. count = 0;
  5381. for (i = 0; i < MAX_INVENTORY; i++) {
  5382. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5383. sd->status.inventory[i].attribute = 0;
  5384. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5385. count++;
  5386. }
  5387. }
  5388. if (count > 0) {
  5389. clif_misceffect(&sd->bl, 3);
  5390. clif_equiplist(sd);
  5391. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5392. } else {
  5393. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5394. return -1;
  5395. }
  5396. return 0;
  5397. }
  5398. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5399. int atcommand_nuke(
  5400. const int fd, struct map_session_data* sd,
  5401. const char* command, const char* message)
  5402. {
  5403. char character[100];
  5404. struct map_session_data *pl_sd;
  5405. nullpo_retr(-1, sd);
  5406. memset(character, '\0', sizeof(character));
  5407. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5408. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5409. return -1;
  5410. }
  5411. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5412. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5413. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5414. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5415. } else {
  5416. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5417. return -1;
  5418. }
  5419. } else {
  5420. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5421. return -1;
  5422. }
  5423. return 0;
  5424. }
  5425. /*==========================================
  5426. *
  5427. *------------------------------------------
  5428. */
  5429. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5430. const char* command, const char* message)
  5431. {
  5432. char NPCname[100];
  5433. nullpo_retr(-1, sd);
  5434. memset(NPCname, '\0', sizeof(NPCname));
  5435. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5436. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5437. return -1;
  5438. }
  5439. if (npc_name2id(NPCname) != NULL) {
  5440. npc_enable(NPCname, 1);
  5441. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5442. } else {
  5443. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5444. return -1;
  5445. }
  5446. return 0;
  5447. }
  5448. /*==========================================
  5449. *
  5450. *------------------------------------------
  5451. */
  5452. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5453. const char* command, const char* message)
  5454. {
  5455. char NPCname[100];
  5456. nullpo_retr(-1, sd);
  5457. memset(NPCname, '\0', sizeof(NPCname));
  5458. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5459. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5460. return -1;
  5461. }
  5462. if (npc_name2id(NPCname) != NULL) {
  5463. npc_enable(NPCname, 0);
  5464. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5465. } else {
  5466. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5467. return -1;
  5468. }
  5469. return 0;
  5470. }
  5471. /*==========================================
  5472. * time in txt for time command (by [Yor])
  5473. *------------------------------------------
  5474. */
  5475. char * txt_time(unsigned int duration) {
  5476. int days, hours, minutes, seconds;
  5477. char temp[256];
  5478. static char temp1[256];
  5479. memset(temp, '\0', sizeof(temp));
  5480. memset(temp1, '\0', sizeof(temp1));
  5481. if (duration < 0)
  5482. duration = 0;
  5483. days = duration / (60 * 60 * 24);
  5484. duration = duration - (60 * 60 * 24 * days);
  5485. hours = duration / (60 * 60);
  5486. duration = duration - (60 * 60 * hours);
  5487. minutes = duration / 60;
  5488. seconds = duration - (60 * minutes);
  5489. if (days < 2)
  5490. sprintf(temp, msg_table[219], days); // %d day
  5491. else
  5492. sprintf(temp, msg_table[220], days); // %d days
  5493. if (hours < 2)
  5494. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5495. else
  5496. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5497. if (minutes < 2)
  5498. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5499. else
  5500. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5501. if (seconds < 2)
  5502. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5503. else
  5504. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5505. return temp1;
  5506. }
  5507. /*==========================================
  5508. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5509. * Calculation management of GM modification (@day/@night GM commands) is done
  5510. *------------------------------------------
  5511. */
  5512. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5513. const char* command, const char* message)
  5514. {
  5515. struct TimerData * timer_data;
  5516. struct TimerData * timer_data2;
  5517. time_t time_server; // variable for number of seconds (used with time() function)
  5518. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5519. char temp[256];
  5520. nullpo_retr(-1, sd);
  5521. memset(temp, '\0', sizeof(temp));
  5522. time(&time_server); // get time in seconds since 1/1/1970
  5523. datetime = localtime(&time_server); // convert seconds in structure
  5524. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5525. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5526. clif_displaymessage(fd, temp);
  5527. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5528. if (night_flag == 0)
  5529. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5530. else
  5531. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5532. } else if (battle_config.night_duration == 0)
  5533. if (night_flag == 1) { // we start with night
  5534. timer_data = get_timer(day_timer_tid);
  5535. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5536. clif_displaymessage(fd, temp);
  5537. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5538. } else
  5539. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5540. else if (battle_config.day_duration == 0)
  5541. if (night_flag == 0) { // we start with day
  5542. timer_data = get_timer(night_timer_tid);
  5543. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5544. clif_displaymessage(fd, temp);
  5545. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5546. } else
  5547. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5548. else {
  5549. if (night_flag == 0) {
  5550. timer_data = get_timer(night_timer_tid);
  5551. timer_data2 = get_timer(day_timer_tid);
  5552. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5553. clif_displaymessage(fd, temp);
  5554. if (timer_data->tick > timer_data2->tick)
  5555. sprintf(temp, msg_table[237], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5556. else
  5557. sprintf(temp, msg_table[237], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in night for %s.
  5558. clif_displaymessage(fd, temp);
  5559. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5560. clif_displaymessage(fd, temp);
  5561. } else {
  5562. timer_data = get_timer(day_timer_tid);
  5563. timer_data2 = get_timer(night_timer_tid);
  5564. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5565. clif_displaymessage(fd, temp);
  5566. if (timer_data->tick > timer_data2->tick)
  5567. sprintf(temp, msg_table[239], txt_time((timer_data->interval - abs(timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5568. else
  5569. sprintf(temp, msg_table[239], txt_time(abs(timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5570. clif_displaymessage(fd, temp);
  5571. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5572. clif_displaymessage(fd, temp);
  5573. }
  5574. }
  5575. return 0;
  5576. }
  5577. /*==========================================
  5578. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5579. * removes <quantity> item from a character
  5580. * item can be equiped or not.
  5581. * Inspired from a old command created by RoVeRT
  5582. *------------------------------------------
  5583. */
  5584. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5585. const char* command, const char* message)
  5586. {
  5587. struct map_session_data *pl_sd;
  5588. char character[100];
  5589. char item_name[100];
  5590. int i, number = 0, item_id, item_position, count;
  5591. char output[200];
  5592. struct item_data *item_data;
  5593. nullpo_retr(-1, sd);
  5594. memset(character, '\0', sizeof(character));
  5595. memset(item_name, '\0', sizeof(item_name));
  5596. memset(output, '\0', sizeof(output));
  5597. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5598. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5599. return -1;
  5600. }
  5601. item_id = 0;
  5602. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5603. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5604. item_id = item_data->nameid;
  5605. if (item_id > 500) {
  5606. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5607. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5608. item_position = pc_search_inventory(pl_sd, item_id);
  5609. if (item_position >= 0) {
  5610. count = 0;
  5611. for(i = 0; i < number && item_position >= 0; i++) {
  5612. pc_delitem(pl_sd, item_position, 1, 0);
  5613. count++;
  5614. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5615. }
  5616. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5617. clif_displaymessage(pl_sd->fd, output);
  5618. if (number == count)
  5619. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5620. else
  5621. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5622. clif_displaymessage(fd, output);
  5623. } else {
  5624. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5625. return -1;
  5626. }
  5627. } else {
  5628. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5629. return -1;
  5630. }
  5631. } else {
  5632. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5633. return -1;
  5634. }
  5635. } else {
  5636. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5637. return -1;
  5638. }
  5639. return 0;
  5640. }
  5641. /*==========================================
  5642. * @jail <char_name> by [Yor]
  5643. * Special warp! No check with nowarp and nowarpto flag
  5644. *------------------------------------------
  5645. */
  5646. int atcommand_jail(
  5647. const int fd, struct map_session_data* sd,
  5648. const char* command, const char* message)
  5649. {
  5650. char character[100];
  5651. struct map_session_data *pl_sd;
  5652. int x, y;
  5653. nullpo_retr(-1, sd);
  5654. memset(character, '\0', sizeof(character));
  5655. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5656. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5657. return -1;
  5658. }
  5659. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5660. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5661. switch(rand() % 2) {
  5662. case 0:
  5663. x = 24;
  5664. y = 75;
  5665. break;
  5666. default:
  5667. x = 49;
  5668. y = 75;
  5669. break;
  5670. }
  5671. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5672. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5673. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5674. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5675. } else {
  5676. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5677. return -1;
  5678. }
  5679. } else {
  5680. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5681. return -1;
  5682. }
  5683. } else {
  5684. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5685. return -1;
  5686. }
  5687. return 0;
  5688. }
  5689. /*==========================================
  5690. * @unjail/@discharge <char_name> by [Yor]
  5691. * Special warp! No check with nowarp and nowarpto flag
  5692. *------------------------------------------
  5693. */
  5694. int atcommand_unjail(
  5695. const int fd, struct map_session_data* sd,
  5696. const char* command, const char* message)
  5697. {
  5698. char character[100];
  5699. struct map_session_data *pl_sd;
  5700. memset(character, '\0', sizeof(character));
  5701. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5702. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5703. return -1;
  5704. }
  5705. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5706. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5707. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5708. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5709. return -1;
  5710. } else if (pc_setpos(pl_sd, "prontera.gat", 0, 0, 3) == 0) { //old coords: 156,191
  5711. pc_setsavepoint(pl_sd, "prontera.gat", 0, 0); // Save char respawn point in Prontera
  5712. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5713. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5714. } else {
  5715. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5716. return -1;
  5717. }
  5718. } else {
  5719. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5720. return -1;
  5721. }
  5722. } else {
  5723. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5724. return -1;
  5725. }
  5726. return 0;
  5727. }
  5728. /*==========================================
  5729. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5730. *------------------------------------------
  5731. */
  5732. int atcommand_disguise(
  5733. const int fd, struct map_session_data* sd,
  5734. const char* command, const char* message)
  5735. {
  5736. int mob_id = 0;
  5737. nullpo_retr(-1, sd);
  5738. if (!message || !*message) {
  5739. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5740. return -1;
  5741. }
  5742. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5743. mob_id = atoi(message);
  5744. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5745. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5746. (mob_id >= 813 && mob_id <= 834) || // NPC
  5747. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5748. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5749. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5750. return -1;
  5751. }
  5752. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5753. sd->disguise = mob_id;
  5754. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5755. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5756. } else {
  5757. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5758. return -1;
  5759. }
  5760. return 0;
  5761. }
  5762. /*==========================================
  5763. * DisguiseAll
  5764. *------------------------------------------
  5765. */
  5766. int atcommand_disguiseall(
  5767. const int fd, struct map_session_data* sd,
  5768. const char* command, const char* message)
  5769. {
  5770. int mob_id=0, i=0;
  5771. struct map_session_data *pl_sd;
  5772. nullpo_retr(-1, sd);
  5773. if (!message || !*message) {
  5774. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5775. return -1;
  5776. }
  5777. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5778. mob_id = atoi(message);
  5779. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5780. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5781. (mob_id >= 813 && mob_id <= 834) || // NPC
  5782. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5783. for(i=0; i < fd_max; i++) {
  5784. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5785. if(pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5786. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5787. } else {
  5788. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5789. pl_sd->disguise = mob_id;
  5790. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5791. }
  5792. }
  5793. }
  5794. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5795. } else {
  5796. return -1;
  5797. }
  5798. return 0;
  5799. }
  5800. /*==========================================
  5801. * @undisguise by [Yor]
  5802. *------------------------------------------
  5803. */
  5804. int atcommand_undisguise(
  5805. const int fd, struct map_session_data* sd,
  5806. const char* command, const char* message)
  5807. {
  5808. nullpo_retr(-1, sd);
  5809. if (sd->disguise) {
  5810. clif_clearchar(&sd->bl, 9);
  5811. sd->disguise = 0;
  5812. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5813. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5814. } else {
  5815. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5816. return -1;
  5817. }
  5818. return 0;
  5819. }
  5820. /*==========================================
  5821. * UndisguiseAll
  5822. *------------------------------------------
  5823. */
  5824. int atcommand_undisguiseall(
  5825. const int fd, struct map_session_data* sd,
  5826. const char* command, const char* message)
  5827. {
  5828. struct map_session_data *pl_sd;
  5829. int i;
  5830. nullpo_retr(-1, sd);
  5831. for(i=0; i < fd_max; i++) {
  5832. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && pl_sd->disguise) {
  5833. clif_clearchar(&pl_sd->bl, 9);
  5834. pl_sd->disguise = 0;
  5835. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5836. }
  5837. }
  5838. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5839. return 0;
  5840. }
  5841. /*==========================================
  5842. * @broadcast by [Valaris]
  5843. *------------------------------------------
  5844. */
  5845. int atcommand_broadcast(
  5846. const int fd, struct map_session_data* sd,
  5847. const char* command, const char* message)
  5848. {
  5849. char output[200];
  5850. nullpo_retr(-1, sd);
  5851. memset(output, '\0', sizeof(output));
  5852. if (!message || !*message) {
  5853. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5854. return -1;
  5855. }
  5856. sprintf(output, "%s : %s", sd->status.name, message);
  5857. intif_GMmessage(output, strlen(output) + 1, 0);
  5858. return 0;
  5859. }
  5860. /*==========================================
  5861. * @localbroadcast by [Valaris]
  5862. *------------------------------------------
  5863. */
  5864. int atcommand_localbroadcast(
  5865. const int fd, struct map_session_data* sd,
  5866. const char* command, const char* message)
  5867. {
  5868. char output[200];
  5869. nullpo_retr(-1, sd);
  5870. memset(output, '\0', sizeof(output));
  5871. if (!message || !*message) {
  5872. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5873. return -1;
  5874. }
  5875. sprintf(output, "%s : %s", sd->status.name, message);
  5876. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5877. return 0;
  5878. }
  5879. /*==========================================
  5880. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5881. *------------------------------------------
  5882. */
  5883. int atcommand_chardisguise(
  5884. const int fd, struct map_session_data* sd,
  5885. const char* command, const char* message)
  5886. {
  5887. int mob_id;
  5888. char character[100];
  5889. char mob_name[100];
  5890. struct map_session_data* pl_sd;
  5891. nullpo_retr(-1, sd);
  5892. memset(character, '\0', sizeof(character));
  5893. memset(mob_name, '\0', sizeof(mob_name));
  5894. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5895. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5896. return -1;
  5897. }
  5898. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5899. mob_id = atoi(mob_name);
  5900. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5901. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5902. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5903. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5904. (mob_id >= 813 && mob_id <= 834) || // NPC
  5905. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5906. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5907. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5908. return -1;
  5909. }
  5910. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5911. pl_sd->disguise = mob_id;
  5912. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5913. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5914. } else {
  5915. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5916. return -1;
  5917. }
  5918. } else {
  5919. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5920. return -1;
  5921. }
  5922. } else {
  5923. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5924. return -1;
  5925. }
  5926. return 0;
  5927. }
  5928. /*==========================================
  5929. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5930. *------------------------------------------
  5931. */
  5932. int atcommand_charundisguise(
  5933. const int fd, struct map_session_data* sd,
  5934. const char* command, const char* message)
  5935. {
  5936. char character[100];
  5937. struct map_session_data* pl_sd;
  5938. nullpo_retr(-1, sd);
  5939. memset(character, '\0', sizeof(character));
  5940. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5941. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5942. return -1;
  5943. }
  5944. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5945. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5946. if (pl_sd->disguise) {
  5947. clif_clearchar(&pl_sd->bl, 9);
  5948. pl_sd->disguise = 0;
  5949. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5950. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5951. } else {
  5952. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5953. return -1;
  5954. }
  5955. } else {
  5956. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5957. return -1;
  5958. }
  5959. } else {
  5960. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5961. return -1;
  5962. }
  5963. return 0;
  5964. }
  5965. /*==========================================
  5966. * @email <actual@email> <new@email> by [Yor]
  5967. *------------------------------------------
  5968. */
  5969. int atcommand_email(
  5970. const int fd, struct map_session_data* sd,
  5971. const char* command, const char* message)
  5972. {
  5973. char actual_email[100];
  5974. char new_email[100];
  5975. nullpo_retr(-1, sd);
  5976. memset(actual_email, '\0', sizeof(actual_email));
  5977. memset(new_email, '\0', sizeof(new_email));
  5978. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5979. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5980. return -1;
  5981. }
  5982. if (e_mail_check(actual_email) == 0) {
  5983. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5984. return -1;
  5985. } else if (e_mail_check(new_email) == 0) {
  5986. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5987. return -1;
  5988. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5989. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5990. return -1;
  5991. } else if (strcmpi(actual_email, new_email) == 0) {
  5992. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5993. return -1;
  5994. } else {
  5995. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5996. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5997. }
  5998. return 0;
  5999. }
  6000. /*==========================================
  6001. *@effect
  6002. *------------------------------------------
  6003. */
  6004. int atcommand_effect(
  6005. const int fd, struct map_session_data* sd,
  6006. const char* command, const char* message)
  6007. {
  6008. struct map_session_data *pl_sd;
  6009. int type = 0, flag = 0, i;
  6010. nullpo_retr(-1, sd);
  6011. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  6012. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  6013. return -1;
  6014. }
  6015. if(flag <=0){
  6016. clif_specialeffect(&sd->bl, type, flag);
  6017. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  6018. }
  6019. else{
  6020. for (i = 0; i < fd_max; i++) {
  6021. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  6022. clif_specialeffect(&pl_sd->bl, type, flag);
  6023. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  6024. }
  6025. }
  6026. }
  6027. return 0;
  6028. }
  6029. /*==========================================
  6030. * @charcartlist <character>: Displays the items list of a player's cart.
  6031. *------------------------------------------
  6032. */
  6033. int
  6034. atcommand_character_cart_list(
  6035. const int fd, struct map_session_data* sd,
  6036. const char* command, const char* message)
  6037. {
  6038. struct map_session_data *pl_sd;
  6039. struct item_data *item_data, *item_temp;
  6040. int i, j, count, counter, counter2;
  6041. char character[100], output[200], outputtmp[200];
  6042. nullpo_retr(-1, sd);
  6043. memset(character, '\0', sizeof(character));
  6044. memset(output, '\0', sizeof(output));
  6045. memset(outputtmp, '\0', sizeof(outputtmp));
  6046. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6047. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6048. return -1;
  6049. }
  6050. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6051. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6052. counter = 0;
  6053. count = 0;
  6054. for (i = 0; i < MAX_CART; i++) {
  6055. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6056. counter = counter + pl_sd->status.cart[i].amount;
  6057. count++;
  6058. if (count == 1) {
  6059. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6060. clif_displaymessage(fd, output);
  6061. }
  6062. if (pl_sd->status.cart[i].refine)
  6063. sprintf(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);
  6064. else
  6065. sprintf(output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6066. clif_displaymessage(fd, output);
  6067. memset(output, '\0', sizeof(output));
  6068. counter2 = 0;
  6069. for (j = 0; j < item_data->slot; j++) {
  6070. if (pl_sd->status.cart[i].card[j]) {
  6071. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6072. if (output[0] == '\0')
  6073. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6074. else
  6075. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6076. strcat(output, outputtmp);
  6077. }
  6078. }
  6079. }
  6080. if (output[0] != '\0') {
  6081. output[strlen(output) - 2] = ')';
  6082. output[strlen(output) - 1] = '\0';
  6083. clif_displaymessage(fd, output);
  6084. }
  6085. }
  6086. }
  6087. if (count == 0)
  6088. clif_displaymessage(fd, "No item found in the cart of this player.");
  6089. else {
  6090. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6091. clif_displaymessage(fd, output);
  6092. }
  6093. } else {
  6094. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6095. return -1;
  6096. }
  6097. } else {
  6098. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6099. return -1;
  6100. }
  6101. return 0;
  6102. }
  6103. /*==========================================
  6104. * @killer by MouseJstr
  6105. * enable killing players even when not in pvp
  6106. *------------------------------------------
  6107. */
  6108. int
  6109. atcommand_killer(
  6110. const int fd, struct map_session_data* sd,
  6111. const char* command, const char* message)
  6112. {
  6113. nullpo_retr(-1, sd);
  6114. sd->special_state.killer = !sd->special_state.killer;
  6115. if(sd->special_state.killer)
  6116. clif_displaymessage(fd, msg_table[241]);
  6117. else
  6118. clif_displaymessage(fd, msg_table[242]);
  6119. return 0;
  6120. }
  6121. /*==========================================
  6122. * @killable by MouseJstr
  6123. * enable other people killing you
  6124. *------------------------------------------
  6125. */
  6126. int
  6127. atcommand_killable(
  6128. const int fd, struct map_session_data* sd,
  6129. const char* command, const char* message)
  6130. {
  6131. nullpo_retr(-1, sd);
  6132. sd->special_state.killable = !sd->special_state.killable;
  6133. if(sd->special_state.killable)
  6134. clif_displaymessage(fd, msg_table[242]);
  6135. else
  6136. clif_displaymessage(fd, msg_table[241]);
  6137. return 0;
  6138. }
  6139. /*==========================================
  6140. * @charkillable by MouseJstr
  6141. * enable another player to be killed
  6142. *------------------------------------------
  6143. */
  6144. int
  6145. atcommand_charkillable(
  6146. const int fd, struct map_session_data* sd,
  6147. const char* command, const char* message)
  6148. {
  6149. struct map_session_data *pl_sd = NULL;
  6150. nullpo_retr(-1, sd);
  6151. if (!message || !*message)
  6152. return -1;
  6153. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6154. return -1;
  6155. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6156. if(pl_sd->special_state.killable)
  6157. clif_displaymessage(fd, "The player is now killable");
  6158. else
  6159. clif_displaymessage(fd, "The player is no longer killable");
  6160. return 0;
  6161. }
  6162. /*==========================================
  6163. * @skillon by MouseJstr
  6164. * turn skills on for the map
  6165. *------------------------------------------
  6166. */
  6167. int
  6168. atcommand_skillon(
  6169. const int fd, struct map_session_data* sd,
  6170. const char* command, const char* message)
  6171. {
  6172. nullpo_retr(-1, sd);
  6173. map[sd->bl.m].flag.noskill = 0;
  6174. clif_displaymessage(fd, msg_table[244]);
  6175. return 0;
  6176. }
  6177. /*==========================================
  6178. * @skilloff by MouseJstr
  6179. * Turn skills off on the map
  6180. *------------------------------------------
  6181. */
  6182. int
  6183. atcommand_skilloff(
  6184. const int fd, struct map_session_data* sd,
  6185. const char* command, const char* message)
  6186. {
  6187. nullpo_retr(-1, sd);
  6188. map[sd->bl.m].flag.noskill = 1;
  6189. clif_displaymessage(fd, msg_table[243]);
  6190. return 0;
  6191. }
  6192. /*==========================================
  6193. * @npcmove by MouseJstr
  6194. *
  6195. * move a npc
  6196. *------------------------------------------
  6197. */
  6198. int
  6199. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6200. const char* command, const char* message)
  6201. {
  6202. char character[100];
  6203. int x = 0, y = 0;
  6204. struct npc_data *nd = 0;
  6205. nullpo_retr(-1, sd);
  6206. if (!message || !*message)
  6207. return -1;
  6208. memset(character, '\0', sizeof character);
  6209. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6210. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6211. return -1;
  6212. }
  6213. nullpo_retr(-1, (nd = npc_name2id(character)));
  6214. npc_enable(character, 0);
  6215. nd->bl.x = x;
  6216. nd->bl.y = y;
  6217. npc_enable(character, 1);
  6218. return 0;
  6219. }
  6220. /*==========================================
  6221. * @addwarp by MouseJstr
  6222. *
  6223. * Create a new static warp point.
  6224. *------------------------------------------
  6225. */
  6226. int
  6227. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6228. const char* command, const char* message)
  6229. {
  6230. char w1[64], w3[64], w4[64];
  6231. char map[30], output[200];
  6232. int x,y,ret;
  6233. nullpo_retr(-1, sd);
  6234. if (!message || !*message)
  6235. return -1;
  6236. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6237. return -1;
  6238. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6239. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6240. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6241. ret = npc_parse_warp(w1, "warp", w3, w4);
  6242. sprintf(output, "New warp NPC => %s",w3);
  6243. clif_displaymessage(fd, output);
  6244. return ret;
  6245. }
  6246. /*==========================================
  6247. * @follow by [MouseJstr]
  6248. *
  6249. * Follow a player .. staying no more then 5 spaces away
  6250. *------------------------------------------
  6251. */
  6252. int
  6253. atcommand_follow(const int fd, struct map_session_data* sd,
  6254. const char* command, const char* message)
  6255. {
  6256. struct map_session_data *pl_sd = NULL;
  6257. nullpo_retr(-1, sd);
  6258. if (!message || !*message)
  6259. return -1;
  6260. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6261. pc_follow(sd, pl_sd->bl.id);
  6262. else
  6263. return 1;
  6264. return 0;
  6265. }
  6266. /*==========================================
  6267. * @dropall by [MouseJstr]
  6268. *
  6269. * Drop all your possession on the ground
  6270. *------------------------------------------
  6271. */
  6272. int
  6273. atcommand_dropall(const int fd, struct map_session_data* sd,
  6274. const char* command, const char* message)
  6275. {
  6276. int i;
  6277. nullpo_retr(-1, sd);
  6278. for (i = 0; i < MAX_INVENTORY; i++) {
  6279. if (sd->status.inventory[i].amount) {
  6280. if(sd->status.inventory[i].equip != 0)
  6281. pc_unequipitem(sd, i, 3);
  6282. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6283. }
  6284. }
  6285. return 0;
  6286. }
  6287. /*==========================================
  6288. * @chardropall by [MouseJstr]
  6289. *
  6290. * Throw all the characters possessions on the ground. Normally
  6291. * done in response to them being disrespectful of a GM
  6292. *------------------------------------------
  6293. */
  6294. int
  6295. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6296. const char* command, const char* message)
  6297. {
  6298. int i;
  6299. struct map_session_data *pl_sd = NULL;
  6300. nullpo_retr(-1, sd);
  6301. if (!message || !*message)
  6302. return -1;
  6303. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6304. return -1;
  6305. for (i = 0; i < MAX_INVENTORY; i++) {
  6306. if (pl_sd->status.inventory[i].amount) {
  6307. if(pl_sd->status.inventory[i].equip != 0)
  6308. pc_unequipitem(pl_sd, i, 3);
  6309. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6310. }
  6311. }
  6312. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6313. clif_displaymessage(fd, "It is done");
  6314. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6315. return 0;
  6316. }
  6317. /*==========================================
  6318. * @storeall by [MouseJstr]
  6319. *
  6320. * Put everything into storage to simplify your inventory to make
  6321. * debugging easie
  6322. *------------------------------------------
  6323. */
  6324. int
  6325. atcommand_storeall(const int fd, struct map_session_data* sd,
  6326. const char* command, const char* message)
  6327. {
  6328. int i;
  6329. nullpo_retr(-1, sd);
  6330. if (storage_storageopen(sd) == 1) {
  6331. clif_displaymessage(fd, "run this command again..");
  6332. return 0;
  6333. }
  6334. for (i = 0; i < MAX_INVENTORY; i++) {
  6335. if (sd->status.inventory[i].amount) {
  6336. if(sd->status.inventory[i].equip != 0)
  6337. pc_unequipitem(sd, i, 3);
  6338. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6339. }
  6340. }
  6341. storage_storageclose(sd);
  6342. clif_displaymessage(fd, "It is done");
  6343. return 0;
  6344. }
  6345. /*==========================================
  6346. * @charstoreall by [MouseJstr]
  6347. *
  6348. * A way to screw with players who piss you off
  6349. *------------------------------------------
  6350. */
  6351. int
  6352. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6353. const char* command, const char* message)
  6354. {
  6355. int i;
  6356. struct map_session_data *pl_sd = NULL;
  6357. nullpo_retr(-1, sd);
  6358. if (!message || !*message)
  6359. return -1;
  6360. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6361. return -1;
  6362. if (storage_storageopen(pl_sd) == 1) {
  6363. clif_displaymessage(fd, "Had to open the characters storage window...");
  6364. clif_displaymessage(fd, "run this command again..");
  6365. return 0;
  6366. }
  6367. for (i = 0; i < MAX_INVENTORY; i++) {
  6368. if (pl_sd->status.inventory[i].amount) {
  6369. if(pl_sd->status.inventory[i].equip != 0)
  6370. pc_unequipitem(pl_sd, i, 3);
  6371. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6372. }
  6373. }
  6374. storage_storageclose(pl_sd);
  6375. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6376. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6377. clif_displaymessage(pl_sd->fd, " -- the management");
  6378. clif_displaymessage(fd, "It is done");
  6379. return 0;
  6380. }
  6381. /*==========================================
  6382. * @skillid by [MouseJstr]
  6383. *
  6384. * lookup a skill by name
  6385. *------------------------------------------
  6386. */
  6387. int
  6388. atcommand_skillid(const int fd, struct map_session_data* sd,
  6389. const char* command, const char* message)
  6390. {
  6391. int skillen = 0, idx = 0;
  6392. nullpo_retr(-1, sd);
  6393. if (!message || !*message)
  6394. return -1;
  6395. skillen = strlen(message);
  6396. while (skill_names[idx].id != 0) {
  6397. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6398. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6399. char output[255];
  6400. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6401. clif_displaymessage(fd, output);
  6402. }
  6403. idx++;
  6404. }
  6405. return 0;
  6406. }
  6407. /*==========================================
  6408. * @useskill by [MouseJstr]
  6409. *
  6410. * A way of using skills without having to find them in the skills menu
  6411. *------------------------------------------
  6412. */
  6413. int
  6414. atcommand_useskill(const int fd, struct map_session_data* sd,
  6415. const char* command, const char* message)
  6416. {
  6417. struct map_session_data *pl_sd = NULL;
  6418. int skillnum;
  6419. int skilllv;
  6420. int inf;
  6421. char target[255];
  6422. nullpo_retr(-1, sd);
  6423. if (!message || !*message)
  6424. return -1;
  6425. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6426. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6427. return -1;
  6428. }
  6429. if((pl_sd=map_nick2sd(target)) == NULL) {
  6430. return -1;
  6431. }
  6432. inf = skill_get_inf(skillnum);
  6433. if ((inf == 2) || (inf == 1))
  6434. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6435. else
  6436. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6437. return 0;
  6438. }
  6439. /*==========================================
  6440. * @skilltree by [MouseJstr]
  6441. *
  6442. * prints the skill tree for a player required to get to a skill
  6443. *------------------------------------------
  6444. */
  6445. int
  6446. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6447. const char* command, const char* message)
  6448. {
  6449. struct map_session_data *pl_sd = NULL;
  6450. int skillnum, skillidx = -1;
  6451. int meets = 1, j, c=0, s=0;
  6452. struct pc_base_job s_class;
  6453. char target[255], *tbl;
  6454. char output[255];
  6455. struct skill_tree_entry *ent;
  6456. nullpo_retr(-1, sd);
  6457. if (!message || !*message)
  6458. return -1;
  6459. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6460. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6461. return -1;
  6462. }
  6463. if((pl_sd=map_nick2sd(target)) == NULL)
  6464. return -1;
  6465. s_class = pc_calc_base_job(pl_sd->status.class_);
  6466. c = s_class.job;
  6467. s = s_class.upper;
  6468. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6469. tbl = job_name(c);
  6470. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6471. s_class.upper ? "upper" : "lower",
  6472. tbl, pc_checkskill(pl_sd, 1));
  6473. clif_displaymessage(fd, output);
  6474. for (j = 0; skill_tree[s][c][j].id != 0; j++) {
  6475. if (skill_tree[s][c][j].id == skillnum) {
  6476. skillidx = j;
  6477. break;
  6478. }
  6479. }
  6480. if (skillidx == -1) {
  6481. sprintf(output, "I do not believe the player can use that skill");
  6482. clif_displaymessage(fd, output);
  6483. return 0;
  6484. }
  6485. ent = &skill_tree[s][c][skillidx];
  6486. for(j=0;j<5;j++)
  6487. if( ent->need[j].id &&
  6488. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6489. {
  6490. int idx = 0;
  6491. char *desc;
  6492. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6493. idx++;
  6494. if (skill_names[idx].id == 0)
  6495. desc = "Unknown skill";
  6496. else
  6497. desc = skill_names[idx].desc;
  6498. sprintf(output, "player requires level %d of skill %s",
  6499. ent->need[j].lv, desc);
  6500. clif_displaymessage(fd, output);
  6501. meets = 0;
  6502. }
  6503. if (meets == 1) {
  6504. sprintf(output, "I believe the player meets all the requirements for that skill");
  6505. clif_displaymessage(fd, output);
  6506. }
  6507. return 0;
  6508. }
  6509. /*==========================================
  6510. * @marry by [MouseJstr], fixed by Lupus
  6511. *
  6512. * Marry two players
  6513. *------------------------------------------
  6514. */
  6515. int
  6516. atcommand_marry(const int fd, struct map_session_data* sd,
  6517. const char* command, const char* message)
  6518. {
  6519. struct map_session_data *pl_sd1 = NULL;
  6520. struct map_session_data *pl_sd2 = NULL;
  6521. char player1[255], player2[255];
  6522. nullpo_retr(-1, sd);
  6523. if (!message || !*message || sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6524. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>.");
  6525. return -1;
  6526. }
  6527. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6528. sprintf(player2, "Cannot find player '%s' online", player1);
  6529. clif_displaymessage(fd, player2);
  6530. return -1;
  6531. }
  6532. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6533. sprintf(player1, "Cannot find player '%s' online", player2);
  6534. clif_displaymessage(fd, player1);
  6535. return -1;
  6536. }
  6537. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6538. clif_displaymessage(fd, "They are married.. wish them well");
  6539. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6540. return 0;
  6541. }
  6542. return -1;
  6543. }
  6544. /*==========================================
  6545. * @divorce by [MouseJstr], fixed by [Lupus]
  6546. *
  6547. * divorce two players
  6548. *------------------------------------------
  6549. */
  6550. int
  6551. atcommand_divorce(const int fd, struct map_session_data* sd,
  6552. const char* command, const char* message)
  6553. {
  6554. struct map_session_data *pl_sd = NULL;
  6555. char player[255], output[255];
  6556. nullpo_retr(-1, sd);
  6557. if (!message || !*message || sscanf(message, "%[^\r\n]", player) != 1) {
  6558. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6559. return -1;
  6560. }
  6561. if((pl_sd=map_nick2sd((char *) player)) != NULL) {
  6562. if (pc_divorce(pl_sd) != 0) {
  6563. sprintf(output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", player);
  6564. clif_displaymessage(fd, output);
  6565. return -1;
  6566. } else {
  6567. sprintf(output, "'%s' and his(her) partner are now divorced.", player);
  6568. clif_displaymessage(fd, output);
  6569. return 0;
  6570. }
  6571. }
  6572. sprintf(output, "Cannot find player '%s' online", player);
  6573. clif_displaymessage(fd, output);
  6574. return -1;
  6575. }
  6576. /*==========================================
  6577. * @rings by [MouseJstr]
  6578. *
  6579. * Give two players rings
  6580. *------------------------------------------
  6581. */
  6582. int
  6583. atcommand_rings(const int fd, struct map_session_data* sd,
  6584. const char* command, const char* message)
  6585. {
  6586. struct item item_tmp;
  6587. int flag;
  6588. memset(&item_tmp, 0, sizeof(item_tmp));
  6589. item_tmp.nameid = 2634;
  6590. item_tmp.identify = 1;
  6591. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6592. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6593. item_tmp.nameid = 2635;
  6594. item_tmp.identify = 1;
  6595. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6596. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6597. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6598. return 0;
  6599. }
  6600. #ifdef DMALLOC
  6601. unsigned long dmark_;
  6602. int
  6603. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6604. const char* command, const char* message)
  6605. {
  6606. dmark_ = dmalloc_mark();
  6607. clif_displaymessage(fd, "debug mark set");
  6608. return 0;
  6609. }
  6610. int
  6611. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6612. const char* command, const char* message)
  6613. {
  6614. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6615. dmark_ = dmalloc_mark();
  6616. clif_displaymessage(fd, "malloc changes logged");
  6617. return 0;
  6618. }
  6619. #endif
  6620. /*==========================================
  6621. * @grind by [MouseJstr]
  6622. *------------------------------------------
  6623. */
  6624. int
  6625. atcommand_grind(const int fd, struct map_session_data* sd,
  6626. const char* command, const char* message)
  6627. {
  6628. struct map_session_data *pl_sd = NULL;
  6629. int skillnum;
  6630. int inf;
  6631. char target[255];
  6632. nullpo_retr(-1, sd);
  6633. if (!message || !*message)
  6634. return -1;
  6635. if(sscanf(message, "%s", target) != 1) {
  6636. clif_displaymessage(fd, "Usage: @grind <target>");
  6637. return -1;
  6638. }
  6639. if((pl_sd=map_nick2sd(target)) == NULL)
  6640. return -1;
  6641. for (skillnum = 1; skillnum < 500; skillnum++) {
  6642. sd->status.sp = sd->status.max_sp;
  6643. atcommand_alive(fd, sd, command, message);
  6644. inf = skill_get_inf(skillnum);
  6645. if ((inf == 2) || (inf == 1))
  6646. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6647. else
  6648. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6649. }
  6650. return 0;
  6651. }
  6652. /*==========================================
  6653. * @grind2 by [MouseJstr]
  6654. *------------------------------------------
  6655. */
  6656. int
  6657. atcommand_grind2(const int fd, struct map_session_data* sd,
  6658. const char* command, const char* message)
  6659. {
  6660. int i, x, y, id;
  6661. for (i = 1000; i <2000; i++) {
  6662. x = sd->bl.x + (rand() % 10 - 5);
  6663. y = sd->bl.y + (rand() % 10 - 5);
  6664. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6665. }
  6666. return 0;
  6667. }
  6668. /*==========================================
  6669. * @changelook by [Celest]
  6670. *------------------------------------------
  6671. */
  6672. int
  6673. atcommand_changelook(const int fd, struct map_session_data* sd,
  6674. const char* command, const char* message)
  6675. {
  6676. int i, j = 0, k = 0;
  6677. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6678. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6679. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6680. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6681. return -1;
  6682. } else if (i == 2) {
  6683. if (j < 1) j = 1;
  6684. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6685. j = pos[j - 1];
  6686. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6687. k = j; // swap
  6688. j = LOOK_HEAD_TOP;
  6689. }
  6690. clif_changelook(&sd->bl,j,k);
  6691. return 0;
  6692. }
  6693. /*==========================================
  6694. *Turns on/off AutoLoot for a specific player
  6695. *------------------------------------------
  6696. *by Upa-Kun
  6697. */
  6698. int
  6699. atcommand_autoloot(
  6700. const int fd, struct map_session_data* sd,
  6701. const char* command, const char* message)
  6702. {
  6703. nullpo_retr(-1, sd);
  6704. if (sd->autoloot)
  6705. {
  6706. sd->autoloot = 0;
  6707. clif_displaymessage(fd, "Autoloot is now off.");
  6708. }
  6709. else
  6710. {
  6711. sd->autoloot = 1;
  6712. clif_displaymessage(fd, "Autoloot is now on.");
  6713. }
  6714. return 0;
  6715. }
  6716. /*==========================================
  6717. * It is made to rain.
  6718. *------------------------------------------
  6719. */
  6720. int
  6721. atcommand_rain(
  6722. const int fd, struct map_session_data* sd,
  6723. const char* command, const char* message)
  6724. {
  6725. int effno = 0;
  6726. nullpo_retr(-1, sd);
  6727. effno = 161;
  6728. if (map[sd->bl.m].flag.rain) {
  6729. map[sd->bl.m].flag.rain=0;
  6730. clif_displaymessage(fd, "The rain has stopped.");
  6731. } else {
  6732. map[sd->bl.m].flag.rain=1;
  6733. clif_specialeffect(&sd->bl,effno,2);
  6734. clif_displaymessage(fd, "It is made to rain.");
  6735. }
  6736. return 0;
  6737. }
  6738. /*==========================================
  6739. * It is made to snow.
  6740. *------------------------------------------
  6741. */
  6742. int
  6743. atcommand_snow(
  6744. const int fd, struct map_session_data* sd,
  6745. const char* command, const char* message)
  6746. {
  6747. int effno = 0;
  6748. effno = 162;
  6749. nullpo_retr(-1, sd);
  6750. if (map[sd->bl.m].flag.snow) {
  6751. map[sd->bl.m].flag.snow=0;
  6752. clif_displaymessage(fd, "Snow has stopped falling.");
  6753. } else {
  6754. map[sd->bl.m].flag.snow=1;
  6755. clif_specialeffect(&sd->bl,effno,2);
  6756. clif_displaymessage(fd, "It is made to snow.");
  6757. }
  6758. return 0;
  6759. }
  6760. /*==========================================
  6761. * Cherry tree snowstorm is made to fall. (Sakura)
  6762. *------------------------------------------
  6763. */
  6764. int
  6765. atcommand_sakura(
  6766. const int fd, struct map_session_data* sd,
  6767. const char* command, const char* message)
  6768. {
  6769. int effno = 0;
  6770. effno = 163;
  6771. nullpo_retr(-1, sd);
  6772. if (map[sd->bl.m].flag.sakura) {
  6773. map[sd->bl.m].flag.sakura=0;
  6774. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6775. } else {
  6776. map[sd->bl.m].flag.sakura=1;
  6777. clif_specialeffect(&sd->bl,effno,2);
  6778. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6779. }
  6780. return 0;
  6781. }
  6782. /*==========================================
  6783. * Fog hangs over.
  6784. *------------------------------------------
  6785. */
  6786. int
  6787. atcommand_fog(
  6788. const int fd, struct map_session_data* sd,
  6789. const char* command, const char* message)
  6790. {
  6791. int effno = 0;
  6792. effno = 233;
  6793. nullpo_retr(-1, sd);
  6794. if (map[sd->bl.m].flag.fog) {
  6795. map[sd->bl.m].flag.fog=0;
  6796. clif_displaymessage(fd, "The fog has gone.");
  6797. } else {
  6798. map[sd->bl.m].flag.fog=1;
  6799. clif_specialeffect(&sd->bl,effno,2);
  6800. clif_displaymessage(fd, "Fog hangs over.");
  6801. }
  6802. return 0;
  6803. }
  6804. /*==========================================
  6805. * Fallen leaves fall.
  6806. *------------------------------------------
  6807. */
  6808. int
  6809. atcommand_leaves(
  6810. const int fd, struct map_session_data* sd,
  6811. const char* command, const char* message)
  6812. {
  6813. int effno = 0;
  6814. effno = 333;
  6815. nullpo_retr(-1, sd);
  6816. if (map[sd->bl.m].flag.leaves) {
  6817. map[sd->bl.m].flag.leaves=0;
  6818. clif_displaymessage(fd, "Leaves no longer fall.");
  6819. } else {
  6820. map[sd->bl.m].flag.leaves=1;
  6821. clif_specialeffect(&sd->bl,effno,2);
  6822. clif_displaymessage(fd, "Fallen leaves fall.");
  6823. }
  6824. return 0;
  6825. }
  6826. /*==========================================
  6827. * Clearing Weather Effects by Dexity
  6828. *------------------------------------------
  6829. */
  6830. int
  6831. atcommand_clearweather(
  6832. const int fd, struct map_session_data* sd,
  6833. const char* command, const char* message)
  6834. {
  6835. //int effno = 0;
  6836. nullpo_retr(-1, sd);
  6837. map[sd->bl.m].flag.rain=0;
  6838. map[sd->bl.m].flag.snow=0;
  6839. map[sd->bl.m].flag.sakura=0;
  6840. map[sd->bl.m].flag.fog=0;
  6841. map[sd->bl.m].flag.leaves=0;
  6842. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6843. return 0;
  6844. }
  6845. /*===============================================================
  6846. * Sound Command - plays a sound for everyone! [Codemaster]
  6847. *---------------------------------------------------------------
  6848. */
  6849. int
  6850. atcommand_sound(
  6851. const int fd, struct map_session_data *sd,
  6852. const char *command, const char *message)
  6853. {
  6854. char sound_file[100];
  6855. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6856. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6857. return -1;
  6858. }
  6859. memset(sound_file, '\0', sizeof(sound_file));
  6860. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6861. return -1;
  6862. if(strstr(sound_file, ".wav") == NULL)
  6863. strcat(sound_file, ".wav");
  6864. clif_soundeffectall(&sd->bl, sound_file,0);
  6865. return 0;
  6866. }
  6867. /*==========================================
  6868. * MOB Search
  6869. *------------------------------------------
  6870. */
  6871. int
  6872. atcommand_mobsearch(
  6873. const int fd, struct map_session_data* sd,
  6874. const char* command, const char* message)
  6875. {
  6876. char mob_name[100];
  6877. char output[100];
  6878. int mob_id,map_id = 0;
  6879. nullpo_retr(-1, sd);
  6880. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6881. return -1;
  6882. if ((mob_id = atoi(mob_name)) == 0)
  6883. mob_id = mobdb_searchname(mob_name);
  6884. if(mob_id !=-1 && (mob_id <= 1000 || mob_id >= 2000)){
  6885. snprintf(output, sizeof output, "Invalid mob id %s!",mob_name);
  6886. clif_displaymessage(fd, output);
  6887. return 0;
  6888. }
  6889. if(mob_id == atoi(mob_name) && mob_db[mob_id].jname)
  6890. strcpy(mob_name,mob_db[mob_id].jname); // --ja--
  6891. // strcpy(mob_name,mob_db[mob_id].name); // --en--
  6892. map_id = sd->bl.m;
  6893. snprintf(output, sizeof output, "Mob Search... %s %s",
  6894. mob_name, sd->mapname);
  6895. clif_displaymessage(fd, output);
  6896. map_foreachinarea(atmobsearch_sub, map_id, 0, 0,
  6897. map[map_id].xs, map[map_id].ys, BL_MOB, mob_id, fd);
  6898. atmobsearch_sub(&sd->bl,0); // 番号リセット
  6899. return 0;
  6900. }
  6901. /*==========================================
  6902. * ドロップアイテムの掃除
  6903. *------------------------------------------
  6904. */
  6905. int
  6906. atcommand_cleanmap(
  6907. const int fd, struct map_session_data* sd,
  6908. const char* command, const char* message)
  6909. {
  6910. int i=0;
  6911. map_foreachinarea(atcommand_cleanmap_sub,sd->bl.m,
  6912. sd->bl.x-AREA_SIZE*2,sd->bl.y-AREA_SIZE*2,
  6913. sd->bl.x+AREA_SIZE*2,sd->bl.y+AREA_SIZE*2,
  6914. BL_ITEM,sd,&i);
  6915. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6916. return 0;
  6917. }
  6918. /*==========================================
  6919. * NPC/PETに話させる
  6920. *------------------------------------------
  6921. */
  6922. int
  6923. atcommand_npctalk(
  6924. const int fd, struct map_session_data* sd,
  6925. const char* command, const char* message)
  6926. {
  6927. char name[100],mes[100];
  6928. struct npc_data *nd;
  6929. if (sscanf(message, "%s %99[^\n]", name, mes) < 2)
  6930. return -1;
  6931. if (!(nd = npc_name2id(name)))
  6932. return -1;
  6933. clif_message(&nd->bl, mes);
  6934. return 0;
  6935. }
  6936. int
  6937. atcommand_pettalk(
  6938. const int fd, struct map_session_data* sd,
  6939. const char* command, const char* message)
  6940. {
  6941. char mes[100],temp[100];
  6942. struct pet_data *pd;
  6943. nullpo_retr(-1, sd);
  6944. if(!sd->status.pet_id || !(pd=sd->pd))
  6945. return -1;
  6946. if (sscanf(message, "%99[^\n]", mes) < 1)
  6947. return -1;
  6948. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  6949. clif_message(&pd->bl, temp);
  6950. return 0;
  6951. }
  6952. /*==========================================
  6953. * @users
  6954. * サーバー内の人数マップを表示させる
  6955. * 手抜きのため汚くなっているのは仕様です。
  6956. *------------------------------------------
  6957. */
  6958. static struct dbt *users_db;
  6959. static int users_all;
  6960. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  6961. int users = (int)strdb_search(users_db,sd->mapname) + 1;
  6962. users_all++;
  6963. strdb_insert(users_db,sd->mapname,(void *)users);
  6964. return 0;
  6965. }
  6966. static int atcommand_users_sub2(void* key,void* val,va_list va) {
  6967. char buf[256];
  6968. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  6969. sprintf(buf,"%s : %d (%d%%)",(char *)key,(int)val,(int)val * 100 / users_all);
  6970. clif_displaymessage(sd->fd,buf);
  6971. return 0;
  6972. }
  6973. int
  6974. atcommand_users(
  6975. const int fd, struct map_session_data* sd,
  6976. const char* command, const char* message)
  6977. {
  6978. char buf[256];
  6979. users_all = 0;
  6980. users_db = strdb_init(24);
  6981. clif_foreachclient(atcommand_users_sub1);
  6982. strdb_foreach(users_db,atcommand_users_sub2,sd);
  6983. sprintf(buf,"all : %d",users_all);
  6984. clif_displaymessage(fd,buf);
  6985. strdb_final(users_db,NULL);
  6986. return 0;
  6987. }
  6988. /*==========================================
  6989. *
  6990. *------------------------------------------
  6991. */
  6992. int
  6993. atcommand_summon(
  6994. const int fd, struct map_session_data* sd,
  6995. const char* command, const char* message)
  6996. {
  6997. char name[100];
  6998. int mob_id = 0;
  6999. int x = 0;
  7000. int y = 0;
  7001. int id = 0;
  7002. struct mob_data *md;
  7003. unsigned int tick=gettick();
  7004. nullpo_retr(-1, sd);
  7005. if (!message || !*message)
  7006. return -1;
  7007. if (sscanf(message, "%99s", name) < 1)
  7008. return -1;
  7009. if ((mob_id = atoi(name)) == 0)
  7010. mob_id = mobdb_searchname(name);
  7011. if(mob_id == 0)
  7012. return -1;
  7013. x = sd->bl.x + (rand() % 10 - 5);
  7014. y = sd->bl.y + (rand() % 10 - 5);
  7015. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7016. if((md=(struct mob_data *)map_id2bl(id))){
  7017. md->master_id=sd->bl.id;
  7018. md->state.special_mob_ai=1;
  7019. md->mode=mob_db[md->class_].mode|0x04;
  7020. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  7021. clif_misceffect2(&md->bl,344);
  7022. }
  7023. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7024. return 0;
  7025. }
  7026. /*==========================================
  7027. * @adjcmdlvl by [MouseJstr]
  7028. *
  7029. * Temp adjust the GM level required to use a GM command
  7030. *
  7031. * Used during beta testing to allow players to use GM commands
  7032. * for short periods of time
  7033. *------------------------------------------
  7034. */
  7035. int
  7036. atcommand_adjcmdlvl(
  7037. const int fd, struct map_session_data* sd,
  7038. const char* command, const char* message)
  7039. {
  7040. int i, newlev;
  7041. char cmd[100];
  7042. nullpo_retr(-1, sd);
  7043. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7044. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7045. return -1;
  7046. }
  7047. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  7048. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7049. atcommand_info[i].level = newlev;
  7050. clif_displaymessage(fd, "@command level changed.");
  7051. return 0;
  7052. }
  7053. clif_displaymessage(fd, "@command not found.");
  7054. return -1;
  7055. }
  7056. /*==========================================
  7057. * @adjgmlvl by [MouseJstr]
  7058. *
  7059. * Create a temp GM
  7060. *
  7061. * Used during beta testing to allow players to use GM commands
  7062. * for short periods of time
  7063. *------------------------------------------
  7064. */
  7065. int
  7066. atcommand_adjgmlvl(
  7067. const int fd, struct map_session_data* sd,
  7068. const char* command, const char* message)
  7069. {
  7070. int newlev;
  7071. char user[100];
  7072. struct map_session_data *pl_sd;
  7073. nullpo_retr(-1, sd);
  7074. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  7075. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7076. return -1;
  7077. }
  7078. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7079. return -1;
  7080. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7081. return 0;
  7082. }
  7083. /*==========================================
  7084. * @trade by [MouseJstr]
  7085. *
  7086. * Open a trade window with a remote player
  7087. *
  7088. * If I have to jump to a remote player one more time, I am
  7089. * gonna scream!
  7090. *------------------------------------------
  7091. */
  7092. int
  7093. atcommand_trade(
  7094. const int fd, struct map_session_data* sd,
  7095. const char* command, const char* message)
  7096. {
  7097. struct map_session_data *pl_sd = NULL;
  7098. nullpo_retr(-1, sd);
  7099. if (!message || !*message)
  7100. return -1;
  7101. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7102. trade_traderequest(sd, pl_sd->bl.id);
  7103. return 0;
  7104. }
  7105. return -1;
  7106. }
  7107. /*==========================================
  7108. * @setbattleflag by [MouseJstr]
  7109. *
  7110. * set a battle_config flag without having to reboot
  7111. */
  7112. int
  7113. atcommand_setbattleflag(
  7114. const int fd, struct map_session_data* sd,
  7115. const char* command, const char* message)
  7116. {
  7117. char flag[128], value[128];
  7118. nullpo_retr(-1, sd);
  7119. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  7120. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7121. return -1;
  7122. }
  7123. if (battle_set_value(flag, value) == 0)
  7124. clif_displaymessage(fd, "unknown battle_config flag");
  7125. else
  7126. clif_displaymessage(fd, "battle_config set as requested");
  7127. return 0;
  7128. }
  7129. /*===========================
  7130. * @unmute [Valaris]
  7131. *===========================
  7132. */
  7133. int atcommand_unmute(
  7134. const int fd, struct map_session_data* sd,
  7135. const char* command, const char* message)
  7136. {
  7137. struct map_session_data *pl_sd = NULL;
  7138. nullpo_retr(-1, sd);
  7139. if (!message || !*message)
  7140. return -1;
  7141. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7142. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  7143. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7144. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7145. clif_displaymessage(sd->fd,"Player unmuted");
  7146. }
  7147. else
  7148. clif_displaymessage(sd->fd,"Player is not muted");
  7149. }
  7150. return 0;
  7151. }
  7152. /*==========================================
  7153. * @uptime by MC Cameri
  7154. *------------------------------------------
  7155. */
  7156. int
  7157. atcommand_uptime(
  7158. const int fd, struct map_session_data* sd,
  7159. const char* command, const char* message)
  7160. {
  7161. char output[200];
  7162. long seconds = 0, day = 24*60*60, hour = 60*60,
  7163. minute = 60, days = 0, hours = 0, minutes = 0;
  7164. nullpo_retr(-1, sd);
  7165. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  7166. days = seconds/day;
  7167. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7168. hours = seconds/hour;
  7169. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7170. minutes = seconds/minute;
  7171. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7172. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  7173. clif_displaymessage(fd,output);
  7174. return 0;
  7175. }
  7176. /*==========================================
  7177. * @changesex <sex>
  7178. * => Changes one's sex. Argument sex can be
  7179. * 0 or 1, m or f, male or female.
  7180. *------------------------------------------
  7181. */
  7182. int
  7183. atcommand_changesex(
  7184. const int fd, struct map_session_data* sd,
  7185. const char* command, const char* message)
  7186. {
  7187. nullpo_retr(-1, sd);
  7188. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7189. return 0;
  7190. }
  7191. /*================================================
  7192. * @mute - Mutes a player for a set amount of time
  7193. *------------------------------------------------
  7194. */
  7195. int atcommand_mute(
  7196. const int fd, struct map_session_data* sd,
  7197. const char* command, const char* message)
  7198. {
  7199. struct map_session_data *pl_sd = NULL;
  7200. char character[100];
  7201. int manner;
  7202. nullpo_retr(-1, sd);
  7203. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  7204. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7205. return -1;
  7206. }
  7207. if ((pl_sd = map_nick2sd(character)) != NULL) {
  7208. pl_sd->status.manner -= manner;
  7209. if(pl_sd->status.manner < 0)
  7210. status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  7211. }
  7212. else {
  7213. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7214. return -1;
  7215. }
  7216. return 0;
  7217. }
  7218. /*==========================================
  7219. * @refresh (like @jumpto <<yourself>>)
  7220. *------------------------------------------
  7221. */
  7222. int atcommand_refresh(
  7223. const int fd, struct map_session_data* sd,
  7224. const char* command, const char* message)
  7225. {
  7226. nullpo_retr(-1, sd);
  7227. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  7228. return 0;
  7229. }
  7230. /*==========================================
  7231. * @petid <part of pet name>
  7232. * => Displays a list of matching pets.
  7233. *------------------------------------------
  7234. */
  7235. int
  7236. atcommand_petid(const int fd, struct map_session_data* sd,
  7237. const char* command, const char* message)
  7238. {
  7239. char searchtext[100];
  7240. char temp0[100];
  7241. char temp1[100];
  7242. int cnt = 0, i = 0;
  7243. nullpo_retr(-1, sd);
  7244. if (!message || !*message)
  7245. return -1;
  7246. if (sscanf(message, "%99s", searchtext) < 1)
  7247. return -1;
  7248. estr_lower(searchtext);
  7249. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7250. clif_displaymessage(fd,temp0);
  7251. while (i < MAX_PET_DB) {
  7252. strcpy(temp1,pet_db[i].name);
  7253. strcpy(temp1, estr_lower(temp1));
  7254. strcpy(temp0,pet_db[i].jname);
  7255. strcpy(temp0, estr_lower(temp1));
  7256. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7257. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7258. pet_db[i].jname);
  7259. if (cnt >= 100) { // Only if there are custom pets
  7260. clif_displaymessage(fd, "Be more specific, can't send more than"
  7261. " 100 results.");
  7262. } else {
  7263. clif_displaymessage(fd, temp0);
  7264. }
  7265. cnt++;
  7266. }
  7267. i++;
  7268. }
  7269. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7270. clif_displaymessage(fd, temp0);
  7271. return 0;
  7272. }
  7273. /*==========================================
  7274. * @identify
  7275. * => GM's magnifier.
  7276. *------------------------------------------
  7277. */
  7278. int
  7279. atcommand_identify(
  7280. const int fd, struct map_session_data* sd,
  7281. const char* command, const char* message)
  7282. {
  7283. int i,num;
  7284. nullpo_retr(-1, sd);
  7285. for(i=num=0;i<MAX_INVENTORY;i++){
  7286. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7287. num++;
  7288. }
  7289. }
  7290. if (num > 0) {
  7291. clif_item_identify_list(sd);
  7292. } else {
  7293. clif_displaymessage(fd,"There are no items to appraise.");
  7294. }
  7295. return 0;
  7296. }
  7297. /*==========================================
  7298. * @gmotd (Global MOTD)
  7299. * by davidsiaw :P
  7300. *------------------------------------------
  7301. */
  7302. int
  7303. atcommand_gmotd(
  7304. const int fd, struct map_session_data* sd,
  7305. const char* command, const char* message)
  7306. {
  7307. char buf[256];
  7308. FILE *fp;
  7309. nullpo_retr(-1, sd);
  7310. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7311. while (fgets(buf, 250, fp) != NULL){
  7312. int i;
  7313. for( i=0; buf[i]; i++){
  7314. if( buf[i]=='\r' || buf[i]=='\n'){
  7315. buf[i]=0;
  7316. break;
  7317. }
  7318. }
  7319. intif_GMmessage(buf,strlen(buf)+1,8);
  7320. }
  7321. fclose(fp);
  7322. }
  7323. return 0;
  7324. }
  7325. int atcommand_misceffect(
  7326. const int fd, struct map_session_data* sd,
  7327. const char* command, const char* message)
  7328. {
  7329. int effect = 0;
  7330. nullpo_retr(-1, sd);
  7331. if (!message || !*message)
  7332. return -1;
  7333. if (sscanf(message, "%d", &effect) < 1)
  7334. return -1;
  7335. clif_misceffect(&sd->bl,effect);
  7336. return 0;
  7337. }
  7338. int charid2sessionid(int charid)
  7339. {
  7340. int i;
  7341. int session_id=0;
  7342. struct map_session_data *pl_sd = NULL;
  7343. for(i=0;i<fd_max;i++){
  7344. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7345. if (pl_sd->status.char_id==charid) { session_id = i; break; }
  7346. }
  7347. }
  7348. return session_id;
  7349. }
  7350. int accountid2sessionid(int accountid)
  7351. {
  7352. int i;
  7353. int session_id=0;
  7354. struct map_session_data *pl_sd = NULL;
  7355. for(i=0;i<fd_max;i++){
  7356. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7357. if (pl_sd->status.account_id==accountid) { session_id = i; break; }
  7358. }
  7359. }
  7360. return session_id;
  7361. }
  7362. /*==========================================
  7363. * Jump to a player by PID number
  7364. * Original by Dino9021
  7365. * Added in by nsstrunks
  7366. *------------------------------------------
  7367. */
  7368. int atcommand_jumptoid(
  7369. const int fd, struct map_session_data* sd,
  7370. const char* command, const char* message)
  7371. {
  7372. char character[100];
  7373. char output[200];
  7374. int cid=0;
  7375. int session_id=0;
  7376. struct map_session_data *pl_sd;
  7377. memset(character, '\0', sizeof(character));
  7378. memset(output, '\0', sizeof(output));
  7379. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7380. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7381. return -1;
  7382. }
  7383. cid=atoi(message);
  7384. if ((session_id=charid2sessionid(cid))!=0)
  7385. {
  7386. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7387. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7388. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7389. return -1;
  7390. }
  7391. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7392. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7393. return -1;
  7394. }
  7395. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7396. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7397. clif_displaymessage(fd, output);
  7398. } else {
  7399. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7400. return -1;
  7401. }
  7402. }
  7403. else
  7404. {
  7405. clif_displaymessage(fd,msg_table[3]);
  7406. }
  7407. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7408. return 0;
  7409. }
  7410. /*==========================================
  7411. * Jump to a player by PID number
  7412. * Original by Dino9021
  7413. * Added in by nsstrunks
  7414. *------------------------------------------
  7415. */
  7416. int atcommand_jumptoid2(
  7417. const int fd, struct map_session_data* sd,
  7418. const char* command, const char* message)
  7419. {
  7420. char character[100];
  7421. char output[200];
  7422. int aid=0;
  7423. int session_id=0;
  7424. struct map_session_data *pl_sd;
  7425. memset(character, '\0', sizeof(character));
  7426. memset(output, '\0', sizeof(output));
  7427. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7428. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7429. return -1;
  7430. }
  7431. aid=atoi(message);
  7432. if ((session_id=accountid2sessionid(aid))!=0)
  7433. {
  7434. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7435. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7436. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7437. return -1;
  7438. }
  7439. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7440. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7441. return -1;
  7442. }
  7443. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7444. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7445. clif_displaymessage(fd, output);
  7446. } else {
  7447. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7448. return -1;
  7449. }
  7450. }
  7451. else
  7452. {
  7453. clif_displaymessage(fd,msg_table[3]);
  7454. }
  7455. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7456. return 0;
  7457. }
  7458. /*==========================================
  7459. * Recall a player by PID number
  7460. * Original by Dino9021
  7461. * Added in by nsstrunks
  7462. *------------------------------------------
  7463. */
  7464. int atcommand_recallid(
  7465. const int fd, struct map_session_data* sd,
  7466. const char* command, const char* message)
  7467. {
  7468. char character[100];
  7469. char output[200];
  7470. int cid=0;
  7471. int session_id=0;
  7472. struct map_session_data *pl_sd;
  7473. memset(character, '\0', sizeof(character));
  7474. memset(output, '\0', sizeof(output));
  7475. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7476. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7477. return -1;
  7478. }
  7479. cid=atoi(message);
  7480. if ((session_id=charid2sessionid(cid))!=0)
  7481. {
  7482. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7483. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7484. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7485. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7486. return -1;
  7487. }
  7488. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7489. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7490. return -1;
  7491. }
  7492. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7493. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7494. clif_displaymessage(fd, output);
  7495. } else {
  7496. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7497. return -1;
  7498. }
  7499. } else {
  7500. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7501. return -1;
  7502. }
  7503. }
  7504. else
  7505. {
  7506. clif_displaymessage(fd,msg_table[3]);
  7507. }
  7508. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7509. return 0;
  7510. }
  7511. /*==========================================
  7512. * Recall a player by PID number
  7513. * Original by Dino9021
  7514. * Added in by nsstrunks
  7515. *------------------------------------------
  7516. */
  7517. int atcommand_recallid2(
  7518. const int fd, struct map_session_data* sd,
  7519. const char* command, const char* message)
  7520. {
  7521. char character[100];
  7522. char output[200];
  7523. int aid=0;
  7524. int session_id=0;
  7525. struct map_session_data *pl_sd;
  7526. memset(character, '\0', sizeof(character));
  7527. memset(output, '\0', sizeof(output));
  7528. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7529. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7530. return -1;
  7531. }
  7532. aid=atoi(message);
  7533. if ((session_id=accountid2sessionid(aid))!=0)
  7534. {
  7535. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7536. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7537. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7538. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7539. return -1;
  7540. }
  7541. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7542. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7543. return -1;
  7544. }
  7545. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7546. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7547. clif_displaymessage(fd, output);
  7548. } else {
  7549. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7550. return -1;
  7551. }
  7552. } else {
  7553. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7554. return -1;
  7555. }
  7556. }
  7557. else
  7558. {
  7559. clif_displaymessage(fd,msg_table[3]);
  7560. }
  7561. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7562. return 0;
  7563. }
  7564. /*==========================================
  7565. * Kick a player by PID number
  7566. * Original by Dino9021
  7567. * Added in by nsstrunks
  7568. *------------------------------------------
  7569. */
  7570. int atcommand_kickid(
  7571. const int fd, struct map_session_data* sd,
  7572. const char* command, const char* message)
  7573. {
  7574. struct map_session_data *pl_sd;
  7575. char character[100];
  7576. int cid=0;
  7577. int session_id=0;
  7578. memset(character, '\0', sizeof(character));
  7579. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7580. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7581. return -1;
  7582. }
  7583. cid=atoi(message);
  7584. if ((session_id=charid2sessionid(cid))!=0)
  7585. {
  7586. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7587. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7588. clif_GM_kick(sd, pl_sd, 1);
  7589. else {
  7590. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7591. return -1;
  7592. }
  7593. } else {
  7594. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7595. return -1;
  7596. }
  7597. }
  7598. else
  7599. {
  7600. clif_displaymessage(fd,msg_table[3]);
  7601. }
  7602. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7603. return 0;
  7604. }
  7605. /*==========================================
  7606. * Kick a player by PID number
  7607. * Original by Dino9021
  7608. * Added in by nsstrunks
  7609. *------------------------------------------
  7610. */
  7611. int atcommand_kickid2(
  7612. const int fd, struct map_session_data* sd,
  7613. const char* command, const char* message)
  7614. {
  7615. struct map_session_data *pl_sd;
  7616. char character[100];
  7617. int aid=0;
  7618. int session_id=0;
  7619. memset(character, '\0', sizeof(character));
  7620. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7621. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7622. return -1;
  7623. }
  7624. aid=atoi(message);
  7625. if ((session_id=accountid2sessionid(aid))!=0)
  7626. {
  7627. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7628. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7629. clif_GM_kick(sd, pl_sd, 1);
  7630. else {
  7631. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7632. return -1;
  7633. }
  7634. } else {
  7635. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7636. return -1;
  7637. }
  7638. }
  7639. else
  7640. {
  7641. clif_displaymessage(fd,msg_table[3]);
  7642. }
  7643. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7644. return 0;
  7645. }
  7646. /*==========================================
  7647. * Revive a player by PID number
  7648. * Original by Dino9021
  7649. * Added in by nsstrunks
  7650. *------------------------------------------
  7651. */
  7652. int atcommand_reviveid(
  7653. const int fd, struct map_session_data* sd,
  7654. const char* command, const char* message)
  7655. {
  7656. char character[100];
  7657. int cid=0;
  7658. int session_id=0;
  7659. struct map_session_data *pl_sd;
  7660. memset(character, '\0', sizeof(character));
  7661. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7662. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7663. return -1;
  7664. }
  7665. cid=atoi(message);
  7666. if ((session_id=charid2sessionid(cid))!=0)
  7667. {
  7668. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7669. pl_sd->status.hp = pl_sd->status.max_hp;
  7670. pc_setstand(pl_sd);
  7671. if (battle_config.pc_invincible_time > 0)
  7672. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7673. clif_updatestatus(pl_sd, SP_HP);
  7674. clif_updatestatus(pl_sd, SP_SP);
  7675. clif_resurrection(&pl_sd->bl, 1);
  7676. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7677. } else {
  7678. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7679. return -1;
  7680. }
  7681. }
  7682. else
  7683. {
  7684. clif_displaymessage(fd,msg_table[3]);
  7685. }
  7686. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7687. return 0;
  7688. }
  7689. /*==========================================
  7690. * Revive a player by PID number
  7691. * Original by Dino9021
  7692. * Added in by nsstrunks
  7693. *------------------------------------------
  7694. */
  7695. int atcommand_reviveid2(
  7696. const int fd, struct map_session_data* sd,
  7697. const char* command, const char* message)
  7698. {
  7699. char character[100];
  7700. int aid=0;
  7701. int session_id=0;
  7702. struct map_session_data *pl_sd;
  7703. memset(character, '\0', sizeof(character));
  7704. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7705. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7706. return -1;
  7707. }
  7708. aid=atoi(message);
  7709. if ((session_id=accountid2sessionid(aid))!=0)
  7710. {
  7711. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7712. pl_sd->status.hp = pl_sd->status.max_hp;
  7713. pc_setstand(pl_sd);
  7714. if (battle_config.pc_invincible_time > 0)
  7715. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7716. clif_updatestatus(pl_sd, SP_HP);
  7717. clif_updatestatus(pl_sd, SP_SP);
  7718. clif_resurrection(&pl_sd->bl, 1);
  7719. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7720. } else {
  7721. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7722. return -1;
  7723. }
  7724. }
  7725. else
  7726. {
  7727. clif_displaymessage(fd,msg_table[3]);
  7728. }
  7729. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7730. return 0;
  7731. }
  7732. /*==========================================
  7733. * Kill a player by PID number
  7734. * Original by Dino9021
  7735. * Added in by nsstrunks
  7736. *------------------------------------------
  7737. */
  7738. int atcommand_killid(
  7739. const int fd, struct map_session_data* sd,
  7740. const char* command, const char* message)
  7741. {
  7742. char character[100];
  7743. int cid=0;
  7744. int session_id=0;
  7745. struct map_session_data *pl_sd;
  7746. memset(character, '\0', sizeof(character));
  7747. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7748. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7749. return -1;
  7750. }
  7751. cid=atoi(message);
  7752. if ((session_id=charid2sessionid(cid))!=0)
  7753. {
  7754. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7755. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7756. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7757. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7758. } else {
  7759. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7760. return -1;
  7761. }
  7762. } else {
  7763. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7764. return -1;
  7765. }
  7766. }
  7767. else
  7768. {
  7769. clif_displaymessage(fd,msg_table[3]);
  7770. }
  7771. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7772. return 0;
  7773. }
  7774. /*==========================================
  7775. * Kill a player by PID number
  7776. * Original by Dino9021
  7777. * Added in by nsstrunks
  7778. *------------------------------------------
  7779. */
  7780. int atcommand_killid2(
  7781. const int fd, struct map_session_data* sd,
  7782. const char* command, const char* message)
  7783. {
  7784. char character[100];
  7785. int aid=0;
  7786. int session_id=0;
  7787. struct map_session_data *pl_sd;
  7788. memset(character, '\0', sizeof(character));
  7789. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7790. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7791. return -1;
  7792. }
  7793. aid=atoi(message);
  7794. if ((session_id=accountid2sessionid(aid))!=0)
  7795. {
  7796. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7797. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7798. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7799. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7800. } else {
  7801. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7802. return -1;
  7803. }
  7804. } else {
  7805. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7806. return -1;
  7807. }
  7808. }
  7809. else
  7810. {
  7811. clif_displaymessage(fd,msg_table[3]);
  7812. }
  7813. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7814. return 0;
  7815. }
  7816. /*==========================================
  7817. * Make a player killable, by PID
  7818. * Original by Dino9021
  7819. * Added in by nsstrunks
  7820. *------------------------------------------
  7821. */
  7822. int
  7823. atcommand_charkillableid(
  7824. const int fd, struct map_session_data* sd,
  7825. const char* command, const char* message)
  7826. {
  7827. struct map_session_data *pl_sd = NULL;
  7828. int cid=0;
  7829. int session_id=0;
  7830. if (!message || (cid = atoi(message)) == 0 || !*message)
  7831. return -1;
  7832. cid=atoi(message);
  7833. if ((session_id=charid2sessionid(cid))!=0)
  7834. {
  7835. if((pl_sd=session[session_id]->session_data) == NULL)
  7836. return -1;
  7837. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7838. if(pl_sd->special_state.killable)
  7839. clif_displaymessage(fd, "The player is now killable");
  7840. else
  7841. clif_displaymessage(fd, "The player is no longer killable");
  7842. }
  7843. else
  7844. {
  7845. clif_displaymessage(fd,msg_table[3]);
  7846. }
  7847. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7848. return 0;
  7849. }
  7850. /*==========================================
  7851. * Make a player killable, by PID
  7852. * Original by Dino9021
  7853. * Added in by nsstrunks
  7854. *------------------------------------------
  7855. */
  7856. int
  7857. atcommand_charkillableid2(
  7858. const int fd, struct map_session_data* sd,
  7859. const char* command, const char* message)
  7860. {
  7861. struct map_session_data *pl_sd = NULL;
  7862. int aid=0;
  7863. int session_id=0;
  7864. if (!message || (aid = atoi(message)) == 0 || !*message)
  7865. return -1;
  7866. aid=atoi(message);
  7867. if ((session_id=accountid2sessionid(aid))!=0)
  7868. {
  7869. if((pl_sd=session[session_id]->session_data) == NULL)
  7870. return -1;
  7871. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7872. if(pl_sd->special_state.killable)
  7873. clif_displaymessage(fd, "The player is now killable");
  7874. else
  7875. clif_displaymessage(fd, "The player is no longer killable");
  7876. }
  7877. else
  7878. {
  7879. clif_displaymessage(fd,msg_table[3]);
  7880. }
  7881. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7882. return 0;
  7883. }
  7884. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7885. /*==========================================
  7886. * Mail System commands by [Valaris]
  7887. *------------------------------------------
  7888. */
  7889. int atcommand_listmail(
  7890. const int fd, struct map_session_data* sd,
  7891. const char* command, const char* message)
  7892. {
  7893. if(!battle_config.mail_system)
  7894. return 0;
  7895. nullpo_retr(-1, sd);
  7896. if(strlen(command)==12)
  7897. mail_check(sd,3);
  7898. else if(strlen(command)==9)
  7899. mail_check(sd,2);
  7900. else
  7901. mail_check(sd,1);
  7902. return 0;
  7903. }
  7904. int atcommand_readmail(
  7905. const int fd, struct map_session_data* sd,
  7906. const char* command, const char* message)
  7907. {
  7908. if(!battle_config.mail_system)
  7909. return 0;
  7910. nullpo_retr(-1, sd);
  7911. if (!message || !*message) {
  7912. clif_displaymessage(sd->fd,"You must specify a message number.");
  7913. return 0;
  7914. }
  7915. if(strlen(command)==11)
  7916. mail_delete(sd,atoi(message));
  7917. else
  7918. mail_read(sd,atoi(message));
  7919. return 0;
  7920. }
  7921. int atcommand_sendmail(
  7922. const int fd, struct map_session_data* sd,
  7923. const char* command, const char* message)
  7924. {
  7925. char name[24],text[80];
  7926. if(!battle_config.mail_system)
  7927. return 0;
  7928. nullpo_retr(-1, sd);
  7929. if (!message || !*message) {
  7930. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7931. return 0;
  7932. }
  7933. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7934. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7935. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7936. return 0;
  7937. }
  7938. if(strlen(command)==17)
  7939. mail_send(sd,name,text,1);
  7940. else
  7941. mail_send(sd,name,text,0);
  7942. return 0;
  7943. }
  7944. /*==========================================
  7945. * Refresh online command for SQL [Valaris]
  7946. * Will refresh and check online column of
  7947. * players and set correctly.
  7948. *------------------------------------------
  7949. */
  7950. int atcommand_refreshonline(
  7951. const int fd, struct map_session_data* sd,
  7952. const char* command, const char* message)
  7953. {
  7954. nullpo_retr(-1, sd);
  7955. char_online_check();
  7956. return 0;
  7957. }
  7958. #endif /* end sql only */
  7959. /*==========================================
  7960. * Show Monster DB Info v 1.0
  7961. * originally by [Lupus] eAthena
  7962. *------------------------------------------
  7963. */
  7964. int atcommand_mobinfo(
  7965. const int fd, struct map_session_data* sd,
  7966. const char* command, const char* message) {
  7967. static char msize[3][8]={"Small","Medium","Large"};
  7968. static char mrace[12][12]={"Formless","Undead","Beast","Plant","Insect","Fish","Demon","Demi-Human","Angel","Dragon","Boss","Non-Boss"};
  7969. static char melement[11][12]={"None","Neutral","Water","Earth","Fire","Wind","Poison","Holy","Dark","Ghost","Undead"};
  7970. char monster[100];
  7971. char output[200];
  7972. char output2[200];
  7973. struct item_data *item_data;
  7974. int mob_id;
  7975. int i,j;
  7976. nullpo_retr(-1, sd);
  7977. memset(monster, '\0', sizeof(monster));
  7978. memset(output, '\0', sizeof(output));
  7979. if (!message || !*message ||
  7980. sscanf(message, "%99s", monster) < 1) {
  7981. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  7982. return -1;
  7983. }
  7984. // If monster identifier/name argument is a name
  7985. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  7986. mob_id = mobdb_checkid(atoi(monster));
  7987. if (mob_id == 0) {
  7988. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  7989. return -1;
  7990. }
  7991. sprintf(output, "N:%04i '%s'/'%s' %s",
  7992. mob_id,mob_db[mob_id].name,mob_db[mob_id].jname, mob_db[mob_id].mexp?"MVP!":"");
  7993. clif_displaymessage(fd, output);
  7994. sprintf(output, " Level:%i HP:%i SP:%i Base EXP:%i Job EXP:%i",
  7995. mob_db[mob_id].lv, mob_db[mob_id].max_hp, mob_db[mob_id].max_sp, mob_db[mob_id].base_exp, mob_db[mob_id].job_exp);
  7996. clif_displaymessage(fd, output);
  7997. sprintf(output, " DEF:%i MDEF:%i STR:%i AGI:%i VIT:%i INT:%i DEX:%i LUK:%i",
  7998. mob_db[mob_id].def, mob_db[mob_id].mdef, mob_db[mob_id].str, mob_db[mob_id].agi, mob_db[mob_id].vit, mob_db[mob_id].int_, mob_db[mob_id].dex, mob_db[mob_id].luk);
  7999. clif_displaymessage(fd, output);
  8000. if (mob_db[mob_id].element<20) {
  8001. //Element - None, Level 0
  8002. i = 0; j = 0;
  8003. } else {
  8004. i = mob_db[mob_id].element%20+1;
  8005. j = mob_db[mob_id].element/20;
  8006. }
  8007. sprintf(output, " ATK:%i~%i Range:%i~%i~%i Size:%s Race:%s Element:%s(%i Lv)",
  8008. mob_db[mob_id].atk1,mob_db[mob_id].atk2, mob_db[mob_id].range, mob_db[mob_id].range2 ,mob_db[mob_id].range3,
  8009. msize[mob_db[mob_id].size],mrace[mob_db[mob_id].race], melement[i],j);
  8010. clif_displaymessage(fd, output);
  8011. if (mob_db[mob_id].mexp) {
  8012. //if MVP, then
  8013. sprintf(output, " MVP Bonus EXP:%i %02.02f%%",
  8014. mob_db[mob_id].mexp, (float)mob_db[mob_id].mexpper / 100);
  8015. clif_displaymessage(fd, output);
  8016. strcpy(output," MVP Items:");
  8017. for (i=0; i<3; i++) {
  8018. if ( mob_db[mob_id].mvpitem[i].nameid<=0 || mob_db[mob_id].mvpitem[i].p<=0)
  8019. continue;
  8020. if( (item_data = itemdb_search(mob_db[mob_id].mvpitem[i].nameid)) == NULL)
  8021. continue;
  8022. sprintf(output2, " - %s %02.02f%%",
  8023. item_data->name, (float)mob_db[mob_id].mvpitem[i].p / 100);
  8024. strcat(output,output2);
  8025. }
  8026. clif_displaymessage(fd, output);
  8027. }
  8028. strcpy(output," Drops:");
  8029. j=0;
  8030. for (i=0; i<10; i++) { // 8 -> 10 Lupus
  8031. if ( mob_db[mob_id].dropitem[i].nameid<=0 || mob_db[mob_id].dropitem[i].p<=0)
  8032. continue;
  8033. if( (item_data = itemdb_search(mob_db[mob_id].dropitem[i].nameid)) == NULL)
  8034. continue;
  8035. sprintf(output2, " - %s %02.02f%%",
  8036. item_data->name, (float)mob_db[mob_id].dropitem[i].p / 100);
  8037. strcat(output,output2);
  8038. if (++j>=3) {
  8039. j=0;
  8040. clif_displaymessage(fd, output);
  8041. strcpy(output," ");
  8042. }
  8043. }
  8044. clif_displaymessage(fd, output);
  8045. return 0;
  8046. }