atcommand.c 266 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859
  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 "log.h"
  12. #include "clif.h"
  13. #include "chrif.h"
  14. #include "intif.h"
  15. #include "itemdb.h"
  16. #include "map.h"
  17. #include "pc.h"
  18. #include "status.h"
  19. #include "skill.h"
  20. #include "mob.h"
  21. #include "pet.h"
  22. #include "battle.h"
  23. #include "party.h"
  24. #include "guild.h"
  25. #include "atcommand.h"
  26. #include "script.h"
  27. #include "npc.h"
  28. #include "trade.h"
  29. #include "core.h"
  30. #ifndef TXT_ONLY
  31. #include "mail.h"
  32. #endif
  33. #define STATE_BLIND 0x10
  34. static char command_symbol = '@'; // first char of the commands (by [Yor])
  35. char msg_table[1000][256]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  36. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  37. ACMD_FUNC(broadcast);
  38. ACMD_FUNC(localbroadcast);
  39. ACMD_FUNC(rura);
  40. ACMD_FUNC(where);
  41. ACMD_FUNC(jumpto);
  42. ACMD_FUNC(jump);
  43. ACMD_FUNC(who);
  44. ACMD_FUNC(who2);
  45. ACMD_FUNC(who3);
  46. ACMD_FUNC(whomap);
  47. ACMD_FUNC(whomap2);
  48. ACMD_FUNC(whomap3);
  49. ACMD_FUNC(whogm); // by Yor
  50. ACMD_FUNC(whozeny); // [Valaris]
  51. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  52. ACMD_FUNC(save);
  53. ACMD_FUNC(load);
  54. ACMD_FUNC(speed);
  55. ACMD_FUNC(storage);
  56. ACMD_FUNC(guildstorage);
  57. ACMD_FUNC(option);
  58. ACMD_FUNC(hide);
  59. ACMD_FUNC(jobchange);
  60. ACMD_FUNC(die);
  61. ACMD_FUNC(kill);
  62. ACMD_FUNC(alive);
  63. ACMD_FUNC(kami);
  64. ACMD_FUNC(heal);
  65. ACMD_FUNC(item);
  66. ACMD_FUNC(item2);
  67. ACMD_FUNC(itemreset);
  68. ACMD_FUNC(itemcheck);
  69. ACMD_FUNC(baselevelup);
  70. ACMD_FUNC(joblevelup);
  71. ACMD_FUNC(help);
  72. ACMD_FUNC(gm);
  73. ACMD_FUNC(pvpoff);
  74. ACMD_FUNC(pvpon);
  75. ACMD_FUNC(gvgoff);
  76. ACMD_FUNC(gvgon);
  77. ACMD_FUNC(model);
  78. ACMD_FUNC(go);
  79. ACMD_FUNC(monster);
  80. ACMD_FUNC(monstersmall);
  81. ACMD_FUNC(monsterbig);
  82. ACMD_FUNC(spawn);
  83. ACMD_FUNC(killmonster);
  84. ACMD_FUNC(killmonster2);
  85. ACMD_FUNC(refine);
  86. ACMD_FUNC(produce);
  87. ACMD_FUNC(memo);
  88. ACMD_FUNC(gat);
  89. ACMD_FUNC(packet);
  90. ACMD_FUNC(statuspoint);
  91. ACMD_FUNC(skillpoint);
  92. ACMD_FUNC(zeny);
  93. ACMD_FUNC(param);
  94. ACMD_FUNC(guildlevelup);
  95. ACMD_FUNC(makeegg);
  96. ACMD_FUNC(hatch);
  97. ACMD_FUNC(petfriendly);
  98. ACMD_FUNC(pethungry);
  99. ACMD_FUNC(petrename);
  100. ACMD_FUNC(recall);
  101. ACMD_FUNC(recallall);
  102. ACMD_FUNC(revive);
  103. ACMD_FUNC(character_stats_all);
  104. ACMD_FUNC(character_save);
  105. ACMD_FUNC(night);
  106. ACMD_FUNC(day);
  107. ACMD_FUNC(doom);
  108. ACMD_FUNC(doommap);
  109. ACMD_FUNC(raise);
  110. ACMD_FUNC(raisemap);
  111. ACMD_FUNC(character_baselevel);
  112. ACMD_FUNC(character_joblevel);
  113. ACMD_FUNC(kick);
  114. ACMD_FUNC(kickall);
  115. ACMD_FUNC(allskill);
  116. ACMD_FUNC(questskill);
  117. ACMD_FUNC(charquestskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(charlostskill);
  120. ACMD_FUNC(spiritball);
  121. ACMD_FUNC(party);
  122. ACMD_FUNC(guild);
  123. ACMD_FUNC(charskreset);
  124. ACMD_FUNC(charstreset);
  125. ACMD_FUNC(charreset);
  126. ACMD_FUNC(charstpoint);
  127. ACMD_FUNC(charmodel);
  128. ACMD_FUNC(charskpoint);
  129. ACMD_FUNC(agitstart);
  130. ACMD_FUNC(agitend);
  131. ACMD_FUNC(reloaditemdb);
  132. ACMD_FUNC(reloadmobdb);
  133. ACMD_FUNC(reloadskilldb);
  134. ACMD_FUNC(reloadscript);
  135. ACMD_FUNC(reloadgmdb); // by Yor
  136. ACMD_FUNC(mapexit);
  137. ACMD_FUNC(idsearch);
  138. ACMD_FUNC(mapinfo);
  139. ACMD_FUNC(dye); //** by fritz
  140. ACMD_FUNC(hair_style); //** by fritz
  141. ACMD_FUNC(hair_color); //** by fritz
  142. ACMD_FUNC(stat_all); //** by fritz
  143. ACMD_FUNC(char_change_sex); // by Yor
  144. ACMD_FUNC(char_block); // by Yor
  145. ACMD_FUNC(char_ban); // by Yor
  146. ACMD_FUNC(char_unblock); // by Yor
  147. ACMD_FUNC(char_unban); // by Yor
  148. ACMD_FUNC(mount_peco); // by Valaris
  149. ACMD_FUNC(char_mount_peco); // by Yor
  150. ACMD_FUNC(guildspy); // [Syrus22]
  151. ACMD_FUNC(partyspy); // [Syrus22]
  152. ACMD_FUNC(repairall); // [Valaris]
  153. ACMD_FUNC(guildrecall); // by Yor
  154. ACMD_FUNC(partyrecall); // by Yor
  155. ACMD_FUNC(nuke); // [Valaris]
  156. ACMD_FUNC(enablenpc);
  157. ACMD_FUNC(disablenpc);
  158. ACMD_FUNC(servertime); // by Yor
  159. ACMD_FUNC(chardelitem); // by Yor
  160. ACMD_FUNC(jail); // by Yor
  161. ACMD_FUNC(unjail); // by Yor
  162. ACMD_FUNC(disguise); // [Valaris]
  163. ACMD_FUNC(undisguise); // by Yor
  164. ACMD_FUNC(chardisguise); // Kalaspuff
  165. ACMD_FUNC(charundisguise); // Kalaspuff
  166. ACMD_FUNC(email); // by Yor
  167. ACMD_FUNC(effect);//by Apple
  168. ACMD_FUNC(character_cart_list); // by Yor
  169. ACMD_FUNC(addwarp); // by MouseJstr
  170. ACMD_FUNC(follow); // by MouseJstr
  171. ACMD_FUNC(skillon); // by MouseJstr
  172. ACMD_FUNC(skilloff); // by MouseJstr
  173. ACMD_FUNC(killer); // by MouseJstr
  174. ACMD_FUNC(npcmove); // by MouseJstr
  175. ACMD_FUNC(killable); // by MouseJstr
  176. ACMD_FUNC(charkillable); // by MouseJstr
  177. ACMD_FUNC(dropall); // by MouseJstr
  178. ACMD_FUNC(chardropall); // by MouseJstr
  179. ACMD_FUNC(storeall); // by MouseJstr
  180. ACMD_FUNC(charstoreall); // by MouseJstr
  181. ACMD_FUNC(skillid); // by MouseJstr
  182. ACMD_FUNC(useskill); // by MouseJstr
  183. ACMD_FUNC(summon);
  184. ACMD_FUNC(rain);
  185. ACMD_FUNC(snow);
  186. ACMD_FUNC(sakura);
  187. ACMD_FUNC(fog);
  188. ACMD_FUNC(leaves);
  189. ACMD_FUNC(adjgmlvl); // by MouseJstr
  190. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  191. ACMD_FUNC(trade); // by MouseJstr
  192. ACMD_FUNC(send); // by davidsiaw
  193. ACMD_FUNC(setbattleflag); // by MouseJstr
  194. ACMD_FUNC(unmute); // [Valaris]
  195. ACMD_FUNC(clearweather); // Dexity
  196. ACMD_FUNC(uptime); // by MC Cameri
  197. ACMD_FUNC(changesex); // by MC Cameri
  198. ACMD_FUNC(mute); // celest
  199. ACMD_FUNC(refresh); // by MC Cameri
  200. ACMD_FUNC(petid); // by MC Cameri
  201. ACMD_FUNC(identify); // by MC Cameri
  202. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  203. ACMD_FUNC(misceffect); // by MC Cameri
  204. ACMD_FUNC(mobsearch);
  205. ACMD_FUNC(cleanmap);
  206. #ifndef TXT_ONLY
  207. ACMD_FUNC(checkmail); // [Valaris]
  208. ACMD_FUNC(listmail); // [Valaris]
  209. ACMD_FUNC(listnewmail); // [Valaris]
  210. ACMD_FUNC(readmail); // [Valaris]
  211. ACMD_FUNC(sendmail); // [Valaris]
  212. ACMD_FUNC(sendprioritymail); // [Valaris]
  213. ACMD_FUNC(deletemail); // [Valaris]
  214. //ACMD_FUNC(sound); // [Valaris]
  215. ACMD_FUNC(refreshonline); // [Valaris]
  216. #endif /* TXT_ONLY */
  217. ACMD_FUNC(skilltree); // by MouseJstr
  218. ACMD_FUNC(marry); // by MouseJstr
  219. ACMD_FUNC(divorce); // by MouseJstr
  220. ACMD_FUNC(rings); // by MouseJstr
  221. ACMD_FUNC(grind); // by MouseJstr
  222. ACMD_FUNC(grind2); // by MouseJstr
  223. #ifdef DMALLOC
  224. ACMD_FUNC(dmstart); // by MouseJstr
  225. ACMD_FUNC(dmtick); // by MouseJstr
  226. #endif
  227. ACMD_FUNC(jumptoid); // by Dino9021
  228. ACMD_FUNC(jumptoid2); // by Dino9021
  229. ACMD_FUNC(recallid); // by Dino9021
  230. ACMD_FUNC(recallid2); // by Dino9021
  231. ACMD_FUNC(kickid); // by Dino9021
  232. ACMD_FUNC(kickid2); // by Dino9021
  233. ACMD_FUNC(reviveid); // by Dino9021
  234. ACMD_FUNC(reviveid2); // by Dino9021
  235. ACMD_FUNC(killid); // by Dino9021
  236. ACMD_FUNC(killid2); // by Dino9021
  237. ACMD_FUNC(charkillableid); // by Dino9021
  238. ACMD_FUNC(charkillableid2); // by Dino9021
  239. ACMD_FUNC(sound);
  240. ACMD_FUNC(undisguiseall);
  241. ACMD_FUNC(disguiseall);
  242. /*==========================================
  243. *AtCommandInfo atcommand_info[]構造体の定義
  244. *------------------------------------------
  245. */
  246. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  247. // to set default level, read atcommand_athena.conf first please.
  248. static AtCommandInfo atcommand_info[] = {
  249. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  250. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  251. { AtCommand_Where, "@where", 1, atcommand_where },
  252. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  253. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  254. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  255. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  256. { AtCommand_Who, "@who", 20, atcommand_who },
  257. { AtCommand_Who, "@whois", 20, atcommand_who },
  258. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  259. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  260. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  261. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  262. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  263. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  264. { AtCommand_Save, "@save", 40, atcommand_save },
  265. { AtCommand_Load, "@return", 40, atcommand_load },
  266. { AtCommand_Load, "@load", 40, atcommand_load },
  267. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  268. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  269. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  270. { AtCommand_Option, "@option", 40, atcommand_option },
  271. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  272. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  273. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  274. { AtCommand_Die, "@die", 1, atcommand_die },
  275. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  276. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  277. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  278. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  279. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  280. { AtCommand_Item, "@item", 60, atcommand_item },
  281. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  282. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  283. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  284. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  285. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  286. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  287. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  288. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  289. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  290. { AtCommand_H, "@h", 20, atcommand_help },
  291. { AtCommand_Help, "@help", 20, atcommand_help },
  292. { AtCommand_GM, "@gm", 100, atcommand_gm },
  293. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  294. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  295. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  296. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  297. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  298. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  299. { AtCommand_Model, "@model", 20, atcommand_model },
  300. { AtCommand_Go, "@go", 10, atcommand_go },
  301. { AtCommand_Spawn, "@monster", 50, atcommand_spawn },
  302. { AtCommand_Spawn, "@spawn", 50, atcommand_spawn },
  303. // { AtCommand_Spawn, "@summon", 50, atcommand_spawn },
  304. { AtCommand_Monster, "@monster2", 50, atcommand_monster },
  305. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  306. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  307. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  308. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  309. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  310. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  311. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  312. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  313. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  314. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  315. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  316. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  317. { AtCommand_Strength, "@str", 60, atcommand_param },
  318. { AtCommand_Agility, "@agi", 60, atcommand_param },
  319. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  320. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  321. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  322. { AtCommand_Luck, "@luk", 60, atcommand_param },
  323. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  324. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  325. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  326. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  327. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  328. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  329. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  330. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  331. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  332. { AtCommand_Night, "@night", 80, atcommand_night },
  333. { AtCommand_Day, "@day", 80, atcommand_day },
  334. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  335. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  336. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  337. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  338. { AtCommand_CharacterBaseLevel, "@charbaselvl", 60, atcommand_character_baselevel },
  339. { AtCommand_CharacterJobLevel, "@charjlvl", 60, atcommand_character_joblevel },
  340. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  341. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  342. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  343. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  344. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  345. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  346. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  347. { AtCommand_CharQuestSkill, "@charquestskill", 60, atcommand_charquestskill },
  348. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  349. { AtCommand_CharLostSkill, "@charlostskill", 60, atcommand_charlostskill },
  350. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  351. { AtCommand_Party, "@party", 1, atcommand_party },
  352. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  353. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  354. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  355. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  356. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  357. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  358. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  359. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  360. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  361. { AtCommand_CharSkReset, "@charskreset", 60, atcommand_charskreset },
  362. { AtCommand_CharStReset, "@charstreset", 60, atcommand_charstreset },
  363. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  364. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  365. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  366. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  367. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  368. { AtCommand_CharModel, "@charmodel", 50, atcommand_charmodel },
  369. { AtCommand_CharSKPoint, "@charskpoint", 60, atcommand_charskpoint },
  370. { AtCommand_CharSTPoint, "@charstpoint", 60, atcommand_charstpoint },
  371. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  372. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  373. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  374. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  375. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  376. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  377. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  378. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  379. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  380. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  381. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  382. // { AtCommand_CharChangeSex, "@charchangesex", 60, atcommand_char_change_sex }, // by Yor
  383. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  384. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  385. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  386. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  387. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  388. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  389. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  390. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  391. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  392. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  393. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  394. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  395. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  396. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  397. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  398. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  399. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  400. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  401. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  402. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  403. { AtCommand_Enablenpc, "@enablenpc", 80, atcommand_enablenpc }, // []
  404. { AtCommand_Disablenpc, "@disablenpc", 80, atcommand_disablenpc }, // []
  405. { AtCommand_ServerTime, "@time", 0, atcommand_servertime }, // by Yor
  406. { AtCommand_ServerTime, "@date", 0, atcommand_servertime }, // by Yor
  407. { AtCommand_ServerTime, "@server_date", 0, atcommand_servertime }, // by Yor
  408. { AtCommand_ServerTime, "@serverdate", 0, atcommand_servertime }, // by Yor
  409. { AtCommand_ServerTime, "@server_time", 0, atcommand_servertime }, // by Yor
  410. { AtCommand_ServerTime, "@servertime", 0, atcommand_servertime }, // by Yor
  411. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  412. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  413. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  414. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  415. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  416. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  417. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  418. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  419. { AtCommand_EMail, "@email", 0, atcommand_email }, // by Yor
  420. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  421. // { AtCommand_Char_Item_List, "@charitemlist", 40, atcommand_character_item_list }, // by Yor, now #itemlist
  422. // { AtCommand_Char_Storage_List, "@charstoragelist", 40, atcommand_character_storage_list }, // by Yor, now #storagelist
  423. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  424. { AtCommand_Follow, "@follow", 10, atcommand_follow }, // by MouseJstr
  425. { AtCommand_AddWarp, "@addwarp", 20, atcommand_addwarp }, // by MouseJstr
  426. { AtCommand_SkillOn, "@skillon", 20, atcommand_skillon }, // by MouseJstr
  427. { AtCommand_SkillOff, "@skilloff", 20, atcommand_skilloff }, // by MouseJstr
  428. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  429. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  430. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  431. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  432. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  433. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  434. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  435. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  436. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  437. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  438. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  439. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  440. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  441. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  442. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  443. /*
  444. { AtCommand_Shuffle, "@shuffle", 99, atcommand_shuffle },
  445. { AtCommand_Maintenance, "@maintenance", 99, atcommand_maintenance },
  446. { AtCommand_Misceffect, "@misceffect", 60, atcommand_misceffect },
  447. */
  448. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  449. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  450. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  451. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  452. { AtCommand_Send, "@send", 60, atcommand_send },
  453. { AtCommand_SetBattleFlag, "@setbattleflag", 60, atcommand_setbattleflag },
  454. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  455. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  456. { AtCommand_UpTime, "@uptime", 0, atcommand_uptime }, // by MC Cameri
  457. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri
  458. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  459. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  460. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  461. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy",40, atcommand_happyhappyjoyjoy }, // [Valaris]
  462. { AtCommand_Refresh, "@refresh", 0, atcommand_refresh }, // by MC Cameri
  463. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  464. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  465. { AtCommand_Gmotd, "@gmotd", 0, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  466. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  467. { AtCommand_MobSearch, "@mobsearch", 0, atcommand_mobsearch },
  468. { AtCommand_CleanMap, "@cleanmap", 0, atcommand_cleanmap },
  469. #ifndef TXT_ONLY // sql-only commands
  470. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  471. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  472. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  473. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  474. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  475. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  476. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  477. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  478. #endif /* TXT_ONLY */
  479. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  480. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  481. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  482. { AtCommand_Rings, "@rings", 40, atcommand_rings }, // [MouseJstr]
  483. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  484. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  485. #ifdef DMALLOC
  486. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  487. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  488. #endif
  489. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  490. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  491. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  492. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  493. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  494. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  495. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  496. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  497. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  498. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  499. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  500. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  501. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  502. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  503. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  504. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  505. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  506. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  507. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  508. // add new commands before this line
  509. { AtCommand_Unknown, NULL, 1, NULL }
  510. };
  511. /*====================================================
  512. * This function return the name of the job (by [Yor])
  513. *----------------------------------------------------
  514. */
  515. char * job_name(int class_) {
  516. switch (class_) {
  517. case 0: return "Novice";
  518. case 1: return "Swordsman";
  519. case 2: return "Mage";
  520. case 3: return "Archer";
  521. case 4: return "Acolyte";
  522. case 5: return "Merchant";
  523. case 6: return "Thief";
  524. case 7: return "Knight";
  525. case 8: return "Priest";
  526. case 9: return "Wizard";
  527. case 10: return "Blacksmith";
  528. case 11: return "Hunter";
  529. case 12: return "Assassin";
  530. case 13: return "Knight 2";
  531. case 14: return "Crusader";
  532. case 15: return "Monk";
  533. case 16: return "Sage";
  534. case 17: return "Rogue";
  535. case 18: return "Alchemist";
  536. case 19: return "Bard";
  537. case 20: return "Dancer";
  538. case 21: return "Crusader 2";
  539. case 22: return "Wedding";
  540. case 23: return "Super Novice";
  541. case 4001: return "Novice High";
  542. case 4002: return "Swordsman High";
  543. case 4003: return "Mage High";
  544. case 4004: return "Archer High";
  545. case 4005: return "Acolyte High";
  546. case 4006: return "Merchant High";
  547. case 4007: return "Thief High";
  548. case 4008: return "Lord Knight";
  549. case 4009: return "High Priest";
  550. case 4010: return "High Wizard";
  551. case 4011: return "Whitesmith";
  552. case 4012: return "Sniper";
  553. case 4013: return "Assassin Cross";
  554. case 4014: return "Peko Knight";
  555. case 4015: return "Paladin";
  556. case 4016: return "Champion";
  557. case 4017: return "Professor";
  558. case 4018: return "Stalker";
  559. case 4019: return "Creator";
  560. case 4020: return "Clown";
  561. case 4021: return "Gypsy";
  562. case 4022: return "Peko Paladin";
  563. case 4023: return "Baby Novice";
  564. case 4024: return "Baby Swordsman";
  565. case 4025: return "Baby Mage";
  566. case 4026: return "Baby Archer";
  567. case 4027: return "Baby Acolyte";
  568. case 4028: return "Baby Merchant";
  569. case 4029: return "Baby Thief";
  570. case 4030: return "Baby Knight";
  571. case 4031: return "Baby Priest";
  572. case 4032: return "Baby Wizard";
  573. case 4033: return "Baby Blacksmith";
  574. case 4034: return "Baby Hunter";
  575. case 4035: return "Baby Assassin";
  576. case 4036: return "Baby Peco Knight";
  577. case 4037: return "Baby Crusader";
  578. case 4038: return "Baby Monk";
  579. case 4039: return "Baby Sage";
  580. case 4040: return "Baby Rogue";
  581. case 4041: return "Baby Alchemist";
  582. case 4042: return "Baby Bard";
  583. case 4043: return "Baby Dancer";
  584. case 4044: return "Baby Peco Crusader";
  585. case 4045: return "Super Baby";
  586. }
  587. return "Unknown Job";
  588. }
  589. /*==========================================
  590. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  591. *------------------------------------------
  592. */
  593. char *estr_lower(char *str)
  594. {
  595. int i;
  596. for (i=0; str[i]; i++)
  597. if ((str[i] >= 65) && (str[i] <= 90))
  598. str[i] += 32;
  599. return str;
  600. }
  601. // compare function for sorting high to lowest
  602. int hightolow_compare (const void * a, const void * b)
  603. {
  604. return ( *(int*)b - *(int*)a );
  605. }
  606. // compare function for sorting lowest to highest
  607. int lowtohigh_compare (const void * a, const void * b)
  608. {
  609. return ( *(int*)a - *(int*)b );
  610. }
  611. //-----------------------------------------------------------
  612. // Return the message string of the specified number by [Yor]
  613. //-----------------------------------------------------------
  614. char * msg_txt(int msg_number) {
  615. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])) &&
  616. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  617. return msg_table[msg_number];
  618. return "??";
  619. }
  620. //------------------------------------------------------------
  621. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  622. //------------------------------------------------------------
  623. int e_mail_check(unsigned char *email) {
  624. char ch;
  625. unsigned char* last_arobas;
  626. // athena limits
  627. if (strlen(email) < 3 || strlen(email) > 39)
  628. return 0;
  629. // part of RFC limits (official reference of e-mail description)
  630. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  631. return 0;
  632. if (email[strlen(email)-1] == '.')
  633. return 0;
  634. last_arobas = strrchr(email, '@');
  635. if (strstr(last_arobas, "@.") != NULL ||
  636. strstr(last_arobas, "..") != NULL)
  637. return 0;
  638. for(ch = 1; ch < 32; ch++) {
  639. if (strchr(last_arobas, ch) != NULL) {
  640. return 0;
  641. break;
  642. }
  643. }
  644. if (strchr(last_arobas, ' ') != NULL ||
  645. strchr(last_arobas, ';') != NULL)
  646. return 0;
  647. // all correct
  648. return 1;
  649. }
  650. /*==========================================
  651. * get_atcommand_level @コマンドの必要レベルを取得
  652. *------------------------------------------
  653. */
  654. int get_atcommand_level(const AtCommandType type) {
  655. int i;
  656. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  657. if (atcommand_info[i].type == type)
  658. return atcommand_info[i].level;
  659. return 100; // 100: command can not be used
  660. }
  661. /*==========================================
  662. *is_atcommand @コマンドに存在するかどうか確認する
  663. *------------------------------------------
  664. */
  665. AtCommandType
  666. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  667. const char* str = message;
  668. int s_flag = 0;
  669. AtCommandInfo info;
  670. AtCommandType type;
  671. nullpo_retr(AtCommand_None, sd);
  672. if (!battle_config.allow_atcommand_when_mute &&
  673. sd->sc_count && sd->sc_data[SC_NOCHAT].timer != -1) {
  674. return AtCommand_Unknown;
  675. }
  676. if (!message || !*message)
  677. return AtCommand_None;
  678. memset(&info, 0, sizeof(info));
  679. str += strlen(sd->status.name);
  680. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  681. if (*str == ':')
  682. s_flag = 1;
  683. str++;
  684. }
  685. if (!*str)
  686. return AtCommand_None;
  687. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  688. if (type != AtCommand_None) {
  689. char command[100];
  690. char output[200];
  691. const char* p = str;
  692. memset(command, '\0', sizeof(command));
  693. memset(output, '\0', sizeof(output));
  694. while (*p && !isspace(*p))
  695. p++;
  696. if (p - str >= sizeof(command)) // too long
  697. return AtCommand_Unknown;
  698. strncpy(command, str, p - str);
  699. while (isspace(*p))
  700. p++;
  701. if (type == AtCommand_Unknown || info.proc == NULL) {
  702. sprintf(output, msg_table[153], command); // %s is Unknown Command.
  703. clif_displaymessage(fd, output);
  704. } else {
  705. if (info.proc(fd, sd, command, p) != 0) {
  706. // Command can not be executed
  707. sprintf(output, msg_table[154], command); // %s failed.
  708. clif_displaymessage(fd, output);
  709. }
  710. }
  711. return info.type;
  712. }
  713. return AtCommand_None;
  714. }
  715. /*==========================================
  716. *
  717. *------------------------------------------
  718. */
  719. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  720. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  721. if (!info)
  722. return AtCommand_None;
  723. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  724. return AtCommand_None;
  725. if (!p || !*p) {
  726. fprintf(stderr, "at command message is empty\n");
  727. return AtCommand_None;
  728. }
  729. if (*p == command_symbol) { // check first char.
  730. char command[101];
  731. int i = 0;
  732. memset(info, 0, sizeof(AtCommandInfo));
  733. sscanf(p, "%100s", command);
  734. command[sizeof(command)-1] = '\0';
  735. while (atcommand_info[i].type != AtCommand_Unknown) {
  736. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  737. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  738. break;
  739. }
  740. i++;
  741. }
  742. if (atcommand_info[i].type == AtCommand_Unknown) {
  743. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  744. if (level == 0)
  745. return AtCommand_None;
  746. else
  747. return AtCommand_Unknown;
  748. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  749. log_atcommand(sd, message);
  750. }
  751. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  752. } else {
  753. return AtCommand_None;
  754. }
  755. return info->type;
  756. }
  757. /*==========================================
  758. *
  759. *------------------------------------------
  760. */
  761. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  762. int flag = va_arg(ap, int);
  763. nullpo_retr(0, bl);
  764. if (flag)
  765. mob_damage(NULL, (struct mob_data *)bl, ((struct mob_data *)bl)->hp, 2);
  766. else
  767. mob_delete((struct mob_data *)bl);
  768. return 0;
  769. }
  770. /*==========================================
  771. * Mob search
  772. *------------------------------------------
  773. */
  774. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  775. {
  776. int mob_id,fd;
  777. static int number=0;
  778. struct mob_data *md;
  779. char output[128];
  780. nullpo_retr(0, bl);
  781. if(!ap){
  782. number=0;
  783. return 0;
  784. }
  785. mob_id = va_arg(ap,int);
  786. fd = va_arg(ap,int);
  787. md = (struct mob_data *)bl;
  788. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  789. snprintf(output, sizeof output, "%2d[%3d:%3d] %s",
  790. ++number,bl->x, bl->y,md->name);
  791. clif_displaymessage(fd, output);
  792. }
  793. return 0;
  794. }
  795. /*==========================================
  796. * cleanmap
  797. *------------------------------------------
  798. */
  799. static int atcommand_cleanmap_sub(struct block_list *bl,va_list ap)
  800. {
  801. struct flooritem_data *fitem;
  802. nullpo_retr(0, bl);
  803. fitem = (struct flooritem_data *)bl;
  804. if(fitem==NULL || fitem->bl.type!=BL_ITEM){
  805. if(battle_config.error_log)
  806. printf("map_clearflooritem_timer : error\n");
  807. return 1;
  808. }
  809. delete_timer(fitem->cleartimer,map_clearflooritem_timer);
  810. if(fitem->item_data.card[0] == (short)0xff00)
  811. intif_delete_petdata(*((long *)(&fitem->item_data.card[1])));
  812. clif_clearflooritem(fitem,0);
  813. map_delobject(fitem->bl.id);
  814. return 0;
  815. }
  816. static int atkillnpc_sub(struct block_list *bl, va_list ap)
  817. {
  818. int flag = va_arg(ap,int);
  819. nullpo_retr(0, bl);
  820. npc_delete((struct npc_data *)bl);
  821. flag = 0;
  822. return 0;
  823. }
  824. void rehash( const int fd, struct map_session_data* sd )
  825. {
  826. int map_id = 0;
  827. int LOADED_MAPS = map_num;
  828. for (map_id = 0; map_id < LOADED_MAPS;map_id++) {
  829. if (map_id > LOADED_MAPS)
  830. break;
  831. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, 0);
  832. map_foreachinarea(atkillnpc_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_NPC, 0);
  833. }
  834. }
  835. /*==========================================
  836. * Read Message Data
  837. *------------------------------------------
  838. */
  839. int msg_config_read(const char *cfgName) {
  840. int msg_number;
  841. char line[1024], w1[1024], w2[1024];
  842. FILE *fp;
  843. if ((fp = fopen(cfgName, "r")) == NULL) {
  844. printf("Messages file not found: %s\n", cfgName);
  845. return 1;
  846. }
  847. while(fgets(line, sizeof(line)-1, fp)) {
  848. if (line[0] == '/' && line[1] == '/')
  849. continue;
  850. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  851. if (strcmpi(w1, "import") == 0) {
  852. msg_config_read(w2);
  853. } else {
  854. msg_number = atoi(w1);
  855. if (msg_number >= 0 && msg_number < (int)(sizeof(msg_table) / sizeof(msg_table[0])))
  856. strcpy(msg_table[msg_number], w2);
  857. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  858. }
  859. }
  860. }
  861. fclose(fp);
  862. return 0;
  863. }
  864. /*==========================================
  865. *
  866. *------------------------------------------
  867. */
  868. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  869. int i;
  870. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  871. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  872. return &atcommand_info[i];
  873. return NULL;
  874. }
  875. /*==========================================
  876. *
  877. *------------------------------------------
  878. */
  879. int atcommand_config_read(const char *cfgName) {
  880. char line[1024], w1[1024], w2[1024];
  881. AtCommandInfo* p;
  882. FILE* fp;
  883. if ((fp = fopen(cfgName, "r")) == NULL) {
  884. printf("At commands configuration file not found: %s\n", cfgName);
  885. return 1;
  886. }
  887. while (fgets(line, sizeof(line)-1, fp)) {
  888. if (line[0] == '/' && line[1] == '/')
  889. continue;
  890. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  891. continue;
  892. p = get_atcommandinfo_byname(w1);
  893. if (p != NULL) {
  894. p->level = atoi(w2);
  895. if (p->level > 100)
  896. p->level = 100;
  897. else if (p->level < 0)
  898. p->level = 0;
  899. }
  900. if (strcmpi(w1, "import") == 0)
  901. atcommand_config_read(w2);
  902. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  903. w2[0] != '/' && // symbol of standard ragnarok GM commands
  904. w2[0] != '%' && // symbol of party chat speaking
  905. w2[0] != '#') // symbol of charcommand
  906. command_symbol = w2[0];
  907. }
  908. fclose(fp);
  909. return 0;
  910. }
  911. /*==========================================
  912. // @ command processing functions
  913. *------------------------------------------
  914. */
  915. /*==========================================
  916. * @send (used for testing packet sends from the client)
  917. *------------------------------------------
  918. */
  919. int atcommand_send(
  920. const int fd, struct map_session_data* sd,
  921. const char* command, const char* message)
  922. {
  923. int a = atoi(message);
  924. if (a)
  925. {
  926. unsigned char buf[1024];
  927. switch(a)
  928. {
  929. case 1:
  930. WBUFW(buf,0)=0x18d;
  931. case 2:
  932. WBUFW(buf,0)=0x18e;
  933. case 3:
  934. WBUFW(buf,0)=0x18f;
  935. case 4:
  936. WBUFW(buf,0)=0x190;
  937. }
  938. }
  939. return 0;
  940. }
  941. // @rura
  942. /*==========================================
  943. *
  944. *------------------------------------------
  945. */
  946. int atcommand_rura(
  947. const int fd, struct map_session_data* sd,
  948. const char* command, const char* message)
  949. {
  950. char map_name[100];
  951. int x = 0, y = 0;
  952. int m;
  953. nullpo_retr(-1, sd);
  954. memset(map_name, '\0', sizeof(map_name));
  955. if (!message || !*message || sscanf(message, "%99s %d %d", map_name, &x, &y) < 1) {
  956. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  957. return -1;
  958. }
  959. if (x <= 0)
  960. x = rand() % 399 + 1;
  961. if (y <= 0)
  962. y = rand() % 399 + 1;
  963. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  964. strcat(map_name, ".gat");
  965. if (x > 0 && x < 400 && y > 0 && y < 400) {
  966. m = map_mapname2mapid(map_name);
  967. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  968. clif_displaymessage(fd, "You are not authorised to warp you to this map.");
  969. return -1;
  970. }
  971. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  972. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  973. return -1;
  974. }
  975. if (pc_setpos(sd, map_name, x, y, 3) == 0)
  976. clif_displaymessage(fd, msg_table[0]); // Warped.
  977. else {
  978. clif_displaymessage(fd, msg_table[1]); // Map not found.
  979. return -1;
  980. }
  981. } else {
  982. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  983. return -1;
  984. }
  985. return 0;
  986. }
  987. /*==========================================
  988. *
  989. *------------------------------------------
  990. */
  991. int atcommand_where(
  992. const int fd, struct map_session_data* sd,
  993. const char* command, const char* message)
  994. {
  995. char character[100];
  996. char output[200];
  997. struct map_session_data *pl_sd = NULL;
  998. nullpo_retr(-1, sd);
  999. if (!message || !*message)
  1000. return -1;
  1001. memset(character, '\0', sizeof character);
  1002. if (sscanf(message, "%99[^\n]", character) < 1)
  1003. return -1;
  1004. if(strncmp(sd->status.name,character,24)==0)
  1005. return -1;
  1006. if ((pl_sd = map_nick2sd(character)) == NULL) {
  1007. snprintf(output, sizeof output, "%s %d %d",
  1008. sd->mapname, sd->bl.x, sd->bl.y);
  1009. clif_displaymessage(fd, output);
  1010. return -1;
  1011. }
  1012. snprintf(output, sizeof output, "%s %s %d %d",
  1013. character, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1014. clif_displaymessage(fd, output);
  1015. return 0;
  1016. }
  1017. /*==========================================
  1018. *
  1019. *------------------------------------------
  1020. */
  1021. int atcommand_jumpto(
  1022. const int fd, struct map_session_data* sd,
  1023. const char* command, const char* message)
  1024. {
  1025. char character[100];
  1026. char output[200];
  1027. struct map_session_data *pl_sd = NULL;
  1028. nullpo_retr(-1, sd);
  1029. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1030. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1031. return -1;
  1032. }
  1033. memset(character, '\0', sizeof character);
  1034. if (sscanf(message, "%99[^\n]", character) < 1)
  1035. return -1;
  1036. if(strncmp(sd->status.name,character,24)==0) //Yourself mate? Tsk tsk tsk.
  1037. return -1;
  1038. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1039. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1040. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  1041. return -1;
  1042. }
  1043. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1044. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1045. return -1;
  1046. }
  1047. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  1048. sprintf(output, msg_table[4], character); // Jump to %s
  1049. clif_displaymessage(fd, output);
  1050. } else {
  1051. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1052. return -1;
  1053. }
  1054. return 0;
  1055. }
  1056. /*==========================================
  1057. *
  1058. *------------------------------------------
  1059. */
  1060. int atcommand_jump(
  1061. const int fd, struct map_session_data* sd,
  1062. const char* command, const char* message)
  1063. {
  1064. char output[200];
  1065. int x = 0, y = 0;
  1066. nullpo_retr(-1, sd);
  1067. memset(output, '\0', sizeof(output));
  1068. sscanf(message, "%d %d", &x, &y);
  1069. if (x <= 0)
  1070. x = rand() % 399 + 1;
  1071. if (y <= 0)
  1072. y = rand() % 399 + 1;
  1073. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1074. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1075. clif_displaymessage(fd, "You are not authorised to warp you to your actual map.");
  1076. return -1;
  1077. }
  1078. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1079. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1080. return -1;
  1081. }
  1082. pc_setpos(sd, sd->mapname, x, y, 3);
  1083. sprintf(output, msg_table[5], x, y); // Jump to %d %d
  1084. clif_displaymessage(fd, output);
  1085. } else {
  1086. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1087. return -1;
  1088. }
  1089. return 0;
  1090. }
  1091. /*==========================================
  1092. *
  1093. *------------------------------------------
  1094. */
  1095. int atcommand_who(
  1096. const int fd, struct map_session_data* sd,
  1097. const char* command, const char* message)
  1098. {
  1099. char output[200];
  1100. struct map_session_data *pl_sd;
  1101. int i, j, count;
  1102. int pl_GM_level, GM_level;
  1103. char match_text[100];
  1104. char player_name[24];
  1105. nullpo_retr(-1, sd);
  1106. memset(output, '\0', sizeof(output));
  1107. memset(match_text, '\0', sizeof(match_text));
  1108. memset(player_name, '\0', sizeof(player_name));
  1109. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1110. strcpy(match_text, "");
  1111. for (j = 0; match_text[j]; j++)
  1112. match_text[j] = tolower(match_text[j]);
  1113. count = 0;
  1114. GM_level = pc_isGM(sd);
  1115. for (i = 0; i < fd_max; i++) {
  1116. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1117. pl_GM_level = pc_isGM(pl_sd);
  1118. 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
  1119. memcpy(player_name, pl_sd->status.name, 24);
  1120. for (j = 0; player_name[j]; j++)
  1121. player_name[j] = tolower(player_name[j]);
  1122. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1123. if (pl_GM_level > 0)
  1124. 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);
  1125. else
  1126. 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);
  1127. clif_displaymessage(fd, output);
  1128. count++;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. if (count == 0)
  1134. clif_displaymessage(fd, msg_table[28]); // No player found.
  1135. else if (count == 1)
  1136. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1137. else {
  1138. sprintf(output, msg_table[30], count); // %d players found.
  1139. clif_displaymessage(fd, output);
  1140. }
  1141. return 0;
  1142. }
  1143. /*==========================================
  1144. *
  1145. *------------------------------------------
  1146. */
  1147. int atcommand_who2(
  1148. const int fd, struct map_session_data* sd,
  1149. const char* command, const char* message)
  1150. {
  1151. char output[200];
  1152. struct map_session_data *pl_sd;
  1153. int i, j, count;
  1154. int pl_GM_level, GM_level;
  1155. char match_text[100];
  1156. char player_name[24];
  1157. nullpo_retr(-1, sd);
  1158. memset(output, '\0', sizeof(output));
  1159. memset(match_text, '\0', sizeof(match_text));
  1160. memset(player_name, '\0', sizeof(player_name));
  1161. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1162. strcpy(match_text, "");
  1163. for (j = 0; match_text[j]; j++)
  1164. match_text[j] = tolower(match_text[j]);
  1165. count = 0;
  1166. GM_level = pc_isGM(sd);
  1167. for (i = 0; i < fd_max; i++) {
  1168. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1169. pl_GM_level = pc_isGM(pl_sd);
  1170. 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
  1171. memcpy(player_name, pl_sd->status.name, 24);
  1172. for (j = 0; player_name[j]; j++)
  1173. player_name[j] = tolower(player_name[j]);
  1174. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1175. if (pl_GM_level > 0)
  1176. 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);
  1177. else
  1178. 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);
  1179. clif_displaymessage(fd, output);
  1180. count++;
  1181. }
  1182. }
  1183. }
  1184. }
  1185. if (count == 0)
  1186. clif_displaymessage(fd, msg_table[28]); // No player found.
  1187. else if (count == 1)
  1188. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1189. else {
  1190. sprintf(output, msg_table[30], count); // %d players found.
  1191. clif_displaymessage(fd, output);
  1192. }
  1193. return 0;
  1194. }
  1195. /*==========================================
  1196. *
  1197. *------------------------------------------
  1198. */
  1199. int atcommand_who3(
  1200. const int fd, struct map_session_data* sd,
  1201. const char* command, const char* message)
  1202. {
  1203. char temp0[100];
  1204. char temp1[100];
  1205. char output[200];
  1206. struct map_session_data *pl_sd;
  1207. int i, j, count;
  1208. int pl_GM_level, GM_level;
  1209. char match_text[100];
  1210. char player_name[24];
  1211. struct guild *g;
  1212. struct party *p;
  1213. nullpo_retr(-1, sd);
  1214. memset(temp0, '\0', sizeof(temp0));
  1215. memset(temp1, '\0', sizeof(temp1));
  1216. memset(output, '\0', sizeof(output));
  1217. memset(match_text, '\0', sizeof(match_text));
  1218. memset(player_name, '\0', sizeof(player_name));
  1219. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1220. strcpy(match_text, "");
  1221. for (j = 0; match_text[j]; j++)
  1222. match_text[j] = tolower(match_text[j]);
  1223. count = 0;
  1224. GM_level = pc_isGM(sd);
  1225. for (i = 0; i < fd_max; i++) {
  1226. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1227. pl_GM_level = pc_isGM(pl_sd);
  1228. 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
  1229. memcpy(player_name, pl_sd->status.name, 24);
  1230. for (j = 0; player_name[j]; j++)
  1231. player_name[j] = tolower(player_name[j]);
  1232. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1233. g = guild_search(pl_sd->status.guild_id);
  1234. if (g == NULL)
  1235. sprintf(temp1, "None");
  1236. else
  1237. sprintf(temp1, "%s", g->name);
  1238. p = party_search(pl_sd->status.party_id);
  1239. if (p == NULL)
  1240. sprintf(temp0, "None");
  1241. else
  1242. sprintf(temp0, "%s", p->name);
  1243. if (pl_GM_level > 0)
  1244. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1245. else
  1246. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1247. clif_displaymessage(fd, output);
  1248. count++;
  1249. }
  1250. }
  1251. }
  1252. }
  1253. if (count == 0)
  1254. clif_displaymessage(fd, msg_table[28]); // No player found.
  1255. else if (count == 1)
  1256. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1257. else {
  1258. sprintf(output, msg_table[30], count); // %d players found.
  1259. clif_displaymessage(fd, output);
  1260. }
  1261. return 0;
  1262. }
  1263. /*==========================================
  1264. *
  1265. *------------------------------------------
  1266. */
  1267. int atcommand_whomap(
  1268. const int fd, struct map_session_data* sd,
  1269. const char* command, const char* message)
  1270. {
  1271. char output[200];
  1272. struct map_session_data *pl_sd;
  1273. int i, count;
  1274. int pl_GM_level, GM_level;
  1275. int map_id;
  1276. char map_name[100];
  1277. memset(output, '\0', sizeof(output));
  1278. memset(map_name, '\0', sizeof(map_name));
  1279. if (!message || !*message)
  1280. map_id = sd->bl.m;
  1281. else {
  1282. sscanf(message, "%99s", map_name);
  1283. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1284. strcat(map_name, ".gat");
  1285. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1286. map_id = sd->bl.m;
  1287. }
  1288. count = 0;
  1289. GM_level = pc_isGM(sd);
  1290. for (i = 0; i < fd_max; i++) {
  1291. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1292. pl_GM_level = pc_isGM(pl_sd);
  1293. 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
  1294. if (pl_sd->bl.m == map_id) {
  1295. if (pl_GM_level > 0)
  1296. 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);
  1297. else
  1298. sprintf(output, "Name: %s | Location: %s %d %d", pl_sd->status.name, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y);
  1299. clif_displaymessage(fd, output);
  1300. count++;
  1301. }
  1302. }
  1303. }
  1304. }
  1305. if (count == 0)
  1306. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1307. else if (count == 1)
  1308. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1309. else {
  1310. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1311. }
  1312. clif_displaymessage(fd, output);
  1313. return 0;
  1314. }
  1315. /*==========================================
  1316. *
  1317. *------------------------------------------
  1318. */
  1319. int atcommand_whomap2(
  1320. const int fd, struct map_session_data* sd,
  1321. const char* command, const char* message)
  1322. {
  1323. char output[200];
  1324. struct map_session_data *pl_sd;
  1325. int i, count;
  1326. int pl_GM_level, GM_level;
  1327. int map_id = 0;
  1328. char map_name[100];
  1329. nullpo_retr(-1, sd);
  1330. memset(output, '\0', sizeof(output));
  1331. memset(map_name, '\0', sizeof(map_name));
  1332. if (!message || !*message)
  1333. map_id = sd->bl.m;
  1334. else {
  1335. sscanf(message, "%99s", map_name);
  1336. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1337. strcat(map_name, ".gat");
  1338. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1339. map_id = sd->bl.m;
  1340. }
  1341. count = 0;
  1342. GM_level = pc_isGM(sd);
  1343. for (i = 0; i < fd_max; i++) {
  1344. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1345. pl_GM_level = pc_isGM(pl_sd);
  1346. 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
  1347. if (pl_sd->bl.m == map_id) {
  1348. if (pl_GM_level > 0)
  1349. 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);
  1350. else
  1351. 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);
  1352. clif_displaymessage(fd, output);
  1353. count++;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. if (count == 0)
  1359. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1360. else if (count == 1)
  1361. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1362. else {
  1363. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1364. }
  1365. clif_displaymessage(fd, output);
  1366. return 0;
  1367. }
  1368. /*==========================================
  1369. *
  1370. *------------------------------------------
  1371. */
  1372. int atcommand_whomap3(
  1373. const int fd, struct map_session_data* sd,
  1374. const char* command, const char* message)
  1375. {
  1376. char temp0[100];
  1377. char temp1[100];
  1378. char output[200];
  1379. struct map_session_data *pl_sd;
  1380. int i, count;
  1381. int pl_GM_level, GM_level;
  1382. int map_id = 0;
  1383. char map_name[100];
  1384. struct guild *g;
  1385. struct party *p;
  1386. nullpo_retr(-1, sd);
  1387. memset(temp0, '\0', sizeof(temp0));
  1388. memset(temp1, '\0', sizeof(temp1));
  1389. memset(output, '\0', sizeof(output));
  1390. memset(map_name, '\0', sizeof(map_name));
  1391. if (!message || !*message)
  1392. map_id = sd->bl.m;
  1393. else {
  1394. sscanf(message, "%99s", map_name);
  1395. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  1396. strcat(map_name, ".gat");
  1397. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1398. map_id = sd->bl.m;
  1399. }
  1400. count = 0;
  1401. GM_level = pc_isGM(sd);
  1402. for (i = 0; i < fd_max; i++) {
  1403. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1404. pl_GM_level = pc_isGM(pl_sd);
  1405. 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
  1406. if (pl_sd->bl.m == map_id) {
  1407. g = guild_search(pl_sd->status.guild_id);
  1408. if (g == NULL)
  1409. sprintf(temp1, "None");
  1410. else
  1411. sprintf(temp1, "%s", g->name);
  1412. p = party_search(pl_sd->status.party_id);
  1413. if (p == NULL)
  1414. sprintf(temp0, "None");
  1415. else
  1416. sprintf(temp0, "%s", p->name);
  1417. if (pl_GM_level > 0)
  1418. sprintf(output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1419. else
  1420. sprintf(output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1421. clif_displaymessage(fd, output);
  1422. count++;
  1423. }
  1424. }
  1425. }
  1426. }
  1427. if (count == 0)
  1428. sprintf(output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1429. else if (count == 1)
  1430. sprintf(output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1431. else {
  1432. sprintf(output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1433. }
  1434. clif_displaymessage(fd, output);
  1435. return 0;
  1436. }
  1437. /*==========================================
  1438. *
  1439. *------------------------------------------
  1440. */
  1441. int atcommand_whogm(
  1442. const int fd, struct map_session_data* sd,
  1443. const char* command, const char* message)
  1444. {
  1445. char temp0[100];
  1446. char temp1[100];
  1447. char output[200];
  1448. struct map_session_data *pl_sd;
  1449. int i, j, count;
  1450. int pl_GM_level, GM_level;
  1451. char match_text[100];
  1452. char player_name[24];
  1453. struct guild *g;
  1454. struct party *p;
  1455. nullpo_retr(-1, sd);
  1456. memset(temp0, '\0', sizeof(temp0));
  1457. memset(temp1, '\0', sizeof(temp1));
  1458. memset(output, '\0', sizeof(output));
  1459. memset(match_text, '\0', sizeof(match_text));
  1460. memset(player_name, '\0', sizeof(player_name));
  1461. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1462. strcpy(match_text, "");
  1463. for (j = 0; match_text[j]; j++)
  1464. match_text[j] = tolower(match_text[j]);
  1465. count = 0;
  1466. GM_level = pc_isGM(sd);
  1467. for (i = 0; i < fd_max; i++) {
  1468. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1469. pl_GM_level = pc_isGM(pl_sd);
  1470. if (pl_GM_level > 0) {
  1471. 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
  1472. memcpy(player_name, pl_sd->status.name, 24);
  1473. for (j = 0; player_name[j]; j++)
  1474. player_name[j] = tolower(player_name[j]);
  1475. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1476. 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);
  1477. clif_displaymessage(fd, output);
  1478. sprintf(output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1479. clif_displaymessage(fd, output);
  1480. g = guild_search(pl_sd->status.guild_id);
  1481. if (g == NULL)
  1482. sprintf(temp1, "None");
  1483. else
  1484. sprintf(temp1, "%s", g->name);
  1485. p = party_search(pl_sd->status.party_id);
  1486. if (p == NULL)
  1487. sprintf(temp0, "None");
  1488. else
  1489. sprintf(temp0, "%s", p->name);
  1490. sprintf(output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1491. clif_displaymessage(fd, output);
  1492. count++;
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. if (count == 0)
  1499. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1500. else if (count == 1)
  1501. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1502. else {
  1503. sprintf(output, msg_table[152], count); // %d GMs found.
  1504. clif_displaymessage(fd, output);
  1505. }
  1506. return 0;
  1507. }
  1508. int atcommand_whozeny(
  1509. const int fd, struct map_session_data* sd,
  1510. const char* command, const char* message)
  1511. {
  1512. char output[200];
  1513. struct map_session_data *pl_sd;
  1514. int i, j, count,c;
  1515. char match_text[100];
  1516. char player_name[24];
  1517. //int zeny[clif_countusers()];
  1518. //int counted[clif_countusers()];
  1519. int *zeny = (int *)aCallocA(clif_countusers(), sizeof(int));
  1520. int *counted = (int *)aCallocA(clif_countusers(), sizeof(int));
  1521. nullpo_retr(-1, sd);
  1522. memset(output, '\0', sizeof(output));
  1523. memset(match_text, '\0', sizeof(match_text));
  1524. memset(player_name, '\0', sizeof(player_name));
  1525. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1526. strcpy(match_text, "");
  1527. for (j = 0; match_text[j]; j++)
  1528. match_text[j] = tolower(match_text[j]);
  1529. count = 0;
  1530. for (i = 0; i < fd_max; i++) {
  1531. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1532. memcpy(player_name, pl_sd->status.name, 24);
  1533. for (j = 0; player_name[j]; j++)
  1534. player_name[j] = tolower(player_name[j]);
  1535. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1536. zeny[count]=pl_sd->status.zeny;
  1537. counted[i]=0;
  1538. count++;
  1539. }
  1540. }
  1541. }
  1542. qsort(zeny, count, sizeof(int), hightolow_compare);
  1543. for (c = 0; c < count && c < 50; c++) {
  1544. if(!zeny[c])
  1545. continue;
  1546. for (i = 0; i < fd_max; i++) {
  1547. if(!zeny[c])
  1548. continue;
  1549. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && zeny[c] && counted[i]==0) {
  1550. if(pl_sd->status.zeny==zeny[c]) {
  1551. sprintf(output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1552. clif_displaymessage(fd, output);
  1553. zeny[c]=0;
  1554. counted[i]=1;
  1555. }
  1556. }
  1557. }
  1558. }
  1559. if (count == 0)
  1560. clif_displaymessage(fd, msg_table[28]); // No player found.
  1561. else if (count == 1)
  1562. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1563. else {
  1564. sprintf(output, msg_table[30], count); // %d players found.
  1565. clif_displaymessage(fd, output);
  1566. }
  1567. free(zeny);
  1568. free(counted);
  1569. return 0;
  1570. }
  1571. // cause random emote on all online players [Valaris]
  1572. int atcommand_happyhappyjoyjoy(
  1573. const int fd, struct map_session_data* sd,
  1574. const char* command, const char* message)
  1575. {
  1576. struct map_session_data *pl_sd;
  1577. int i,e;
  1578. nullpo_retr(-1, sd);
  1579. for (i = 0; i < fd_max; i++) {
  1580. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  1581. e=rand()%40;
  1582. if(e==34)
  1583. e = 0;
  1584. clif_emotion(&pl_sd->bl,e);
  1585. }
  1586. }
  1587. return 0;
  1588. }
  1589. /*==========================================
  1590. *
  1591. *------------------------------------------
  1592. */
  1593. int atcommand_save(
  1594. const int fd, struct map_session_data* sd,
  1595. const char* command, const char* message)
  1596. {
  1597. nullpo_retr(-1, sd);
  1598. pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
  1599. if (sd->status.pet_id > 0 && sd->pd)
  1600. intif_save_petdata(sd->status.account_id, &sd->pet);
  1601. pc_makesavestatus(sd);
  1602. chrif_save(sd);
  1603. storage_storage_save(sd);
  1604. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1605. return 0;
  1606. }
  1607. /*==========================================
  1608. *
  1609. *------------------------------------------
  1610. */
  1611. int atcommand_load(
  1612. const int fd, struct map_session_data* sd,
  1613. const char* command, const char* message)
  1614. {
  1615. int m;
  1616. nullpo_retr(-1, sd);
  1617. m = map_mapname2mapid(sd->status.save_point.map);
  1618. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1619. clif_displaymessage(fd, "You are not authorised to warp you to your save map.");
  1620. return -1;
  1621. }
  1622. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1623. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  1624. return -1;
  1625. }
  1626. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1627. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1628. return 0;
  1629. }
  1630. /*==========================================
  1631. *
  1632. *------------------------------------------
  1633. */
  1634. int atcommand_speed(
  1635. const int fd, struct map_session_data* sd,
  1636. const char* command, const char* message)
  1637. {
  1638. char output[200];
  1639. int speed;
  1640. nullpo_retr(-1, sd);
  1641. memset(output, '\0', sizeof(output));
  1642. if (!message || !*message) {
  1643. sprintf(output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1644. clif_displaymessage(fd, output);
  1645. return -1;
  1646. }
  1647. speed = atoi(message);
  1648. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1649. sd->speed = speed;
  1650. //sd->walktimer = x;
  1651. //この文を追加 by れ�
  1652. clif_updatestatus(sd, SP_SPEED);
  1653. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1654. } else {
  1655. sprintf(output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1656. clif_displaymessage(fd, output);
  1657. return -1;
  1658. }
  1659. return 0;
  1660. }
  1661. /*==========================================
  1662. *
  1663. *------------------------------------------
  1664. */
  1665. int atcommand_storage(
  1666. const int fd, struct map_session_data* sd,
  1667. const char* command, const char* message)
  1668. {
  1669. nullpo_retr(-1, sd);
  1670. storage_storageopen(sd);
  1671. return 0;
  1672. }
  1673. /*==========================================
  1674. *
  1675. *------------------------------------------
  1676. */
  1677. int atcommand_guildstorage(
  1678. const int fd, struct map_session_data* sd,
  1679. const char* command, const char* message)
  1680. {
  1681. nullpo_retr(-1, sd);
  1682. if (sd->status.guild_id > 0)
  1683. storage_guild_storageopen(sd);
  1684. return 0;
  1685. }
  1686. /*==========================================
  1687. *
  1688. *------------------------------------------
  1689. */
  1690. int atcommand_option(
  1691. const int fd, struct map_session_data* sd,
  1692. const char* command, const char* message)
  1693. {
  1694. int param1 = 0, param2 = 0, param3 = 0;
  1695. nullpo_retr(-1, sd);
  1696. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1697. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1698. return -1;
  1699. }
  1700. sd->opt1 = param1;
  1701. sd->opt2 = param2;
  1702. if (!(sd->status.option & CART_MASK) && param3 & CART_MASK) {
  1703. clif_cart_itemlist(sd);
  1704. clif_cart_equiplist(sd);
  1705. clif_updatestatus(sd, SP_CARTINFO);
  1706. }
  1707. sd->status.option = param3;
  1708. // fix pecopeco display
  1709. if (sd->status.class_ == 13 || sd->status.class_ == 21 || sd->status.class_ == 4014 || sd->status.class_ == 4022) {
  1710. if (!pc_isriding(sd)) { // sd have the new value...
  1711. if (sd->status.class_ == 13)
  1712. sd->status.class_ = sd->view_class = 7;
  1713. else if (sd->status.class_ == 21)
  1714. sd->status.class_ = sd->view_class = 14;
  1715. else if (sd->status.class_ == 4014)
  1716. sd->status.class_ = sd->view_class = 4008;
  1717. else if (sd->status.class_ == 4022)
  1718. sd->status.class_ = sd->view_class = 4015;
  1719. }
  1720. } else {
  1721. if (pc_isriding(sd)) { // sd have the new value...
  1722. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] (code added by [Yor])
  1723. sd->status.option &= ~0x0020;
  1724. } else {
  1725. if (sd->status.class_ == 7)
  1726. sd->status.class_ = sd->view_class = 13;
  1727. else if (sd->status.class_ == 14)
  1728. sd->status.class_ = sd->view_class = 21;
  1729. else if (sd->status.class_ == 4008)
  1730. sd->status.class_ = sd->view_class = 4014;
  1731. else if (sd->status.class_ == 4015)
  1732. sd->status.class_ = sd->view_class = 4022;
  1733. else
  1734. sd->status.option &= ~0x0020;
  1735. }
  1736. }
  1737. }
  1738. clif_changeoption(&sd->bl);
  1739. status_calc_pc(sd, 0);
  1740. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1741. return 0;
  1742. }
  1743. /*==========================================
  1744. *
  1745. *------------------------------------------
  1746. */
  1747. int atcommand_hide(
  1748. const int fd, struct map_session_data* sd,
  1749. const char* command, const char* message)
  1750. {
  1751. nullpo_retr(-1, sd);
  1752. if (sd->status.option & OPTION_HIDE) {
  1753. sd->status.option &= ~OPTION_HIDE;
  1754. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1755. } else {
  1756. sd->status.option |= OPTION_HIDE;
  1757. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1758. }
  1759. clif_changeoption(&sd->bl);
  1760. return 0;
  1761. }
  1762. /*==========================================
  1763. * 転職する upperを指定すると転生や養子にもなれる
  1764. *------------------------------------------
  1765. */
  1766. int atcommand_jobchange(
  1767. const int fd, struct map_session_data* sd,
  1768. const char* command, const char* message)
  1769. {
  1770. int job = 0, upper = 0;
  1771. nullpo_retr(-1, sd);
  1772. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1773. int i, found = 0;
  1774. const struct { char name[16]; int id; } jobs[] = {
  1775. { "novice", 0 },
  1776. { "swordsman", 1 },
  1777. { "mage", 2 },
  1778. { "archer", 3 },
  1779. { "acolyte", 4 },
  1780. { "merchant", 5 },
  1781. { "thief", 6 },
  1782. { "knight", 7 },
  1783. { "priest", 8 },
  1784. { "priestess", 8 },
  1785. { "wizard", 9 },
  1786. { "blacksmith", 10 },
  1787. { "hunter", 11 },
  1788. { "assassin", 12 },
  1789. { "crusader", 14 },
  1790. { "monk", 15 },
  1791. { "sage", 16 },
  1792. { "rogue", 17 },
  1793. { "alchemist", 18 },
  1794. { "bard", 19 },
  1795. { "dancer", 20 },
  1796. { "super novice", 23 },
  1797. { "supernovice", 23 },
  1798. { "high novice", 4001 },
  1799. { "swordsman high", 4002 },
  1800. { "mage high", 4003 },
  1801. { "archer high", 4004 },
  1802. { "acolyte high", 4005 },
  1803. { "merchant high", 4006 },
  1804. { "thief high", 4007 },
  1805. { "lord knight", 4008 },
  1806. { "high priest", 4009 },
  1807. { "high priestess", 4009 },
  1808. { "high wizard", 4010 },
  1809. { "whitesmith", 4011 },
  1810. { "sniper", 4012 },
  1811. { "assassin cross", 4013 },
  1812. { "paladin", 4015 },
  1813. { "champion", 4016 },
  1814. { "professor", 4017 },
  1815. { "stalker", 4018 },
  1816. { "creator", 4019 },
  1817. { "clown", 4020 },
  1818. { "gypsy", 4021 },
  1819. { "baby novice", 4023 },
  1820. { "baby swordsman", 4024 },
  1821. { "baby mage", 4025 },
  1822. { "baby archer", 4026 },
  1823. { "baby acolyte", 4027 },
  1824. { "baby merchant", 4028 },
  1825. { "baby thief", 4029 },
  1826. { "baby knight", 4030 },
  1827. { "baby priest", 4031 },
  1828. { "baby priestess", 4031 },
  1829. { "baby wizard", 4032 },
  1830. { "baby blacksmith",4033 },
  1831. { "baby hunter", 4034 },
  1832. { "baby assassin", 4035 },
  1833. { "baby crusader", 4037 },
  1834. { "baby monk", 4038 },
  1835. { "baby sage", 4039 },
  1836. { "baby rogue", 4040 },
  1837. { "baby alchemist", 4041 },
  1838. { "baby bard", 4042 },
  1839. { "baby dancer", 4043 },
  1840. { "super baby", 4045 },
  1841. };
  1842. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  1843. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1844. job = jobs[i].id;
  1845. upper = 0;
  1846. found = 1;
  1847. break;
  1848. }
  1849. }
  1850. if (!found) {
  1851. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  1852. return -1;
  1853. }
  1854. }
  1855. if (job == 37 ||job == 45)
  1856. return 0;
  1857. if ((job >= 0 && job < MAX_PC_CLASS)) {
  1858. int j;
  1859. // fix pecopeco display
  1860. if ((job != 13 && job != 21 && job != 4014 && job != 4022)) {
  1861. if (pc_isriding(sd)) {
  1862. if (sd->status.class_ == 13)
  1863. sd->status.class_ = sd->view_class = 7;
  1864. if (sd->status.class_ == 21)
  1865. sd->status.class_ = sd->view_class = 14;
  1866. if (sd->status.class_ == 4014)
  1867. sd->status.class_ = sd->view_class = 4008;
  1868. if (sd->status.class_ == 4022)
  1869. sd->status.class_ = sd->view_class = 4015;
  1870. sd->status.option &= ~0x0020;
  1871. clif_changeoption(&sd->bl);
  1872. status_calc_pc(sd, 0);
  1873. }
  1874. } else {
  1875. if (!pc_isriding(sd)) {
  1876. if (job == 13)
  1877. job = 7;
  1878. if (job == 21)
  1879. job = 14;
  1880. if (job == 4014)
  1881. job = 4008;
  1882. if (job == 4022)
  1883. job = 4015;
  1884. }
  1885. }
  1886. for (j=0; j < MAX_INVENTORY; j++) {
  1887. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  1888. pc_unequipitem(sd, j, 3);
  1889. }
  1890. if (pc_jobchange(sd, job, upper) == 0)
  1891. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  1892. else {
  1893. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  1894. return -1;
  1895. }
  1896. } else {
  1897. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  1898. return -1;
  1899. }
  1900. return 0;
  1901. }
  1902. /*==========================================
  1903. *
  1904. *------------------------------------------
  1905. */
  1906. int atcommand_die(
  1907. const int fd, struct map_session_data* sd,
  1908. const char* command, const char* message)
  1909. {
  1910. nullpo_retr(-1, sd);
  1911. clif_specialeffect(&sd->bl,450,1);
  1912. pc_damage(NULL, sd, sd->status.hp + 1);
  1913. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  1914. return 0;
  1915. }
  1916. /*==========================================
  1917. *
  1918. *------------------------------------------
  1919. */
  1920. int atcommand_kill(
  1921. const int fd, struct map_session_data* sd,
  1922. const char* command, const char* message)
  1923. {
  1924. char character[100];
  1925. struct map_session_data *pl_sd;
  1926. nullpo_retr(-1, sd);
  1927. memset(character, '\0', sizeof(character));
  1928. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  1929. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  1930. return -1;
  1931. }
  1932. if ((pl_sd = map_nick2sd(character)) != NULL) {
  1933. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  1934. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  1935. clif_displaymessage(fd, msg_table[14]); // Character killed.
  1936. } else {
  1937. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  1938. return -1;
  1939. }
  1940. } else {
  1941. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1942. return -1;
  1943. }
  1944. return 0;
  1945. }
  1946. /*==========================================
  1947. *
  1948. *------------------------------------------
  1949. */
  1950. int atcommand_alive(
  1951. const int fd, struct map_session_data* sd,
  1952. const char* command, const char* message)
  1953. {
  1954. nullpo_retr(-1, sd);
  1955. if (pc_isdead(sd)) {
  1956. sd->status.hp = sd->status.max_hp;
  1957. sd->status.sp = sd->status.max_sp;
  1958. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1959. pc_setstand(sd);
  1960. if (battle_config.pc_invincible_time > 0)
  1961. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  1962. clif_updatestatus(sd, SP_HP);
  1963. clif_updatestatus(sd, SP_SP);
  1964. clif_resurrection(&sd->bl, 1);
  1965. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  1966. return 0;
  1967. }
  1968. return -1;
  1969. }
  1970. /*==========================================
  1971. *
  1972. *------------------------------------------
  1973. */
  1974. int atcommand_kami(
  1975. const int fd, struct map_session_data* sd,
  1976. const char* command, const char* message)
  1977. {
  1978. char output[200];
  1979. nullpo_retr(-1, sd);
  1980. memset(output, '\0', sizeof(output));
  1981. if (!message || !*message) {
  1982. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1983. return -1;
  1984. }
  1985. sscanf(message, "%199[^\n]", output);
  1986. intif_GMmessage(output, strlen(output) + 1, (*(command + 5) == 'b') ? 0x10 : 0);
  1987. return 0;
  1988. }
  1989. /*==========================================
  1990. *
  1991. *------------------------------------------
  1992. */
  1993. int atcommand_heal(
  1994. const int fd, struct map_session_data* sd,
  1995. const char* command, const char* message)
  1996. {
  1997. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1998. nullpo_retr(-1, sd);
  1999. sscanf(message, "%d %d", &hp, &sp);
  2000. if (hp == 0 && sp == 0) {
  2001. hp = sd->status.max_hp - sd->status.hp;
  2002. sp = sd->status.max_sp - sd->status.sp;
  2003. } else {
  2004. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2005. hp = sd->status.max_hp - sd->status.hp;
  2006. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2007. hp = 1 - sd->status.hp;
  2008. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2009. sp = sd->status.max_sp - sd->status.sp;
  2010. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2011. sp = 1 - sd->status.sp;
  2012. }
  2013. if (hp > 0) // display like heal
  2014. clif_heal(fd, SP_HP, hp);
  2015. else if (hp < 0) // display like damage
  2016. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2017. if (sp > 0) // no display when we lost SP
  2018. clif_heal(fd, SP_SP, sp);
  2019. if (hp != 0 || sp != 0) {
  2020. pc_heal(sd, hp, sp);
  2021. if (hp >= 0 && sp >= 0)
  2022. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2023. else
  2024. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2025. } else {
  2026. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2027. return -1;
  2028. }
  2029. return 0;
  2030. }
  2031. /*==========================================
  2032. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2033. *------------------------------------------
  2034. */
  2035. int atcommand_item(
  2036. const int fd, struct map_session_data* sd,
  2037. const char* command, const char* message)
  2038. {
  2039. char item_name[100];
  2040. int number = 0, item_id, flag;
  2041. struct item item_tmp;
  2042. struct item_data *item_data;
  2043. int get_count, i, pet_id;
  2044. nullpo_retr(-1, sd);
  2045. memset(item_name, '\0', sizeof(item_name));
  2046. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2047. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2048. return -1;
  2049. }
  2050. if (number <= 0)
  2051. number = 1;
  2052. item_id = 0;
  2053. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2054. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2055. item_id = item_data->nameid;
  2056. if (item_id >= 500) {
  2057. get_count = number;
  2058. // check pet egg
  2059. pet_id = search_petDB_index(item_id, PET_EGG);
  2060. if (item_data->type == 4 || item_data->type == 5 ||
  2061. item_data->type == 7 || item_data->type == 8) {
  2062. get_count = 1;
  2063. }
  2064. for (i = 0; i < number; i += get_count) {
  2065. // if pet egg
  2066. if (pet_id >= 0) {
  2067. sd->catch_target_class = pet_db[pet_id].class_;
  2068. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2069. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  2070. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2071. 100, 0, 1, pet_db[pet_id].jname);
  2072. // if not pet egg
  2073. } else {
  2074. memset(&item_tmp, 0, sizeof(item_tmp));
  2075. item_tmp.nameid = item_id;
  2076. item_tmp.identify = 1;
  2077. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2078. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2079. }
  2080. }
  2081. clif_displaymessage(fd, msg_table[18]); // Item created.
  2082. } else {
  2083. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2084. return -1;
  2085. }
  2086. return 0;
  2087. }
  2088. /*==========================================
  2089. *
  2090. *------------------------------------------
  2091. */
  2092. int atcommand_item2(
  2093. const int fd, struct map_session_data* sd,
  2094. const char* command, const char* message)
  2095. {
  2096. struct item item_tmp;
  2097. struct item_data *item_data;
  2098. char item_name[100];
  2099. int item_id, number = 0;
  2100. int identify = 0, refine = 0, attr = 0;
  2101. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2102. int flag;
  2103. int loop, get_count, i;
  2104. nullpo_retr(-1, sd);
  2105. memset(item_name, '\0', sizeof(item_name));
  2106. 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) {
  2107. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2108. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2109. return -1;
  2110. }
  2111. if (number <= 0)
  2112. number = 1;
  2113. item_id = 0;
  2114. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2115. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2116. item_id = item_data->nameid;
  2117. if (item_id > 500) {
  2118. loop = 1;
  2119. get_count = number;
  2120. if (item_data->type == 4 || item_data->type == 5 ||
  2121. item_data->type == 7 || item_data->type == 8) {
  2122. loop = number;
  2123. get_count = 1;
  2124. if (item_data->type == 7) {
  2125. identify = 1;
  2126. refine = 0;
  2127. }
  2128. if (item_data->type == 8)
  2129. refine = 0;
  2130. if (refine > 10)
  2131. refine = 10;
  2132. } else {
  2133. identify = 1;
  2134. refine = attr = 0;
  2135. }
  2136. for (i = 0; i < loop; i++) {
  2137. memset(&item_tmp, 0, sizeof(item_tmp));
  2138. item_tmp.nameid = item_id;
  2139. item_tmp.identify = identify;
  2140. item_tmp.refine = refine;
  2141. item_tmp.attribute = attr;
  2142. item_tmp.card[0] = c1;
  2143. item_tmp.card[1] = c2;
  2144. item_tmp.card[2] = c3;
  2145. item_tmp.card[3] = c4;
  2146. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2147. clif_additem(sd, 0, 0, flag);
  2148. }
  2149. clif_displaymessage(fd, msg_table[18]); // Item created.
  2150. } else {
  2151. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2152. return -1;
  2153. }
  2154. return 0;
  2155. }
  2156. /*==========================================
  2157. *
  2158. *------------------------------------------
  2159. */
  2160. int atcommand_itemreset(
  2161. const int fd, struct map_session_data* sd,
  2162. const char* command, const char* message)
  2163. {
  2164. int i;
  2165. nullpo_retr(-1, sd);
  2166. for (i = 0; i < MAX_INVENTORY; i++) {
  2167. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0)
  2168. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2169. }
  2170. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2171. return 0;
  2172. }
  2173. /*==========================================
  2174. *
  2175. *------------------------------------------
  2176. */
  2177. int atcommand_itemcheck(
  2178. const int fd, struct map_session_data* sd,
  2179. const char* command, const char* message)
  2180. {
  2181. nullpo_retr(-1, sd);
  2182. pc_checkitem(sd);
  2183. return 0;
  2184. }
  2185. /*==========================================
  2186. *
  2187. *------------------------------------------
  2188. */
  2189. int atcommand_baselevelup(
  2190. const int fd, struct map_session_data* sd,
  2191. const char* command, const char* message)
  2192. {
  2193. int level, i;
  2194. nullpo_retr(-1, sd);
  2195. if (!message || !*message || (level = atoi(message)) == 0) {
  2196. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2197. return -1;
  2198. }
  2199. if (level > 0) {
  2200. if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  2201. clif_displaymessage(fd, msg_table[47]); // Base level can't go any higher.
  2202. return -1;
  2203. } // End Addition
  2204. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow
  2205. level = battle_config.maximum_level - sd->status.base_level;
  2206. for (i = 1; i <= level; i++)
  2207. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2208. sd->status.base_level += level;
  2209. clif_updatestatus(sd, SP_BASELEVEL);
  2210. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2211. clif_updatestatus(sd, SP_STATUSPOINT);
  2212. status_calc_pc(sd, 0);
  2213. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2214. clif_misceffect(&sd->bl, 0);
  2215. clif_displaymessage(fd, msg_table[21]); // Base level raised.
  2216. } else {
  2217. if (sd->status.base_level == 1) {
  2218. clif_displaymessage(fd, msg_table[158]); // Base level can't go any lower.
  2219. return -1;
  2220. }
  2221. if (level < -(int)battle_config.maximum_level || level < (1 - (int)sd->status.base_level)) // fix negativ overflow
  2222. level = 1 - sd->status.base_level;
  2223. if (sd->status.status_point > 0) {
  2224. for (i = 0; i > level; i--)
  2225. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2226. if (sd->status.status_point < 0)
  2227. sd->status.status_point = 0;
  2228. clif_updatestatus(sd, SP_STATUSPOINT);
  2229. } // to add: remove status points from stats
  2230. sd->status.base_level += level;
  2231. clif_updatestatus(sd, SP_BASELEVEL);
  2232. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2233. status_calc_pc(sd, 0);
  2234. clif_displaymessage(fd, msg_table[22]); // Base level lowered.
  2235. }
  2236. return 0;
  2237. }
  2238. /*==========================================
  2239. *
  2240. *------------------------------------------
  2241. */
  2242. int atcommand_joblevelup(
  2243. const int fd, struct map_session_data* sd,
  2244. const char* command, const char* message)
  2245. {
  2246. unsigned int up_level = 50;
  2247. int level;
  2248. struct pc_base_job s_class;
  2249. nullpo_retr(-1, sd);
  2250. s_class = pc_calc_base_job(sd->status.class_);
  2251. if (!message || !*message || (level = atoi(message)) == 0) {
  2252. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2253. return -1;
  2254. }
  2255. if (s_class.job == 0)
  2256. up_level -= 40;
  2257. // super novices can go up to 99 [celest]
  2258. else if (s_class.job == 23)
  2259. up_level += 49;
  2260. else if (sd->status.class_ > 4007 && sd->status.class_ < 4023)
  2261. up_level += 20;
  2262. if (level > 0) {
  2263. if (sd->status.job_level == up_level) {
  2264. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2265. return -1;
  2266. }
  2267. if ((unsigned int)level > up_level || (unsigned int)level > (up_level - sd->status.job_level)) // fix positiv overflow
  2268. level = up_level - sd->status.job_level;
  2269. sd->status.job_level += level;
  2270. clif_updatestatus(sd, SP_JOBLEVEL);
  2271. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2272. sd->status.skill_point += level;
  2273. clif_updatestatus(sd, SP_SKILLPOINT);
  2274. status_calc_pc(sd, 0);
  2275. clif_misceffect(&sd->bl, 1);
  2276. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2277. } else {
  2278. if (sd->status.job_level == 1) {
  2279. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2280. return -1;
  2281. }
  2282. if (level < -(int)up_level || level < (1 - (int)sd->status.job_level)) // fix negativ overflow
  2283. level = 1 - sd->status.job_level;
  2284. sd->status.job_level += level;
  2285. clif_updatestatus(sd, SP_JOBLEVEL);
  2286. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2287. if (sd->status.skill_point > 0) {
  2288. sd->status.skill_point += level;
  2289. if (sd->status.skill_point < 0)
  2290. sd->status.skill_point = 0;
  2291. clif_updatestatus(sd, SP_SKILLPOINT);
  2292. } // to add: remove status points from skills
  2293. status_calc_pc(sd, 0);
  2294. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2295. }
  2296. return 0;
  2297. }
  2298. /*==========================================
  2299. *
  2300. *------------------------------------------
  2301. */
  2302. int atcommand_help(
  2303. const int fd, struct map_session_data* sd,
  2304. const char* command, const char* message)
  2305. {
  2306. char buf[2048], w1[2048], w2[2048];
  2307. int i, gm_level;
  2308. FILE* fp;
  2309. nullpo_retr(-1, sd);
  2310. memset(buf, '\0', sizeof(buf));
  2311. if ((fp = fopen(help_txt, "r")) != NULL) {
  2312. clif_displaymessage(fd, msg_table[26]); // Help commands:
  2313. gm_level = pc_isGM(sd);
  2314. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2315. if (buf[0] == '/' && buf[1] == '/')
  2316. continue;
  2317. for (i = 0; buf[i] != '\0'; i++) {
  2318. if (buf[i] == '\r' || buf[i] == '\n') {
  2319. buf[i] = '\0';
  2320. break;
  2321. }
  2322. }
  2323. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2324. clif_displaymessage(fd, buf);
  2325. else if (gm_level >= atoi(w1))
  2326. clif_displaymessage(fd, w2);
  2327. }
  2328. fclose(fp);
  2329. } else {
  2330. clif_displaymessage(fd, msg_table[27]); // File help.txt not found.
  2331. return -1;
  2332. }
  2333. return 0;
  2334. }
  2335. /*==========================================
  2336. *
  2337. *------------------------------------------
  2338. */
  2339. int atcommand_gm(
  2340. const int fd, struct map_session_data* sd,
  2341. const char* command, const char* message)
  2342. {
  2343. char password[100];
  2344. nullpo_retr(-1, sd);
  2345. memset(password, '\0', sizeof(password));
  2346. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2347. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2348. return -1;
  2349. }
  2350. if (pc_isGM(sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!)
  2351. clif_displaymessage(fd, msg_table[50]); // You already have some GM powers.
  2352. return -1;
  2353. } else
  2354. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2355. return 0;
  2356. }
  2357. /*==========================================
  2358. *
  2359. *------------------------------------------
  2360. */
  2361. int atcommand_pvpoff(
  2362. const int fd, struct map_session_data* sd,
  2363. const char* command, const char* message)
  2364. {
  2365. struct map_session_data *pl_sd;
  2366. int i;
  2367. nullpo_retr(-1, sd);
  2368. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2369. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2370. return -1;
  2371. }
  2372. if (map[sd->bl.m].flag.pvp) {
  2373. map[sd->bl.m].flag.pvp = 0;
  2374. clif_send0199(sd->bl.m, 0);
  2375. for (i = 0; i < fd_max; i++) { //人数分ループ
  2376. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2377. if (sd->bl.m == pl_sd->bl.m) {
  2378. clif_pvpset(pl_sd, 0, 0, 2);
  2379. if (pl_sd->pvp_timer != -1) {
  2380. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2381. pl_sd->pvp_timer = -1;
  2382. }
  2383. }
  2384. }
  2385. }
  2386. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2387. } else {
  2388. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2389. return -1;
  2390. }
  2391. return 0;
  2392. }
  2393. /*==========================================
  2394. *
  2395. *------------------------------------------
  2396. */
  2397. int atcommand_pvpon(
  2398. const int fd, struct map_session_data* sd,
  2399. const char* command, const char* message)
  2400. {
  2401. struct map_session_data *pl_sd;
  2402. int i;
  2403. nullpo_retr(-1, sd);
  2404. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2405. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2406. return -1;
  2407. }
  2408. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2409. map[sd->bl.m].flag.pvp = 1;
  2410. clif_send0199(sd->bl.m, 1);
  2411. for (i = 0; i < fd_max; i++) {
  2412. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  2413. if (sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2414. pl_sd->pvp_timer = add_timer(gettick() + 200,
  2415. pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2416. pl_sd->pvp_rank = 0;
  2417. pl_sd->pvp_lastusers = 0;
  2418. pl_sd->pvp_point = 5;
  2419. }
  2420. }
  2421. }
  2422. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2423. } else {
  2424. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2425. return -1;
  2426. }
  2427. return 0;
  2428. }
  2429. /*==========================================
  2430. *
  2431. *------------------------------------------
  2432. */
  2433. int atcommand_gvgoff(
  2434. const int fd, struct map_session_data* sd,
  2435. const char* command, const char* message)
  2436. {
  2437. nullpo_retr(-1, sd);
  2438. if (map[sd->bl.m].flag.gvg) {
  2439. map[sd->bl.m].flag.gvg = 0;
  2440. clif_send0199(sd->bl.m, 0);
  2441. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2442. } else {
  2443. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2444. return -1;
  2445. }
  2446. return 0;
  2447. }
  2448. /*==========================================
  2449. *
  2450. *------------------------------------------
  2451. */
  2452. int atcommand_gvgon(
  2453. const int fd, struct map_session_data* sd,
  2454. const char* command, const char* message)
  2455. {
  2456. nullpo_retr(-1, sd);
  2457. if (!map[sd->bl.m].flag.gvg) {
  2458. map[sd->bl.m].flag.gvg = 1;
  2459. clif_send0199(sd->bl.m, 3);
  2460. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2461. } else {
  2462. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2463. return -1;
  2464. }
  2465. return 0;
  2466. }
  2467. /*==========================================
  2468. *
  2469. *------------------------------------------
  2470. */
  2471. int atcommand_model(
  2472. const int fd, struct map_session_data* sd,
  2473. const char* command, const char* message)
  2474. {
  2475. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2476. char output[200];
  2477. nullpo_retr(-1, sd);
  2478. memset(output, '\0', sizeof(output));
  2479. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2480. sprintf(output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2481. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2482. clif_displaymessage(fd, output);
  2483. return -1;
  2484. }
  2485. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2486. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2487. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2488. //服の色変更
  2489. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2490. //服の色未実装職の判定
  2491. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2492. return -1;
  2493. } else {
  2494. pc_changelook(sd, LOOK_HAIR, hair_style);
  2495. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2496. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2497. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2498. }
  2499. } else {
  2500. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2501. return -1;
  2502. }
  2503. return 0;
  2504. }
  2505. /*==========================================
  2506. * @dye && @ccolor
  2507. *------------------------------------------
  2508. */
  2509. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2510. {
  2511. int cloth_color = 0;
  2512. char output[200];
  2513. nullpo_retr(-1, sd);
  2514. memset(output, '\0', sizeof(output));
  2515. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2516. sprintf(output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2517. clif_displaymessage(fd, output);
  2518. return -1;
  2519. }
  2520. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2521. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2522. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2523. } else {
  2524. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2525. return -1;
  2526. }
  2527. return 0;
  2528. }
  2529. /*==========================================
  2530. * @hairstyle && @hstyle
  2531. *------------------------------------------
  2532. */
  2533. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2534. {
  2535. int hair_style = 0;
  2536. char output[200];
  2537. nullpo_retr(-1, sd);
  2538. memset(output, '\0', sizeof(output));
  2539. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2540. sprintf(output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2541. clif_displaymessage(fd, output);
  2542. return -1;
  2543. }
  2544. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2545. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2546. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2547. return -1;
  2548. } else {
  2549. pc_changelook(sd, LOOK_HAIR, hair_style);
  2550. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2551. }
  2552. } else {
  2553. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2554. return -1;
  2555. }
  2556. return 0;
  2557. }
  2558. /*==========================================
  2559. * @charhairstyle by [MouseJstr]
  2560. *------------------------------------------
  2561. */
  2562. int
  2563. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2564. const char* command, const char* message)
  2565. {
  2566. nullpo_retr(-1, sd);
  2567. return 0;
  2568. }
  2569. /*==========================================
  2570. * @haircolor && @hcolor
  2571. *------------------------------------------
  2572. */
  2573. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2574. {
  2575. int hair_color = 0;
  2576. char output[200];
  2577. nullpo_retr(-1, sd);
  2578. memset(output, '\0', sizeof(output));
  2579. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2580. sprintf(output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2581. clif_displaymessage(fd, output);
  2582. return -1;
  2583. }
  2584. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2585. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == 12 || sd->status.class_ == 17)) {
  2586. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2587. return -1;
  2588. } else {
  2589. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2590. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2591. }
  2592. } else {
  2593. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2594. return -1;
  2595. }
  2596. return 0;
  2597. }
  2598. /*==========================================
  2599. * @go [city_number/city_name]: improved by [yor] to add city names and help
  2600. *------------------------------------------
  2601. */
  2602. int atcommand_go(
  2603. const int fd, struct map_session_data* sd,
  2604. const char* command, const char* message)
  2605. {
  2606. int i;
  2607. int town;
  2608. char map_name[100];
  2609. char output[200];
  2610. int m;
  2611. const struct { char map[16]; int x, y; } data[] = {
  2612. { "prontera.gat", 156, 191 }, // 0=Prontera
  2613. { "morocc.gat", 156, 93 }, // 1=Morroc
  2614. { "geffen.gat", 119, 59 }, // 2=Geffen
  2615. { "payon.gat", 162, 233 }, // 3=Payon
  2616. { "alberta.gat", 192, 147 }, // 4=Alberta
  2617. { "izlude.gat", 128, 114 }, // 5=Izlude
  2618. { "aldebaran.gat",140, 131 }, // 6=Al de Baran
  2619. { "xmas.gat", 147, 134 }, // 7=Lutie
  2620. { "comodo.gat", 209, 143 }, // 8=Comodo
  2621. { "yuno.gat", 157, 51 }, // 9=Yuno
  2622. { "amatsu.gat", 198, 84 }, // 10=Amatsu
  2623. { "gonryun.gat", 160, 120 }, // 11=Gon Ryun
  2624. { "umbala.gat", 89, 157 }, // 12=Umbala
  2625. { "niflheim.gat", 21, 153 }, // 13=Niflheim
  2626. { "louyang.gat", 217, 40 }, // 14=Lou Yang
  2627. { "new_1-1.gat", 53, 111 }, // 15=Start point
  2628. { "sec_pri.gat", 23, 61 }, // 16=Prison
  2629. { "jawaii.gat", 249, 127 }, // 17=Jawaii
  2630. { "ayothaya.gat", 151, 117 }, // 18=Ayothaya
  2631. };
  2632. nullpo_retr(-1, sd);
  2633. if(map[sd->bl.m].flag.nogo) {
  2634. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2635. return 0;
  2636. }
  2637. memset(map_name, '\0', sizeof(map_name));
  2638. memset(output, '\0', sizeof(output));
  2639. // get the number
  2640. town = atoi(message);
  2641. // if no value, display all value
  2642. if (!message || !*message || sscanf(message, "%99s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2643. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2644. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2645. clif_displaymessage(fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun");
  2646. clif_displaymessage(fd, "-2=(Memo point 1) 5=Izlude 12=Umbala");
  2647. clif_displaymessage(fd, "-1=(Memo point 0) 6=Al de Baran 13=Niflheim");
  2648. clif_displaymessage(fd, " 0=Prontera 7=Lutie 14=Lou Yang");
  2649. clif_displaymessage(fd, " 1=Morroc 8=Comodo 15=Start point");
  2650. clif_displaymessage(fd, " 2=Geffen 9=Yuno 16=Prison");
  2651. clif_displaymessage(fd, " 3=Payon 10=Amatsu 17=Jawaii");
  2652. clif_displaymessage(fd, " 18=Ayothaya");
  2653. return -1;
  2654. } else {
  2655. // get possible name of the city and add .gat if not in the name
  2656. map_name[sizeof(map_name)-1] = '\0';
  2657. for (i = 0; map_name[i]; i++)
  2658. map_name[i] = tolower(map_name[i]);
  2659. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  2660. strcat(map_name, ".gat");
  2661. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2662. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2663. town = 0;
  2664. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2665. town = 1;
  2666. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2667. town = 2;
  2668. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2669. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2670. town = 3;
  2671. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2672. town = 4;
  2673. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2674. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2675. town = 5;
  2676. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2677. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2678. town = 6;
  2679. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2680. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2681. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2682. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2683. town = 7;
  2684. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2685. town = 8;
  2686. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2687. town = 9;
  2688. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2689. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2690. town = 10;
  2691. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2692. town = 11;
  2693. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2694. town = 12;
  2695. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2696. town = 13;
  2697. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2698. town = 14;
  2699. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2700. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2701. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2702. town = 15;
  2703. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2704. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2705. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2706. town = 16;
  2707. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2708. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2709. town = 17;
  2710. } else if (strncmp(map_name, "ayothaya.gat", 4) == 0 || // 3 first characters
  2711. strncmp(map_name, "ayotaya.gat", 4) == 0) { // writing error (3 first characters)
  2712. town = 18;
  2713. }
  2714. if (town >= -3 && town <= -1) {
  2715. if (sd->status.memo_point[-town-1].map[0]) {
  2716. m = map_mapname2mapid(sd->status.memo_point[-town-1].map);
  2717. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2718. clif_displaymessage(fd, "You are not authorised to warp you to this memo map.");
  2719. return -1;
  2720. }
  2721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2722. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2723. return -1;
  2724. }
  2725. 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) {
  2726. clif_displaymessage(fd, msg_table[0]); // Warped.
  2727. } else {
  2728. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2729. return -1;
  2730. }
  2731. } else {
  2732. sprintf(output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2733. clif_displaymessage(fd, output);
  2734. return -1;
  2735. }
  2736. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2737. m = map_mapname2mapid((char *)data[town].map);
  2738. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2739. clif_displaymessage(fd, "You are not authorised to warp you to this destination map.");
  2740. return -1;
  2741. }
  2742. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2743. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  2744. return -1;
  2745. }
  2746. if (pc_setpos(sd, (char *)data[town].map, data[town].x, data[town].y, 3) == 0) {
  2747. clif_displaymessage(fd, msg_table[0]); // Warped.
  2748. } else {
  2749. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2750. return -1;
  2751. }
  2752. } else { // if you arrive here, you have an error in town variable when reading of names
  2753. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2754. return -1;
  2755. }
  2756. }
  2757. return 0;
  2758. }
  2759. /*==========================================
  2760. *
  2761. *------------------------------------------
  2762. */
  2763. int atcommand_monster(
  2764. const int fd, struct map_session_data* sd,
  2765. const char* command, const char* message)
  2766. {
  2767. char name[100];
  2768. char monster[100];
  2769. char output[200];
  2770. int mob_id;
  2771. int number = 0;
  2772. int x = 0, y = 0;
  2773. int count;
  2774. int i, j, k;
  2775. int mx, my, range;
  2776. nullpo_retr(-1, sd);
  2777. memset(name, '\0', sizeof(name));
  2778. memset(monster, '\0', sizeof(monster));
  2779. memset(output, '\0', sizeof(output));
  2780. if (!message || !*message ||
  2781. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2782. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2783. sscanf(message, "%99s %99s %d %d %d", name, monster, &number, &x, &y) < 2)) {
  2784. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  2785. return -1;
  2786. }
  2787. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2788. mob_id = mobdb_checkid(atoi(monster));
  2789. if (mob_id == 0) {
  2790. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2791. return -1;
  2792. }
  2793. if (mob_id == 1288) {
  2794. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2795. return -1;
  2796. }
  2797. if (number <= 0)
  2798. number = 1;
  2799. if (strlen(name) < 1)
  2800. strcpy(name, "--ja--");
  2801. // 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
  2802. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2803. number = battle_config.atc_spawn_quantity_limit;
  2804. if (battle_config.etc_log)
  2805. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2806. count = 0;
  2807. range = (int)sqrt(number) / 2;
  2808. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2809. for (i = 0; i < number; i++) {
  2810. j = 0;
  2811. k = 0;
  2812. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2813. if (x <= 0)
  2814. mx = sd->bl.x + (rand() % range - (range / 2));
  2815. else
  2816. mx = x;
  2817. if (y <= 0)
  2818. my = sd->bl.y + (rand() % range - (range / 2));
  2819. else
  2820. my = y;
  2821. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2822. }
  2823. count += (k != 0) ? 1 : 0;
  2824. }
  2825. if (count != 0)
  2826. if (number == count)
  2827. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2828. else {
  2829. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2830. clif_displaymessage(fd, output);
  2831. }
  2832. else {
  2833. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2834. return -1;
  2835. }
  2836. return 0;
  2837. }
  2838. /*==========================================
  2839. *
  2840. *------------------------------------------
  2841. */
  2842. int atcommand_spawn(
  2843. const int fd, struct map_session_data* sd,
  2844. const char* command, const char* message) {
  2845. char name[100];
  2846. char monster[100];
  2847. char output[200];
  2848. int mob_id;
  2849. int number = 0;
  2850. int x = 0, y = 0;
  2851. int count;
  2852. int i, j, k;
  2853. int mx, my, range;
  2854. nullpo_retr(-1, sd);
  2855. memset(name, '\0', sizeof(name));
  2856. memset(monster, '\0', sizeof(monster));
  2857. memset(output, '\0', sizeof(output));
  2858. if (!message || !*message ||
  2859. (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2860. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2861. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1)) {
  2862. clif_displaymessage(fd, msg_table[143]); // Give a monster name/id please.
  2863. return -1;
  2864. }
  2865. // If monster identifier/name argument is a name
  2866. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2867. mob_id = mobdb_checkid(atoi(monster));
  2868. if (mob_id == 0) {
  2869. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2870. return -1;
  2871. }
  2872. if (mob_id == 1288) {
  2873. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  2874. return -1;
  2875. }
  2876. if (number <= 0)
  2877. number = 1;
  2878. if (strlen(name) < 1)
  2879. strcpy(name, "--ja--");
  2880. // 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
  2881. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2882. number = battle_config.atc_spawn_quantity_limit;
  2883. if (battle_config.etc_log)
  2884. printf("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  2885. count = 0;
  2886. range = (int)sqrt(number) / 2;
  2887. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  2888. for (i = 0; i < number; i++) {
  2889. j = 0;
  2890. k = 0;
  2891. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  2892. if (x <= 0)
  2893. mx = sd->bl.x + (rand() % range - (range / 2));
  2894. else
  2895. mx = x;
  2896. if (y <= 0)
  2897. my = sd->bl.y + (rand() % range - (range / 2));
  2898. else
  2899. my = y;
  2900. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  2901. }
  2902. count += (k != 0) ? 1 : 0;
  2903. }
  2904. if (count != 0)
  2905. if (number == count)
  2906. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  2907. else {
  2908. sprintf(output, msg_table[240], count); // %d monster(s) summoned!
  2909. clif_displaymessage(fd, output);
  2910. }
  2911. else {
  2912. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  2913. return -1;
  2914. }
  2915. return 0;
  2916. }
  2917. // small monster spawning [Valaris]
  2918. int atcommand_monstersmall(
  2919. const int fd, struct map_session_data* sd,
  2920. const char* command, const char* message) {
  2921. char name[100] = "";
  2922. char monster[100] = "";
  2923. int mob_id = 0;
  2924. int number = 0;
  2925. int x = 0;
  2926. int y = 0;
  2927. int count;
  2928. int i;
  2929. nullpo_retr(-1, sd);
  2930. if (!message || !*message) {
  2931. clif_displaymessage(fd, "Give a monster name/id please.");
  2932. return 0;
  2933. }
  2934. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2935. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2936. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  2937. clif_displaymessage(fd, "Give a monster name/id please.");
  2938. return 0;
  2939. }
  2940. // If monster identifier/name argument is a name
  2941. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2942. mob_id = atoi(monster);
  2943. if (mob_id == 0) {
  2944. clif_displaymessage(fd, "Monster name hasn't been found.");
  2945. return 0;
  2946. }
  2947. if (mob_id == 1288) {
  2948. clif_displaymessage(fd, "Cannot spawn emperium.");
  2949. return 0;
  2950. }
  2951. if (mob_id > 2000) {
  2952. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2953. return 0;
  2954. }
  2955. if (number <= 0)
  2956. number = 1;
  2957. if (strlen(name) < 1)
  2958. strcpy(name, "--ja--");
  2959. // 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
  2960. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2961. number = battle_config.atc_spawn_quantity_limit;
  2962. count = 0;
  2963. for (i = 0; i < number; i++) {
  2964. int mx, my;
  2965. if (x <= 0)
  2966. mx = sd->bl.x + (rand() % 11 - 5);
  2967. else
  2968. mx = x;
  2969. if (y <= 0)
  2970. my = sd->bl.y + (rand() % 11 - 5);
  2971. else
  2972. my = y;
  2973. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2000, 1, "") != 0) ? 1 : 0;
  2974. }
  2975. if (count != 0)
  2976. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  2977. else
  2978. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  2979. return 0;
  2980. }
  2981. // big monster spawning [Valaris]
  2982. int atcommand_monsterbig(
  2983. const int fd, struct map_session_data* sd,
  2984. const char* command, const char* message) {
  2985. char name[100] = "";
  2986. char monster[100] = "";
  2987. int mob_id = 0;
  2988. int number = 0;
  2989. int x = 0;
  2990. int y = 0;
  2991. int count;
  2992. int i;
  2993. nullpo_retr(-1, sd);
  2994. if (!message || !*message) {
  2995. clif_displaymessage(fd, "Give a monster name/id please.");
  2996. return 0;
  2997. }
  2998. if (sscanf(message, "\"%[^\"]\" %99s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2999. sscanf(message, "%99s \"%[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3000. sscanf(message, "%99s %d %99s %d %d", monster, &number, name, &x, &y) < 1) {
  3001. clif_displaymessage(fd, "Give a monster name/id please.");
  3002. return 0;
  3003. }
  3004. // If monster identifier/name argument is a name
  3005. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3006. mob_id = atoi(monster);
  3007. if (mob_id == 0) {
  3008. clif_displaymessage(fd, "Monster name hasn't been found.");
  3009. return 0;
  3010. }
  3011. if (mob_id == 1288) {
  3012. clif_displaymessage(fd, "Cannot spawn emperium.");
  3013. return 0;
  3014. }
  3015. if (mob_id > 2000) {
  3016. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3017. return 0;
  3018. }
  3019. if (number <= 0)
  3020. number = 1;
  3021. if (strlen(name) < 1)
  3022. strcpy(name, "--ja--");
  3023. // 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
  3024. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3025. number = battle_config.atc_spawn_quantity_limit;
  3026. count = 0;
  3027. for (i = 0; i < number; i++) {
  3028. int mx, my;
  3029. if (x <= 0)
  3030. mx = sd->bl.x + (rand() % 11 - 5);
  3031. else
  3032. mx = x;
  3033. if (y <= 0)
  3034. my = sd->bl.y + (rand() % 11 - 5);
  3035. else
  3036. my = y;
  3037. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+4000, 1, "") != 0) ? 1 : 0;
  3038. }
  3039. if (count != 0)
  3040. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3041. else
  3042. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3043. return 0;
  3044. }
  3045. /*==========================================
  3046. *
  3047. *------------------------------------------
  3048. */
  3049. void atcommand_killmonster_sub(
  3050. const int fd, struct map_session_data* sd, const char* message,
  3051. const int drop)
  3052. {
  3053. int map_id;
  3054. char map_name[100];
  3055. if (!sd) return;
  3056. memset(map_name, '\0', sizeof(map_name));
  3057. if (!message || !*message || sscanf(message, "%99s", map_name) < 1)
  3058. map_id = sd->bl.m;
  3059. else {
  3060. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  3061. strcat(map_name, ".gat");
  3062. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3063. map_id = sd->bl.m;
  3064. }
  3065. map_foreachinarea(atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop);
  3066. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3067. return;
  3068. }
  3069. /*==========================================
  3070. *
  3071. *------------------------------------------
  3072. */
  3073. int atcommand_killmonster(
  3074. const int fd, struct map_session_data* sd,
  3075. const char* command, const char* message)
  3076. {
  3077. if (!sd) return 0;
  3078. atcommand_killmonster_sub(fd, sd, message, 1);
  3079. return 0;
  3080. }
  3081. /*==========================================
  3082. *
  3083. *------------------------------------------
  3084. */
  3085. int atcommand_killmonster2(
  3086. const int fd, struct map_session_data* sd,
  3087. const char* command, const char* message)
  3088. {
  3089. if (!sd) return 0;
  3090. atcommand_killmonster_sub(fd, sd, message, 0);
  3091. return 0;
  3092. }
  3093. /*==========================================
  3094. *
  3095. *------------------------------------------
  3096. */
  3097. int atcommand_refine(
  3098. const int fd, struct map_session_data* sd,
  3099. const char* command, const char* message)
  3100. {
  3101. int i, position = 0, refine = 0, current_position, final_refine;
  3102. int count;
  3103. char output[200];
  3104. nullpo_retr(-1, sd);
  3105. memset(output, '\0', sizeof(output));
  3106. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3107. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3108. return -1;
  3109. }
  3110. if (refine < -10)
  3111. refine = -10;
  3112. else if (refine > 10)
  3113. refine = 10;
  3114. else if (refine == 0)
  3115. refine = 1;
  3116. count = 0;
  3117. for (i = 0; i < MAX_INVENTORY; i++) {
  3118. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3119. (sd->status.inventory[i].equip & position ||
  3120. (sd->status.inventory[i].equip && !position))) {
  3121. final_refine = sd->status.inventory[i].refine + refine;
  3122. if (final_refine > 10)
  3123. final_refine = 10;
  3124. else if (final_refine < 0)
  3125. final_refine = 0;
  3126. if (sd->status.inventory[i].refine != final_refine) {
  3127. sd->status.inventory[i].refine = final_refine;
  3128. current_position = sd->status.inventory[i].equip;
  3129. pc_unequipitem(sd, i, 3);
  3130. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3131. clif_delitem(sd, i, 1);
  3132. clif_additem(sd, i, 1, 0);
  3133. pc_equipitem(sd, i, current_position);
  3134. clif_misceffect((struct block_list*)&sd->bl, 3);
  3135. count++;
  3136. }
  3137. }
  3138. }
  3139. if (count == 0)
  3140. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3141. else if (count == 1)
  3142. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3143. else {
  3144. sprintf(output, msg_table[168], count); // %d items have been refined!
  3145. clif_displaymessage(fd, output);
  3146. }
  3147. return 0;
  3148. }
  3149. /*==========================================
  3150. *
  3151. *------------------------------------------
  3152. */
  3153. int atcommand_produce(
  3154. const int fd, struct map_session_data* sd,
  3155. const char* command, const char* message)
  3156. {
  3157. char item_name[100];
  3158. int item_id, attribute = 0, star = 0;
  3159. int flag = 0;
  3160. struct item_data *item_data;
  3161. struct item tmp_item;
  3162. char output[200];
  3163. nullpo_retr(-1, sd);
  3164. memset(output, '\0', sizeof(output));
  3165. memset(item_name, '\0', sizeof(item_name));
  3166. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3167. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3168. return -1;
  3169. }
  3170. item_id = 0;
  3171. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3172. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3173. item_id = item_data->nameid;
  3174. if (itemdb_exists(item_id) &&
  3175. (item_id <= 500 || item_id > 1099) &&
  3176. (item_id < 4001 || item_id > 4148) &&
  3177. (item_id < 7001 || item_id > 10019) &&
  3178. itemdb_isequip(item_id)) {
  3179. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3180. attribute = ATTRIBUTE_NORMAL;
  3181. if (star < MIN_STAR || star > MAX_STAR)
  3182. star = 0;
  3183. memset(&tmp_item, 0, sizeof tmp_item);
  3184. tmp_item.nameid = item_id;
  3185. tmp_item.amount = 1;
  3186. tmp_item.identify = 1;
  3187. tmp_item.card[0] = 0x00ff;
  3188. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3189. *((unsigned long *)(&tmp_item.card[2])) = sd->char_id;
  3190. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3191. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3192. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3193. clif_additem(sd, 0, 0, flag);
  3194. } else {
  3195. if (battle_config.error_log)
  3196. printf("@produce NOT WEAPON [%d]\n", item_id);
  3197. if (item_id != 0 && itemdb_exists(item_id))
  3198. sprintf(output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3199. else
  3200. sprintf(output, msg_table[170]); // This item is not an equipment.
  3201. clif_displaymessage(fd, output);
  3202. return -1;
  3203. }
  3204. return 0;
  3205. }
  3206. /*==========================================
  3207. * Sub-function to display actual memo points
  3208. *------------------------------------------
  3209. */
  3210. void atcommand_memo_sub(struct map_session_data* sd) {
  3211. int i;
  3212. char output[200];
  3213. if (!sd) return;
  3214. memset(output, '\0', sizeof(output));
  3215. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3216. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3217. if (sd->status.memo_point[i].map[0])
  3218. 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);
  3219. else
  3220. sprintf(output, msg_table[171], i); // %d - void
  3221. clif_displaymessage(sd->fd, output);
  3222. }
  3223. return;
  3224. }
  3225. /*==========================================
  3226. *
  3227. *------------------------------------------
  3228. */
  3229. int atcommand_memo(
  3230. const int fd, struct map_session_data* sd,
  3231. const char* command, const char* message)
  3232. {
  3233. int position = 0;
  3234. char output[200];
  3235. nullpo_retr(-1, sd);
  3236. memset(output, '\0', sizeof(output));
  3237. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3238. atcommand_memo_sub(sd);
  3239. else {
  3240. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3241. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3242. clif_displaymessage(fd, "You are not authorised to memo this map.");
  3243. return -1;
  3244. }
  3245. if (sd->status.memo_point[position].map[0]) {
  3246. 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).
  3247. clif_displaymessage(fd, output);
  3248. }
  3249. memcpy(sd->status.memo_point[position].map, map[sd->bl.m].name, 24);
  3250. sd->status.memo_point[position].x = sd->bl.x;
  3251. sd->status.memo_point[position].y = sd->bl.y;
  3252. clif_skill_memo(sd, 0);
  3253. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3254. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3255. atcommand_memo_sub(sd);
  3256. } else {
  3257. sprintf(output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3258. clif_displaymessage(fd, output);
  3259. atcommand_memo_sub(sd);
  3260. return -1;
  3261. }
  3262. }
  3263. return 0;
  3264. }
  3265. /*==========================================
  3266. *
  3267. *------------------------------------------
  3268. */
  3269. int atcommand_gat(
  3270. const int fd, struct map_session_data* sd,
  3271. const char* command, const char* message)
  3272. {
  3273. char output[200];
  3274. int y;
  3275. nullpo_retr(-1, sd);
  3276. memset(output, '\0', sizeof(output));
  3277. for (y = 2; y >= -2; y--) {
  3278. sprintf(output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3279. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3280. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3281. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3282. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3283. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3284. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3285. clif_displaymessage(fd, output);
  3286. }
  3287. return 0;
  3288. }
  3289. /*==========================================
  3290. *
  3291. *------------------------------------------
  3292. */
  3293. int atcommand_packet(
  3294. const int fd, struct map_session_data* sd,
  3295. const char* command, const char* message)
  3296. {
  3297. int x = 0, y = 0;
  3298. nullpo_retr(-1, sd);
  3299. if (!message || !*message || sscanf(message, "%d %d", &x, &y) < 2) {
  3300. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3301. return -1;
  3302. }
  3303. clif_status_change(&sd->bl, x, y);
  3304. return 0;
  3305. }
  3306. /*==========================================
  3307. * @stpoint (Rewritten by [Yor])
  3308. *------------------------------------------
  3309. */
  3310. int atcommand_statuspoint(
  3311. const int fd, struct map_session_data* sd,
  3312. const char* command, const char* message)
  3313. {
  3314. int point, new_status_point;
  3315. if (!message || !*message || (point = atoi(message)) == 0) {
  3316. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3317. return -1;
  3318. }
  3319. new_status_point = (int)sd->status.status_point + point;
  3320. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3321. new_status_point = 0x7FFF;
  3322. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3323. new_status_point = 0;
  3324. if (new_status_point != (int)sd->status.status_point) {
  3325. sd->status.status_point = (short)new_status_point;
  3326. clif_updatestatus(sd, SP_STATUSPOINT);
  3327. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3328. } else {
  3329. if (point < 0)
  3330. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3331. else
  3332. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3333. return -1;
  3334. }
  3335. return 0;
  3336. }
  3337. /*==========================================
  3338. * @skpoint (Rewritten by [Yor])
  3339. *------------------------------------------
  3340. */
  3341. int atcommand_skillpoint(
  3342. const int fd, struct map_session_data* sd,
  3343. const char* command, const char* message)
  3344. {
  3345. int point, new_skill_point;
  3346. nullpo_retr(-1, sd);
  3347. if (!message || !*message || (point = atoi(message)) == 0) {
  3348. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3349. return -1;
  3350. }
  3351. new_skill_point = (int)sd->status.skill_point + point;
  3352. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3353. new_skill_point = 0x7FFF;
  3354. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3355. new_skill_point = 0;
  3356. if (new_skill_point != (int)sd->status.skill_point) {
  3357. sd->status.skill_point = (short)new_skill_point;
  3358. clif_updatestatus(sd, SP_SKILLPOINT);
  3359. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3360. } else {
  3361. if (point < 0)
  3362. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3363. else
  3364. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3365. return -1;
  3366. }
  3367. return 0;
  3368. }
  3369. /*==========================================
  3370. * @zeny (Rewritten by [Yor])
  3371. *------------------------------------------
  3372. */
  3373. int atcommand_zeny(
  3374. const int fd, struct map_session_data* sd,
  3375. const char* command, const char* message)
  3376. {
  3377. int zeny, new_zeny;
  3378. nullpo_retr(-1, sd);
  3379. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3380. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3381. return -1;
  3382. }
  3383. new_zeny = sd->status.zeny + zeny;
  3384. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3385. new_zeny = MAX_ZENY;
  3386. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3387. new_zeny = 0;
  3388. if (new_zeny != sd->status.zeny) {
  3389. sd->status.zeny = new_zeny;
  3390. clif_updatestatus(sd, SP_ZENY);
  3391. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3392. } else {
  3393. if (zeny < 0)
  3394. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3395. else
  3396. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3397. return -1;
  3398. }
  3399. return 0;
  3400. }
  3401. /*==========================================
  3402. *
  3403. *------------------------------------------
  3404. */
  3405. int atcommand_param(
  3406. const int fd, struct map_session_data* sd,
  3407. const char* command, const char* message)
  3408. {
  3409. int i, index, value = 0, new_value;
  3410. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3411. short* status[] = {
  3412. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3413. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3414. };
  3415. char output[200];
  3416. nullpo_retr(-1, sd);
  3417. memset(output, '\0', sizeof(output));
  3418. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3419. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3420. clif_displaymessage(fd, output);
  3421. return -1;
  3422. }
  3423. index = -1;
  3424. for (i = 0; param[i] != NULL; i++) {
  3425. if (strcmpi(command, param[i]) == 0) {
  3426. index = i;
  3427. break;
  3428. }
  3429. }
  3430. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3431. sprintf(output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3432. clif_displaymessage(fd, output);
  3433. return -1;
  3434. }
  3435. new_value = (int)*status[index] + value;
  3436. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3437. new_value = battle_config.max_parameter;
  3438. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3439. new_value = 1;
  3440. if (new_value != (int)*status[index]) {
  3441. *status[index] = new_value;
  3442. clif_updatestatus(sd, SP_STR + index);
  3443. clif_updatestatus(sd, SP_USTR + index);
  3444. status_calc_pc(sd, 0);
  3445. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3446. } else {
  3447. if (value < 0)
  3448. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3449. else
  3450. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3451. return -1;
  3452. }
  3453. return 0;
  3454. }
  3455. /*==========================================
  3456. *
  3457. *------------------------------------------
  3458. */
  3459. //** Stat all by fritz (rewritten by [Yor])
  3460. int atcommand_stat_all(
  3461. const int fd, struct map_session_data* sd,
  3462. const char* command, const char* message)
  3463. {
  3464. int index, count, value = 0, new_value;
  3465. short* status[] = {
  3466. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3467. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3468. };
  3469. nullpo_retr(-1, sd);
  3470. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3471. value = battle_config.max_parameter;
  3472. count = 0;
  3473. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3474. new_value = (int)*status[index] + value;
  3475. if (value > 0 && ((unsigned int)value > battle_config.max_parameter || (unsigned int)new_value > battle_config.max_parameter)) // fix positiv overflow
  3476. new_value = battle_config.max_parameter;
  3477. else if (value < 0 && (value < -(int)battle_config.max_parameter || new_value < 1)) // fix negativ overflow
  3478. new_value = 1;
  3479. if (new_value != (int)*status[index]) {
  3480. *status[index] = new_value;
  3481. clif_updatestatus(sd, SP_STR + index);
  3482. clif_updatestatus(sd, SP_USTR + index);
  3483. status_calc_pc(sd, 0);
  3484. count++;
  3485. }
  3486. }
  3487. if (count > 0) // if at least 1 stat modified
  3488. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3489. else {
  3490. if (value < 0)
  3491. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3492. else
  3493. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3494. return -1;
  3495. }
  3496. return 0;
  3497. }
  3498. /*==========================================
  3499. *
  3500. *------------------------------------------
  3501. */
  3502. int atcommand_guildlevelup(
  3503. const int fd, struct map_session_data* sd,
  3504. const char* command, const char* message)
  3505. {
  3506. int level = 0;
  3507. short added_level;
  3508. struct guild *guild_info;
  3509. nullpo_retr(-1, sd);
  3510. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3511. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3512. return -1;
  3513. }
  3514. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3515. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3516. return -1;
  3517. }
  3518. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3519. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3520. return -1;
  3521. }
  3522. added_level = (short)level;
  3523. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3524. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3525. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3526. added_level = 1 - guild_info->guild_lv;
  3527. if (added_level != 0) {
  3528. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3529. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3530. } else {
  3531. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3532. return -1;
  3533. }
  3534. return 0;
  3535. }
  3536. /*==========================================
  3537. *
  3538. *------------------------------------------
  3539. */
  3540. int atcommand_makeegg(
  3541. const int fd, struct map_session_data* sd,
  3542. const char* command, const char* message)
  3543. {
  3544. struct item_data *item_data;
  3545. int id, pet_id;
  3546. nullpo_retr(-1, sd);
  3547. if (!message || !*message) {
  3548. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3549. return -1;
  3550. }
  3551. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3552. id = item_data->nameid;
  3553. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3554. id = atoi(message);
  3555. pet_id = search_petDB_index(id, PET_CLASS);
  3556. if (pet_id < 0)
  3557. pet_id = search_petDB_index(id, PET_EGG);
  3558. if (pet_id >= 0) {
  3559. sd->catch_target_class = pet_db[pet_id].class_;
  3560. intif_create_pet(
  3561. sd->status.account_id, sd->status.char_id,
  3562. (short)pet_db[pet_id].class_, (short)mob_db[pet_db[pet_id].class_].lv,
  3563. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3564. 100, 0, 1, pet_db[pet_id].jname);
  3565. } else {
  3566. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3567. return -1;
  3568. }
  3569. return 0;
  3570. }
  3571. /*==========================================
  3572. *
  3573. *------------------------------------------
  3574. */
  3575. int atcommand_hatch(
  3576. const int fd, struct map_session_data* sd,
  3577. const char* command, const char* message)
  3578. {
  3579. nullpo_retr(-1, sd);
  3580. if (sd->status.pet_id <= 0)
  3581. clif_sendegg(sd);
  3582. else {
  3583. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3584. return -1;
  3585. }
  3586. return 0;
  3587. }
  3588. /*==========================================
  3589. *
  3590. *------------------------------------------
  3591. */
  3592. int atcommand_petfriendly(
  3593. const int fd, struct map_session_data* sd,
  3594. const char* command, const char* message)
  3595. {
  3596. int friendly;
  3597. int t;
  3598. nullpo_retr(-1, sd);
  3599. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3600. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3601. return -1;
  3602. }
  3603. if (sd->status.pet_id > 0 && sd->pd) {
  3604. if (friendly >= 0 && friendly <= 1000) {
  3605. if (friendly != sd->pet.intimate) {
  3606. t = sd->pet.intimate;
  3607. sd->pet.intimate = friendly;
  3608. clif_send_petstatus(sd);
  3609. if (battle_config.pet_status_support) {
  3610. if ((sd->pet.intimate > 0 && t <= 0) ||
  3611. (sd->pet.intimate <= 0 && t > 0)) {
  3612. if (sd->bl.prev != NULL)
  3613. status_calc_pc(sd, 0);
  3614. else
  3615. status_calc_pc(sd, 2);
  3616. }
  3617. }
  3618. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3619. } else {
  3620. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3621. return -1;
  3622. }
  3623. } else {
  3624. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3625. return -1;
  3626. }
  3627. } else {
  3628. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3629. return -1;
  3630. }
  3631. return 0;
  3632. }
  3633. /*==========================================
  3634. *
  3635. *------------------------------------------
  3636. */
  3637. int atcommand_pethungry(
  3638. const int fd, struct map_session_data* sd,
  3639. const char* command, const char* message)
  3640. {
  3641. int hungry;
  3642. nullpo_retr(-1, sd);
  3643. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3644. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3645. return -1;
  3646. }
  3647. if (sd->status.pet_id > 0 && sd->pd) {
  3648. if (hungry >= 0 && hungry <= 100) {
  3649. if (hungry != sd->pet.hungry) {
  3650. sd->pet.hungry = hungry;
  3651. clif_send_petstatus(sd);
  3652. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3653. } else {
  3654. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3655. return -1;
  3656. }
  3657. } else {
  3658. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3659. return -1;
  3660. }
  3661. } else {
  3662. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3663. return -1;
  3664. }
  3665. return 0;
  3666. }
  3667. /*==========================================
  3668. *
  3669. *------------------------------------------
  3670. */
  3671. int atcommand_petrename(
  3672. const int fd, struct map_session_data* sd,
  3673. const char* command, const char* message)
  3674. {
  3675. nullpo_retr(-1, sd);
  3676. if (sd->status.pet_id > 0 && sd->pd) {
  3677. if (sd->pet.rename_flag != 0) {
  3678. sd->pet.rename_flag = 0;
  3679. intif_save_petdata(sd->status.account_id, &sd->pet);
  3680. clif_send_petstatus(sd);
  3681. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3682. } else {
  3683. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3684. return -1;
  3685. }
  3686. } else {
  3687. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3688. return -1;
  3689. }
  3690. return 0;
  3691. }
  3692. /*==========================================
  3693. *
  3694. *------------------------------------------
  3695. */
  3696. int
  3697. atcommand_recall(
  3698. const int fd, struct map_session_data* sd,
  3699. const char* command, const char* message)
  3700. {
  3701. char character[100];
  3702. char output[200];
  3703. struct map_session_data *pl_sd = NULL;
  3704. nullpo_retr(-1, sd);
  3705. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3706. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3707. return -1;
  3708. }
  3709. memset(character, '\0', sizeof character);
  3710. if(sscanf(message, "%99[^\n]", character) < 1)
  3711. return -1;
  3712. if(strncmp(sd->status.name,character,24)==0)
  3713. return -1;
  3714. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3715. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3716. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3717. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3718. return -1;
  3719. }
  3720. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3721. clif_displaymessage(fd, "You are not authorised to warp this player from its actual map.");
  3722. return -1;
  3723. }
  3724. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  3725. sprintf(output, msg_table[46], character); // %s recalled!
  3726. clif_displaymessage(fd, output);
  3727. } else {
  3728. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3729. return -1;
  3730. }
  3731. } else {
  3732. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3733. return -1;
  3734. }
  3735. return 0;
  3736. }
  3737. /*==========================================
  3738. *
  3739. *------------------------------------------
  3740. */
  3741. int atcommand_revive(
  3742. const int fd, struct map_session_data* sd,
  3743. const char* command, const char* message)
  3744. {
  3745. char character[100];
  3746. struct map_session_data *pl_sd;
  3747. nullpo_retr(-1, sd);
  3748. memset(character, '\0', sizeof(character));
  3749. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3750. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3751. return -1;
  3752. }
  3753. if ((pl_sd = map_nick2sd(character)) != NULL) {
  3754. if (pc_isdead(pl_sd)) {
  3755. pl_sd->status.hp = pl_sd->status.max_hp;
  3756. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3757. pc_setstand(pl_sd);
  3758. if (battle_config.pc_invincible_time > 0)
  3759. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3760. clif_updatestatus(pl_sd, SP_HP);
  3761. clif_updatestatus(pl_sd, SP_SP);
  3762. clif_resurrection(&pl_sd->bl, 1);
  3763. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3764. return 0;
  3765. }
  3766. return -1;
  3767. } else {
  3768. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3769. return -1;
  3770. }
  3771. return 0;
  3772. }
  3773. /*==========================================
  3774. * charchangesex command (usage: charchangesex <player_name>)
  3775. *------------------------------------------
  3776. */
  3777. int atcommand_char_change_sex(
  3778. const int fd, struct map_session_data* sd,
  3779. const char* command, const char* message)
  3780. {
  3781. char character[100];
  3782. nullpo_retr(-1, sd);
  3783. memset(character, '\0', sizeof(character));
  3784. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3785. clif_displaymessage(fd, "Please, enter a player name (usage: @charchangesex <name>).");
  3786. return -1;
  3787. }
  3788. // check player name
  3789. if (strlen(character) < 4) {
  3790. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3791. return -1;
  3792. } else if (strlen(character) > 23) {
  3793. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3794. return -1;
  3795. } else {
  3796. chrif_char_ask_name(sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex
  3797. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3798. }
  3799. return 0;
  3800. }
  3801. /*==========================================
  3802. * charblock command (usage: charblock <player_name>)
  3803. * This command do a definitiv ban on a player
  3804. *------------------------------------------
  3805. */
  3806. int atcommand_char_block(
  3807. const int fd, struct map_session_data* sd,
  3808. const char* command, const char* message)
  3809. {
  3810. char character[100];
  3811. nullpo_retr(-1, sd);
  3812. memset(character, '\0', sizeof(character));
  3813. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3814. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3815. return -1;
  3816. }
  3817. // check player name
  3818. if (strlen(character) < 4) {
  3819. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3820. return -1;
  3821. } else if (strlen(character) > 23) {
  3822. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3823. return -1;
  3824. } else {
  3825. chrif_char_ask_name(sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3826. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3827. }
  3828. return 0;
  3829. }
  3830. /*==========================================
  3831. * charban command (usage: charban <time> <player_name>)
  3832. * This command do a limited ban on a player
  3833. * Time is done as follows:
  3834. * Adjustment value (-1, 1, +1, etc...)
  3835. * Modified element:
  3836. * a or y: year
  3837. * m: month
  3838. * j or d: day
  3839. * h: hour
  3840. * mn: minute
  3841. * s: second
  3842. * <example> @ban +1m-2mn1s-6y test_player
  3843. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3844. *------------------------------------------
  3845. */
  3846. int atcommand_char_ban(
  3847. const int fd, struct map_session_data* sd,
  3848. const char* command, const char* message)
  3849. {
  3850. char modif[100], character[100];
  3851. char * modif_p;
  3852. int year, month, day, hour, minute, second, value;
  3853. nullpo_retr(-1, sd);
  3854. memset(modif, '\0', sizeof(modif));
  3855. memset(character, '\0', sizeof(character));
  3856. if (!message || !*message || sscanf(message, "%s %99[^\n]", modif, character) < 2) {
  3857. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3858. return -1;
  3859. }
  3860. modif[sizeof(modif)-1] = '\0';
  3861. character[sizeof(character)-1] = '\0';
  3862. modif_p = modif;
  3863. year = month = day = hour = minute = second = 0;
  3864. while (modif_p[0] != '\0') {
  3865. value = atoi(modif_p);
  3866. if (value == 0)
  3867. modif_p++;
  3868. else {
  3869. if (modif_p[0] == '-' || modif_p[0] == '+')
  3870. modif_p++;
  3871. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3872. modif_p++;
  3873. if (modif_p[0] == 's') {
  3874. second = value;
  3875. modif_p++;
  3876. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3877. minute = value;
  3878. modif_p = modif_p + 2;
  3879. } else if (modif_p[0] == 'h') {
  3880. hour = value;
  3881. modif_p++;
  3882. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3883. day = value;
  3884. modif_p++;
  3885. } else if (modif_p[0] == 'm') {
  3886. month = value;
  3887. modif_p++;
  3888. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3889. year = value;
  3890. modif_p++;
  3891. } else if (modif_p[0] != '\0') {
  3892. modif_p++;
  3893. }
  3894. }
  3895. }
  3896. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3897. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  3898. return -1;
  3899. }
  3900. // check player name
  3901. if (strlen(character) < 4) {
  3902. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3903. return -1;
  3904. } else if (strlen(character) > 23) {
  3905. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3906. return -1;
  3907. } else {
  3908. chrif_char_ask_name(sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3909. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3910. }
  3911. return 0;
  3912. }
  3913. /*==========================================
  3914. * charunblock command (usage: charunblock <player_name>)
  3915. *------------------------------------------
  3916. */
  3917. int atcommand_char_unblock(
  3918. const int fd, struct map_session_data* sd,
  3919. const char* command, const char* message)
  3920. {
  3921. char character[100];
  3922. nullpo_retr(-1, sd);
  3923. memset(character, '\0', sizeof(character));
  3924. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3925. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3926. return -1;
  3927. }
  3928. // check player name
  3929. if (strlen(character) < 4) {
  3930. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3931. return -1;
  3932. } else if (strlen(character) > 23) {
  3933. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3934. return -1;
  3935. } else {
  3936. // send answer to login server via char-server
  3937. chrif_char_ask_name(sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3938. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3939. }
  3940. return 0;
  3941. }
  3942. /*==========================================
  3943. * charunban command (usage: charunban <player_name>)
  3944. *------------------------------------------
  3945. */
  3946. int atcommand_char_unban(
  3947. const int fd, struct map_session_data* sd,
  3948. const char* command, const char* message)
  3949. {
  3950. char character[100];
  3951. nullpo_retr(-1, sd);
  3952. memset(character, '\0', sizeof(character));
  3953. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  3954. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3955. return -1;
  3956. }
  3957. // check player name
  3958. if (strlen(character) < 4) {
  3959. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  3960. return -1;
  3961. } else if (strlen(character) > 23) {
  3962. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  3963. return -1;
  3964. } else {
  3965. // send answer to login server via char-server
  3966. chrif_char_ask_name(sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3967. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  3968. }
  3969. return 0;
  3970. }
  3971. /*==========================================
  3972. *
  3973. *------------------------------------------
  3974. */
  3975. int atcommand_night(
  3976. const int fd, struct map_session_data* sd,
  3977. const char* command, const char* message)
  3978. {
  3979. struct map_session_data *pl_sd;
  3980. int i;
  3981. nullpo_retr(-1, sd);
  3982. if (night_flag != 1) {
  3983. night_flag = 1; // 0=day, 1=night [Yor]
  3984. for(i = 0; i < fd_max; i++) {
  3985. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && !map[sd->bl.m].flag.indoors) {
  3986. //pl_sd->opt2 |= STATE_BLIND;
  3987. //clif_changeoption(&pl_sd->bl);
  3988. if (battle_config.night_darkness_level > 0)
  3989. clif_specialeffect(&pl_sd->bl, 474 + battle_config.night_darkness_level, 0);
  3990. else {
  3991. //clif_specialeffect(&pl_sd->bl, 483, 0); // default darkness level
  3992. pl_sd->opt2 |= STATE_BLIND;
  3993. clif_changeoption(&pl_sd->bl);
  3994. }
  3995. clif_displaymessage(pl_sd->fd, msg_table[59]); // Night has fallen.
  3996. }
  3997. }
  3998. } else {
  3999. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4000. return -1;
  4001. }
  4002. return 0;
  4003. }
  4004. /*==========================================
  4005. *
  4006. *------------------------------------------
  4007. */
  4008. int atcommand_day(
  4009. const int fd, struct map_session_data* sd,
  4010. const char* command, const char* message)
  4011. {
  4012. struct map_session_data *pl_sd;
  4013. int i;
  4014. nullpo_retr(-1, sd);
  4015. if (night_flag != 0) {
  4016. night_flag = 0; // 0=day, 1=night [Yor]
  4017. for(i = 0; i < fd_max; i++) {
  4018. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4019. pl_sd->opt2 &= ~STATE_BLIND;
  4020. clif_changeoption(&pl_sd->bl);
  4021. clif_displaymessage(pl_sd->fd, msg_table[60]); // Day has arrived.
  4022. }
  4023. }
  4024. } else {
  4025. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4026. return -1;
  4027. }
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. *
  4032. *------------------------------------------
  4033. */
  4034. int atcommand_doom(
  4035. const int fd, struct map_session_data* sd,
  4036. const char* command, const char* message)
  4037. {
  4038. struct map_session_data *pl_sd;
  4039. int i;
  4040. nullpo_retr(-1, sd);
  4041. clif_specialeffect(&sd->bl,450,2);
  4042. for(i = 0; i < fd_max; i++) {
  4043. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd &&
  4044. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4045. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4046. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4047. }
  4048. }
  4049. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4050. return 0;
  4051. }
  4052. /*==========================================
  4053. *
  4054. *------------------------------------------
  4055. */
  4056. int atcommand_doommap(
  4057. const int fd, struct map_session_data* sd,
  4058. const char* command, const char* message)
  4059. {
  4060. struct map_session_data *pl_sd;
  4061. int i;
  4062. nullpo_retr(-1, sd);
  4063. clif_specialeffect(&sd->bl,450,3);
  4064. for (i = 0; i < fd_max; i++) {
  4065. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && i != fd && sd->bl.m == pl_sd->bl.m &&
  4066. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4067. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  4068. // clif_specialeffect(&pl_sd->bl,450,1);
  4069. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4070. }
  4071. }
  4072. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4073. return 0;
  4074. }
  4075. /*==========================================
  4076. *
  4077. *------------------------------------------
  4078. */
  4079. static void atcommand_raise_sub(struct map_session_data* sd)
  4080. {
  4081. if (sd && sd->state.auth && pc_isdead(sd)) {
  4082. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4083. sd->status.hp = sd->status.max_hp;
  4084. sd->status.sp = sd->status.max_sp;
  4085. pc_setstand(sd);
  4086. clif_updatestatus(sd, SP_HP);
  4087. clif_updatestatus(sd, SP_SP);
  4088. clif_resurrection(&sd->bl, 1);
  4089. if (battle_config.pc_invincible_time > 0)
  4090. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4091. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4092. }
  4093. }
  4094. /*==========================================
  4095. *
  4096. *------------------------------------------
  4097. */
  4098. int atcommand_raise(
  4099. const int fd, struct map_session_data* sd,
  4100. const char* command, const char* message)
  4101. {
  4102. int i;
  4103. nullpo_retr(-1, sd);
  4104. for (i = 0; i < fd_max; i++) {
  4105. if (session[i])
  4106. atcommand_raise_sub(session[i]->session_data);
  4107. }
  4108. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4109. return 0;
  4110. }
  4111. /*==========================================
  4112. *
  4113. *------------------------------------------
  4114. */
  4115. int atcommand_raisemap(
  4116. const int fd, struct map_session_data* sd,
  4117. const char* command, const char* message)
  4118. {
  4119. struct map_session_data *pl_sd;
  4120. int i;
  4121. nullpo_retr(-1, sd);
  4122. for (i = 0; i < fd_max; i++) {
  4123. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m)
  4124. atcommand_raise_sub(pl_sd);
  4125. }
  4126. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4127. return 0;
  4128. }
  4129. /*==========================================
  4130. * atcommand_character_baselevel @charbaselvlで対象キャラのレベルを上げる
  4131. *------------------------------------------
  4132. */
  4133. int atcommand_character_baselevel(
  4134. const int fd, struct map_session_data* sd,
  4135. const char* command, const char* message)
  4136. {
  4137. struct map_session_data *pl_sd;
  4138. char character[100];
  4139. int level = 0, i;
  4140. nullpo_retr(-1, sd);
  4141. memset(character, '\0', sizeof(character));
  4142. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4143. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charbaselvl <#> <nickname>).");
  4144. return -1;
  4145. }
  4146. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4147. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change base level only lower or same gm level
  4148. if (level > 0) {
  4149. if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris
  4150. clif_displaymessage(fd, msg_table[91]); // Character's base level can't go any higher.
  4151. return 0;
  4152. } // End Addition
  4153. if ((unsigned int)level > battle_config.maximum_level || (unsigned int)level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow
  4154. level = battle_config.maximum_level - pl_sd->status.base_level;
  4155. for (i = 1; i <= level; i++)
  4156. pl_sd->status.status_point += (pl_sd->status.base_level + i + 14) / 5;
  4157. pl_sd->status.base_level += level;
  4158. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4159. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4160. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4161. status_calc_pc(pl_sd, 0);
  4162. pc_heal(pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp);
  4163. clif_misceffect(&pl_sd->bl, 0);
  4164. clif_displaymessage(fd, msg_table[65]); // Character's base level raised.
  4165. } else {
  4166. if (pl_sd->status.base_level == 1) {
  4167. clif_displaymessage(fd, msg_table[193]); // Character's base level can't go any lower.
  4168. return -1;
  4169. }
  4170. if (level < -(int)battle_config.maximum_level || level < (1 - (int)pl_sd->status.base_level)) // fix negativ overflow
  4171. level = 1 - pl_sd->status.base_level;
  4172. if (pl_sd->status.status_point > 0) {
  4173. for (i = 0; i > level; i--)
  4174. pl_sd->status.status_point -= (pl_sd->status.base_level + i + 14) / 5;
  4175. if (pl_sd->status.status_point < 0)
  4176. pl_sd->status.status_point = 0;
  4177. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4178. } // to add: remove status points from stats
  4179. pl_sd->status.base_level += level;
  4180. clif_updatestatus(pl_sd, SP_BASELEVEL);
  4181. clif_updatestatus(pl_sd, SP_NEXTBASEEXP);
  4182. status_calc_pc(pl_sd, 0);
  4183. clif_displaymessage(fd, msg_table[66]); // Character's base level lowered.
  4184. }
  4185. } else {
  4186. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4187. return -1;
  4188. }
  4189. } else {
  4190. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4191. return -1;
  4192. }
  4193. return 0; //正常終了
  4194. }
  4195. /*==========================================
  4196. * atcommand_character_joblevel @charjoblvlで対象キャラのJobレベルを上げる
  4197. *------------------------------------------
  4198. */
  4199. int atcommand_character_joblevel(
  4200. const int fd, struct map_session_data* sd,
  4201. const char* command, const char* message)
  4202. {
  4203. struct map_session_data *pl_sd;
  4204. char character[100];
  4205. unsigned int max_level = 50;
  4206. int level = 0;
  4207. //転生や養子の場合の元の職業を算出する
  4208. struct pc_base_job pl_s_class;
  4209. nullpo_retr(-1, sd);
  4210. memset(character, '\0', sizeof(character));
  4211. if (!message || !*message || sscanf(message, "%d %99[^\n]", &level, character) < 2 || level == 0) {
  4212. clif_displaymessage(fd, "Please, enter a level adjustement and a player name (usage: @charjlvl <#> <nickname>).");
  4213. return -1;
  4214. }
  4215. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4216. pl_s_class = pc_calc_base_job(pl_sd->status.class_);
  4217. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can change job level only lower or same gm level
  4218. if (pl_s_class.job == 0)
  4219. max_level -= 40;
  4220. // super novices can go up to 99 [celest]
  4221. else if (pl_s_class.job == 23)
  4222. max_level += 49;
  4223. else if (pl_sd->status.class_ > 4007 && pl_sd->status.class_ < 4023)
  4224. max_level += 20;
  4225. if (level > 0) {
  4226. if (pl_sd->status.job_level == max_level) {
  4227. clif_displaymessage(fd, msg_table[67]); // Character's job level can't go any higher.
  4228. return -1;
  4229. }
  4230. if (pl_sd->status.job_level + level > max_level)
  4231. level = max_level - pl_sd->status.job_level;
  4232. pl_sd->status.job_level += level;
  4233. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4234. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4235. pl_sd->status.skill_point += level;
  4236. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4237. status_calc_pc(pl_sd, 0);
  4238. clif_misceffect(&pl_sd->bl, 1);
  4239. clif_displaymessage(fd, msg_table[68]); // character's job level raised.
  4240. } else {
  4241. if (pl_sd->status.job_level == 1) {
  4242. clif_displaymessage(fd, msg_table[194]); // Character's job level can't go any lower.
  4243. return -1;
  4244. }
  4245. if (pl_sd->status.job_level + level < 1)
  4246. level = 1 - pl_sd->status.job_level;
  4247. pl_sd->status.job_level += level;
  4248. clif_updatestatus(pl_sd, SP_JOBLEVEL);
  4249. clif_updatestatus(pl_sd, SP_NEXTJOBEXP);
  4250. if (pl_sd->status.skill_point > 0) {
  4251. pl_sd->status.skill_point += level;
  4252. if (pl_sd->status.skill_point < 0)
  4253. pl_sd->status.skill_point = 0;
  4254. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4255. } // to add: remove status points from skills
  4256. status_calc_pc(pl_sd, 0);
  4257. clif_displaymessage(fd, msg_table[69]); // Character's job level lowered.
  4258. }
  4259. } else {
  4260. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4261. return -1;
  4262. }
  4263. } else {
  4264. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4265. return -1;
  4266. }
  4267. return 0;
  4268. }
  4269. /*==========================================
  4270. *
  4271. *------------------------------------------
  4272. */
  4273. int atcommand_kick(
  4274. const int fd, struct map_session_data* sd,
  4275. const char* command, const char* message)
  4276. {
  4277. struct map_session_data *pl_sd;
  4278. char character[100];
  4279. nullpo_retr(-1, sd);
  4280. memset(character, '\0', sizeof(character));
  4281. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4282. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4283. return -1;
  4284. }
  4285. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4286. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4287. clif_GM_kick(sd, pl_sd, 1);
  4288. else {
  4289. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4290. return -1;
  4291. }
  4292. } else {
  4293. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4294. return -1;
  4295. }
  4296. return 0;
  4297. }
  4298. /*==========================================
  4299. *
  4300. *------------------------------------------
  4301. */
  4302. int atcommand_kickall(
  4303. const int fd, struct map_session_data* sd,
  4304. const char* command, const char* message)
  4305. {
  4306. struct map_session_data *pl_sd;
  4307. int i;
  4308. nullpo_retr(-1, sd);
  4309. for (i = 0; i < fd_max; i++) {
  4310. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4311. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4312. if (sd->status.account_id != pl_sd->status.account_id)
  4313. clif_GM_kick(sd, pl_sd, 0);
  4314. }
  4315. }
  4316. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4317. return 0;
  4318. }
  4319. /*==========================================
  4320. *
  4321. *------------------------------------------
  4322. */
  4323. int atcommand_allskill(
  4324. const int fd, struct map_session_data* sd,
  4325. const char* command, const char* message)
  4326. {
  4327. nullpo_retr(-1, sd);
  4328. pc_allskillup(sd); // all skills
  4329. sd->status.skill_point = 0; // 0 skill points
  4330. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4331. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4332. return 0;
  4333. }
  4334. /*==========================================
  4335. *
  4336. *------------------------------------------
  4337. */
  4338. int atcommand_questskill(
  4339. const int fd, struct map_session_data* sd,
  4340. const char* command, const char* message)
  4341. {
  4342. int skill_id;
  4343. nullpo_retr(-1, sd);
  4344. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4345. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4346. return -1;
  4347. }
  4348. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4349. if (skill_get_inf2(skill_id) & 0x01) {
  4350. if (pc_checkskill(sd, skill_id) == 0) {
  4351. pc_skill(sd, skill_id, 1, 0);
  4352. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4353. } else {
  4354. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4355. return -1;
  4356. }
  4357. } else {
  4358. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4359. return -1;
  4360. }
  4361. } else {
  4362. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4363. return -1;
  4364. }
  4365. return 0;
  4366. }
  4367. /*==========================================
  4368. *
  4369. *------------------------------------------
  4370. */
  4371. int atcommand_charquestskill(
  4372. const int fd, struct map_session_data* sd,
  4373. const char* command, const char* message)
  4374. {
  4375. char character[100];
  4376. struct map_session_data *pl_sd;
  4377. int skill_id = 0;
  4378. nullpo_retr(-1, sd);
  4379. memset(character, '\0', sizeof(character));
  4380. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4381. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charquestskill <#:0+> <char_name>).");
  4382. return -1;
  4383. }
  4384. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4385. if (skill_get_inf2(skill_id) & 0x01) {
  4386. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4387. if (pc_checkskill(pl_sd, skill_id) == 0) {
  4388. pc_skill(pl_sd, skill_id, 1, 0);
  4389. clif_displaymessage(fd, msg_table[199]); // This player has learned the skill.
  4390. } else {
  4391. clif_displaymessage(fd, msg_table[200]); // This player already has this quest skill.
  4392. return -1;
  4393. }
  4394. } else {
  4395. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4396. return -1;
  4397. }
  4398. } else {
  4399. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4400. return -1;
  4401. }
  4402. } else {
  4403. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4404. return -1;
  4405. }
  4406. return 0;
  4407. }
  4408. /*==========================================
  4409. *
  4410. *------------------------------------------
  4411. */
  4412. int atcommand_lostskill(
  4413. const int fd, struct map_session_data* sd,
  4414. const char* command, const char* message)
  4415. {
  4416. int skill_id;
  4417. nullpo_retr(-1, sd);
  4418. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4419. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4420. return -1;
  4421. }
  4422. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4423. if (skill_get_inf2(skill_id) & 0x01) {
  4424. if (pc_checkskill(sd, skill_id) > 0) {
  4425. sd->status.skill[skill_id].lv = 0;
  4426. sd->status.skill[skill_id].flag = 0;
  4427. clif_skillinfoblock(sd);
  4428. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4429. } else {
  4430. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4431. return -1;
  4432. }
  4433. } else {
  4434. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4435. return -1;
  4436. }
  4437. } else {
  4438. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4439. return -1;
  4440. }
  4441. return 0;
  4442. }
  4443. /*==========================================
  4444. *
  4445. *------------------------------------------
  4446. */
  4447. int atcommand_charlostskill(
  4448. const int fd, struct map_session_data* sd,
  4449. const char* command, const char* message)
  4450. {
  4451. char character[100];
  4452. struct map_session_data *pl_sd;
  4453. int skill_id = 0;
  4454. nullpo_retr(-1, sd);
  4455. memset(character, '\0', sizeof(character));
  4456. if (!message || !*message || sscanf(message, "%d %99[^\n]", &skill_id, character) < 2 || skill_id < 0) {
  4457. clif_displaymessage(fd, "Please, enter a quest skill number and a player name (usage: @charlostskill <#:0+> <char_name>).");
  4458. return -1;
  4459. }
  4460. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4461. if (skill_get_inf2(skill_id) & 0x01) {
  4462. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4463. if (pc_checkskill(pl_sd, skill_id) > 0) {
  4464. pl_sd->status.skill[skill_id].lv = 0;
  4465. pl_sd->status.skill[skill_id].flag = 0;
  4466. clif_skillinfoblock(pl_sd);
  4467. clif_displaymessage(fd, msg_table[202]); // This player has forgotten the skill.
  4468. } else {
  4469. clif_displaymessage(fd, msg_table[203]); // This player doesn't have this quest skill.
  4470. return -1;
  4471. }
  4472. } else {
  4473. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4474. return -1;
  4475. }
  4476. } else {
  4477. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4478. return -1;
  4479. }
  4480. } else {
  4481. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4482. return -1;
  4483. }
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. *
  4488. *------------------------------------------
  4489. */
  4490. int atcommand_spiritball(
  4491. const int fd, struct map_session_data* sd,
  4492. const char* command, const char* message)
  4493. {
  4494. int number;
  4495. nullpo_retr(-1, sd);
  4496. if (!message || !*message || (number = atoi(message)) < 0) {
  4497. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4498. return -1;
  4499. }
  4500. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4501. if (number > 500)
  4502. number = 500;
  4503. if (number >= 0 && number <= 0x7FFF) {
  4504. if (sd->spiritball != number || number > 499) {
  4505. if (sd->spiritball > 0)
  4506. pc_delspiritball(sd, sd->spiritball, 1);
  4507. sd->spiritball = number;
  4508. clif_spiritball(sd);
  4509. // no message, player can look the difference
  4510. if (number > 1000)
  4511. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4512. } else {
  4513. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4514. return -1;
  4515. }
  4516. } else {
  4517. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4518. return -1;
  4519. }
  4520. return 0;
  4521. }
  4522. /*==========================================
  4523. *
  4524. *------------------------------------------
  4525. */
  4526. int atcommand_party(
  4527. const int fd, struct map_session_data* sd,
  4528. const char* command, const char* message)
  4529. {
  4530. char party[100];
  4531. nullpo_retr(-1, sd);
  4532. memset(party, '\0', sizeof(party));
  4533. if (!message || !*message || sscanf(message, "%99[^\n]", party) < 1) {
  4534. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4535. return -1;
  4536. }
  4537. party_create(sd, party);
  4538. return 0;
  4539. }
  4540. /*==========================================
  4541. *
  4542. *------------------------------------------
  4543. */
  4544. int atcommand_guild(
  4545. const int fd, struct map_session_data* sd,
  4546. const char* command, const char* message)
  4547. {
  4548. char guild[100];
  4549. int prev;
  4550. nullpo_retr(-1, sd);
  4551. memset(guild, '\0', sizeof(guild));
  4552. if (!message || !*message || sscanf(message, "%99[^\n]", guild) < 1) {
  4553. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4554. return -1;
  4555. }
  4556. prev = battle_config.guild_emperium_check;
  4557. battle_config.guild_emperium_check = 0;
  4558. guild_create(sd, guild);
  4559. battle_config.guild_emperium_check = prev;
  4560. return 0;
  4561. }
  4562. /*==========================================
  4563. *
  4564. *------------------------------------------
  4565. */
  4566. int atcommand_agitstart(
  4567. const int fd, struct map_session_data* sd,
  4568. const char* command, const char* message)
  4569. {
  4570. nullpo_retr(-1, sd);
  4571. if (agit_flag == 1) {
  4572. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4573. return -1;
  4574. }
  4575. agit_flag = 1;
  4576. guild_agit_start();
  4577. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. *
  4582. *------------------------------------------
  4583. */
  4584. int atcommand_agitend(
  4585. const int fd, struct map_session_data* sd,
  4586. const char* command, const char* message)
  4587. {
  4588. nullpo_retr(-1, sd);
  4589. if (agit_flag == 0) {
  4590. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4591. return -1;
  4592. }
  4593. agit_flag = 0;
  4594. guild_agit_end();
  4595. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4596. return 0;
  4597. }
  4598. /*==========================================
  4599. * @mapexitでマップサーバーを終了させる
  4600. *------------------------------------------
  4601. */
  4602. int atcommand_mapexit(
  4603. const int fd, struct map_session_data* sd,
  4604. const char* command, const char* message)
  4605. {
  4606. struct map_session_data *pl_sd;
  4607. int i;
  4608. nullpo_retr(-1, sd);
  4609. for (i = 0; i < fd_max; i++) {
  4610. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  4611. if (sd->status.account_id != pl_sd->status.account_id)
  4612. clif_GM_kick(sd, pl_sd, 0);
  4613. }
  4614. }
  4615. clif_GM_kick(sd, sd, 0);
  4616. runflag = 0;
  4617. return 0;
  4618. }
  4619. /*==========================================
  4620. * idsearch <part_of_name>: revrited by [Yor]
  4621. *------------------------------------------
  4622. */
  4623. int atcommand_idsearch(
  4624. const int fd, struct map_session_data* sd,
  4625. const char* command, const char* message)
  4626. {
  4627. char item_name[100];
  4628. char output[200];
  4629. unsigned int i, match;
  4630. struct item_data *item;
  4631. nullpo_retr(-1, sd);
  4632. memset(item_name, '\0', sizeof(item_name));
  4633. memset(output, '\0', sizeof(output));
  4634. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4635. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4636. return -1;
  4637. }
  4638. sprintf(output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4639. clif_displaymessage(fd, output);
  4640. match = 0;
  4641. for(i = 0; i < 20000; i++) {
  4642. if ((item = itemdb_exists(i)) != NULL && strstr(item->jname, item_name) != NULL) {
  4643. match++;
  4644. sprintf(output, msg_table[78], item->jname, item->nameid); // %s: %d
  4645. clif_displaymessage(fd, output);
  4646. }
  4647. }
  4648. sprintf(output, msg_table[79], match); // It is %d affair above.
  4649. clif_displaymessage(fd, output);
  4650. return 0;
  4651. }
  4652. /*==========================================
  4653. * Character Skill Reset
  4654. *------------------------------------------
  4655. */
  4656. int atcommand_charskreset(
  4657. const int fd, struct map_session_data* sd,
  4658. const char* command, const char* message)
  4659. {
  4660. char character[100];
  4661. char output[200];
  4662. struct map_session_data *pl_sd;
  4663. nullpo_retr(-1, sd);
  4664. memset(character, '\0', sizeof(character));
  4665. memset(output, '\0', sizeof(output));
  4666. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4667. clif_displaymessage(fd, "Please, enter a player name (usage: @charskreset <charname>).");
  4668. return -1;
  4669. }
  4670. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4671. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset skill points only lower or same gm level
  4672. pc_resetskill(pl_sd);
  4673. sprintf(output, msg_table[206], character); // '%s' skill points reseted!
  4674. clif_displaymessage(fd, output);
  4675. } else {
  4676. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4677. return -1;
  4678. }
  4679. } else {
  4680. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4681. return -1;
  4682. }
  4683. return 0;
  4684. }
  4685. /*==========================================
  4686. * Character Stat Reset
  4687. *------------------------------------------
  4688. */
  4689. int atcommand_charstreset(
  4690. const int fd, struct map_session_data* sd,
  4691. const char* command, const char* message)
  4692. {
  4693. char character[100];
  4694. char output[200];
  4695. struct map_session_data *pl_sd;
  4696. nullpo_retr(-1, sd);
  4697. memset(character, '\0', sizeof(character));
  4698. memset(output, '\0', sizeof(output));
  4699. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  4700. clif_displaymessage(fd, "Please, enter a player name (usage: @charstreset <charname>).");
  4701. return -1;
  4702. }
  4703. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4704. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can reset stats points only lower or same gm level
  4705. pc_resetstate(pl_sd);
  4706. sprintf(output, msg_table[207], character); // '%s' stats points reseted!
  4707. clif_displaymessage(fd, output);
  4708. } else {
  4709. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4710. return -1;
  4711. }
  4712. } else {
  4713. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4714. return -1;
  4715. }
  4716. return 0;
  4717. }
  4718. /*==========================================
  4719. * Character Model by chbrules
  4720. *------------------------------------------
  4721. */
  4722. int atcommand_charmodel(
  4723. const int fd, struct map_session_data* sd,
  4724. const char* command, const char* message)
  4725. {
  4726. int hair_style = 0, hair_color = 0, cloth_color = 0;
  4727. struct map_session_data *pl_sd;
  4728. char character[100];
  4729. char output[200];
  4730. nullpo_retr(-1, sd);
  4731. memset(character, '\0', sizeof(character));
  4732. memset(output, '\0', sizeof(output));
  4733. 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) {
  4734. 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>).",
  4735. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  4736. clif_displaymessage(fd, output);
  4737. return -1;
  4738. }
  4739. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4740. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  4741. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  4742. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  4743. if (cloth_color != 0 &&
  4744. pl_sd->status.sex == 1 &&
  4745. (pl_sd->status.class_ == 12 || pl_sd->status.class_ == 17)) {
  4746. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  4747. return -1;
  4748. } else {
  4749. pc_changelook(pl_sd, LOOK_HAIR, hair_style);
  4750. pc_changelook(pl_sd, LOOK_HAIR_COLOR, hair_color);
  4751. pc_changelook(pl_sd, LOOK_CLOTHES_COLOR, cloth_color);
  4752. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  4753. }
  4754. } else {
  4755. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4756. return -1;
  4757. }
  4758. } else {
  4759. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4760. return -1;
  4761. }
  4762. return 0;
  4763. }
  4764. /*==========================================
  4765. * Character Skill Point (Rewritten by [Yor])
  4766. *------------------------------------------
  4767. */
  4768. int atcommand_charskpoint(
  4769. const int fd, struct map_session_data* sd,
  4770. const char* command, const char* message)
  4771. {
  4772. struct map_session_data *pl_sd;
  4773. char character[100];
  4774. int new_skill_point;
  4775. int point = 0;
  4776. nullpo_retr(-1, sd);
  4777. memset(character, '\0', sizeof(character));
  4778. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4779. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charskpoint <amount> <name>).");
  4780. return -1;
  4781. }
  4782. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4783. new_skill_point = (int)pl_sd->status.skill_point + point;
  4784. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  4785. new_skill_point = 0x7FFF;
  4786. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  4787. new_skill_point = 0;
  4788. if (new_skill_point != (int)pl_sd->status.skill_point) {
  4789. pl_sd->status.skill_point = new_skill_point;
  4790. clif_updatestatus(pl_sd, SP_SKILLPOINT);
  4791. clif_displaymessage(fd, msg_table[209]); // Character's number of skill points changed!
  4792. } else {
  4793. if (point < 0)
  4794. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4795. else
  4796. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4797. return -1;
  4798. }
  4799. } else {
  4800. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4801. return -1;
  4802. }
  4803. return 0;
  4804. }
  4805. /*==========================================
  4806. * Character Status Point (rewritten by [Yor])
  4807. *------------------------------------------
  4808. */
  4809. int atcommand_charstpoint(
  4810. const int fd, struct map_session_data* sd,
  4811. const char* command, const char* message)
  4812. {
  4813. struct map_session_data *pl_sd;
  4814. char character[100];
  4815. int new_status_point;
  4816. int point = 0;
  4817. nullpo_retr(-1, sd);
  4818. memset(character, '\0', sizeof(character));
  4819. if (!message || !*message || sscanf(message, "%d %99[^\n]", &point, character) < 2 || point == 0) {
  4820. clif_displaymessage(fd, "Please, enter a number and a player name (usage: @charstpoint <amount> <name>).");
  4821. return -1;
  4822. }
  4823. if ((pl_sd = map_nick2sd(character)) != NULL) {
  4824. new_status_point = (int)pl_sd->status.status_point + point;
  4825. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  4826. new_status_point = 0x7FFF;
  4827. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  4828. new_status_point = 0;
  4829. if (new_status_point != (int)pl_sd->status.status_point) {
  4830. pl_sd->status.status_point = new_status_point;
  4831. clif_updatestatus(pl_sd, SP_STATUSPOINT);
  4832. clif_displaymessage(fd, msg_table[210]); // Character's number of status points changed!
  4833. } else {
  4834. if (point < 0)
  4835. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  4836. else
  4837. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  4838. return -1;
  4839. }
  4840. } else {
  4841. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4842. return -1;
  4843. }
  4844. return 0;
  4845. }
  4846. /*==========================================
  4847. * Recall All Characters Online To Your Location
  4848. *------------------------------------------
  4849. */
  4850. int atcommand_recallall(
  4851. const int fd, struct map_session_data* sd,
  4852. const char* command, const char* message)
  4853. {
  4854. struct map_session_data *pl_sd;
  4855. int i;
  4856. int count;
  4857. char output[200];
  4858. nullpo_retr(-1, sd);
  4859. memset(output, '\0', sizeof(output));
  4860. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4861. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4862. return -1;
  4863. }
  4864. count = 0;
  4865. for (i = 0; i < fd_max; i++) {
  4866. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && sd->status.account_id != pl_sd->status.account_id &&
  4867. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4868. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4869. count++;
  4870. else
  4871. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4872. }
  4873. }
  4874. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4875. if (count) {
  4876. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4877. clif_displaymessage(fd, output);
  4878. }
  4879. return 0;
  4880. }
  4881. /*==========================================
  4882. * Recall online characters of a guild to your location
  4883. *------------------------------------------
  4884. */
  4885. int atcommand_guildrecall(
  4886. const int fd, struct map_session_data* sd,
  4887. const char* command, const char* message)
  4888. {
  4889. struct map_session_data *pl_sd;
  4890. int i;
  4891. char guild_name[100];
  4892. char output[200];
  4893. struct guild *g;
  4894. int count;
  4895. nullpo_retr(-1, sd);
  4896. memset(guild_name, '\0', sizeof(guild_name));
  4897. memset(output, '\0', sizeof(output));
  4898. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  4899. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4900. return -1;
  4901. }
  4902. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4903. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4904. return -1;
  4905. }
  4906. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4907. (g = guild_search(atoi(message))) != NULL) {
  4908. count = 0;
  4909. for (i = 0; i < fd_max; i++) {
  4910. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4911. sd->status.account_id != pl_sd->status.account_id &&
  4912. pl_sd->status.guild_id == g->guild_id) {
  4913. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4914. count++;
  4915. else
  4916. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4917. }
  4918. }
  4919. sprintf(output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4920. clif_displaymessage(fd, output);
  4921. if (count) {
  4922. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4923. clif_displaymessage(fd, output);
  4924. }
  4925. } else {
  4926. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4927. return -1;
  4928. }
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * Recall online characters of a party to your location
  4933. *------------------------------------------
  4934. */
  4935. int atcommand_partyrecall(
  4936. const int fd, struct map_session_data* sd,
  4937. const char* command, const char* message)
  4938. {
  4939. int i;
  4940. struct map_session_data *pl_sd;
  4941. char party_name[100];
  4942. char output[200];
  4943. struct party *p;
  4944. int count;
  4945. nullpo_retr(-1, sd);
  4946. memset(party_name, '\0', sizeof(party_name));
  4947. memset(output, '\0', sizeof(output));
  4948. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  4949. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4950. return -1;
  4951. }
  4952. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4953. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4954. return -1;
  4955. }
  4956. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4957. (p = party_search(atoi(message))) != NULL) {
  4958. count = 0;
  4959. for (i = 0; i < fd_max; i++) {
  4960. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  4961. sd->status.account_id != pl_sd->status.account_id &&
  4962. pl_sd->status.party_id == p->party_id) {
  4963. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4964. count++;
  4965. else
  4966. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  4967. }
  4968. }
  4969. sprintf(output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4970. clif_displaymessage(fd, output);
  4971. if (count) {
  4972. sprintf(output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4973. clif_displaymessage(fd, output);
  4974. }
  4975. } else {
  4976. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4977. return -1;
  4978. }
  4979. return 0;
  4980. }
  4981. /*==========================================
  4982. *
  4983. *------------------------------------------
  4984. */
  4985. int atcommand_reloaditemdb(
  4986. const int fd, struct map_session_data* sd,
  4987. const char* command, const char* message)
  4988. {
  4989. nullpo_retr(-1, sd);
  4990. itemdb_reload();
  4991. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4992. return 0;
  4993. }
  4994. /*==========================================
  4995. *
  4996. *------------------------------------------
  4997. */
  4998. int atcommand_reloadmobdb(
  4999. const int fd, struct map_session_data* sd,
  5000. const char* command, const char* message)
  5001. {
  5002. nullpo_retr(-1, sd);
  5003. mob_reload();
  5004. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  5005. return 0;
  5006. }
  5007. /*==========================================
  5008. *
  5009. *------------------------------------------
  5010. */
  5011. int atcommand_reloadskilldb(
  5012. const int fd, struct map_session_data* sd,
  5013. const char* command, const char* message)
  5014. {
  5015. nullpo_retr(-1, sd);
  5016. skill_reload();
  5017. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  5018. return 0;
  5019. }
  5020. /*==========================================
  5021. *
  5022. *------------------------------------------
  5023. */
  5024. int atcommand_reloadscript(
  5025. const int fd, struct map_session_data* sd,
  5026. const char* command, const char* message)
  5027. {
  5028. nullpo_retr(-1, sd);
  5029. atcommand_broadcast( fd, sd, "@broadcast", "eAthena SQL Server is Rehashing..." );
  5030. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  5031. rehash( fd, sd );
  5032. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  5033. do_init_npc();
  5034. do_init_script();
  5035. npc_event_do_oninit();
  5036. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  5037. return 0;
  5038. }
  5039. /*==========================================
  5040. *
  5041. *------------------------------------------
  5042. */
  5043. int atcommand_reloadgmdb( // by [Yor]
  5044. const int fd, struct map_session_data* sd,
  5045. const char* command, const char* message)
  5046. {
  5047. nullpo_retr(-1, sd);
  5048. chrif_reloadGMdb();
  5049. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  5050. return 0;
  5051. }
  5052. /*==========================================
  5053. * @mapinfo <map name> [0-3] by MC_Cameri
  5054. * => Shows information about the map [map name]
  5055. * 0 = no additional information
  5056. * 1 = Show users in that map and their location
  5057. * 2 = Shows NPCs in that map
  5058. * 3 = Shows the shops/chats in that map (not implemented)
  5059. *------------------------------------------
  5060. */
  5061. int atcommand_mapinfo(
  5062. const int fd, struct map_session_data* sd,
  5063. const char* command, const char* message)
  5064. {
  5065. struct map_session_data *pl_sd;
  5066. struct npc_data *nd = NULL;
  5067. struct chat_data *cd = NULL;
  5068. char output[200], map_name[100];
  5069. char direction[12];
  5070. int m_id, i, chat_num, list = 0;
  5071. nullpo_retr(-1, sd);
  5072. memset(output, '\0', sizeof(output));
  5073. memset(map_name, '\0', sizeof(map_name));
  5074. memset(direction, '\0', sizeof(direction));
  5075. sscanf(message, "%d %99[^\n]", &list, map_name);
  5076. if (list < 0 || list > 3) {
  5077. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5078. return -1;
  5079. }
  5080. if (map_name[0] == '\0')
  5081. strcpy(map_name, sd->mapname);
  5082. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < 13) // 16 - 4 (.gat)
  5083. strcat(map_name, ".gat");
  5084. if ((m_id = map_mapname2mapid(map_name)) < 0) {
  5085. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5086. return -1;
  5087. }
  5088. clif_displaymessage(fd, "------ Map Info ------");
  5089. sprintf(output, "Map Name: %s", map_name);
  5090. clif_displaymessage(fd, output);
  5091. sprintf(output, "Players In Map: %d", map[m_id].users);
  5092. clif_displaymessage(fd, output);
  5093. sprintf(output, "NPCs In Map: %d", map[m_id].npc_num);
  5094. clif_displaymessage(fd, output);
  5095. chat_num = 0;
  5096. for (i = 0; i < fd_max; i++) {
  5097. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5098. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  5099. chat_num++;
  5100. }
  5101. }
  5102. sprintf(output, "Chats In Map: %d", chat_num);
  5103. clif_displaymessage(fd, output);
  5104. clif_displaymessage(fd, "------ Map Flags ------");
  5105. sprintf(output, "Player vs Player: %s | No Guild: %s | No Party: %s",
  5106. (map[m_id].flag.pvp) ? "True" : "False",
  5107. (map[m_id].flag.pvp_noguild) ? "True" : "False",
  5108. (map[m_id].flag.pvp_noparty) ? "True" : "False");
  5109. clif_displaymessage(fd, output);
  5110. sprintf(output, "Guild vs Guild: %s | No Party: %s", (map[m_id].flag.gvg) ? "True" : "False", (map[m_id].flag.gvg_noparty) ? "True" : "False");
  5111. clif_displaymessage(fd, output);
  5112. sprintf(output, "No Dead Branch: %s", (map[m_id].flag.nobranch) ? "True" : "False");
  5113. clif_displaymessage(fd, output);
  5114. sprintf(output, "No Memo: %s", (map[m_id].flag.nomemo) ? "True" : "False");
  5115. clif_displaymessage(fd, output);
  5116. sprintf(output, "No Penalty: %s", (map[m_id].flag.nopenalty) ? "True" : "False");
  5117. clif_displaymessage(fd, output);
  5118. sprintf(output, "No Return: %s", (map[m_id].flag.noreturn) ? "True" : "False");
  5119. clif_displaymessage(fd, output);
  5120. sprintf(output, "No Save: %s", (map[m_id].flag.nosave) ? "True" : "False");
  5121. clif_displaymessage(fd, output);
  5122. sprintf(output, "No Teleport: %s", (map[m_id].flag.noteleport) ? "True" : "False");
  5123. clif_displaymessage(fd, output);
  5124. sprintf(output, "No Monster Teleport: %s", (map[m_id].flag.monster_noteleport) ? "True" : "False");
  5125. clif_displaymessage(fd, output);
  5126. sprintf(output, "No Zeny Penalty: %s", (map[m_id].flag.nozenypenalty) ? "True" : "False");
  5127. clif_displaymessage(fd, output);
  5128. switch (list) {
  5129. case 0:
  5130. // Do nothing. It's list 0, no additional display.
  5131. break;
  5132. case 1:
  5133. clif_displaymessage(fd, "----- Players in Map -----");
  5134. for (i = 0; i < fd_max; i++) {
  5135. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && strcmp(pl_sd->mapname, map_name) == 0) {
  5136. sprintf(output, "Player '%s' (session #%d) | Location: %d,%d",
  5137. pl_sd->status.name, i, pl_sd->bl.x, pl_sd->bl.y);
  5138. clif_displaymessage(fd, output);
  5139. }
  5140. }
  5141. break;
  5142. case 2:
  5143. clif_displaymessage(fd, "----- NPCs in Map -----");
  5144. for (i = 0; i < map[m_id].npc_num;) {
  5145. nd = map[m_id].npc[i];
  5146. switch(nd->dir) {
  5147. case 0: strcpy(direction, "North"); break;
  5148. case 1: strcpy(direction, "North West"); break;
  5149. case 2: strcpy(direction, "West"); break;
  5150. case 3: strcpy(direction, "South West"); break;
  5151. case 4: strcpy(direction, "South"); break;
  5152. case 5: strcpy(direction, "South East"); break;
  5153. case 6: strcpy(direction, "East"); break;
  5154. case 7: strcpy(direction, "North East"); break;
  5155. case 9: strcpy(direction, "North"); break;
  5156. default: strcpy(direction, "Unknown"); break;
  5157. }
  5158. sprintf(output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5159. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5160. clif_displaymessage(fd, output);
  5161. }
  5162. break;
  5163. case 3:
  5164. clif_displaymessage(fd, "----- Chats in Map -----");
  5165. for (i = 0; i < fd_max; i++) {
  5166. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth &&
  5167. (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5168. strcmp(pl_sd->mapname, map_name) == 0 &&
  5169. cd->usersd[0] == pl_sd) {
  5170. sprintf(output, "Chat %d: %s | Player: %s | Location: %d %d",
  5171. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5172. clif_displaymessage(fd, output);
  5173. sprintf(output, " Users: %d/%d | Password: %s | Public: %s",
  5174. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5175. clif_displaymessage(fd, output);
  5176. }
  5177. }
  5178. break;
  5179. default: // normally impossible to arrive here
  5180. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5181. return -1;
  5182. break;
  5183. }
  5184. return 0;
  5185. }
  5186. /*==========================================
  5187. *
  5188. *------------------------------------------
  5189. */
  5190. int atcommand_mount_peco(
  5191. const int fd, struct map_session_data* sd,
  5192. const char* command, const char* message)
  5193. {
  5194. nullpo_retr(-1, sd);
  5195. if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5196. clif_displaymessage(fd, msg_table[212]); // Cannot mount a Peco while in disguise.
  5197. return -1;
  5198. }
  5199. if (!pc_isriding(sd)) { // if actually no peco
  5200. if (sd->status.class_ == 7 || sd->status.class_ == 14 || sd->status.class_ == 4008 || sd->status.class_ == 4015) {
  5201. if (sd->status.class_ == 7)
  5202. sd->status.class_ = sd->view_class = 13;
  5203. else if (sd->status.class_ == 14)
  5204. sd->status.class_ = sd->view_class = 21;
  5205. else if (sd->status.class_ == 4008)
  5206. sd->status.class_ = sd->view_class = 4014;
  5207. else if (sd->status.class_ == 4015)
  5208. sd->status.class_ = sd->view_class = 4022;
  5209. pc_setoption(sd, sd->status.option | 0x0020);
  5210. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5211. } else {
  5212. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5213. return -1;
  5214. }
  5215. } else {
  5216. if (sd->status.class_ == 13)
  5217. sd->status.class_ = sd->view_class = 7;
  5218. else if (sd->status.class_ == 21)
  5219. sd->status.class_ = sd->view_class = 14;
  5220. else if (sd->status.class_ == 4014)
  5221. sd->status.class_ = sd->view_class = 4008;
  5222. else if (sd->status.class_ == 4022)
  5223. sd->status.class_ = sd->view_class = 4015;
  5224. pc_setoption(sd, sd->status.option & ~0x0020);
  5225. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5226. }
  5227. return 0;
  5228. }
  5229. /*==========================================
  5230. *
  5231. *------------------------------------------
  5232. */
  5233. int atcommand_char_mount_peco(
  5234. const int fd, struct map_session_data* sd,
  5235. const char* command, const char* message)
  5236. {
  5237. char character[100];
  5238. struct map_session_data *pl_sd;
  5239. nullpo_retr(-1, sd);
  5240. memset(character, '\0', sizeof(character));
  5241. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5242. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5243. return -1;
  5244. }
  5245. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5246. if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5247. clif_displaymessage(fd, msg_table[215]); // This player cannot mount a Peco while in disguise.
  5248. return -1;
  5249. }
  5250. if (!pc_isriding(pl_sd)) { // if actually no peco
  5251. if (pl_sd->status.class_ == 7 || pl_sd->status.class_ == 14 || pl_sd->status.class_ == 4008 || pl_sd->status.class_ == 4015) {
  5252. if (pl_sd->status.class_ == 7)
  5253. pl_sd->status.class_ = pl_sd->view_class = 13;
  5254. else if (pl_sd->status.class_ == 14)
  5255. pl_sd->status.class_ = pl_sd->view_class = 21;
  5256. else if (pl_sd->status.class_ == 4008)
  5257. pl_sd->status.class_ = pl_sd->view_class = 4014;
  5258. else if (pl_sd->status.class_ == 4015)
  5259. pl_sd->status.class_ = pl_sd->view_class = 4022;
  5260. pc_setoption(pl_sd, pl_sd->status.option | 0x0020);
  5261. clif_displaymessage(fd, msg_table[216]); // Now, this player mounts a peco.
  5262. } else {
  5263. clif_displaymessage(fd, msg_table[217]); // This player can not mount a peco with his/her job.
  5264. return -1;
  5265. }
  5266. } else {
  5267. if (pl_sd->status.class_ == 13)
  5268. pl_sd->status.class_ = pl_sd->view_class = 7;
  5269. else if (pl_sd->status.class_ == 21)
  5270. pl_sd->status.class_ = pl_sd->view_class = 14;
  5271. else if (pl_sd->status.class_ == 4014)
  5272. pl_sd->status.class_ = pl_sd->view_class = 4008;
  5273. else if (pl_sd->status.class_ == 4022)
  5274. pl_sd->status.class_ = pl_sd->view_class = 4015;
  5275. pc_setoption(pl_sd, pl_sd->status.option & ~0x0020);
  5276. clif_displaymessage(fd, msg_table[218]); // Now, this player has not more peco.
  5277. }
  5278. } else {
  5279. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5280. return -1;
  5281. }
  5282. return 0;
  5283. }
  5284. /*==========================================
  5285. *Spy Commands by Syrus22
  5286. *------------------------------------------
  5287. */
  5288. int atcommand_guildspy(
  5289. const int fd, struct map_session_data* sd,
  5290. const char* command, const char* message)
  5291. {
  5292. char guild_name[100];
  5293. char output[200];
  5294. struct guild *g;
  5295. nullpo_retr(-1, sd);
  5296. memset(guild_name, '\0', sizeof(guild_name));
  5297. memset(output, '\0', sizeof(output));
  5298. if (!message || !*message || sscanf(message, "%99[^\n]", guild_name) < 1) {
  5299. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5300. return -1;
  5301. }
  5302. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5303. (g = guild_search(atoi(message))) != NULL) {
  5304. if (sd->guildspy == g->guild_id) {
  5305. sd->guildspy = 0;
  5306. sprintf(output, msg_table[103], g->name); // No longer spying on the %s guild.
  5307. clif_displaymessage(fd, output);
  5308. } else {
  5309. sd->guildspy = g->guild_id;
  5310. sprintf(output, msg_table[104], g->name); // Spying on the %s guild.
  5311. clif_displaymessage(fd, output);
  5312. }
  5313. } else {
  5314. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5315. return -1;
  5316. }
  5317. return 0;
  5318. }
  5319. /*==========================================
  5320. *
  5321. *------------------------------------------
  5322. */
  5323. int atcommand_partyspy(
  5324. const int fd, struct map_session_data* sd,
  5325. const char* command, const char* message)
  5326. {
  5327. char party_name[100];
  5328. char output[200];
  5329. struct party *p;
  5330. nullpo_retr(-1, sd);
  5331. memset(party_name, '\0', sizeof(party_name));
  5332. memset(output, '\0', sizeof(output));
  5333. if (!message || !*message || sscanf(message, "%99[^\n]", party_name) < 1) {
  5334. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5335. return -1;
  5336. }
  5337. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5338. (p = party_search(atoi(message))) != NULL) {
  5339. if (sd->partyspy == p->party_id) {
  5340. sd->partyspy = 0;
  5341. sprintf(output, msg_table[105], p->name); // No longer spying on the %s party.
  5342. clif_displaymessage(fd, output);
  5343. } else {
  5344. sd->partyspy = p->party_id;
  5345. sprintf(output, msg_table[106], p->name); // Spying on the %s party.
  5346. clif_displaymessage(fd, output);
  5347. }
  5348. } else {
  5349. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5350. return -1;
  5351. }
  5352. return 0;
  5353. }
  5354. /*==========================================
  5355. * @repairall [Valaris]
  5356. *------------------------------------------
  5357. */
  5358. int atcommand_repairall(
  5359. const int fd, struct map_session_data* sd,
  5360. const char* command, const char* message)
  5361. {
  5362. int count, i;
  5363. nullpo_retr(-1, sd);
  5364. count = 0;
  5365. for (i = 0; i < MAX_INVENTORY; i++) {
  5366. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5367. sd->status.inventory[i].attribute = 0;
  5368. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5369. count++;
  5370. }
  5371. }
  5372. if (count > 0) {
  5373. clif_misceffect(&sd->bl, 3);
  5374. clif_equiplist(sd);
  5375. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5376. } else {
  5377. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5378. return -1;
  5379. }
  5380. return 0;
  5381. }
  5382. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5383. int atcommand_nuke(
  5384. const int fd, struct map_session_data* sd,
  5385. const char* command, const char* message)
  5386. {
  5387. char character[100];
  5388. struct map_session_data *pl_sd;
  5389. nullpo_retr(-1, sd);
  5390. memset(character, '\0', sizeof(character));
  5391. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5392. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5393. return -1;
  5394. }
  5395. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5396. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5397. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5398. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5399. } else {
  5400. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5401. return -1;
  5402. }
  5403. } else {
  5404. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5405. return -1;
  5406. }
  5407. return 0;
  5408. }
  5409. /*==========================================
  5410. *
  5411. *------------------------------------------
  5412. */
  5413. int atcommand_enablenpc(const int fd, struct map_session_data* sd,
  5414. const char* command, const char* message)
  5415. {
  5416. char NPCname[100];
  5417. nullpo_retr(-1, sd);
  5418. memset(NPCname, '\0', sizeof(NPCname));
  5419. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5420. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5421. return -1;
  5422. }
  5423. if (npc_name2id(NPCname) != NULL) {
  5424. npc_enable(NPCname, 1);
  5425. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5426. } else {
  5427. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5428. return -1;
  5429. }
  5430. return 0;
  5431. }
  5432. /*==========================================
  5433. *
  5434. *------------------------------------------
  5435. */
  5436. int atcommand_disablenpc(const int fd, struct map_session_data* sd,
  5437. const char* command, const char* message)
  5438. {
  5439. char NPCname[100];
  5440. nullpo_retr(-1, sd);
  5441. memset(NPCname, '\0', sizeof(NPCname));
  5442. if (!message || !*message || sscanf(message, "%99[^\n]", NPCname) < 1) {
  5443. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5444. return -1;
  5445. }
  5446. if (npc_name2id(NPCname) != NULL) {
  5447. npc_enable(NPCname, 0);
  5448. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5449. } else {
  5450. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5451. return -1;
  5452. }
  5453. return 0;
  5454. }
  5455. /*==========================================
  5456. * time in txt for time command (by [Yor])
  5457. *------------------------------------------
  5458. */
  5459. char * txt_time(unsigned int duration) {
  5460. int days, hours, minutes, seconds;
  5461. char temp[256];
  5462. static char temp1[256];
  5463. memset(temp, '\0', sizeof(temp));
  5464. memset(temp1, '\0', sizeof(temp1));
  5465. if (duration < 0)
  5466. duration = 0;
  5467. days = duration / (60 * 60 * 24);
  5468. duration = duration - (60 * 60 * 24 * days);
  5469. hours = duration / (60 * 60);
  5470. duration = duration - (60 * 60 * hours);
  5471. minutes = duration / 60;
  5472. seconds = duration - (60 * minutes);
  5473. if (days < 2)
  5474. sprintf(temp, msg_table[219], days); // %d day
  5475. else
  5476. sprintf(temp, msg_table[220], days); // %d days
  5477. if (hours < 2)
  5478. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5479. else
  5480. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5481. if (minutes < 2)
  5482. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5483. else
  5484. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5485. if (seconds < 2)
  5486. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5487. else
  5488. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5489. return temp1;
  5490. }
  5491. /*==========================================
  5492. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5493. * Calculation management of GM modification (@day/@night GM commands) is done
  5494. *------------------------------------------
  5495. */
  5496. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5497. const char* command, const char* message)
  5498. {
  5499. struct TimerData * timer_data;
  5500. struct TimerData * timer_data2;
  5501. time_t time_server; // variable for number of seconds (used with time() function)
  5502. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5503. char temp[256];
  5504. nullpo_retr(-1, sd);
  5505. memset(temp, '\0', sizeof(temp));
  5506. time(&time_server); // get time in seconds since 1/1/1970
  5507. datetime = localtime(&time_server); // convert seconds in structure
  5508. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5509. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5510. clif_displaymessage(fd, temp);
  5511. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5512. if (night_flag == 0)
  5513. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5514. else
  5515. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5516. } else if (battle_config.night_duration == 0)
  5517. if (night_flag == 1) { // we start with night
  5518. timer_data = get_timer(day_timer_tid);
  5519. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5520. clif_displaymessage(fd, temp);
  5521. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5522. } else
  5523. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5524. else if (battle_config.day_duration == 0)
  5525. if (night_flag == 0) { // we start with day
  5526. timer_data = get_timer(night_timer_tid);
  5527. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5528. clif_displaymessage(fd, temp);
  5529. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5530. } else
  5531. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5532. else {
  5533. if (night_flag == 0) {
  5534. timer_data = get_timer(night_timer_tid);
  5535. timer_data2 = get_timer(day_timer_tid);
  5536. sprintf(temp, msg_table[235], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in daylight for %s.
  5537. clif_displaymessage(fd, temp);
  5538. if (timer_data->tick > timer_data2->tick)
  5539. 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.
  5540. else
  5541. 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.
  5542. clif_displaymessage(fd, temp);
  5543. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5544. clif_displaymessage(fd, temp);
  5545. } else {
  5546. timer_data = get_timer(day_timer_tid);
  5547. timer_data2 = get_timer(night_timer_tid);
  5548. sprintf(temp, msg_table[233], txt_time((timer_data->tick - gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5549. clif_displaymessage(fd, temp);
  5550. if (timer_data->tick > timer_data2->tick)
  5551. 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.
  5552. else
  5553. 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.
  5554. clif_displaymessage(fd, temp);
  5555. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5556. clif_displaymessage(fd, temp);
  5557. }
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5563. * removes <quantity> item from a character
  5564. * item can be equiped or not.
  5565. * Inspired from a old command created by RoVeRT
  5566. *------------------------------------------
  5567. */
  5568. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5569. const char* command, const char* message)
  5570. {
  5571. struct map_session_data *pl_sd;
  5572. char character[100];
  5573. char item_name[100];
  5574. int i, number = 0, item_id, item_position, count;
  5575. char output[200];
  5576. struct item_data *item_data;
  5577. nullpo_retr(-1, sd);
  5578. memset(character, '\0', sizeof(character));
  5579. memset(item_name, '\0', sizeof(item_name));
  5580. memset(output, '\0', sizeof(output));
  5581. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, character) < 3 || number < 1) {
  5582. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5583. return -1;
  5584. }
  5585. item_id = 0;
  5586. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5587. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5588. item_id = item_data->nameid;
  5589. if (item_id > 500) {
  5590. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5591. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5592. item_position = pc_search_inventory(pl_sd, item_id);
  5593. if (item_position >= 0) {
  5594. count = 0;
  5595. for(i = 0; i < number && item_position >= 0; i++) {
  5596. pc_delitem(pl_sd, item_position, 1, 0);
  5597. count++;
  5598. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5599. }
  5600. sprintf(output, msg_table[113], count); // %d item(s) removed by a GM.
  5601. clif_displaymessage(pl_sd->fd, output);
  5602. if (number == count)
  5603. sprintf(output, msg_table[114], count); // %d item(s) removed from the player.
  5604. else
  5605. sprintf(output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5606. clif_displaymessage(fd, output);
  5607. } else {
  5608. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5609. return -1;
  5610. }
  5611. } else {
  5612. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5613. return -1;
  5614. }
  5615. } else {
  5616. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5617. return -1;
  5618. }
  5619. } else {
  5620. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5621. return -1;
  5622. }
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @jail <char_name> by [Yor]
  5627. * Special warp! No check with nowarp and nowarpto flag
  5628. *------------------------------------------
  5629. */
  5630. int atcommand_jail(
  5631. const int fd, struct map_session_data* sd,
  5632. const char* command, const char* message)
  5633. {
  5634. char character[100];
  5635. struct map_session_data *pl_sd;
  5636. int x, y;
  5637. nullpo_retr(-1, sd);
  5638. memset(character, '\0', sizeof(character));
  5639. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5640. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5641. return -1;
  5642. }
  5643. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5644. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5645. switch(rand() % 2) {
  5646. case 0:
  5647. x = 24;
  5648. y = 75;
  5649. break;
  5650. default:
  5651. x = 49;
  5652. y = 75;
  5653. break;
  5654. }
  5655. if (pc_setpos(pl_sd, "sec_pri.gat", x, y, 3) == 0) {
  5656. pc_setsavepoint(pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus]
  5657. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5658. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5659. } else {
  5660. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5661. return -1;
  5662. }
  5663. } else {
  5664. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5665. return -1;
  5666. }
  5667. } else {
  5668. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5669. return -1;
  5670. }
  5671. return 0;
  5672. }
  5673. /*==========================================
  5674. * @unjail/@discharge <char_name> by [Yor]
  5675. * Special warp! No check with nowarp and nowarpto flag
  5676. *------------------------------------------
  5677. */
  5678. int atcommand_unjail(
  5679. const int fd, struct map_session_data* sd,
  5680. const char* command, const char* message)
  5681. {
  5682. char character[100];
  5683. struct map_session_data *pl_sd;
  5684. memset(character, '\0', sizeof(character));
  5685. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5686. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5687. return -1;
  5688. }
  5689. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5690. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5691. if (pl_sd->bl.m != map_mapname2mapid("sec_pri.gat")) {
  5692. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5693. return -1;
  5694. } else if (pc_setpos(pl_sd, "prontera.gat", 156, 191, 3) == 0) {
  5695. pc_setsavepoint(pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera
  5696. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5697. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5698. } else {
  5699. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5700. return -1;
  5701. }
  5702. } else {
  5703. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5704. return -1;
  5705. }
  5706. } else {
  5707. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5708. return -1;
  5709. }
  5710. return 0;
  5711. }
  5712. /*==========================================
  5713. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5714. *------------------------------------------
  5715. */
  5716. int atcommand_disguise(
  5717. const int fd, struct map_session_data* sd,
  5718. const char* command, const char* message)
  5719. {
  5720. int mob_id = 0;
  5721. nullpo_retr(-1, sd);
  5722. if (!message || !*message) {
  5723. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5724. return -1;
  5725. }
  5726. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5727. mob_id = atoi(message);
  5728. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5729. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5730. (mob_id >= 813 && mob_id <= 834) || // NPC
  5731. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5732. if (pc_isriding(sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5733. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5734. return -1;
  5735. }
  5736. sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5737. sd->disguise = mob_id;
  5738. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5739. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5740. } else {
  5741. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5742. return -1;
  5743. }
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * DisguiseAll
  5748. *------------------------------------------
  5749. */
  5750. int atcommand_disguiseall(
  5751. const int fd, struct map_session_data* sd,
  5752. const char* command, const char* message)
  5753. {
  5754. int mob_id=0, i=0;
  5755. struct map_session_data *pl_sd;
  5756. nullpo_retr(-1, sd);
  5757. if (!message || !*message) {
  5758. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5759. return -1;
  5760. }
  5761. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5762. mob_id = atoi(message);
  5763. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5764. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5765. (mob_id >= 813 && mob_id <= 834) || // NPC
  5766. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5767. for(i=0; i < fd_max; i++) {
  5768. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  5769. if(pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5770. clif_displaymessage(fd, msg_table[227]); // Cannot wear disguise while riding a Peco.
  5771. } else {
  5772. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5773. pl_sd->disguise = mob_id;
  5774. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5775. }
  5776. }
  5777. }
  5778. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5779. } else {
  5780. return -1;
  5781. }
  5782. return 0;
  5783. }
  5784. /*==========================================
  5785. * @undisguise by [Yor]
  5786. *------------------------------------------
  5787. */
  5788. int atcommand_undisguise(
  5789. const int fd, struct map_session_data* sd,
  5790. const char* command, const char* message)
  5791. {
  5792. nullpo_retr(-1, sd);
  5793. if (sd->disguise) {
  5794. clif_clearchar(&sd->bl, 9);
  5795. sd->disguise = 0;
  5796. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  5797. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5798. } else {
  5799. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5800. return -1;
  5801. }
  5802. return 0;
  5803. }
  5804. /*==========================================
  5805. * UndisguiseAll
  5806. *------------------------------------------
  5807. */
  5808. int atcommand_undisguiseall(
  5809. const int fd, struct map_session_data* sd,
  5810. const char* command, const char* message)
  5811. {
  5812. struct map_session_data *pl_sd;
  5813. int i;
  5814. nullpo_retr(-1, sd);
  5815. for(i=0; i < fd_max; i++) {
  5816. if(session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth && pl_sd->disguise) {
  5817. clif_clearchar(&pl_sd->bl, 9);
  5818. pl_sd->disguise = 0;
  5819. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5820. }
  5821. }
  5822. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5823. return 0;
  5824. }
  5825. /*==========================================
  5826. * @broadcast by [Valaris]
  5827. *------------------------------------------
  5828. */
  5829. int atcommand_broadcast(
  5830. const int fd, struct map_session_data* sd,
  5831. const char* command, const char* message)
  5832. {
  5833. char output[200];
  5834. nullpo_retr(-1, sd);
  5835. memset(output, '\0', sizeof(output));
  5836. if (!message || !*message) {
  5837. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5838. return -1;
  5839. }
  5840. sprintf(output, "%s : %s", sd->status.name, message);
  5841. intif_GMmessage(output, strlen(output) + 1, 0);
  5842. return 0;
  5843. }
  5844. /*==========================================
  5845. * @localbroadcast by [Valaris]
  5846. *------------------------------------------
  5847. */
  5848. int atcommand_localbroadcast(
  5849. const int fd, struct map_session_data* sd,
  5850. const char* command, const char* message)
  5851. {
  5852. char output[200];
  5853. nullpo_retr(-1, sd);
  5854. memset(output, '\0', sizeof(output));
  5855. if (!message || !*message) {
  5856. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5857. return -1;
  5858. }
  5859. sprintf(output, "%s : %s", sd->status.name, message);
  5860. clif_GMmessage(&sd->bl, output, strlen(output) + 1, 1); // 1: ALL_SAMEMAP
  5861. return 0;
  5862. }
  5863. /*==========================================
  5864. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5865. *------------------------------------------
  5866. */
  5867. int atcommand_chardisguise(
  5868. const int fd, struct map_session_data* sd,
  5869. const char* command, const char* message)
  5870. {
  5871. int mob_id;
  5872. char character[100];
  5873. char mob_name[100];
  5874. struct map_session_data* pl_sd;
  5875. nullpo_retr(-1, sd);
  5876. memset(character, '\0', sizeof(character));
  5877. memset(mob_name, '\0', sizeof(mob_name));
  5878. if (!message || !*message || sscanf(message, "%s %99[^\n]", mob_name, character) < 2) {
  5879. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5880. return -1;
  5881. }
  5882. if ((mob_id = mobdb_searchname(mob_name)) == 0) // check name first (to avoid possible name begining by a number)
  5883. mob_id = atoi(mob_name);
  5884. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5885. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5886. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5887. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5888. (mob_id >= 813 && mob_id <= 834) || // NPC
  5889. (mob_id > 1000 && mob_id < 1521)) { // monsters
  5890. if (pc_isriding(pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris]
  5891. clif_displaymessage(fd, msg_table[228]); // Character cannot wear disguise while riding a Peco.
  5892. return -1;
  5893. }
  5894. pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris]
  5895. pl_sd->disguise = mob_id;
  5896. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5897. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5898. } else {
  5899. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5900. return -1;
  5901. }
  5902. } else {
  5903. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5904. return -1;
  5905. }
  5906. } else {
  5907. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5908. return -1;
  5909. }
  5910. return 0;
  5911. }
  5912. /*==========================================
  5913. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5914. *------------------------------------------
  5915. */
  5916. int atcommand_charundisguise(
  5917. const int fd, struct map_session_data* sd,
  5918. const char* command, const char* message)
  5919. {
  5920. char character[100];
  5921. struct map_session_data* pl_sd;
  5922. nullpo_retr(-1, sd);
  5923. memset(character, '\0', sizeof(character));
  5924. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  5925. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5926. return -1;
  5927. }
  5928. if ((pl_sd = map_nick2sd(character)) != NULL) {
  5929. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5930. if (pl_sd->disguise) {
  5931. clif_clearchar(&pl_sd->bl, 9);
  5932. pl_sd->disguise = 0;
  5933. pc_setpos(pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  5934. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5935. } else {
  5936. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5937. return -1;
  5938. }
  5939. } else {
  5940. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5941. return -1;
  5942. }
  5943. } else {
  5944. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5945. return -1;
  5946. }
  5947. return 0;
  5948. }
  5949. /*==========================================
  5950. * @email <actual@email> <new@email> by [Yor]
  5951. *------------------------------------------
  5952. */
  5953. int atcommand_email(
  5954. const int fd, struct map_session_data* sd,
  5955. const char* command, const char* message)
  5956. {
  5957. char actual_email[100];
  5958. char new_email[100];
  5959. nullpo_retr(-1, sd);
  5960. memset(actual_email, '\0', sizeof(actual_email));
  5961. memset(new_email, '\0', sizeof(new_email));
  5962. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5963. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5964. return -1;
  5965. }
  5966. if (e_mail_check(actual_email) == 0) {
  5967. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5968. return -1;
  5969. } else if (e_mail_check(new_email) == 0) {
  5970. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5971. return -1;
  5972. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5973. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5974. return -1;
  5975. } else if (strcmpi(actual_email, new_email) == 0) {
  5976. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5977. return -1;
  5978. } else {
  5979. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5980. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5981. }
  5982. return 0;
  5983. }
  5984. /*==========================================
  5985. *@effect
  5986. *------------------------------------------
  5987. */
  5988. int atcommand_effect(
  5989. const int fd, struct map_session_data* sd,
  5990. const char* command, const char* message)
  5991. {
  5992. struct map_session_data *pl_sd;
  5993. int type = 0, flag = 0, i;
  5994. nullpo_retr(-1, sd);
  5995. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5996. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5997. return -1;
  5998. }
  5999. if(flag <=0){
  6000. clif_specialeffect(&sd->bl, type, flag);
  6001. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  6002. }
  6003. else{
  6004. for (i = 0; i < fd_max; i++) {
  6005. if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) {
  6006. clif_specialeffect(&pl_sd->bl, type, flag);
  6007. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  6008. }
  6009. }
  6010. }
  6011. return 0;
  6012. }
  6013. /*==========================================
  6014. * @charcartlist <character>: Displays the items list of a player's cart.
  6015. *------------------------------------------
  6016. */
  6017. int
  6018. atcommand_character_cart_list(
  6019. const int fd, struct map_session_data* sd,
  6020. const char* command, const char* message)
  6021. {
  6022. struct map_session_data *pl_sd;
  6023. struct item_data *item_data, *item_temp;
  6024. int i, j, count, counter, counter2;
  6025. char character[100], output[200], outputtmp[200];
  6026. nullpo_retr(-1, sd);
  6027. memset(character, '\0', sizeof(character));
  6028. memset(output, '\0', sizeof(output));
  6029. memset(outputtmp, '\0', sizeof(outputtmp));
  6030. if (!message || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  6031. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6032. return -1;
  6033. }
  6034. if ((pl_sd = map_nick2sd(character)) != NULL) {
  6035. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6036. counter = 0;
  6037. count = 0;
  6038. for (i = 0; i < MAX_CART; i++) {
  6039. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6040. counter = counter + pl_sd->status.cart[i].amount;
  6041. count++;
  6042. if (count == 1) {
  6043. sprintf(output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6044. clif_displaymessage(fd, output);
  6045. }
  6046. if (pl_sd->status.cart[i].refine)
  6047. 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);
  6048. else
  6049. 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);
  6050. clif_displaymessage(fd, output);
  6051. memset(output, '\0', sizeof(output));
  6052. counter2 = 0;
  6053. for (j = 0; j < item_data->slot; j++) {
  6054. if (pl_sd->status.cart[i].card[j]) {
  6055. if ((item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6056. if (output[0] == '\0')
  6057. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6058. else
  6059. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6060. strcat(output, outputtmp);
  6061. }
  6062. }
  6063. }
  6064. if (output[0] != '\0') {
  6065. output[strlen(output) - 2] = ')';
  6066. output[strlen(output) - 1] = '\0';
  6067. clif_displaymessage(fd, output);
  6068. }
  6069. }
  6070. }
  6071. if (count == 0)
  6072. clif_displaymessage(fd, "No item found in the cart of this player.");
  6073. else {
  6074. sprintf(output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6075. clif_displaymessage(fd, output);
  6076. }
  6077. } else {
  6078. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6079. return -1;
  6080. }
  6081. } else {
  6082. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6083. return -1;
  6084. }
  6085. return 0;
  6086. }
  6087. /*==========================================
  6088. * @killer by MouseJstr
  6089. * enable killing players even when not in pvp
  6090. *------------------------------------------
  6091. */
  6092. int
  6093. atcommand_killer(
  6094. const int fd, struct map_session_data* sd,
  6095. const char* command, const char* message)
  6096. {
  6097. nullpo_retr(-1, sd);
  6098. sd->special_state.killer = !sd->special_state.killer;
  6099. if(sd->special_state.killer)
  6100. clif_displaymessage(fd, msg_table[241]);
  6101. else
  6102. clif_displaymessage(fd, msg_table[242]);
  6103. return 0;
  6104. }
  6105. /*==========================================
  6106. * @killable by MouseJstr
  6107. * enable other people killing you
  6108. *------------------------------------------
  6109. */
  6110. int
  6111. atcommand_killable(
  6112. const int fd, struct map_session_data* sd,
  6113. const char* command, const char* message)
  6114. {
  6115. nullpo_retr(-1, sd);
  6116. sd->special_state.killable = !sd->special_state.killable;
  6117. if(sd->special_state.killable)
  6118. clif_displaymessage(fd, msg_table[242]);
  6119. else
  6120. clif_displaymessage(fd, msg_table[241]);
  6121. return 0;
  6122. }
  6123. /*==========================================
  6124. * @charkillable by MouseJstr
  6125. * enable another player to be killed
  6126. *------------------------------------------
  6127. */
  6128. int
  6129. atcommand_charkillable(
  6130. const int fd, struct map_session_data* sd,
  6131. const char* command, const char* message)
  6132. {
  6133. struct map_session_data *pl_sd = NULL;
  6134. nullpo_retr(-1, sd);
  6135. if (!message || !*message)
  6136. return -1;
  6137. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6138. return -1;
  6139. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6140. if(pl_sd->special_state.killable)
  6141. clif_displaymessage(fd, "The player is now killable");
  6142. else
  6143. clif_displaymessage(fd, "The player is no longer killable");
  6144. return 0;
  6145. }
  6146. /*==========================================
  6147. * @skillon by MouseJstr
  6148. * turn skills on for the map
  6149. *------------------------------------------
  6150. */
  6151. int
  6152. atcommand_skillon(
  6153. const int fd, struct map_session_data* sd,
  6154. const char* command, const char* message)
  6155. {
  6156. nullpo_retr(-1, sd);
  6157. map[sd->bl.m].flag.noskill = 0;
  6158. clif_displaymessage(fd, msg_table[244]);
  6159. return 0;
  6160. }
  6161. /*==========================================
  6162. * @skilloff by MouseJstr
  6163. * Turn skills off on the map
  6164. *------------------------------------------
  6165. */
  6166. int
  6167. atcommand_skilloff(
  6168. const int fd, struct map_session_data* sd,
  6169. const char* command, const char* message)
  6170. {
  6171. nullpo_retr(-1, sd);
  6172. map[sd->bl.m].flag.noskill = 1;
  6173. clif_displaymessage(fd, msg_table[243]);
  6174. return 0;
  6175. }
  6176. /*==========================================
  6177. * @npcmove by MouseJstr
  6178. *
  6179. * move a npc
  6180. *------------------------------------------
  6181. */
  6182. int
  6183. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6184. const char* command, const char* message)
  6185. {
  6186. char character[100];
  6187. int x = 0, y = 0;
  6188. struct npc_data *nd = 0;
  6189. nullpo_retr(-1, sd);
  6190. if (!message || !*message)
  6191. return -1;
  6192. memset(character, '\0', sizeof character);
  6193. if (sscanf(message, "%d %d %99[^\n]", &x, &y, character) < 3) {
  6194. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6195. return -1;
  6196. }
  6197. nullpo_retr(-1, (nd = npc_name2id(character)));
  6198. npc_enable(character, 0);
  6199. nd->bl.x = x;
  6200. nd->bl.y = y;
  6201. npc_enable(character, 1);
  6202. return 0;
  6203. }
  6204. /*==========================================
  6205. * @addwarp by MouseJstr
  6206. *
  6207. * Create a new static warp point.
  6208. *------------------------------------------
  6209. */
  6210. int
  6211. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6212. const char* command, const char* message)
  6213. {
  6214. char w1[64], w3[64], w4[64];
  6215. char map[30], output[200];
  6216. int x,y,ret;
  6217. nullpo_retr(-1, sd);
  6218. if (!message || !*message)
  6219. return -1;
  6220. if (sscanf(message, "%99s %d %d[^\n]", map, &x, &y ) < 3)
  6221. return -1;
  6222. sprintf(w1,"%s,%d,%d", sd->mapname, sd->bl.x, sd->bl.y);
  6223. sprintf(w3,"%s%d%d%d%d", map,sd->bl.x, sd->bl.y, x, y);
  6224. sprintf(w4,"1,1,%s.gat,%d,%d", map, x, y);
  6225. ret = npc_parse_warp(w1, "warp", w3, w4);
  6226. sprintf(output, "New warp NPC => %s",w3);
  6227. clif_displaymessage(fd, output);
  6228. return ret;
  6229. }
  6230. /*==========================================
  6231. * @follow by [MouseJstr]
  6232. *
  6233. * Follow a player .. staying no more then 5 spaces away
  6234. *------------------------------------------
  6235. */
  6236. int
  6237. atcommand_follow(const int fd, struct map_session_data* sd,
  6238. const char* command, const char* message)
  6239. {
  6240. struct map_session_data *pl_sd = NULL;
  6241. nullpo_retr(-1, sd);
  6242. if (!message || !*message)
  6243. return -1;
  6244. if((pl_sd=map_nick2sd((char *) message)) != NULL)
  6245. pc_follow(sd, pl_sd->bl.id);
  6246. else
  6247. return 1;
  6248. return 0;
  6249. }
  6250. /*==========================================
  6251. * @dropall by [MouseJstr]
  6252. *
  6253. * Drop all your possession on the ground
  6254. *------------------------------------------
  6255. */
  6256. int
  6257. atcommand_dropall(const int fd, struct map_session_data* sd,
  6258. const char* command, const char* message)
  6259. {
  6260. int i;
  6261. nullpo_retr(-1, sd);
  6262. for (i = 0; i < MAX_INVENTORY; i++) {
  6263. if (sd->status.inventory[i].amount) {
  6264. if(sd->status.inventory[i].equip != 0)
  6265. pc_unequipitem(sd, i, 3);
  6266. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6267. }
  6268. }
  6269. return 0;
  6270. }
  6271. /*==========================================
  6272. * @chardropall by [MouseJstr]
  6273. *
  6274. * Throw all the characters possessions on the ground. Normally
  6275. * done in response to them being disrespectful of a GM
  6276. *------------------------------------------
  6277. */
  6278. int
  6279. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6280. const char* command, const char* message)
  6281. {
  6282. int i;
  6283. struct map_session_data *pl_sd = NULL;
  6284. nullpo_retr(-1, sd);
  6285. if (!message || !*message)
  6286. return -1;
  6287. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6288. return -1;
  6289. for (i = 0; i < MAX_INVENTORY; i++) {
  6290. if (pl_sd->status.inventory[i].amount) {
  6291. if(pl_sd->status.inventory[i].equip != 0)
  6292. pc_unequipitem(pl_sd, i, 3);
  6293. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6294. }
  6295. }
  6296. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6297. clif_displaymessage(fd, "It is done");
  6298. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6299. return 0;
  6300. }
  6301. /*==========================================
  6302. * @storeall by [MouseJstr]
  6303. *
  6304. * Put everything into storage to simplify your inventory to make
  6305. * debugging easie
  6306. *------------------------------------------
  6307. */
  6308. int
  6309. atcommand_storeall(const int fd, struct map_session_data* sd,
  6310. const char* command, const char* message)
  6311. {
  6312. int i;
  6313. nullpo_retr(-1, sd);
  6314. if (storage_storageopen(sd) == 1) {
  6315. clif_displaymessage(fd, "run this command again..");
  6316. return 0;
  6317. }
  6318. for (i = 0; i < MAX_INVENTORY; i++) {
  6319. if (sd->status.inventory[i].amount) {
  6320. if(sd->status.inventory[i].equip != 0)
  6321. pc_unequipitem(sd, i, 3);
  6322. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6323. }
  6324. }
  6325. storage_storageclose(sd);
  6326. clif_displaymessage(fd, "It is done");
  6327. return 0;
  6328. }
  6329. /*==========================================
  6330. * @charstoreall by [MouseJstr]
  6331. *
  6332. * A way to screw with players who piss you off
  6333. *------------------------------------------
  6334. */
  6335. int
  6336. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6337. const char* command, const char* message)
  6338. {
  6339. int i;
  6340. struct map_session_data *pl_sd = NULL;
  6341. nullpo_retr(-1, sd);
  6342. if (!message || !*message)
  6343. return -1;
  6344. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6345. return -1;
  6346. if (storage_storageopen(pl_sd) == 1) {
  6347. clif_displaymessage(fd, "Had to open the characters storage window...");
  6348. clif_displaymessage(fd, "run this command again..");
  6349. return 0;
  6350. }
  6351. for (i = 0; i < MAX_INVENTORY; i++) {
  6352. if (pl_sd->status.inventory[i].amount) {
  6353. if(pl_sd->status.inventory[i].equip != 0)
  6354. pc_unequipitem(pl_sd, i, 3);
  6355. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6356. }
  6357. }
  6358. storage_storageclose(pl_sd);
  6359. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6360. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6361. clif_displaymessage(pl_sd->fd, " -- the management");
  6362. clif_displaymessage(fd, "It is done");
  6363. return 0;
  6364. }
  6365. /*==========================================
  6366. * @skillid by [MouseJstr]
  6367. *
  6368. * lookup a skill by name
  6369. *------------------------------------------
  6370. */
  6371. int
  6372. atcommand_skillid(const int fd, struct map_session_data* sd,
  6373. const char* command, const char* message)
  6374. {
  6375. int skillen = 0, idx = 0;
  6376. nullpo_retr(-1, sd);
  6377. if (!message || !*message)
  6378. return -1;
  6379. skillen = strlen(message);
  6380. while (skill_names[idx].id != 0) {
  6381. if ((strnicmp(skill_names[idx].name, message, skillen) == 0) ||
  6382. (strnicmp(skill_names[idx].desc, message, skillen) == 0)) {
  6383. char output[255];
  6384. sprintf(output, "skill %d: %s", skill_names[idx].id, skill_names[idx].desc);
  6385. clif_displaymessage(fd, output);
  6386. }
  6387. idx++;
  6388. }
  6389. return 0;
  6390. }
  6391. /*==========================================
  6392. * @useskill by [MouseJstr]
  6393. *
  6394. * A way of using skills without having to find them in the skills menu
  6395. *------------------------------------------
  6396. */
  6397. int
  6398. atcommand_useskill(const int fd, struct map_session_data* sd,
  6399. const char* command, const char* message)
  6400. {
  6401. struct map_session_data *pl_sd = NULL;
  6402. int skillnum;
  6403. int skilllv;
  6404. int inf;
  6405. char target[255];
  6406. nullpo_retr(-1, sd);
  6407. if (!message || !*message)
  6408. return -1;
  6409. if(sscanf(message, "%d %d %s", &skillnum, &skilllv, target) != 3) {
  6410. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6411. return -1;
  6412. }
  6413. if((pl_sd=map_nick2sd(target)) == NULL) {
  6414. return -1;
  6415. }
  6416. inf = skill_get_inf(skillnum);
  6417. if ((inf == 2) || (inf == 1))
  6418. skill_use_pos(sd, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6419. else
  6420. skill_use_id(sd, pl_sd->bl.id, skillnum, skilllv);
  6421. return 0;
  6422. }
  6423. /*==========================================
  6424. * @skilltree by [MouseJstr]
  6425. *
  6426. * prints the skill tree for a player required to get to a skill
  6427. *------------------------------------------
  6428. */
  6429. int
  6430. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6431. const char* command, const char* message)
  6432. {
  6433. struct map_session_data *pl_sd = NULL;
  6434. int skillnum, skillidx = -1;
  6435. int meets = 1, j, c=0, s=0;
  6436. struct pc_base_job s_class;
  6437. char target[255], *tbl;
  6438. char output[255];
  6439. struct skill_tree_entry *ent;
  6440. nullpo_retr(-1, sd);
  6441. if (!message || !*message)
  6442. return -1;
  6443. if(sscanf(message, "%d %[^\r\n]", &skillnum, target) != 2) {
  6444. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6445. return -1;
  6446. }
  6447. if((pl_sd=map_nick2sd(target)) == NULL)
  6448. return -1;
  6449. s_class = pc_calc_base_job(pl_sd->status.class_);
  6450. c = s_class.job;
  6451. s = s_class.upper;
  6452. c = pc_calc_skilltree_normalize_job(c, pl_sd);
  6453. tbl = job_name(c);
  6454. sprintf(output, "Player is using %s %s skill tree (%d basic points)",
  6455. s_class.upper ? "upper" : "lower",
  6456. tbl, pc_checkskill(pl_sd, 1));
  6457. clif_displaymessage(fd, output);
  6458. for (j = 0; skill_tree[s][c][j].id != 0; j++) {
  6459. if (skill_tree[s][c][j].id == skillnum) {
  6460. skillidx = j;
  6461. break;
  6462. }
  6463. }
  6464. if (skillidx == -1) {
  6465. sprintf(output, "I do not believe the player can use that skill");
  6466. clif_displaymessage(fd, output);
  6467. return 0;
  6468. }
  6469. ent = &skill_tree[s][c][skillidx];
  6470. for(j=0;j<5;j++)
  6471. if( ent->need[j].id &&
  6472. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6473. {
  6474. int idx = 0;
  6475. char *desc;
  6476. while (skill_names[idx].id != 0 && skill_names[idx].id != ent->need[j].id)
  6477. idx++;
  6478. if (skill_names[idx].id == 0)
  6479. desc = "Unknown skill";
  6480. else
  6481. desc = skill_names[idx].desc;
  6482. sprintf(output, "player requires level %d of skill %s",
  6483. ent->need[j].lv, desc);
  6484. clif_displaymessage(fd, output);
  6485. meets = 0;
  6486. }
  6487. if (meets == 1) {
  6488. sprintf(output, "I believe the player meets all the requirements for that skill");
  6489. clif_displaymessage(fd, output);
  6490. }
  6491. return 0;
  6492. }
  6493. /*==========================================
  6494. * @marry by [MouseJstr]
  6495. *
  6496. * Marry two players
  6497. *------------------------------------------
  6498. */
  6499. int
  6500. atcommand_marry(const int fd, struct map_session_data* sd,
  6501. const char* command, const char* message)
  6502. {
  6503. struct map_session_data *pl_sd1 = NULL;
  6504. struct map_session_data *pl_sd2 = NULL;
  6505. char player1[255], player2[255];
  6506. nullpo_retr(-1, sd);
  6507. if (!message || !*message)
  6508. return -1;
  6509. if (sscanf(message, "%[^,],%[^\r\n]", player1, player2) != 2) {
  6510. clif_displaymessage(fd, "usage: @marry <player1> <player2>.");
  6511. return -1;
  6512. }
  6513. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6514. sprintf(player2, "Cannot find player %s online", player1);
  6515. clif_displaymessage(fd, player2);
  6516. return -1;
  6517. }
  6518. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6519. sprintf(player1, "Cannot find player %s online", player2);
  6520. clif_displaymessage(fd, player1);
  6521. return -1;
  6522. }
  6523. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6524. clif_displaymessage(fd, "They are married.. wish them well");
  6525. return 0;
  6526. } else
  6527. return -1;
  6528. }
  6529. /*==========================================
  6530. * @divorce by [MouseJstr]
  6531. *
  6532. * divorce two players
  6533. *------------------------------------------
  6534. */
  6535. int
  6536. atcommand_divorce(const int fd, struct map_session_data* sd,
  6537. const char* command, const char* message)
  6538. {
  6539. struct map_session_data *pl_sd = NULL;
  6540. nullpo_retr(-1, sd);
  6541. if (!message || !*message)
  6542. return -1;
  6543. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6544. return pc_divorce(pl_sd);
  6545. clif_displaymessage(fd, "They are now divorced.");
  6546. } else
  6547. clif_displaymessage(fd, "The divorce has failed.. talk to the judge..");
  6548. return 0;
  6549. }
  6550. /*==========================================
  6551. * @rings by [MouseJstr]
  6552. *
  6553. * Give two players rings
  6554. *------------------------------------------
  6555. */
  6556. int
  6557. atcommand_rings(const int fd, struct map_session_data* sd,
  6558. const char* command, const char* message)
  6559. {
  6560. struct item item_tmp;
  6561. int flag;
  6562. memset(&item_tmp, 0, sizeof(item_tmp));
  6563. item_tmp.nameid = 2634;
  6564. item_tmp.identify = 1;
  6565. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6566. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6567. item_tmp.nameid = 2635;
  6568. item_tmp.identify = 1;
  6569. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, 1)))
  6570. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  6571. clif_displaymessage(fd, "You have rings! Give them to the lovers.");
  6572. return 0;
  6573. }
  6574. #ifdef DMALLOC
  6575. unsigned long dmark_;
  6576. int
  6577. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6578. const char* command, const char* message)
  6579. {
  6580. dmark_ = dmalloc_mark();
  6581. clif_displaymessage(fd, "debug mark set");
  6582. return 0;
  6583. }
  6584. int
  6585. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6586. const char* command, const char* message)
  6587. {
  6588. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6589. dmark_ = dmalloc_mark();
  6590. clif_displaymessage(fd, "malloc changes logged");
  6591. return 0;
  6592. }
  6593. #endif
  6594. /*==========================================
  6595. * @grind by [MouseJstr]
  6596. *------------------------------------------
  6597. */
  6598. int
  6599. atcommand_grind(const int fd, struct map_session_data* sd,
  6600. const char* command, const char* message)
  6601. {
  6602. struct map_session_data *pl_sd = NULL;
  6603. int skillnum;
  6604. int inf;
  6605. char target[255];
  6606. nullpo_retr(-1, sd);
  6607. if (!message || !*message)
  6608. return -1;
  6609. if(sscanf(message, "%s", target) != 1) {
  6610. clif_displaymessage(fd, "Usage: @grind <target>");
  6611. return -1;
  6612. }
  6613. if((pl_sd=map_nick2sd(target)) == NULL)
  6614. return -1;
  6615. for (skillnum = 1; skillnum < 500; skillnum++) {
  6616. sd->status.sp = sd->status.max_sp;
  6617. atcommand_alive(fd, sd, command, message);
  6618. inf = skill_get_inf(skillnum);
  6619. if ((inf == 2) || (inf == 1))
  6620. skill_use_pos(sd, pl_sd->bl.x+5, pl_sd->bl.y+5, skillnum, 1);
  6621. else
  6622. skill_use_id(sd, pl_sd->bl.id, skillnum, 1);
  6623. }
  6624. return 0;
  6625. }
  6626. /*==========================================
  6627. * @grind2 by [MouseJstr]
  6628. *------------------------------------------
  6629. */
  6630. int
  6631. atcommand_grind2(const int fd, struct map_session_data* sd,
  6632. const char* command, const char* message)
  6633. {
  6634. int i, x, y, id;
  6635. for (i = 1000; i <2000; i++) {
  6636. x = sd->bl.x + (rand() % 10 - 5);
  6637. y = sd->bl.y + (rand() % 10 - 5);
  6638. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6639. }
  6640. return 0;
  6641. }
  6642. /*==========================================
  6643. * It is made to rain.
  6644. *------------------------------------------
  6645. */
  6646. int
  6647. atcommand_rain(
  6648. const int fd, struct map_session_data* sd,
  6649. const char* command, const char* message)
  6650. {
  6651. int effno = 0;
  6652. nullpo_retr(-1, sd);
  6653. effno = 161;
  6654. if (map[sd->bl.m].flag.rain) {
  6655. map[sd->bl.m].flag.rain=0;
  6656. clif_displaymessage(fd, "The rain has stopped.");
  6657. } else {
  6658. map[sd->bl.m].flag.rain=1;
  6659. clif_specialeffect(&sd->bl,effno,2);
  6660. clif_displaymessage(fd, "It is made to rain.");
  6661. }
  6662. return 0;
  6663. }
  6664. /*==========================================
  6665. * It is made to snow.
  6666. *------------------------------------------
  6667. */
  6668. int
  6669. atcommand_snow(
  6670. const int fd, struct map_session_data* sd,
  6671. const char* command, const char* message)
  6672. {
  6673. int effno = 0;
  6674. effno = 162;
  6675. nullpo_retr(-1, sd);
  6676. if (map[sd->bl.m].flag.snow) {
  6677. map[sd->bl.m].flag.snow=0;
  6678. clif_displaymessage(fd, "Snow has stopped falling.");
  6679. } else {
  6680. map[sd->bl.m].flag.snow=1;
  6681. clif_specialeffect(&sd->bl,effno,2);
  6682. clif_displaymessage(fd, "It is made to snow.");
  6683. }
  6684. return 0;
  6685. }
  6686. /*==========================================
  6687. * Cherry tree snowstorm is made to fall. (Sakura)
  6688. *------------------------------------------
  6689. */
  6690. int
  6691. atcommand_sakura(
  6692. const int fd, struct map_session_data* sd,
  6693. const char* command, const char* message)
  6694. {
  6695. int effno = 0;
  6696. effno = 163;
  6697. nullpo_retr(-1, sd);
  6698. if (map[sd->bl.m].flag.sakura) {
  6699. map[sd->bl.m].flag.sakura=0;
  6700. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6701. } else {
  6702. map[sd->bl.m].flag.sakura=1;
  6703. clif_specialeffect(&sd->bl,effno,2);
  6704. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6705. }
  6706. return 0;
  6707. }
  6708. /*==========================================
  6709. * Fog hangs over.
  6710. *------------------------------------------
  6711. */
  6712. int
  6713. atcommand_fog(
  6714. const int fd, struct map_session_data* sd,
  6715. const char* command, const char* message)
  6716. {
  6717. int effno = 0;
  6718. effno = 233;
  6719. nullpo_retr(-1, sd);
  6720. if (map[sd->bl.m].flag.fog) {
  6721. map[sd->bl.m].flag.fog=0;
  6722. clif_displaymessage(fd, "The fog has gone.");
  6723. } else {
  6724. map[sd->bl.m].flag.fog=1;
  6725. clif_specialeffect(&sd->bl,effno,2);
  6726. clif_displaymessage(fd, "Fog hangs over.");
  6727. }
  6728. return 0;
  6729. }
  6730. /*==========================================
  6731. * Fallen leaves fall.
  6732. *------------------------------------------
  6733. */
  6734. int
  6735. atcommand_leaves(
  6736. const int fd, struct map_session_data* sd,
  6737. const char* command, const char* message)
  6738. {
  6739. int effno = 0;
  6740. effno = 333;
  6741. nullpo_retr(-1, sd);
  6742. if (map[sd->bl.m].flag.leaves) {
  6743. map[sd->bl.m].flag.leaves=0;
  6744. clif_displaymessage(fd, "Leaves no longer fall.");
  6745. } else {
  6746. map[sd->bl.m].flag.leaves=1;
  6747. clif_specialeffect(&sd->bl,effno,2);
  6748. clif_displaymessage(fd, "Fallen leaves fall.");
  6749. }
  6750. return 0;
  6751. }
  6752. /*==========================================
  6753. * Clearing Weather Effects by Dexity
  6754. *------------------------------------------
  6755. */
  6756. int
  6757. atcommand_clearweather(
  6758. const int fd, struct map_session_data* sd,
  6759. const char* command, const char* message)
  6760. {
  6761. //int effno = 0;
  6762. nullpo_retr(-1, sd);
  6763. map[sd->bl.m].flag.rain=0;
  6764. map[sd->bl.m].flag.snow=0;
  6765. map[sd->bl.m].flag.sakura=0;
  6766. map[sd->bl.m].flag.fog=0;
  6767. map[sd->bl.m].flag.leaves=0;
  6768. //clif_specialeffect(&sd->bl,effno,2); // not required. [celest]
  6769. return 0;
  6770. }
  6771. /*===============================================================
  6772. * Sound Command - plays a sound for everyone! [Codemaster]
  6773. *---------------------------------------------------------------
  6774. */
  6775. int
  6776. atcommand_sound(
  6777. const int fd, struct map_session_data *sd,
  6778. const char *command, const char *message)
  6779. {
  6780. char sound_file[100];
  6781. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6782. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6783. return -1;
  6784. }
  6785. memset(sound_file, '\0', sizeof(sound_file));
  6786. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6787. return -1;
  6788. if(strstr(sound_file, ".wav") == NULL)
  6789. strcat(sound_file, ".wav");
  6790. clif_soundeffectall(&sd->bl, sound_file,0);
  6791. return 0;
  6792. }
  6793. /*==========================================
  6794. * MOB Search
  6795. *------------------------------------------
  6796. */
  6797. int
  6798. atcommand_mobsearch(
  6799. const int fd, struct map_session_data* sd,
  6800. const char* command, const char* message)
  6801. {
  6802. char mob_name[100];
  6803. char output[100];
  6804. int mob_id,map_id = 0;
  6805. nullpo_retr(-1, sd);
  6806. if (sscanf(message, "%99s", mob_name) < 0)
  6807. return -1;
  6808. if ((mob_id = atoi(mob_name)) == 0)
  6809. mob_id = mobdb_searchname(mob_name);
  6810. if(mob_id !=-1 && (mob_id <= 1000 || mob_id >= 2000)){
  6811. snprintf(output, sizeof output, "Invalid mob id %s!",mob_name);
  6812. clif_displaymessage(fd, output);
  6813. return 0;
  6814. }
  6815. if(mob_id == atoi(mob_name) && mob_db[mob_id].jname)
  6816. strcpy(mob_name,mob_db[mob_id].jname); // --ja--
  6817. // strcpy(mob_name,mob_db[mob_id].name); // --en--
  6818. map_id = sd->bl.m;
  6819. snprintf(output, sizeof output, "Mob Search... %s %s",
  6820. mob_name, sd->mapname);
  6821. clif_displaymessage(fd, output);
  6822. map_foreachinarea(atmobsearch_sub, map_id, 0, 0,
  6823. map[map_id].xs, map[map_id].ys, BL_MOB, mob_id, fd);
  6824. atmobsearch_sub(&sd->bl,0); // 番号リセット
  6825. return 0;
  6826. }
  6827. /*==========================================
  6828. * ドロップアイテムの掃除
  6829. *------------------------------------------
  6830. */
  6831. int
  6832. atcommand_cleanmap(
  6833. const int fd, struct map_session_data* sd,
  6834. const char* command, const char* message)
  6835. {
  6836. int i=0;
  6837. map_foreachinarea(atcommand_cleanmap_sub,sd->bl.m,
  6838. sd->bl.x-AREA_SIZE*2,sd->bl.y-AREA_SIZE*2,
  6839. sd->bl.x+AREA_SIZE*2,sd->bl.y+AREA_SIZE*2,
  6840. BL_ITEM,sd,&i);
  6841. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  6842. return 0;
  6843. }
  6844. /*==========================================
  6845. *
  6846. *------------------------------------------
  6847. */
  6848. int
  6849. atcommand_summon(
  6850. const int fd, struct map_session_data* sd,
  6851. const char* command, const char* message)
  6852. {
  6853. char name[100];
  6854. int mob_id = 0;
  6855. int x = 0;
  6856. int y = 0;
  6857. int id = 0;
  6858. struct mob_data *md;
  6859. unsigned int tick=gettick();
  6860. nullpo_retr(-1, sd);
  6861. if (!message || !*message)
  6862. return -1;
  6863. if (sscanf(message, "%99s", name) < 1)
  6864. return -1;
  6865. if ((mob_id = atoi(name)) == 0)
  6866. mob_id = mobdb_searchname(name);
  6867. if(mob_id == 0)
  6868. return -1;
  6869. x = sd->bl.x + (rand() % 10 - 5);
  6870. y = sd->bl.y + (rand() % 10 - 5);
  6871. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  6872. if((md=(struct mob_data *)map_id2bl(id))){
  6873. md->master_id=sd->bl.id;
  6874. md->state.special_mob_ai=1;
  6875. md->mode=mob_db[md->class_].mode|0x04;
  6876. md->deletetimer=add_timer(tick+60000,mob_timer_delete,id,0);
  6877. clif_misceffect2(&md->bl,344);
  6878. }
  6879. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  6880. return 0;
  6881. }
  6882. /*==========================================
  6883. * @adjcmdlvl by [MouseJstr]
  6884. *
  6885. * Temp adjust the GM level required to use a GM command
  6886. *
  6887. * Used during beta testing to allow players to use GM commands
  6888. * for short periods of time
  6889. *------------------------------------------
  6890. */
  6891. int
  6892. atcommand_adjcmdlvl(
  6893. const int fd, struct map_session_data* sd,
  6894. const char* command, const char* message)
  6895. {
  6896. int i, newlev;
  6897. char cmd[100];
  6898. nullpo_retr(-1, sd);
  6899. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  6900. clif_displaymessage(fd, "usage: @adjcmdlvl <lvl> <command>.");
  6901. return -1;
  6902. }
  6903. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  6904. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  6905. atcommand_info[i].level = newlev;
  6906. clif_displaymessage(fd, "@command level changed.");
  6907. return 0;
  6908. }
  6909. clif_displaymessage(fd, "@command not found.");
  6910. return -1;
  6911. }
  6912. /*==========================================
  6913. * @adjgmlvl by [MouseJstr]
  6914. *
  6915. * Create a temp GM
  6916. *
  6917. * Used during beta testing to allow players to use GM commands
  6918. * for short periods of time
  6919. *------------------------------------------
  6920. */
  6921. int
  6922. atcommand_adjgmlvl(
  6923. const int fd, struct map_session_data* sd,
  6924. const char* command, const char* message)
  6925. {
  6926. int newlev;
  6927. char user[100];
  6928. struct map_session_data *pl_sd;
  6929. nullpo_retr(-1, sd);
  6930. if (!message || !*message || sscanf(message, "%d %[^\r\n]", &newlev, user) != 2) {
  6931. clif_displaymessage(fd, "usage: @adjgmlvl <lvl> <user>.");
  6932. return -1;
  6933. }
  6934. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  6935. return -1;
  6936. pc_set_gm_level(pl_sd->status.account_id, newlev);
  6937. return 0;
  6938. }
  6939. /*==========================================
  6940. * @trade by [MouseJstr]
  6941. *
  6942. * Open a trade window with a remote player
  6943. *
  6944. * If I have to jump to a remote player one more time, I am
  6945. * gonna scream!
  6946. *------------------------------------------
  6947. */
  6948. int
  6949. atcommand_trade(
  6950. const int fd, struct map_session_data* sd,
  6951. const char* command, const char* message)
  6952. {
  6953. struct map_session_data *pl_sd = NULL;
  6954. nullpo_retr(-1, sd);
  6955. if (!message || !*message)
  6956. return -1;
  6957. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6958. trade_traderequest(sd, pl_sd->bl.id);
  6959. return 0;
  6960. }
  6961. return -1;
  6962. }
  6963. /*==========================================
  6964. * @setbattleflag by [MouseJstr]
  6965. *
  6966. * set a battle_config flag without having to reboot
  6967. */
  6968. int
  6969. atcommand_setbattleflag(
  6970. const int fd, struct map_session_data* sd,
  6971. const char* command, const char* message)
  6972. {
  6973. char flag[128], value[128];
  6974. nullpo_retr(-1, sd);
  6975. if (!message || !*message || sscanf(message, "%s %s", flag, value) != 2) {
  6976. clif_displaymessage(fd, "usage: @setbattleflag <flag> <value>.");
  6977. return -1;
  6978. }
  6979. if (battle_set_value(flag, value) == 0)
  6980. clif_displaymessage(fd, "unknown battle_config flag");
  6981. else
  6982. clif_displaymessage(fd, "battle_config set as requested");
  6983. return 0;
  6984. }
  6985. /*===========================
  6986. * @unmute [Valaris]
  6987. *===========================
  6988. */
  6989. int atcommand_unmute(
  6990. const int fd, struct map_session_data* sd,
  6991. const char* command, const char* message)
  6992. {
  6993. struct map_session_data *pl_sd = NULL;
  6994. nullpo_retr(-1, sd);
  6995. if (!message || !*message)
  6996. return -1;
  6997. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  6998. if(pl_sd->sc_data[SC_NOCHAT].timer!=-1) {
  6999. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7000. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7001. clif_displaymessage(sd->fd,"Player unmuted");
  7002. }
  7003. else
  7004. clif_displaymessage(sd->fd,"Player is not muted");
  7005. }
  7006. return 0;
  7007. }
  7008. /*==========================================
  7009. * @uptime by MC Cameri
  7010. *------------------------------------------
  7011. */
  7012. int
  7013. atcommand_uptime(
  7014. const int fd, struct map_session_data* sd,
  7015. const char* command, const char* message)
  7016. {
  7017. char output[200];
  7018. long seconds = 0, day = 24*60*60, hour = 60*60,
  7019. minute = 60, days = 0, hours = 0, minutes = 0;
  7020. nullpo_retr(-1, sd);
  7021. seconds = (gettick()-ticks)/CLOCKS_PER_SEC;
  7022. days = seconds/day;
  7023. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7024. hours = seconds/hour;
  7025. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7026. minutes = seconds/minute;
  7027. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7028. snprintf(output, sizeof(output), msg_table[245], days, hours, minutes, seconds);
  7029. clif_displaymessage(fd,output);
  7030. return 0;
  7031. }
  7032. /*==========================================
  7033. * @changesex <sex>
  7034. * => Changes one's sex. Argument sex can be
  7035. * 0 or 1, m or f, male or female.
  7036. *------------------------------------------
  7037. */
  7038. int
  7039. atcommand_changesex(
  7040. const int fd, struct map_session_data* sd,
  7041. const char* command, const char* message)
  7042. {
  7043. nullpo_retr(-1, sd);
  7044. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7045. return 0;
  7046. }
  7047. /*================================================
  7048. * @mute - Mutes a player for a set amount of time
  7049. *------------------------------------------------
  7050. */
  7051. int atcommand_mute(
  7052. const int fd, struct map_session_data* sd,
  7053. const char* command, const char* message)
  7054. {
  7055. struct map_session_data *pl_sd = NULL;
  7056. char character[100];
  7057. int manner;
  7058. nullpo_retr(-1, sd);
  7059. if (!message || !*message || sscanf(message, "%d %99[^\n]", &manner, character) < 1) {
  7060. clif_displaymessage(fd, "usage: @mute <time> <character name>.");
  7061. return -1;
  7062. }
  7063. if ((pl_sd = map_nick2sd(character)) != NULL) {
  7064. pl_sd->status.manner -= manner;
  7065. if(pl_sd->status.manner < 0)
  7066. status_change_start(&pl_sd->bl,SC_NOCHAT,0,0,0,0,0,0);
  7067. }
  7068. else {
  7069. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7070. return -1;
  7071. }
  7072. return 0;
  7073. }
  7074. /*==========================================
  7075. * @refresh (like @jumpto <<yourself>>)
  7076. *------------------------------------------
  7077. */
  7078. int atcommand_refresh(
  7079. const int fd, struct map_session_data* sd,
  7080. const char* command, const char* message)
  7081. {
  7082. nullpo_retr(-1, sd);
  7083. pc_setpos(sd, sd->mapname, sd->bl.x, sd->bl.y, 3);
  7084. return 0;
  7085. }
  7086. /*==========================================
  7087. * @petid <part of pet name>
  7088. * => Displays a list of matching pets.
  7089. *------------------------------------------
  7090. */
  7091. int
  7092. atcommand_petid(const int fd, struct map_session_data* sd,
  7093. const char* command, const char* message)
  7094. {
  7095. char searchtext[100];
  7096. char temp0[100];
  7097. char temp1[100];
  7098. int cnt = 0, i = 0;
  7099. nullpo_retr(-1, sd);
  7100. if (!message || !*message)
  7101. return -1;
  7102. if (sscanf(message, "%99s", searchtext) < 1)
  7103. return -1;
  7104. estr_lower(searchtext);
  7105. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7106. clif_displaymessage(fd,temp0);
  7107. while (i < MAX_PET_DB) {
  7108. strcpy(temp1,pet_db[i].name);
  7109. strcpy(temp1, estr_lower(temp1));
  7110. strcpy(temp0,pet_db[i].jname);
  7111. strcpy(temp0, estr_lower(temp1));
  7112. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7113. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7114. pet_db[i].jname);
  7115. if (cnt >= 100) { // Only if there are custom pets
  7116. clif_displaymessage(fd, "Be more specific, can't send more than"
  7117. " 100 results.");
  7118. } else {
  7119. clif_displaymessage(fd, temp0);
  7120. }
  7121. cnt++;
  7122. }
  7123. i++;
  7124. }
  7125. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7126. clif_displaymessage(fd, temp0);
  7127. return 0;
  7128. }
  7129. /*==========================================
  7130. * @identify
  7131. * => GM's magnifier.
  7132. *------------------------------------------
  7133. */
  7134. int
  7135. atcommand_identify(
  7136. const int fd, struct map_session_data* sd,
  7137. const char* command, const char* message)
  7138. {
  7139. int i,num;
  7140. nullpo_retr(-1, sd);
  7141. for(i=num=0;i<MAX_INVENTORY;i++){
  7142. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7143. num++;
  7144. }
  7145. }
  7146. if (num > 0) {
  7147. clif_item_identify_list(sd);
  7148. } else {
  7149. clif_displaymessage(fd,"There are no items to appraise.");
  7150. }
  7151. return 0;
  7152. }
  7153. /*==========================================
  7154. * @gmotd (Global MOTD)
  7155. * by davidsiaw :P
  7156. *------------------------------------------
  7157. */
  7158. int
  7159. atcommand_gmotd(
  7160. const int fd, struct map_session_data* sd,
  7161. const char* command, const char* message)
  7162. {
  7163. char buf[256];
  7164. FILE *fp;
  7165. nullpo_retr(-1, sd);
  7166. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7167. while (fgets(buf, 250, fp) != NULL){
  7168. int i;
  7169. for( i=0; buf[i]; i++){
  7170. if( buf[i]=='\r' || buf[i]=='\n'){
  7171. buf[i]=0;
  7172. break;
  7173. }
  7174. }
  7175. intif_GMmessage(buf,strlen(buf)+1,8);
  7176. }
  7177. fclose(fp);
  7178. }
  7179. return 0;
  7180. }
  7181. int atcommand_misceffect(
  7182. const int fd, struct map_session_data* sd,
  7183. const char* command, const char* message)
  7184. {
  7185. int effect = 0;
  7186. nullpo_retr(-1, sd);
  7187. if (!message || !*message)
  7188. return -1;
  7189. if (sscanf(message, "%d", &effect) < 1)
  7190. return -1;
  7191. clif_misceffect(&sd->bl,effect);
  7192. return 0;
  7193. }
  7194. int charid2sessionid(int charid)
  7195. {
  7196. int i;
  7197. int session_id=0;
  7198. struct map_session_data *pl_sd = NULL;
  7199. for(i=0;i<fd_max;i++){
  7200. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7201. if (pl_sd->status.char_id==charid) { session_id = i; break; }
  7202. }
  7203. }
  7204. return session_id;
  7205. }
  7206. int accountid2sessionid(int accountid)
  7207. {
  7208. int i;
  7209. int session_id=0;
  7210. struct map_session_data *pl_sd = NULL;
  7211. for(i=0;i<fd_max;i++){
  7212. if(session[i] && (pl_sd=session[i]->session_data) && pl_sd->state.auth){
  7213. if (pl_sd->status.account_id==accountid) { session_id = i; break; }
  7214. }
  7215. }
  7216. return session_id;
  7217. }
  7218. /*==========================================
  7219. * Jump to a player by PID number
  7220. * Original by Dino9021
  7221. * Added in by nsstrunks
  7222. *------------------------------------------
  7223. */
  7224. int atcommand_jumptoid(
  7225. const int fd, struct map_session_data* sd,
  7226. const char* command, const char* message)
  7227. {
  7228. char character[100];
  7229. char output[200];
  7230. int cid=0;
  7231. int session_id=0;
  7232. struct map_session_data *pl_sd;
  7233. memset(character, '\0', sizeof(character));
  7234. memset(output, '\0', sizeof(output));
  7235. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7236. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7237. return -1;
  7238. }
  7239. cid=atoi(message);
  7240. if ((session_id=charid2sessionid(cid))!=0)
  7241. {
  7242. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7243. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7244. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7245. return -1;
  7246. }
  7247. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7248. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7249. return -1;
  7250. }
  7251. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7252. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7253. clif_displaymessage(fd, output);
  7254. } else {
  7255. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7256. return -1;
  7257. }
  7258. }
  7259. else
  7260. {
  7261. clif_displaymessage(fd,msg_table[3]);
  7262. }
  7263. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7264. return 0;
  7265. }
  7266. /*==========================================
  7267. * Jump to a player by PID number
  7268. * Original by Dino9021
  7269. * Added in by nsstrunks
  7270. *------------------------------------------
  7271. */
  7272. int atcommand_jumptoid2(
  7273. const int fd, struct map_session_data* sd,
  7274. const char* command, const char* message)
  7275. {
  7276. char character[100];
  7277. char output[200];
  7278. int aid=0;
  7279. int session_id=0;
  7280. struct map_session_data *pl_sd;
  7281. memset(character, '\0', sizeof(character));
  7282. memset(output, '\0', sizeof(output));
  7283. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7284. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7285. return -1;
  7286. }
  7287. aid=atoi(message);
  7288. if ((session_id=accountid2sessionid(aid))!=0)
  7289. {
  7290. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7291. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7292. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7293. return -1;
  7294. }
  7295. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7296. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7297. return -1;
  7298. }
  7299. pc_setpos(sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3);
  7300. sprintf(output, msg_table[4], pl_sd->status.name); // Jump to %s
  7301. clif_displaymessage(fd, output);
  7302. } else {
  7303. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7304. return -1;
  7305. }
  7306. }
  7307. else
  7308. {
  7309. clif_displaymessage(fd,msg_table[3]);
  7310. }
  7311. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7312. return 0;
  7313. }
  7314. /*==========================================
  7315. * Recall a player by PID number
  7316. * Original by Dino9021
  7317. * Added in by nsstrunks
  7318. *------------------------------------------
  7319. */
  7320. int atcommand_recallid(
  7321. const int fd, struct map_session_data* sd,
  7322. const char* command, const char* message)
  7323. {
  7324. char character[100];
  7325. char output[200];
  7326. int cid=0;
  7327. int session_id=0;
  7328. struct map_session_data *pl_sd;
  7329. memset(character, '\0', sizeof(character));
  7330. memset(output, '\0', sizeof(output));
  7331. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7332. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7333. return -1;
  7334. }
  7335. cid=atoi(message);
  7336. if ((session_id=charid2sessionid(cid))!=0)
  7337. {
  7338. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7339. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7340. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7341. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7342. return -1;
  7343. }
  7344. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7345. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7346. return -1;
  7347. }
  7348. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7349. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7350. clif_displaymessage(fd, output);
  7351. } else {
  7352. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7353. return -1;
  7354. }
  7355. } else {
  7356. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7357. return -1;
  7358. }
  7359. }
  7360. else
  7361. {
  7362. clif_displaymessage(fd,msg_table[3]);
  7363. }
  7364. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7365. return 0;
  7366. }
  7367. /*==========================================
  7368. * Recall a player by PID number
  7369. * Original by Dino9021
  7370. * Added in by nsstrunks
  7371. *------------------------------------------
  7372. */
  7373. int atcommand_recallid2(
  7374. const int fd, struct map_session_data* sd,
  7375. const char* command, const char* message)
  7376. {
  7377. char character[100];
  7378. char output[200];
  7379. int aid=0;
  7380. int session_id=0;
  7381. struct map_session_data *pl_sd;
  7382. memset(character, '\0', sizeof(character));
  7383. memset(output, '\0', sizeof(output));
  7384. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7385. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7386. return -1;
  7387. }
  7388. aid=atoi(message);
  7389. if ((session_id=accountid2sessionid(aid))!=0)
  7390. {
  7391. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7392. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7393. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7394. clif_displaymessage(fd, "You are not authorised to warp you to the map of this player.");
  7395. return -1;
  7396. }
  7397. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7398. clif_displaymessage(fd, "You are not authorised to warp you from your actual map.");
  7399. return -1;
  7400. }
  7401. pc_setpos(pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2);
  7402. sprintf(output, msg_table[46], pl_sd->status.name); // Jump to %s
  7403. clif_displaymessage(fd, output);
  7404. } else {
  7405. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7406. return -1;
  7407. }
  7408. } else {
  7409. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7410. return -1;
  7411. }
  7412. }
  7413. else
  7414. {
  7415. clif_displaymessage(fd,msg_table[3]);
  7416. }
  7417. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7418. return 0;
  7419. }
  7420. /*==========================================
  7421. * Kick a player by PID number
  7422. * Original by Dino9021
  7423. * Added in by nsstrunks
  7424. *------------------------------------------
  7425. */
  7426. int atcommand_kickid(
  7427. const int fd, struct map_session_data* sd,
  7428. const char* command, const char* message)
  7429. {
  7430. struct map_session_data *pl_sd;
  7431. char character[100];
  7432. int cid=0;
  7433. int session_id=0;
  7434. memset(character, '\0', sizeof(character));
  7435. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7436. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7437. return -1;
  7438. }
  7439. cid=atoi(message);
  7440. if ((session_id=charid2sessionid(cid))!=0)
  7441. {
  7442. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7443. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7444. clif_GM_kick(sd, pl_sd, 1);
  7445. else {
  7446. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7447. return -1;
  7448. }
  7449. } else {
  7450. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7451. return -1;
  7452. }
  7453. }
  7454. else
  7455. {
  7456. clif_displaymessage(fd,msg_table[3]);
  7457. }
  7458. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7459. return 0;
  7460. }
  7461. /*==========================================
  7462. * Kick a player by PID number
  7463. * Original by Dino9021
  7464. * Added in by nsstrunks
  7465. *------------------------------------------
  7466. */
  7467. int atcommand_kickid2(
  7468. const int fd, struct map_session_data* sd,
  7469. const char* command, const char* message)
  7470. {
  7471. struct map_session_data *pl_sd;
  7472. char character[100];
  7473. int aid=0;
  7474. int session_id=0;
  7475. memset(character, '\0', sizeof(character));
  7476. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7477. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7478. return -1;
  7479. }
  7480. aid=atoi(message);
  7481. if ((session_id=accountid2sessionid(aid))!=0)
  7482. {
  7483. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7484. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7485. clif_GM_kick(sd, pl_sd, 1);
  7486. else {
  7487. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7488. return -1;
  7489. }
  7490. } else {
  7491. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7492. return -1;
  7493. }
  7494. }
  7495. else
  7496. {
  7497. clif_displaymessage(fd,msg_table[3]);
  7498. }
  7499. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7500. return 0;
  7501. }
  7502. /*==========================================
  7503. * Revive a player by PID number
  7504. * Original by Dino9021
  7505. * Added in by nsstrunks
  7506. *------------------------------------------
  7507. */
  7508. int atcommand_reviveid(
  7509. const int fd, struct map_session_data* sd,
  7510. const char* command, const char* message)
  7511. {
  7512. char character[100];
  7513. int cid=0;
  7514. int session_id=0;
  7515. struct map_session_data *pl_sd;
  7516. memset(character, '\0', sizeof(character));
  7517. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7518. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7519. return -1;
  7520. }
  7521. cid=atoi(message);
  7522. if ((session_id=charid2sessionid(cid))!=0)
  7523. {
  7524. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7525. pl_sd->status.hp = pl_sd->status.max_hp;
  7526. pc_setstand(pl_sd);
  7527. if (battle_config.pc_invincible_time > 0)
  7528. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7529. clif_updatestatus(pl_sd, SP_HP);
  7530. clif_updatestatus(pl_sd, SP_SP);
  7531. clif_resurrection(&pl_sd->bl, 1);
  7532. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7533. } else {
  7534. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7535. return -1;
  7536. }
  7537. }
  7538. else
  7539. {
  7540. clif_displaymessage(fd,msg_table[3]);
  7541. }
  7542. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7543. return 0;
  7544. }
  7545. /*==========================================
  7546. * Revive a player by PID number
  7547. * Original by Dino9021
  7548. * Added in by nsstrunks
  7549. *------------------------------------------
  7550. */
  7551. int atcommand_reviveid2(
  7552. const int fd, struct map_session_data* sd,
  7553. const char* command, const char* message)
  7554. {
  7555. char character[100];
  7556. int aid=0;
  7557. int session_id=0;
  7558. struct map_session_data *pl_sd;
  7559. memset(character, '\0', sizeof(character));
  7560. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7561. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7562. return -1;
  7563. }
  7564. aid=atoi(message);
  7565. if ((session_id=accountid2sessionid(aid))!=0)
  7566. {
  7567. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7568. pl_sd->status.hp = pl_sd->status.max_hp;
  7569. pc_setstand(pl_sd);
  7570. if (battle_config.pc_invincible_time > 0)
  7571. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7572. clif_updatestatus(pl_sd, SP_HP);
  7573. clif_updatestatus(pl_sd, SP_SP);
  7574. clif_resurrection(&pl_sd->bl, 1);
  7575. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7576. } else {
  7577. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7578. return -1;
  7579. }
  7580. }
  7581. else
  7582. {
  7583. clif_displaymessage(fd,msg_table[3]);
  7584. }
  7585. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7586. return 0;
  7587. }
  7588. /*==========================================
  7589. * Kill a player by PID number
  7590. * Original by Dino9021
  7591. * Added in by nsstrunks
  7592. *------------------------------------------
  7593. */
  7594. int atcommand_killid(
  7595. const int fd, struct map_session_data* sd,
  7596. const char* command, const char* message)
  7597. {
  7598. char character[100];
  7599. int cid=0;
  7600. int session_id=0;
  7601. struct map_session_data *pl_sd;
  7602. memset(character, '\0', sizeof(character));
  7603. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7604. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7605. return -1;
  7606. }
  7607. cid=atoi(message);
  7608. if ((session_id=charid2sessionid(cid))!=0)
  7609. {
  7610. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7611. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7612. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7613. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7614. } else {
  7615. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7616. return -1;
  7617. }
  7618. } else {
  7619. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7620. return -1;
  7621. }
  7622. }
  7623. else
  7624. {
  7625. clif_displaymessage(fd,msg_table[3]);
  7626. }
  7627. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7628. return 0;
  7629. }
  7630. /*==========================================
  7631. * Kill a player by PID number
  7632. * Original by Dino9021
  7633. * Added in by nsstrunks
  7634. *------------------------------------------
  7635. */
  7636. int atcommand_killid2(
  7637. const int fd, struct map_session_data* sd,
  7638. const char* command, const char* message)
  7639. {
  7640. char character[100];
  7641. int aid=0;
  7642. int session_id=0;
  7643. struct map_session_data *pl_sd;
  7644. memset(character, '\0', sizeof(character));
  7645. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", character) < 1) {
  7646. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7647. return -1;
  7648. }
  7649. aid=atoi(message);
  7650. if ((session_id=accountid2sessionid(aid))!=0)
  7651. {
  7652. if ((pl_sd = session[session_id]->session_data) != NULL) {
  7653. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7654. pc_damage(NULL, pl_sd, pl_sd->status.hp + 1);
  7655. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7656. } else {
  7657. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7658. return -1;
  7659. }
  7660. } else {
  7661. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7662. return -1;
  7663. }
  7664. }
  7665. else
  7666. {
  7667. clif_displaymessage(fd,msg_table[3]);
  7668. }
  7669. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7670. return 0;
  7671. }
  7672. /*==========================================
  7673. * Make a player killable, by PID
  7674. * Original by Dino9021
  7675. * Added in by nsstrunks
  7676. *------------------------------------------
  7677. */
  7678. int
  7679. atcommand_charkillableid(
  7680. const int fd, struct map_session_data* sd,
  7681. const char* command, const char* message)
  7682. {
  7683. struct map_session_data *pl_sd = NULL;
  7684. int cid=0;
  7685. int session_id=0;
  7686. if (!message || (cid = atoi(message)) == 0 || !*message)
  7687. return -1;
  7688. cid=atoi(message);
  7689. if ((session_id=charid2sessionid(cid))!=0)
  7690. {
  7691. if((pl_sd=session[session_id]->session_data) == NULL)
  7692. return -1;
  7693. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7694. if(pl_sd->special_state.killable)
  7695. clif_displaymessage(fd, "The player is now killable");
  7696. else
  7697. clif_displaymessage(fd, "The player is no longer killable");
  7698. }
  7699. else
  7700. {
  7701. clif_displaymessage(fd,msg_table[3]);
  7702. }
  7703. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7704. return 0;
  7705. }
  7706. /*==========================================
  7707. * Make a player killable, by PID
  7708. * Original by Dino9021
  7709. * Added in by nsstrunks
  7710. *------------------------------------------
  7711. */
  7712. int
  7713. atcommand_charkillableid2(
  7714. const int fd, struct map_session_data* sd,
  7715. const char* command, const char* message)
  7716. {
  7717. struct map_session_data *pl_sd = NULL;
  7718. int aid=0;
  7719. int session_id=0;
  7720. if (!message || (aid = atoi(message)) == 0 || !*message)
  7721. return -1;
  7722. aid=atoi(message);
  7723. if ((session_id=accountid2sessionid(aid))!=0)
  7724. {
  7725. if((pl_sd=session[session_id]->session_data) == NULL)
  7726. return -1;
  7727. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7728. if(pl_sd->special_state.killable)
  7729. clif_displaymessage(fd, "The player is now killable");
  7730. else
  7731. clif_displaymessage(fd, "The player is no longer killable");
  7732. }
  7733. else
  7734. {
  7735. clif_displaymessage(fd,msg_table[3]);
  7736. }
  7737. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7738. return 0;
  7739. }
  7740. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7741. /*==========================================
  7742. * Mail System commands by [Valaris]
  7743. *------------------------------------------
  7744. */
  7745. int atcommand_listmail(
  7746. const int fd, struct map_session_data* sd,
  7747. const char* command, const char* message)
  7748. {
  7749. if(!battle_config.mail_system)
  7750. return 0;
  7751. nullpo_retr(-1, sd);
  7752. if(strlen(command)==12)
  7753. mail_check(sd,3);
  7754. else if(strlen(command)==9)
  7755. mail_check(sd,2);
  7756. else
  7757. mail_check(sd,1);
  7758. return 0;
  7759. }
  7760. int atcommand_readmail(
  7761. const int fd, struct map_session_data* sd,
  7762. const char* command, const char* message)
  7763. {
  7764. if(!battle_config.mail_system)
  7765. return 0;
  7766. nullpo_retr(-1, sd);
  7767. if (!message || !*message) {
  7768. clif_displaymessage(sd->fd,"You must specify a message number.");
  7769. return 0;
  7770. }
  7771. if(strlen(command)==11)
  7772. mail_delete(sd,atoi(message));
  7773. else
  7774. mail_read(sd,atoi(message));
  7775. return 0;
  7776. }
  7777. int atcommand_sendmail(
  7778. const int fd, struct map_session_data* sd,
  7779. const char* command, const char* message)
  7780. {
  7781. char name[24],text[80];
  7782. if(!battle_config.mail_system)
  7783. return 0;
  7784. nullpo_retr(-1, sd);
  7785. if (!message || !*message) {
  7786. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7787. return 0;
  7788. }
  7789. if ((sscanf(message, "\"%[^\"]\" %79[^\n]", name, text) < 2) &&
  7790. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7791. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7792. return 0;
  7793. }
  7794. if(strlen(command)==17)
  7795. mail_send(sd,name,text,1);
  7796. else
  7797. mail_send(sd,name,text,0);
  7798. return 0;
  7799. }
  7800. /*==========================================
  7801. * Refresh online command for SQL [Valaris]
  7802. * Will refresh and check online column of
  7803. * players and set correctly.
  7804. *------------------------------------------
  7805. */
  7806. int atcommand_refreshonline(
  7807. const int fd, struct map_session_data* sd,
  7808. const char* command, const char* message)
  7809. {
  7810. nullpo_retr(-1, sd);
  7811. char_online_check();
  7812. return 0;
  7813. }
  7814. #endif /* end sql only */