atcommand.c 317 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/cbasetypes.h"
  9. #include "../common/mmo.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "../common/malloc.h"
  15. #include "../common/socket.h"
  16. #include "atcommand.h"
  17. #include "log.h"
  18. #include "clif.h"
  19. #include "chrif.h"
  20. #include "intif.h"
  21. #include "itemdb.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "npc.h"
  28. #include "pet.h"
  29. #include "mercenary.h" //[orn]
  30. #include "battle.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "npc.h"
  35. #include "trade.h"
  36. #include "unit.h"
  37. #ifndef TXT_ONLY
  38. #include "mail.h"
  39. #endif
  40. char atcommand_symbol = '@'; // first char of the commands (by [Yor])
  41. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  42. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  43. ACMD_FUNC(broadcast);
  44. ACMD_FUNC(localbroadcast);
  45. ACMD_FUNC(rura);
  46. ACMD_FUNC(where);
  47. ACMD_FUNC(jumpto);
  48. ACMD_FUNC(jump);
  49. ACMD_FUNC(who);
  50. ACMD_FUNC(who2);
  51. ACMD_FUNC(who3);
  52. ACMD_FUNC(whomap);
  53. ACMD_FUNC(whomap2);
  54. ACMD_FUNC(whomap3);
  55. ACMD_FUNC(whogm); // by Yor
  56. ACMD_FUNC(whozeny); // [Valaris]
  57. ACMD_FUNC(save);
  58. ACMD_FUNC(load);
  59. ACMD_FUNC(speed);
  60. ACMD_FUNC(charspeed);
  61. ACMD_FUNC(storage);
  62. ACMD_FUNC(guildstorage);
  63. ACMD_FUNC(option);
  64. ACMD_FUNC(hide);
  65. ACMD_FUNC(jobchange);
  66. ACMD_FUNC(die);
  67. ACMD_FUNC(kill);
  68. ACMD_FUNC(alive);
  69. ACMD_FUNC(kami);
  70. ACMD_FUNC(heal);
  71. ACMD_FUNC(item);
  72. ACMD_FUNC(item2);
  73. ACMD_FUNC(itemreset);
  74. ACMD_FUNC(baselevelup);
  75. ACMD_FUNC(joblevelup);
  76. ACMD_FUNC(help);
  77. ACMD_FUNC(help2);
  78. ACMD_FUNC(gm);
  79. ACMD_FUNC(pvpoff);
  80. ACMD_FUNC(pvpon);
  81. ACMD_FUNC(gvgoff);
  82. ACMD_FUNC(gvgon);
  83. ACMD_FUNC(model);
  84. ACMD_FUNC(go);
  85. ACMD_FUNC(monster);
  86. ACMD_FUNC(monstersmall);
  87. ACMD_FUNC(monsterbig);
  88. ACMD_FUNC(spawn);
  89. ACMD_FUNC(killmonster);
  90. ACMD_FUNC(killmonster2);
  91. ACMD_FUNC(refine);
  92. ACMD_FUNC(produce);
  93. ACMD_FUNC(memo);
  94. ACMD_FUNC(gat);
  95. ACMD_FUNC(packet);
  96. ACMD_FUNC(waterlevel);
  97. ACMD_FUNC(statuspoint);
  98. ACMD_FUNC(skillpoint);
  99. ACMD_FUNC(zeny);
  100. ACMD_FUNC(param);
  101. ACMD_FUNC(guildlevelup);
  102. ACMD_FUNC(makeegg);
  103. ACMD_FUNC(hatch);
  104. ACMD_FUNC(petfriendly);
  105. ACMD_FUNC(pethungry);
  106. ACMD_FUNC(petrename);
  107. ACMD_FUNC(recall);
  108. ACMD_FUNC(recallall);
  109. ACMD_FUNC(revive);
  110. ACMD_FUNC(night);
  111. ACMD_FUNC(day);
  112. ACMD_FUNC(doom);
  113. ACMD_FUNC(doommap);
  114. ACMD_FUNC(raise);
  115. ACMD_FUNC(raisemap);
  116. ACMD_FUNC(kick);
  117. ACMD_FUNC(kickall);
  118. ACMD_FUNC(allskill);
  119. ACMD_FUNC(questskill);
  120. ACMD_FUNC(lostskill);
  121. ACMD_FUNC(spiritball);
  122. ACMD_FUNC(party);
  123. ACMD_FUNC(guild);
  124. ACMD_FUNC(agitstart);
  125. ACMD_FUNC(agitend);
  126. ACMD_FUNC(reloaditemdb);
  127. ACMD_FUNC(reloadmobdb);
  128. ACMD_FUNC(reloadskilldb);
  129. ACMD_FUNC(reloadscript);
  130. ACMD_FUNC(reloadgmdb); // by Yor
  131. ACMD_FUNC(reloadatcommand);
  132. ACMD_FUNC(reloadbattleconf);
  133. ACMD_FUNC(reloadstatusdb);
  134. ACMD_FUNC(reloadpcdb);
  135. ACMD_FUNC(reloadmotd); // [Valaris]
  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_block); // by Yor
  144. ACMD_FUNC(char_ban); // by Yor
  145. ACMD_FUNC(char_unblock); // by Yor
  146. ACMD_FUNC(char_unban); // by Yor
  147. ACMD_FUNC(mount_peco); // by Valaris
  148. ACMD_FUNC(char_mount_peco); // by Yor
  149. ACMD_FUNC(guildspy); // [Syrus22]
  150. ACMD_FUNC(partyspy); // [Syrus22]
  151. ACMD_FUNC(repairall); // [Valaris]
  152. ACMD_FUNC(guildrecall); // by Yor
  153. ACMD_FUNC(partyrecall); // by Yor
  154. ACMD_FUNC(nuke); // [Valaris]
  155. ACMD_FUNC(shownpc);
  156. ACMD_FUNC(hidenpc);
  157. ACMD_FUNC(loadnpc);
  158. ACMD_FUNC(unloadnpc);
  159. ACMD_FUNC(servertime); // by Yor
  160. ACMD_FUNC(chardelitem); // by Yor
  161. ACMD_FUNC(jail); // by Yor
  162. ACMD_FUNC(unjail); // by Yor
  163. ACMD_FUNC(jailfor); // Alias Meruru
  164. ACMD_FUNC(jailtime); // Coltaro
  165. ACMD_FUNC(charjailtime); // Coltaro
  166. ACMD_FUNC(disguise); // [Valaris]
  167. ACMD_FUNC(undisguise); // by Yor
  168. ACMD_FUNC(chardisguise); // Kalaspuff
  169. ACMD_FUNC(charundisguise); // Kalaspuff
  170. ACMD_FUNC(email); // by Yor
  171. ACMD_FUNC(effect);//by Apple
  172. ACMD_FUNC(character_cart_list); // by Yor
  173. ACMD_FUNC(addwarp); // by MouseJstr
  174. ACMD_FUNC(follow); // by MouseJstr
  175. ACMD_FUNC(skillon); // by MouseJstr
  176. ACMD_FUNC(skilloff); // by MouseJstr
  177. ACMD_FUNC(killer); // by MouseJstr
  178. ACMD_FUNC(npcmove); // by MouseJstr
  179. ACMD_FUNC(killable); // by MouseJstr
  180. ACMD_FUNC(charkillable); // by MouseJstr
  181. ACMD_FUNC(dropall); // by MouseJstr
  182. ACMD_FUNC(chardropall); // by MouseJstr
  183. ACMD_FUNC(storeall); // by MouseJstr
  184. ACMD_FUNC(charstoreall); // by MouseJstr
  185. ACMD_FUNC(skillid); // by MouseJstr
  186. ACMD_FUNC(useskill); // by MouseJstr
  187. ACMD_FUNC(summon);
  188. ACMD_FUNC(rain);
  189. ACMD_FUNC(snow);
  190. ACMD_FUNC(sakura);
  191. ACMD_FUNC(clouds);
  192. ACMD_FUNC(clouds2); // [Valaris]
  193. ACMD_FUNC(fog);
  194. ACMD_FUNC(fireworks);
  195. ACMD_FUNC(leaves);
  196. ACMD_FUNC(adjgmlvl); // by MouseJstr
  197. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  198. ACMD_FUNC(trade); // by MouseJstr
  199. ACMD_FUNC(send); // by davidsiaw
  200. ACMD_FUNC(setbattleflag); // by MouseJstr
  201. ACMD_FUNC(unmute); // [Valaris]
  202. ACMD_FUNC(clearweather); // Dexity
  203. ACMD_FUNC(uptime); // by MC Cameri
  204. ACMD_FUNC(changesex); // by MC Cameri
  205. ACMD_FUNC(mute); // celest
  206. ACMD_FUNC(refresh); // by MC Cameri
  207. ACMD_FUNC(petid); // by MC Cameri
  208. ACMD_FUNC(identify); // by MC Cameri
  209. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  210. ACMD_FUNC(misceffect); // by MC Cameri
  211. ACMD_FUNC(mobsearch);
  212. ACMD_FUNC(cleanmap);
  213. ACMD_FUNC(npctalk);
  214. ACMD_FUNC(pettalk);
  215. ACMD_FUNC(users);
  216. ACMD_FUNC(reset);
  217. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  218. #ifndef TXT_ONLY
  219. ACMD_FUNC(checkmail); // [Valaris]
  220. ACMD_FUNC(listmail); // [Valaris]
  221. ACMD_FUNC(listnewmail); // [Valaris]
  222. ACMD_FUNC(readmail); // [Valaris]
  223. ACMD_FUNC(sendmail); // [Valaris]
  224. ACMD_FUNC(sendprioritymail); // [Valaris]
  225. ACMD_FUNC(deletemail); // [Valaris]
  226. ACMD_FUNC(refreshonline); // [Valaris]
  227. #endif /* TXT_ONLY */
  228. ACMD_FUNC(skilltree); // by MouseJstr
  229. ACMD_FUNC(marry); // by MouseJstr
  230. ACMD_FUNC(divorce); // by MouseJstr
  231. ACMD_FUNC(grind); // by MouseJstr
  232. ACMD_FUNC(grind2); // by MouseJstr
  233. #ifdef DMALLOC
  234. ACMD_FUNC(dmstart); // by MouseJstr
  235. ACMD_FUNC(dmtick); // by MouseJstr
  236. #endif
  237. ACMD_FUNC(jumptoid); // by Dino9021
  238. ACMD_FUNC(jumptoid2); // by Dino9021
  239. ACMD_FUNC(recallid); // by Dino9021
  240. ACMD_FUNC(recallid2); // by Dino9021
  241. ACMD_FUNC(kickid); // by Dino9021
  242. ACMD_FUNC(kickid2); // by Dino9021
  243. ACMD_FUNC(reviveid); // by Dino9021
  244. ACMD_FUNC(reviveid2); // by Dino9021
  245. ACMD_FUNC(killid); // by Dino9021
  246. ACMD_FUNC(killid2); // by Dino9021
  247. ACMD_FUNC(charkillableid); // by Dino9021
  248. ACMD_FUNC(charkillableid2); // by Dino9021
  249. ACMD_FUNC(sound);
  250. ACMD_FUNC(undisguiseall);
  251. ACMD_FUNC(disguiseall);
  252. ACMD_FUNC(changelook);
  253. ACMD_FUNC(mobinfo); //by Lupus
  254. ACMD_FUNC(exp); // by Skotlex
  255. ACMD_FUNC(adopt); // by Veider
  256. ACMD_FUNC(version); // by Ancyker
  257. ACMD_FUNC(mutearea); // by MouseJstr
  258. ACMD_FUNC(rates); // by MouseJstr
  259. ACMD_FUNC(iteminfo); // Lupus
  260. ACMD_FUNC(whodrops); //Skotlex
  261. ACMD_FUNC(mapflag); // Lupus
  262. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  263. ACMD_FUNC(monsterignore); // [Valaris]
  264. ACMD_FUNC(fakename); //[Valaris]
  265. ACMD_FUNC(size); //[Valaris]
  266. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  267. ACMD_FUNC(showzeny);
  268. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  269. ACMD_FUNC(autotrade);// durf
  270. ACMD_FUNC(changeleader);// [Skotlex]
  271. ACMD_FUNC(partyoption);// [Skotlex]
  272. ACMD_FUNC(changegm);// durf
  273. // Duel [LuzZza]
  274. ACMD_FUNC(invite);
  275. ACMD_FUNC(duel);
  276. ACMD_FUNC(leave);
  277. ACMD_FUNC(accept);
  278. ACMD_FUNC(reject);
  279. ACMD_FUNC(away); // LuzZza
  280. ACMD_FUNC(main); // LuzZza
  281. ACMD_FUNC(clone); // [Valaris]
  282. ACMD_FUNC(tonpc); // LuzZza
  283. ACMD_FUNC(commands); // [Skotlex]
  284. ACMD_FUNC(noask); //LuzZza
  285. ACMD_FUNC(request); //[Skotlex]
  286. ACMD_FUNC(homlevel); //[orn]
  287. ACMD_FUNC(homevolution); //[orn]
  288. ACMD_FUNC(makehomun); //[orn]
  289. ACMD_FUNC(homfriendly); //[orn]
  290. ACMD_FUNC(homhungry); //[orn]
  291. ACMD_FUNC(homtalk); //[orn]
  292. ACMD_FUNC(hominfo); //[Toms]
  293. ACMD_FUNC(homstats); //[Skotlex]
  294. ACMD_FUNC(homshuffle); //[Skotlex]
  295. ACMD_FUNC(showmobs); //KarLaeda
  296. /*==========================================
  297. *AtCommandInfo atcommand_info[] structure definition
  298. *------------------------------------------
  299. */
  300. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  301. // to set default level, read atcommand_athena.conf first please.
  302. static AtCommandInfo atcommand_info[] = {
  303. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  304. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  305. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  306. { AtCommand_Where, "@where", 1, atcommand_where },
  307. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  308. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  309. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  310. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  311. { AtCommand_Who, "@who", 20, atcommand_who },
  312. { AtCommand_Who, "@whois", 20, atcommand_who },
  313. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  314. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  315. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  316. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  317. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  318. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  319. { AtCommand_Save, "@save", 40, atcommand_save },
  320. { AtCommand_Load, "@return", 40, atcommand_load },
  321. { AtCommand_Load, "@load", 40, atcommand_load },
  322. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  323. { AtCommand_CharSpeed, "@charspeed", 40, atcommand_charspeed },
  324. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  325. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  326. { AtCommand_Option, "@option", 40, atcommand_option },
  327. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  328. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  329. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  330. { AtCommand_Die, "@die", 1, atcommand_die },
  331. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  332. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  333. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  334. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  335. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  336. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  337. { AtCommand_Item, "@item", 60, atcommand_item },
  338. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  339. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  340. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  341. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  342. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  343. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  344. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  345. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  346. { AtCommand_H, "@h", 20, atcommand_help },
  347. { AtCommand_Help, "@help", 20, atcommand_help },
  348. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  349. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  350. { AtCommand_GM, "@gm", 100, atcommand_gm },
  351. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  352. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  353. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  354. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  355. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  356. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  357. { AtCommand_Model, "@model", 20, atcommand_model },
  358. { AtCommand_Go, "@go", 10, atcommand_go },
  359. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  360. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  361. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  362. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  363. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  364. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  365. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  366. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  367. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  368. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  369. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  370. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  371. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  372. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  373. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  374. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  375. { AtCommand_Strength, "@str", 60, atcommand_param },
  376. { AtCommand_Agility, "@agi", 60, atcommand_param },
  377. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  378. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  379. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  380. { AtCommand_Luck, "@luk", 60, atcommand_param },
  381. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  382. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  383. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  384. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  385. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  386. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  387. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  388. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  389. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  390. { AtCommand_Night, "@night", 80, atcommand_night },
  391. { AtCommand_Day, "@day", 80, atcommand_day },
  392. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  393. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  394. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  395. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  396. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  397. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  398. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  399. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  400. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  401. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  402. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  403. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  404. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  405. { AtCommand_Party, "@party", 1, atcommand_party },
  406. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  407. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  408. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  409. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  410. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  411. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  412. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  413. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  414. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  415. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  416. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  417. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  418. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  419. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  420. { AtCommand_ReloadBattleConf, "@reloadbattleconf",99, atcommand_reloadbattleconf },
  421. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  422. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  423. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  424. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  425. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  426. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  427. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  428. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  429. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  430. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  431. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  432. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  433. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  434. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  435. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  436. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  437. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  438. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  439. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  440. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  441. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  442. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  443. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  444. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  445. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  446. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  447. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  448. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  449. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  450. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  451. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  452. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  453. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  454. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  455. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  456. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  457. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  458. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  459. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  460. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  461. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  462. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  463. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  464. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  465. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  466. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  467. { AtCommand_JailFor, "@jailfor", 60, atcommand_jailfor }, //Meruru
  468. { AtCommand_JailTime, "@jailtime", 1, atcommand_jailtime },
  469. { AtCommand_CharJailTime, "@charjailtime", 60, atcommand_charjailtime },
  470. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  471. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  472. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  473. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  474. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  475. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  476. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  477. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  478. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  479. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  480. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  481. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  482. { AtCommand_NpcMove, "@npcmove", 80, atcommand_npcmove }, // by MouseJstr
  483. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  484. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  485. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  486. { AtCommand_Chardropall, "@chardropall", 60, atcommand_chardropall }, // MouseJstr
  487. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  488. { AtCommand_Charstoreall, "@charstoreall", 60, atcommand_charstoreall }, // MouseJstr
  489. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  490. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  491. // { AtCommand_Rain, "@rain", 99, atcommand_rain }, //Client no longer supports rain!
  492. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  493. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  494. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  495. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  496. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  497. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  498. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  499. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  500. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  501. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  502. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  503. { AtCommand_Send, "@send", 99, atcommand_send },
  504. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  505. { AtCommand_UnMute, "@unmute", 80, atcommand_unmute }, // [Valaris]
  506. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  507. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  508. { AtCommand_ChangeSex, "@changesex", 60, atcommand_changesex }, // by MC Cameri
  509. { AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
  510. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  511. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  512. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  513. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  514. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  515. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  516. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  517. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  518. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  519. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  520. { AtCommand_Users, "@users", 40, atcommand_users },
  521. { AtCommand_ResetState, "@reset", 40, atcommand_reset },
  522. #ifndef TXT_ONLY // sql-only commands
  523. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  524. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  525. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  526. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  527. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  528. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  529. { AtCommand_SendPriorityMail, "@sendprioritymail",80, atcommand_sendmail }, // [Valaris]
  530. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  531. #endif /* TXT_ONLY */
  532. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  533. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  534. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  535. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  536. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  537. #ifdef DMALLOC
  538. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  539. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  540. #endif
  541. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  542. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  543. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  544. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  545. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  546. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  547. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  548. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  549. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  550. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  551. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  552. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  553. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  554. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  555. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  556. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  557. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  558. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  559. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  560. { AtCommand_ChangeLook, "@changelook", 60, atcommand_changelook },
  561. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  562. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  563. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  564. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  565. { AtCommand_Exp, "@exp", 1, atcommand_exp }, // [Skotlex]
  566. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  567. { AtCommand_Version, "@version", 1, atcommand_version },
  568. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  569. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  570. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  571. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  572. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  573. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  574. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  575. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  576. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  577. { AtCommand_MonsterIgnore, "@battleignore", 99, atcommand_monsterignore },
  578. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  579. { AtCommand_Size, "@size", 20, atcommand_size },
  580. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  581. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  582. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  583. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  584. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  585. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  586. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  587. { AtCommand_PartyOption, "@partyoption", 10, atcommand_partyoption}, // durf
  588. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  589. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  590. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  591. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  592. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  593. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  594. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  595. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  596. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  597. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  598. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  599. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  600. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  601. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  602. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  603. { AtCommand_HomLevel, "@homlvup", 60, atcommand_homlevel },
  604. { AtCommand_HomEvolution, "@homevolution", 60, atcommand_homevolution },
  605. { AtCommand_MakeHomun, "@makehomun", 60, atcommand_makehomun },
  606. { AtCommand_HomFriendly, "@homfriendly", 60, atcommand_homfriendly },
  607. { AtCommand_HomHungry, "@homhungry", 60, atcommand_homhungry },
  608. { AtCommand_HomTalk, "@homtalk", 10, atcommand_homtalk },
  609. { AtCommand_HomInfo, "@hominfo", 1, atcommand_hominfo },
  610. { AtCommand_HomStats, "@homstats", 1, atcommand_homstats },
  611. { AtCommand_HomShuffle, "@homshuffle", 60, atcommand_homshuffle },
  612. { AtCommand_ShowMobs, "@showmobs", 10, atcommand_showmobs }, //KarLaeda
  613. // add new commands before this line
  614. { AtCommand_Unknown, NULL, 1, NULL }
  615. };
  616. /*=========================================
  617. * Generic variables
  618. *-----------------------------------------
  619. */
  620. char atcmd_output[200];
  621. char atcmd_player_name[100];
  622. char atcmd_temp[100];
  623. /*==========================================
  624. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  625. *------------------------------------------
  626. */
  627. char *estr_lower(char *str)
  628. {
  629. int i;
  630. for (i=0; str[i]; i++)
  631. if ((str[i] >= 65) && (str[i] <= 90))
  632. str[i] += 32;
  633. return str;
  634. }
  635. // compare function for sorting high to lowest
  636. int hightolow_compare (const void * a, const void * b)
  637. {
  638. return ( *(int*)b - *(int*)a );
  639. }
  640. // compare function for sorting lowest to highest
  641. int lowtohigh_compare (const void * a, const void * b)
  642. {
  643. return ( *(int*)a - *(int*)b );
  644. }
  645. //-----------------------------------------------------------
  646. // Return the message string of the specified number by [Yor]
  647. //-----------------------------------------------------------
  648. char * msg_txt(int msg_number)
  649. {
  650. if (msg_number >= 0 && msg_number < MAX_MSG &&
  651. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  652. return msg_table[msg_number];
  653. return "??";
  654. }
  655. //-----------------------------------------------------------
  656. // Returns Players title (from msg_athena.conf) [Lupus]
  657. //-----------------------------------------------------------
  658. char * player_title_txt(int level) {
  659. if (level < battle_config.title_lvl1)
  660. return ""; //w/o any titles
  661. if (level >= battle_config.title_lvl8)
  662. sprintf(atcmd_temp, msg_txt(332), level);
  663. else
  664. if (level >= battle_config.title_lvl7)
  665. sprintf(atcmd_temp, msg_txt(331), level);
  666. else
  667. if (level >= battle_config.title_lvl6)
  668. sprintf(atcmd_temp, msg_txt(330), level);
  669. else
  670. if (level >= battle_config.title_lvl5)
  671. sprintf(atcmd_temp, msg_txt(329), level);
  672. else
  673. if (level >= battle_config.title_lvl4)
  674. sprintf(atcmd_temp, msg_txt(328), level);
  675. else
  676. if (level >= battle_config.title_lvl3)
  677. sprintf(atcmd_temp, msg_txt(327), level);
  678. else
  679. if (level >= battle_config.title_lvl2)
  680. sprintf(atcmd_temp, msg_txt(326), level);
  681. else
  682. sprintf(atcmd_temp, msg_txt(325), level); //lvl1
  683. return atcmd_temp;
  684. }
  685. //------------------------------------------------------------
  686. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  687. //------------------------------------------------------------
  688. int e_mail_check(char *email)
  689. {
  690. char ch;
  691. char* last_arobas;
  692. // athena limits
  693. if (strlen(email) < 3 || strlen(email) > 39)
  694. return 0;
  695. // part of RFC limits (official reference of e-mail description)
  696. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  697. return 0;
  698. if (email[strlen(email)-1] == '.')
  699. return 0;
  700. last_arobas = strrchr(email, '@');
  701. if (strstr(last_arobas, "@.") != NULL ||
  702. strstr(last_arobas, "..") != NULL)
  703. return 0;
  704. for(ch = 1; ch < 32; ch++) {
  705. if (strchr(last_arobas, ch) != NULL) {
  706. return 0;
  707. break;
  708. }
  709. }
  710. if (strchr(last_arobas, ' ') != NULL ||
  711. strchr(last_arobas, ';') != NULL)
  712. return 0;
  713. // all correct
  714. return 1;
  715. }
  716. /*==========================================
  717. * Retrieve the atcommand's required gm level
  718. *------------------------------------------
  719. */
  720. int get_atcommand_level(const AtCommandType type)
  721. {
  722. int i;
  723. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  724. if (atcommand_info[i].type == type)
  725. return atcommand_info[i].level;
  726. return 100; // 100: command can not be used
  727. }
  728. AtCommandType is_atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl)
  729. {
  730. AtCommandInfo info;
  731. AtCommandType type;
  732. memset(&info, 0, sizeof(info));
  733. type = atcommand(sd, gmlvl, str, &info);
  734. if (type != AtCommand_None) {
  735. char command[100];
  736. const char* p = str;
  737. if (map[sd->bl.m].nocommand &&
  738. gmlvl < map[sd->bl.m].nocommand)
  739. { //Command not allowed on this map.
  740. sprintf(atcmd_output, msg_txt(143));
  741. clif_displaymessage(fd, atcmd_output);
  742. return AtCommand_None;
  743. }
  744. memset(command, '\0', sizeof(command));
  745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  746. while (*p && !isspace(*p))
  747. p++;
  748. if (p - str >= sizeof(command)) // too long
  749. return AtCommand_Unknown;
  750. strncpy(command, str, p - str);
  751. while (isspace(*p))
  752. p++;
  753. if (type == AtCommand_Unknown || info.proc == NULL) {
  754. sprintf(atcmd_output, msg_txt(153), command); // %s is Unknown Command.
  755. clif_displaymessage(fd, atcmd_output);
  756. } else {
  757. if (info.proc(fd, sd, command, p) != 0) {
  758. // Command can not be executed
  759. sprintf(atcmd_output, msg_txt(154), command); // %s failed.
  760. clif_displaymessage(fd, atcmd_output);
  761. }
  762. }
  763. return info.type;
  764. }
  765. return AtCommand_None;
  766. }
  767. /*==========================================
  768. *
  769. *------------------------------------------
  770. */
  771. AtCommandType is_atcommand(const int fd, struct map_session_data* sd, const char* message)
  772. {
  773. const char* str = message;
  774. int s_flag = 0;
  775. nullpo_retr(AtCommand_None, sd);
  776. if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
  777. return AtCommand_Unknown;
  778. }
  779. if (!message || !*message)
  780. return AtCommand_None;
  781. str += strlen(sd->status.name);
  782. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  783. if (*str == ':')
  784. s_flag = 1;
  785. str++;
  786. }
  787. if (!*str)
  788. return AtCommand_None;
  789. if(str[0] == '|' && strlen(str) >= 4 && str[3] == atcommand_symbol)
  790. str += 3; // skip 10/11-langtype's codepage indicator, if detected
  791. return is_atcommand_sub(fd,sd,str,pc_isGM(sd));
  792. }
  793. /*==========================================
  794. *
  795. *------------------------------------------
  796. */
  797. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info)
  798. {
  799. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  800. if (!info)
  801. return AtCommand_None;
  802. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  803. return AtCommand_None;
  804. if (!p || !*p) {
  805. ShowError("at command message is empty\n");
  806. return AtCommand_None;
  807. }
  808. if (*p == atcommand_symbol) { // check first char
  809. char command[101];
  810. int i = 0;
  811. memset(info, 0, sizeof(AtCommandInfo));
  812. sscanf(p, "%100s", command);
  813. command[sizeof(command)-1] = '\0';
  814. while (atcommand_info[i].type != AtCommand_Unknown) {
  815. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  816. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  817. break;
  818. }
  819. i++;
  820. }
  821. if (atcommand_info[i].type == AtCommand_Unknown) {
  822. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  823. if (level == 0)
  824. return AtCommand_None;
  825. else
  826. return AtCommand_Unknown;
  827. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  828. log_atcommand(sd, message);
  829. }
  830. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  831. } else {
  832. return AtCommand_None;
  833. }
  834. return info->type;
  835. }
  836. /*==========================================
  837. * Read Message Data
  838. *------------------------------------------
  839. */
  840. int msg_config_read(const char *cfgName)
  841. {
  842. int msg_number;
  843. char line[1024], w1[1024], w2[1024];
  844. FILE *fp;
  845. static int called = 1;
  846. if ((fp = fopen(cfgName, "r")) == NULL) {
  847. ShowError("Messages file not found: %s\n", cfgName);
  848. return 1;
  849. }
  850. if ((--called) == 0)
  851. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  852. while(fgets(line, sizeof(line)-1, fp)) {
  853. if (line[0] == '/' && line[1] == '/')
  854. continue;
  855. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  856. if (strcmpi(w1, "import") == 0) {
  857. msg_config_read(w2);
  858. } else {
  859. msg_number = atoi(w1);
  860. if (msg_number >= 0 && msg_number < MAX_MSG) {
  861. if (msg_table[msg_number] != NULL)
  862. aFree(msg_table[msg_number]);
  863. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  864. strcpy(msg_table[msg_number],w2);
  865. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  866. }
  867. }
  868. }
  869. }
  870. fclose(fp);
  871. return 0;
  872. }
  873. /*==========================================
  874. * Cleanup Message Data
  875. *------------------------------------------
  876. */
  877. void do_final_msg (void)
  878. {
  879. int i;
  880. for (i = 0; i < MAX_MSG; i++)
  881. aFree(msg_table[i]);
  882. return;
  883. }
  884. /*==========================================
  885. *
  886. *------------------------------------------
  887. */
  888. static AtCommandInfo* get_atcommandinfo_byname(const char* name)
  889. {
  890. int i;
  891. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  892. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  893. return &atcommand_info[i];
  894. return NULL;
  895. }
  896. /*==========================================
  897. *
  898. *------------------------------------------
  899. */
  900. int atcommand_config_read(const char *cfgName)
  901. {
  902. char line[1024], w1[1024], w2[1024];
  903. AtCommandInfo* p;
  904. FILE* fp;
  905. if ((fp = fopen(cfgName, "r")) == NULL) {
  906. ShowError("At commands configuration file not found: %s\n", cfgName);
  907. return 1;
  908. }
  909. while (fgets(line, sizeof(line)-1, fp)) {
  910. if (line[0] == '/' && line[1] == '/')
  911. continue;
  912. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  913. continue;
  914. p = get_atcommandinfo_byname(w1);
  915. if (p != NULL) {
  916. p->level = atoi(w2);
  917. if (p->level > 100)
  918. p->level = 100;
  919. else if (p->level < 0)
  920. p->level = 0;
  921. }
  922. if (strcmpi(w1, "import") == 0)
  923. atcommand_config_read(w2);
  924. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  925. w2[0] != '/' && // symbol of standard ragnarok GM commands
  926. w2[0] != '%' && // symbol of party chat speaking
  927. w2[0] != '$' && // symbol of guild chat
  928. w2[0] != '#') // symbol of charcommand
  929. atcommand_symbol = w2[0];
  930. }
  931. fclose(fp);
  932. return 0;
  933. }
  934. /*==========================================
  935. // @ command processing functions
  936. *------------------------------------------
  937. */
  938. /*==========================================
  939. * @commands Lists available @ commands to you (code 98% from Meruru)
  940. *------------------------------------------
  941. */
  942. int atcommand_commands(const int fd, struct map_session_data* sd, const char* command, const char* message)
  943. {
  944. char cz_line_buff[CHATBOX_SIZE+1];
  945. register char *lpcz_cur = cz_line_buff;
  946. register unsigned int ui_slen;
  947. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  948. memset(cz_line_buff,' ',CHATBOX_SIZE);
  949. cz_line_buff[CHATBOX_SIZE] = 0;
  950. clif_displaymessage(fd, msg_txt(273));
  951. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  952. {
  953. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  954. continue;
  955. count++;
  956. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  957. //remember not <= bc we need null terminator
  958. if(((CHATBOX_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  959. {
  960. clif_displaymessage(fd,(char*)cz_line_buff);
  961. lpcz_cur = cz_line_buff;
  962. memset(cz_line_buff,' ',CHATBOX_SIZE);
  963. cz_line_buff[CHATBOX_SIZE] = 0;
  964. }
  965. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  966. lpcz_cur += ui_slen+(10-ui_slen%10);
  967. }
  968. clif_displaymessage(fd,(char*)cz_line_buff);
  969. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  970. clif_displaymessage(fd, atcmd_output);
  971. return 0;
  972. }
  973. /*==========================================
  974. * @send (used for testing packet sends from the client)
  975. *------------------------------------------
  976. */
  977. int atcommand_send(const int fd, struct map_session_data* sd, const char* command, const char* message)
  978. {
  979. int len=0,off,end,type;
  980. long num;
  981. (void)command; // not used
  982. // read message type as hex number (without the 0x)
  983. if(!message || !*message ||
  984. !((sscanf(message, "len %x", &type)==1 && (len=1))
  985. || sscanf(message, "%x", &type)==1) )
  986. {
  987. clif_displaymessage(fd, "Usage:");
  988. clif_displaymessage(fd, " @send len <packet hex number>");
  989. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  990. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  991. return -1;
  992. }
  993. #define PARSE_ERROR(error,p) \
  994. {\
  995. clif_displaymessage(fd, (error));\
  996. sprintf(atcmd_output, ">%s", (p));\
  997. clif_displaymessage(fd, atcmd_output);\
  998. }
  999. //define PARSE_ERROR
  1000. #define CHECK_EOS(p) \
  1001. if(*(p) == 0){\
  1002. clif_displaymessage(fd, "Unexpected end of string");\
  1003. return -1;\
  1004. }
  1005. //define CHECK_EOS
  1006. #define SKIP_VALUE(p) \
  1007. {\
  1008. while(*(p) && !isspace(*(p))) ++(p); /* non-space */\
  1009. while(*(p) && isspace(*(p))) ++(p); /* space */\
  1010. }
  1011. //define SKIP_VALUE
  1012. #define GET_VALUE(p,num) \
  1013. {\
  1014. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  1015. PARSE_ERROR("Invalid number in:",(p));\
  1016. return -1;\
  1017. }\
  1018. }
  1019. //define GET_VALUE
  1020. if (type > 0 && type < MAX_PACKET_DB) {
  1021. if(len)
  1022. {// show packet length
  1023. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  1024. clif_displaymessage(fd, atcmd_output);
  1025. return 0;
  1026. }
  1027. len=packet_db[sd->packet_ver][type].len;
  1028. off=2;
  1029. if(len == 0)
  1030. {// unknown packet - ERROR
  1031. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  1032. clif_displaymessage(fd, atcmd_output);
  1033. return -1;
  1034. } else if(len == -1)
  1035. {// dynamic packet
  1036. len=SHRT_MAX-4; // maximum length
  1037. off=4;
  1038. }
  1039. WFIFOHEAD(fd, len);
  1040. WFIFOW(fd,0)=TOW(type);
  1041. // parse packet contents
  1042. SKIP_VALUE(message);
  1043. while(*message != 0 && off < len){
  1044. if(isdigit(*message) || *message == '-' || *message == '+')
  1045. {// default (byte)
  1046. GET_VALUE(message,num);
  1047. WFIFOB(fd,off)=TOB(num);
  1048. ++off;
  1049. } else if(toupper(*message) == 'B')
  1050. {// byte
  1051. ++message;
  1052. GET_VALUE(message,num);
  1053. WFIFOB(fd,off)=TOB(num);
  1054. ++off;
  1055. } else if(toupper(*message) == 'W')
  1056. {// word (2 bytes)
  1057. ++message;
  1058. GET_VALUE(message,num);
  1059. WFIFOW(fd,off)=TOW(num);
  1060. off+=2;
  1061. } else if(toupper(*message) == 'L')
  1062. {// long word (4 bytes)
  1063. ++message;
  1064. GET_VALUE(message,num);
  1065. WFIFOL(fd,off)=TOL(num);
  1066. off+=4;
  1067. } else if(toupper(*message) == 'S')
  1068. {// string - escapes are valid
  1069. // get string length - num <= 0 means not fixed length (default)
  1070. ++message;
  1071. if(*message == '"'){
  1072. num=0;
  1073. } else {
  1074. GET_VALUE(message,num);
  1075. while(*message != '"')
  1076. {// find start of string
  1077. if(*message == 0 || isspace(*message)){
  1078. PARSE_ERROR("Not a string:",message);
  1079. return -1;
  1080. }
  1081. ++message;
  1082. }
  1083. }
  1084. // parse string
  1085. ++message;
  1086. CHECK_EOS(message);
  1087. end=(num<=0? 0: min(off+((int)num),len));
  1088. for(; *message != '"' && (off < end || end == 0); ++off){
  1089. if(*message == '\\'){
  1090. ++message;
  1091. CHECK_EOS(message);
  1092. switch(*message){
  1093. case 'a': num=0x07; break; // Bell
  1094. case 'b': num=0x08; break; // Backspace
  1095. case 't': num=0x09; break; // Horizontal tab
  1096. case 'n': num=0x0A; break; // Line feed
  1097. case 'v': num=0x0B; break; // Vertical tab
  1098. case 'f': num=0x0C; break; // Form feed
  1099. case 'r': num=0x0D; break; // Carriage return
  1100. case 'e': num=0x1B; break; // Escape
  1101. default: num=*message; break;
  1102. case 'x': // Hexadecimal
  1103. {
  1104. ++message;
  1105. CHECK_EOS(message);
  1106. if(!isxdigit(*message)){
  1107. PARSE_ERROR("Not a hexadecimal digit:",message);
  1108. return -1;
  1109. }
  1110. num=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1111. if(isxdigit(*message)){
  1112. ++message;
  1113. CHECK_EOS(message);
  1114. num<<=8;
  1115. num+=(isdigit(*message)?*message-'0':tolower(*message)-'a'+10);
  1116. }
  1117. WFIFOB(fd,off)=TOB(num);
  1118. ++message;
  1119. CHECK_EOS(message);
  1120. continue;
  1121. }
  1122. case '0':
  1123. case '1':
  1124. case '2':
  1125. case '3':
  1126. case '4':
  1127. case '5':
  1128. case '6':
  1129. case '7': // Octal
  1130. {
  1131. num=*message-'0'; // 1st octal digit
  1132. ++message;
  1133. CHECK_EOS(message);
  1134. if(isdigit(*message) && *message < '8'){
  1135. num<<=3;
  1136. num+=*message-'0'; // 2nd octal digit
  1137. ++message;
  1138. CHECK_EOS(message);
  1139. if(isdigit(*message) && *message < '8'){
  1140. num<<=3;
  1141. num+=*message-'0'; // 3rd octal digit
  1142. ++message;
  1143. CHECK_EOS(message);
  1144. }
  1145. }
  1146. WFIFOB(fd,off)=TOB(num);
  1147. continue;
  1148. }
  1149. }
  1150. } else
  1151. num=*message;
  1152. WFIFOB(fd,off)=TOB(num);
  1153. ++message;
  1154. CHECK_EOS(message);
  1155. }//for
  1156. while(*message != '"')
  1157. {// ignore extra characters
  1158. ++message;
  1159. CHECK_EOS(message);
  1160. }
  1161. // terminate the string
  1162. if(off < end)
  1163. {// fill the rest with 0's
  1164. memset(WFIFOP(fd,off),0,end-off);
  1165. off=end;
  1166. }
  1167. } else
  1168. {// unknown
  1169. PARSE_ERROR("Unknown type of value in:",message);
  1170. return -1;
  1171. }
  1172. SKIP_VALUE(message);
  1173. }
  1174. if(packet_db[sd->packet_ver][type].len == -1)
  1175. {// send dynamic packet
  1176. WFIFOW(fd,2)=TOW(off);
  1177. WFIFOSET(fd,off);
  1178. } else
  1179. {// send static packet
  1180. if(off < len)
  1181. memset(WFIFOP(fd,off),0,len-off);
  1182. WFIFOSET(fd,len);
  1183. }
  1184. } else {
  1185. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  1186. return -1;
  1187. }
  1188. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  1189. clif_displaymessage(fd, atcmd_output);
  1190. return 0;
  1191. #undef PARSE_ERROR
  1192. #undef CHECK_EOS
  1193. #undef SKIP_VALUE
  1194. #undef GET_VALUE
  1195. }
  1196. /*==========================================
  1197. * @rura
  1198. *------------------------------------------
  1199. */
  1200. int atcommand_rura( const int fd, struct map_session_data* sd, const char* command, const char* message)
  1201. {
  1202. char map_name[MAP_NAME_LENGTH];
  1203. unsigned short mapindex;
  1204. int x = 0, y = 0;
  1205. int m = -1;
  1206. nullpo_retr(-1, sd);
  1207. memset(map_name, '\0', sizeof(map_name));
  1208. if (!message || !*message ||
  1209. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1210. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1211. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1212. return -1;
  1213. }
  1214. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1215. strcat(map_name, ".gat");
  1216. mapindex = mapindex_name2id(map_name);
  1217. if (mapindex)
  1218. m = map_mapindex2mapid(mapindex);
  1219. if (!mapindex || m < 0) {
  1220. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1221. return -1;
  1222. }
  1223. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  1224. { //This is to prevent the pc_setpos call from printing an error.
  1225. clif_displaymessage(fd, msg_txt(2));
  1226. x = y = 0; //Invalid cell, use random spot.
  1227. }
  1228. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1229. clif_displaymessage(fd, msg_txt(247));
  1230. return -1;
  1231. }
  1232. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1233. clif_displaymessage(fd, msg_txt(248));
  1234. return -1;
  1235. }
  1236. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1237. clif_displaymessage(fd, msg_txt(0)); // Warped.
  1238. else {
  1239. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  1240. return -1;
  1241. }
  1242. return 0;
  1243. }
  1244. /*==========================================
  1245. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1246. *------------------------------------------
  1247. */
  1248. int atcommand_where(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1249. {
  1250. struct map_session_data *pl_sd = NULL;
  1251. int GM_level, pl_GM_level;
  1252. nullpo_retr(-1, sd);
  1253. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1254. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1255. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1256. return -1;
  1257. }
  1258. pl_sd = map_nick2sd(atcmd_player_name);
  1259. if (pl_sd == NULL)
  1260. return -1;
  1261. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1262. return -1;
  1263. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1264. pl_GM_level = pc_isGM(pl_sd);
  1265. if (battle_config.hide_GM_session) {
  1266. if(GM_level < pl_GM_level) {
  1267. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1268. return -1;
  1269. }
  1270. }
  1271. }
  1272. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1273. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1274. clif_displaymessage(fd, atcmd_output);
  1275. return 0;
  1276. }
  1277. /*==========================================
  1278. *
  1279. *------------------------------------------
  1280. */
  1281. int atcommand_jumpto(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1282. {
  1283. struct map_session_data *pl_sd = NULL;
  1284. nullpo_retr(-1, sd);
  1285. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1286. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1287. return -1;
  1288. }
  1289. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1290. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1291. return -1;
  1292. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1293. return -1;
  1294. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1295. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1296. clif_displaymessage(fd, msg_txt(247));
  1297. return -1;
  1298. }
  1299. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1300. clif_displaymessage(fd, msg_txt(248));
  1301. return -1;
  1302. }
  1303. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1304. sprintf(atcmd_output, msg_txt(4), atcmd_player_name); // Jump to %s
  1305. clif_displaymessage(fd, atcmd_output);
  1306. } else {
  1307. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1308. return -1;
  1309. }
  1310. return 0;
  1311. }
  1312. /*==========================================
  1313. *
  1314. *------------------------------------------
  1315. */
  1316. int atcommand_jump(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1317. {
  1318. int x = 0, y = 0;
  1319. nullpo_retr(-1, sd);
  1320. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1321. sscanf(message, "%d %d", &x, &y);
  1322. if (x <= 0) //If coordinates are 'wrong', random jump.
  1323. x = -1;
  1324. if (y <= 0)
  1325. y = -1;
  1326. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarp || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1327. clif_displaymessage(fd, msg_txt(248));
  1328. return -1;
  1329. }
  1330. pc_setpos(sd, sd->mapindex, x, y, 3);
  1331. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jump to %d %d
  1332. clif_displaymessage(fd, atcmd_output);
  1333. return 0;
  1334. }
  1335. /*==========================================
  1336. * @who3 = Player name, his location
  1337. *------------------------------------------
  1338. */
  1339. int atcommand_who3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1340. {
  1341. char temp0[100];
  1342. struct map_session_data *pl_sd, **pl_allsd;
  1343. int i, j, count, users;
  1344. int pl_GM_level, GM_level;
  1345. char match_text[100];
  1346. char player_name[NAME_LENGTH];
  1347. nullpo_retr(-1, sd);
  1348. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1349. memset(match_text, '\0', sizeof(match_text));
  1350. memset(player_name, '\0', sizeof(player_name));
  1351. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1352. strcpy(match_text, "");
  1353. for (j = 0; match_text[j]; j++)
  1354. match_text[j] = tolower(match_text[j]);
  1355. count = 0;
  1356. GM_level = pc_isGM(sd);
  1357. pl_allsd = map_getallusers(&users);
  1358. for (i = 0; i < users; i++) {
  1359. if ((pl_sd = pl_allsd[i])) {
  1360. pl_GM_level = pc_isGM(pl_sd);
  1361. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1362. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1363. for (j = 0; player_name[j]; j++)
  1364. player_name[j] = tolower(player_name[j]);
  1365. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1366. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1367. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1368. } else {
  1369. atcmd_output[0]=0;
  1370. }
  1371. //Player name
  1372. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1373. strcat(atcmd_output,temp0);
  1374. //Player title, if exists
  1375. if (pl_GM_level > 0) {
  1376. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1377. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1378. strcat(atcmd_output,temp0);
  1379. }
  1380. //Players Location: map x y
  1381. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1382. strcat(atcmd_output,temp0);
  1383. clif_displaymessage(fd, atcmd_output);
  1384. count++;
  1385. }
  1386. }
  1387. }
  1388. }
  1389. if (count == 0)
  1390. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1391. else if (count == 1)
  1392. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1393. else {
  1394. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1395. clif_displaymessage(fd, atcmd_output);
  1396. }
  1397. return 0;
  1398. }
  1399. /*==========================================
  1400. * Player name, BLevel, Job,
  1401. *------------------------------------------
  1402. */
  1403. int atcommand_who2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1404. {
  1405. char temp0[100];
  1406. struct map_session_data *pl_sd, **pl_allsd;
  1407. int i, j, count, users;
  1408. int pl_GM_level, GM_level;
  1409. char match_text[100];
  1410. char player_name[NAME_LENGTH];
  1411. nullpo_retr(-1, sd);
  1412. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1413. memset(match_text, '\0', sizeof(match_text));
  1414. memset(player_name, '\0', sizeof(player_name));
  1415. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1416. strcpy(match_text, "");
  1417. for (j = 0; match_text[j]; j++)
  1418. match_text[j] = tolower(match_text[j]);
  1419. count = 0;
  1420. GM_level = pc_isGM(sd);
  1421. pl_allsd = map_getallusers(&users);
  1422. for (i = 0; i < users; i++) {
  1423. if ((pl_sd = pl_allsd[i])) {
  1424. pl_GM_level = pc_isGM(pl_sd);
  1425. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1426. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1427. for (j = 0; player_name[j]; j++)
  1428. player_name[j] = tolower(player_name[j]);
  1429. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1430. //Players Name
  1431. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1432. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1433. //Player title, if exists
  1434. if (pl_GM_level > 0) {
  1435. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1436. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1437. strcat(atcmd_output,temp0);
  1438. }
  1439. //Players Base Level / Job name
  1440. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1441. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1442. strcat(atcmd_output,temp0);
  1443. clif_displaymessage(fd, atcmd_output);
  1444. count++;
  1445. }
  1446. }
  1447. }
  1448. }
  1449. if (count == 0)
  1450. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1451. else if (count == 1)
  1452. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1453. else {
  1454. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1455. clif_displaymessage(fd, atcmd_output);
  1456. }
  1457. return 0;
  1458. }
  1459. /*==========================================
  1460. * Player name, Playrs Party / Guild name
  1461. *------------------------------------------
  1462. */
  1463. int atcommand_who(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1464. {
  1465. char temp0[100];
  1466. struct map_session_data *pl_sd, **pl_allsd;
  1467. int i, j, count, users;
  1468. int pl_GM_level, GM_level;
  1469. char match_text[100];
  1470. char player_name[NAME_LENGTH];
  1471. struct guild *g;
  1472. struct party_data *p;
  1473. nullpo_retr(-1, sd);
  1474. memset(temp0, '\0', sizeof(temp0));
  1475. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1476. memset(match_text, '\0', sizeof(match_text));
  1477. memset(player_name, '\0', sizeof(player_name));
  1478. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1479. strcpy(match_text, "");
  1480. for (j = 0; match_text[j]; j++)
  1481. match_text[j] = tolower(match_text[j]);
  1482. count = 0;
  1483. GM_level = pc_isGM(sd);
  1484. pl_allsd = map_getallusers(&users);
  1485. for (i = 0; i < users; i++) {
  1486. if ((pl_sd = pl_allsd[i])) {
  1487. pl_GM_level = pc_isGM(pl_sd);
  1488. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1489. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1490. for (j = 0; player_name[j]; j++)
  1491. player_name[j] = tolower(player_name[j]);
  1492. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1493. g = guild_search(pl_sd->status.guild_id);
  1494. p = party_search(pl_sd->status.party_id);
  1495. //Players Name
  1496. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1497. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1498. //Player title, if exists
  1499. if (pl_GM_level > 0) {
  1500. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1501. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1502. strcat(atcmd_output,temp0);
  1503. }
  1504. //Players Party if exists
  1505. if (p != NULL) {
  1506. //sprintf(temp0," | Party: '%s'", p->name);
  1507. sprintf(temp0, msg_txt(335), p->party.name);
  1508. strcat(atcmd_output,temp0);
  1509. }
  1510. //Players Guild if exists
  1511. if (g != NULL) {
  1512. //sprintf(temp0," | Guild: '%s'", g->name);
  1513. sprintf(temp0, msg_txt(336), g->name);
  1514. strcat(atcmd_output,temp0);
  1515. }
  1516. clif_displaymessage(fd, atcmd_output);
  1517. count++;
  1518. }
  1519. }
  1520. }
  1521. }
  1522. if (count == 0)
  1523. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1524. else if (count == 1)
  1525. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1526. else {
  1527. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1528. clif_displaymessage(fd, atcmd_output);
  1529. }
  1530. return 0;
  1531. }
  1532. /*==========================================
  1533. *
  1534. *------------------------------------------
  1535. */
  1536. int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1537. {
  1538. struct map_session_data *pl_sd, **pl_allsd;
  1539. int i, count, users;
  1540. int pl_GM_level, GM_level;
  1541. int map_id;
  1542. char map_name[MAP_NAME_LENGTH];
  1543. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1544. memset(map_name, '\0', sizeof(map_name));
  1545. if (!message || !*message)
  1546. map_id = sd->bl.m;
  1547. else {
  1548. sscanf(message, "%15s", map_name);
  1549. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1550. strcat(map_name, ".gat");
  1551. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1552. map_id = sd->bl.m;
  1553. }
  1554. count = 0;
  1555. GM_level = pc_isGM(sd);
  1556. pl_allsd = map_getallusers(&users);
  1557. for (i = 0; i < users; i++) {
  1558. if ((pl_sd = pl_allsd[i])) {
  1559. pl_GM_level = pc_isGM(pl_sd);
  1560. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1561. if (pl_sd->bl.m == map_id) {
  1562. if (pl_GM_level > 0)
  1563. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1564. else
  1565. sprintf(atcmd_output, "Name: %s | Location: %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1566. clif_displaymessage(fd, atcmd_output);
  1567. count++;
  1568. }
  1569. }
  1570. }
  1571. }
  1572. if (count == 0)
  1573. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1574. else if (count == 1)
  1575. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1576. else {
  1577. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1578. }
  1579. clif_displaymessage(fd, atcmd_output);
  1580. return 0;
  1581. }
  1582. /*==========================================
  1583. *
  1584. *------------------------------------------
  1585. */
  1586. int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1587. {
  1588. struct map_session_data *pl_sd, **pl_allsd;
  1589. int i, count, users;
  1590. int pl_GM_level, GM_level;
  1591. int map_id = 0;
  1592. char map_name[MAP_NAME_LENGTH];
  1593. nullpo_retr(-1, sd);
  1594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1595. memset(map_name, '\0', sizeof(map_name));
  1596. if (!message || !*message)
  1597. map_id = sd->bl.m;
  1598. else {
  1599. sscanf(message, "%15s", map_name);
  1600. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1601. strcat(map_name, ".gat");
  1602. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1603. map_id = sd->bl.m;
  1604. }
  1605. count = 0;
  1606. GM_level = pc_isGM(sd);
  1607. pl_allsd = map_getallusers(&users);
  1608. for (i = 0; i < users; i++) {
  1609. if ((pl_sd = pl_allsd[i])) {
  1610. pl_GM_level = pc_isGM(pl_sd);
  1611. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1612. if (pl_sd->bl.m == map_id) {
  1613. if (pl_GM_level > 0)
  1614. sprintf(atcmd_output, "Name: %s (GM:%d) | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_GM_level, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1615. else
  1616. sprintf(atcmd_output, "Name: %s | BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.name, pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1617. clif_displaymessage(fd, atcmd_output);
  1618. count++;
  1619. }
  1620. }
  1621. }
  1622. }
  1623. if (count == 0)
  1624. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1625. else if (count == 1)
  1626. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1627. else {
  1628. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1629. }
  1630. clif_displaymessage(fd, atcmd_output);
  1631. return 0;
  1632. }
  1633. /*==========================================
  1634. *
  1635. *------------------------------------------
  1636. */
  1637. int atcommand_whomap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1638. {
  1639. char temp0[100];
  1640. char temp1[100];
  1641. struct map_session_data *pl_sd, **pl_allsd;
  1642. int i, count, users;
  1643. int pl_GM_level, GM_level;
  1644. int map_id = 0;
  1645. char map_name[MAP_NAME_LENGTH];
  1646. struct guild *g;
  1647. struct party_data *p;
  1648. nullpo_retr(-1, sd);
  1649. memset(temp0, '\0', sizeof(temp0));
  1650. memset(temp1, '\0', sizeof(temp1));
  1651. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1652. memset(map_name, '\0', sizeof(map_name));
  1653. if (!message || !*message)
  1654. map_id = sd->bl.m;
  1655. else {
  1656. sscanf(message, "%15s", map_name);
  1657. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1658. strcat(map_name, ".gat");
  1659. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1660. map_id = sd->bl.m;
  1661. }
  1662. count = 0;
  1663. GM_level = pc_isGM(sd);
  1664. pl_allsd = map_getallusers(&users);
  1665. for (i = 0; i < users; i++) {
  1666. if ((pl_sd = pl_allsd[i])) {
  1667. pl_GM_level = pc_isGM(pl_sd);
  1668. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1669. if (pl_sd->bl.m == map_id) {
  1670. g = guild_search(pl_sd->status.guild_id);
  1671. if (g == NULL)
  1672. sprintf(temp1, "None");
  1673. else
  1674. sprintf(temp1, "%s", g->name);
  1675. p = party_search(pl_sd->status.party_id);
  1676. if (p == NULL)
  1677. sprintf(temp0, "None");
  1678. else
  1679. sprintf(temp0, "%s", p->party.name);
  1680. if (pl_GM_level > 0)
  1681. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1682. else
  1683. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1684. clif_displaymessage(fd, atcmd_output);
  1685. count++;
  1686. }
  1687. }
  1688. }
  1689. }
  1690. if (count == 0)
  1691. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1692. else if (count == 1)
  1693. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1694. else {
  1695. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1696. }
  1697. clif_displaymessage(fd, atcmd_output);
  1698. return 0;
  1699. }
  1700. /*==========================================
  1701. *
  1702. *------------------------------------------
  1703. */
  1704. int atcommand_whogm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1705. {
  1706. char temp0[100];
  1707. char temp1[100];
  1708. struct map_session_data *pl_sd, **pl_allsd;
  1709. int i, j, count, users;
  1710. int pl_GM_level, GM_level;
  1711. char match_text[100];
  1712. char player_name[NAME_LENGTH];
  1713. struct guild *g;
  1714. struct party_data *p;
  1715. nullpo_retr(-1, sd);
  1716. memset(temp0, '\0', sizeof(temp0));
  1717. memset(temp1, '\0', sizeof(temp1));
  1718. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1719. memset(match_text, '\0', sizeof(match_text));
  1720. memset(player_name, '\0', sizeof(player_name));
  1721. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1722. strcpy(match_text, "");
  1723. for (j = 0; match_text[j]; j++)
  1724. match_text[j] = tolower(match_text[j]);
  1725. count = 0;
  1726. GM_level = pc_isGM(sd);
  1727. pl_allsd = map_getallusers(&users);
  1728. for (i = 0; i < users; i++) {
  1729. if ((pl_sd = pl_allsd[i])) {
  1730. pl_GM_level = pc_isGM(pl_sd);
  1731. if (pl_GM_level > 0) {
  1732. if (!((battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level))) { // you can look only lower or same level
  1733. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1734. for (j = 0; player_name[j]; j++)
  1735. player_name[j] = tolower(player_name[j]);
  1736. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1737. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d", pl_sd->status.name, pl_GM_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1738. clif_displaymessage(fd, atcmd_output);
  1739. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)", pl_sd->status.base_level, job_name(pl_sd->status.class_), pl_sd->status.job_level);
  1740. clif_displaymessage(fd, atcmd_output);
  1741. g = guild_search(pl_sd->status.guild_id);
  1742. if (g == NULL)
  1743. sprintf(temp1, "None");
  1744. else
  1745. sprintf(temp1, "%s", g->name);
  1746. p = party_search(pl_sd->status.party_id);
  1747. if (p == NULL)
  1748. sprintf(temp0, "None");
  1749. else
  1750. sprintf(temp0, "%s", p->party.name);
  1751. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1752. clif_displaymessage(fd, atcmd_output);
  1753. count++;
  1754. }
  1755. }
  1756. }
  1757. }
  1758. }
  1759. if (count == 0)
  1760. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  1761. else if (count == 1)
  1762. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  1763. else {
  1764. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  1765. clif_displaymessage(fd, atcmd_output);
  1766. }
  1767. return 0;
  1768. }
  1769. int atcommand_whozeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1770. {
  1771. struct map_session_data *pl_sd, **pl_allsd;
  1772. int i, j, count,c, users;
  1773. char match_text[100];
  1774. char player_name[NAME_LENGTH];
  1775. int *zeny;
  1776. int *counted;
  1777. nullpo_retr(-1, sd);
  1778. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1779. memset(match_text, '\0', sizeof(match_text));
  1780. memset(player_name, '\0', sizeof(player_name));
  1781. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1782. strcpy(match_text, "");
  1783. for (j = 0; match_text[j]; j++)
  1784. match_text[j] = tolower(match_text[j]);
  1785. count = 0;
  1786. pl_allsd = map_getallusers(&users);
  1787. if (users < 1)
  1788. {
  1789. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1790. return 0;
  1791. }
  1792. zeny = (int *)aMallocA(users*sizeof(int));
  1793. counted = (int *)aMallocA(users*sizeof(int));
  1794. for (i = 0; i < users; i++) {
  1795. if ((pl_sd = pl_allsd[i])) {
  1796. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1797. for (j = 0; player_name[j]; j++)
  1798. player_name[j] = tolower(player_name[j]);
  1799. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1800. zeny[count]=pl_sd->status.zeny;
  1801. counted[i]=0;
  1802. count++;
  1803. }
  1804. }
  1805. }
  1806. qsort(zeny, count, sizeof(int), hightolow_compare);
  1807. for (c = 0; c < count && c < 50; c++) {
  1808. if(!zeny[c])
  1809. continue;
  1810. for (i = 0; i < users; i++) {
  1811. if(!zeny[c])
  1812. continue;
  1813. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1814. if(pl_sd->status.zeny==zeny[c]) {
  1815. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1816. clif_displaymessage(fd, atcmd_output);
  1817. zeny[c]=0;
  1818. counted[i]=1;
  1819. }
  1820. }
  1821. }
  1822. }
  1823. if (count == 0)
  1824. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1825. else if (count == 1)
  1826. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1827. else {
  1828. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1829. clif_displaymessage(fd, atcmd_output);
  1830. }
  1831. aFree(zeny);
  1832. aFree(counted);
  1833. return 0;
  1834. }
  1835. /*==========================================
  1836. *
  1837. *------------------------------------------
  1838. */
  1839. int atcommand_save(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1840. {
  1841. nullpo_retr(-1, sd);
  1842. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1843. if (sd->status.pet_id > 0 && sd->pd)
  1844. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  1845. chrif_save(sd,0);
  1846. clif_displaymessage(fd, msg_txt(6)); // Character data respawn point saved.
  1847. return 0;
  1848. }
  1849. /*==========================================
  1850. *
  1851. *------------------------------------------
  1852. */
  1853. int atcommand_load(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1854. {
  1855. int m;
  1856. nullpo_retr(-1, sd);
  1857. m = map_mapindex2mapid(sd->status.save_point.map);
  1858. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1859. clif_displaymessage(fd, msg_txt(249));
  1860. return -1;
  1861. }
  1862. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1863. clif_displaymessage(fd, msg_txt(248));
  1864. return -1;
  1865. }
  1866. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1867. clif_displaymessage(fd, msg_txt(7)); // Warping to respawn point.
  1868. return 0;
  1869. }
  1870. /*==========================================
  1871. *
  1872. *------------------------------------------
  1873. */
  1874. int atcommand_speed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1875. {
  1876. int speed;
  1877. nullpo_retr(-1, sd);
  1878. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1879. if (!message || !*message) {
  1880. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1881. clif_displaymessage(fd, atcmd_output);
  1882. return -1;
  1883. }
  1884. speed = atoi(message);
  1885. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1886. sd->base_status.speed = speed;
  1887. status_calc_bl(&sd->bl, SCB_SPEED);
  1888. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1889. } else {
  1890. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1891. clif_displaymessage(fd, atcmd_output);
  1892. return -1;
  1893. }
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. *
  1898. *------------------------------------------
  1899. */
  1900. int atcommand_charspeed(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1901. {
  1902. struct map_session_data *pl_sd;
  1903. int speed;
  1904. nullpo_retr(-1, sd);
  1905. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1906. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1907. if (!message || !*message || sscanf(message, "%d %23[^\n]", &speed, atcmd_player_name) < 2) {
  1908. sprintf(atcmd_output, "Please, enter a speed and a player name (usage: @charspeed <speed <%d-%d>> <char name>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1909. clif_displaymessage(fd, atcmd_output);
  1910. return -1;
  1911. }
  1912. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  1913. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1914. return -1;
  1915. }
  1916. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1917. { //GM level check
  1918. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1919. return -1;
  1920. }
  1921. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1922. pl_sd->base_status.speed = speed;
  1923. status_calc_bl(&pl_sd->bl, SCB_SPEED);
  1924. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  1925. if(pl_sd->fd)
  1926. clif_displaymessage(pl_sd->fd, msg_txt(8)); // Speed changed.
  1927. } else {
  1928. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1929. clif_displaymessage(fd, atcmd_output);
  1930. return -1;
  1931. }
  1932. return 0;
  1933. }
  1934. /*==========================================
  1935. *
  1936. *------------------------------------------
  1937. */
  1938. int atcommand_storage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1939. {
  1940. nullpo_retr(-1, sd);
  1941. if (storage_storageopen(sd) == 1)
  1942. { //Already open.
  1943. clif_displaymessage(fd, msg_txt(250));
  1944. return -1;
  1945. }
  1946. return 0;
  1947. }
  1948. /*==========================================
  1949. *
  1950. *------------------------------------------
  1951. */
  1952. int atcommand_guildstorage(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1953. {
  1954. struct storage *stor; //changes from Freya/Yor
  1955. nullpo_retr(-1, sd);
  1956. if (sd->status.guild_id > 0) {
  1957. if (sd->state.storage_flag) {
  1958. clif_displaymessage(fd, msg_txt(251));
  1959. return -1;
  1960. }
  1961. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1962. clif_displaymessage(fd, msg_txt(251));
  1963. return -1;
  1964. }
  1965. storage_guild_storageopen(sd);
  1966. } else {
  1967. clif_displaymessage(fd, msg_txt(252));
  1968. return -1;
  1969. }
  1970. return 0;
  1971. }
  1972. /*==========================================
  1973. *
  1974. *------------------------------------------
  1975. */
  1976. int atcommand_option(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1977. {
  1978. int param1 = 0, param2 = 0, param3 = 0;
  1979. nullpo_retr(-1, sd);
  1980. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1981. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1982. return -1;
  1983. }
  1984. sd->sc.opt1 = param1;
  1985. sd->sc.opt2 = param2;
  1986. pc_setoption(sd, param3);
  1987. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1988. return 0;
  1989. }
  1990. /*==========================================
  1991. *
  1992. *------------------------------------------
  1993. */
  1994. int atcommand_hide(const int fd, struct map_session_data* sd, const char* command, const char* message)
  1995. {
  1996. nullpo_retr(-1, sd);
  1997. if (sd->sc.option & OPTION_INVISIBLE) {
  1998. sd->sc.option &= ~OPTION_INVISIBLE;
  1999. if (sd->disguise)
  2000. status_set_viewdata(&sd->bl, sd->disguise);
  2001. else
  2002. status_set_viewdata(&sd->bl, sd->status.class_);
  2003. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  2004. } else {
  2005. sd->sc.option |= OPTION_INVISIBLE;
  2006. sd->vd.class_ = INVISIBLE_CLASS;
  2007. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  2008. }
  2009. clif_changeoption(&sd->bl);
  2010. return 0;
  2011. }
  2012. /*==========================================
  2013. * Changes a character's class
  2014. *------------------------------------------
  2015. */
  2016. int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2017. {
  2018. int job = 0, upper = 0;
  2019. nullpo_retr(-1, sd);
  2020. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  2021. int i, found = 0;
  2022. const struct { char name[16]; int id; } jobs[] = {
  2023. { "novice", 0 },
  2024. { "swordsman", 1 },
  2025. { "mage", 2 },
  2026. { "archer", 3 },
  2027. { "acolyte", 4 },
  2028. { "merchant", 5 },
  2029. { "thief", 6 },
  2030. { "knight", 7 },
  2031. { "priest", 8 },
  2032. { "priestess", 8 },
  2033. { "wizard", 9 },
  2034. { "blacksmith", 10 },
  2035. { "hunter", 11 },
  2036. { "assassin", 12 },
  2037. { "crusader", 14 },
  2038. { "monk", 15 },
  2039. { "sage", 16 },
  2040. { "rogue", 17 },
  2041. { "alchemist", 18 },
  2042. { "bard", 19 },
  2043. { "dancer", 20 },
  2044. { "super novice", 23 },
  2045. { "supernovice", 23 },
  2046. { "gunslinger", 24 },
  2047. { "gunner", 24 },
  2048. { "ninja", 25 },
  2049. { "high novice", 4001 },
  2050. { "swordsman high", 4002 },
  2051. { "mage high", 4003 },
  2052. { "archer high", 4004 },
  2053. { "acolyte high", 4005 },
  2054. { "merchant high", 4006 },
  2055. { "thief high", 4007 },
  2056. { "lord knight", 4008 },
  2057. { "high priest", 4009 },
  2058. { "high priestess", 4009 },
  2059. { "high wizard", 4010 },
  2060. { "whitesmith", 4011 },
  2061. { "sniper", 4012 },
  2062. { "assassin cross", 4013 },
  2063. { "paladin", 4015 },
  2064. { "champion", 4016 },
  2065. { "professor", 4017 },
  2066. { "stalker", 4018 },
  2067. { "creator", 4019 },
  2068. { "clown", 4020 },
  2069. { "gypsy", 4021 },
  2070. { "baby novice", 4023 },
  2071. { "baby swordsman", 4024 },
  2072. { "baby mage", 4025 },
  2073. { "baby archer", 4026 },
  2074. { "baby acolyte", 4027 },
  2075. { "baby merchant", 4028 },
  2076. { "baby thief", 4029 },
  2077. { "baby knight", 4030 },
  2078. { "baby priest", 4031 },
  2079. { "baby priestess", 4031 },
  2080. { "baby wizard", 4032 },
  2081. { "baby blacksmith",4033 },
  2082. { "baby hunter", 4034 },
  2083. { "baby assassin", 4035 },
  2084. { "baby crusader", 4037 },
  2085. { "baby monk", 4038 },
  2086. { "baby sage", 4039 },
  2087. { "baby rogue", 4040 },
  2088. { "baby alchemist", 4041 },
  2089. { "baby bard", 4042 },
  2090. { "baby dancer", 4043 },
  2091. { "super baby", 4045 },
  2092. { "taekwon", 4046 },
  2093. { "taekwon boy", 4046 },
  2094. { "taekwon girl", 4046 },
  2095. { "star gladiator", 4047 },
  2096. { "soul linker", 4049 },
  2097. };
  2098. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2099. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2100. job = jobs[i].id;
  2101. upper = 0;
  2102. found = 1;
  2103. break;
  2104. }
  2105. }
  2106. if (!found) {
  2107. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2108. return -1;
  2109. }
  2110. }
  2111. if (job == 37 ||job == 45)
  2112. return 0;
  2113. if ((job >= 0 && job < MAX_PC_CLASS))
  2114. {
  2115. int j;
  2116. for (j=0; j < MAX_INVENTORY; j++) {
  2117. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2118. pc_unequipitem(sd, j, 3);
  2119. }
  2120. if (pc_jobchange(sd, job, upper) == 0)
  2121. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  2122. else {
  2123. clif_displaymessage(fd, msg_txt(155)); // Impossible to change your job.
  2124. return -1;
  2125. }
  2126. } else {
  2127. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2128. return -1;
  2129. }
  2130. return 0;
  2131. }
  2132. /*==========================================
  2133. *
  2134. *------------------------------------------
  2135. */
  2136. int atcommand_die(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2137. {
  2138. nullpo_retr(-1, sd);
  2139. clif_specialeffect(&sd->bl,450,SELF);
  2140. status_kill(&sd->bl);
  2141. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  2142. return 0;
  2143. }
  2144. /*==========================================
  2145. *
  2146. *------------------------------------------
  2147. */
  2148. int atcommand_kill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2149. {
  2150. struct map_session_data *pl_sd;
  2151. nullpo_retr(-1, sd);
  2152. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2153. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2154. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2155. return -1;
  2156. }
  2157. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2158. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2159. status_kill(&pl_sd->bl);
  2160. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  2161. } else {
  2162. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  2163. return -1;
  2164. }
  2165. } else {
  2166. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2167. return -1;
  2168. }
  2169. return 0;
  2170. }
  2171. /*==========================================
  2172. *
  2173. *------------------------------------------
  2174. */
  2175. int atcommand_alive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2176. {
  2177. nullpo_retr(-1, sd);
  2178. if (!status_revive(&sd->bl, 100, 100))
  2179. return -1;
  2180. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2181. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  2182. return 0;
  2183. }
  2184. /*==========================================
  2185. * +kamic [LuzZza]
  2186. *------------------------------------------
  2187. */
  2188. int atcommand_kami(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2189. {
  2190. unsigned long color=0;
  2191. nullpo_retr(-1, sd);
  2192. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2193. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2194. if (!message || !*message) {
  2195. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2196. return -1;
  2197. }
  2198. sscanf(message, "%199[^\n]", atcmd_output);
  2199. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2200. } else {
  2201. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2202. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2203. return -1;
  2204. }
  2205. if(color > 0xFFFFFF) {
  2206. clif_displaymessage(fd, "Invalid color.");
  2207. return -1;
  2208. }
  2209. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2210. }
  2211. return 0;
  2212. }
  2213. /*==========================================
  2214. *
  2215. *------------------------------------------
  2216. */
  2217. int atcommand_heal(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2218. {
  2219. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2220. nullpo_retr(-1, sd);
  2221. sscanf(message, "%d %d", &hp, &sp);
  2222. if (hp == 0 && sp == 0) {
  2223. if (!status_percent_heal(&sd->bl, 100, 100))
  2224. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2225. else
  2226. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2227. return 0;
  2228. }
  2229. if(hp > 0 && sp >= 0) {
  2230. if(!status_heal(&sd->bl, hp, sp, 0))
  2231. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  2232. else
  2233. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  2234. return 0;
  2235. }
  2236. if(hp < 0 && sp <= 0) {
  2237. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2238. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2239. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2240. return 0;
  2241. }
  2242. //Opposing signs.
  2243. if (hp) {
  2244. if (hp > 0)
  2245. status_heal(&sd->bl, hp, 0, 0);
  2246. else {
  2247. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2248. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2249. }
  2250. }
  2251. if (sp) {
  2252. if (sp > 0)
  2253. status_heal(&sd->bl, 0, sp, 0);
  2254. else
  2255. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2256. }
  2257. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  2258. return 0;
  2259. }
  2260. /*==========================================
  2261. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2262. *------------------------------------------
  2263. */
  2264. int atcommand_item(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2265. {
  2266. char item_name[100];
  2267. int number = 0, item_id, flag;
  2268. struct item item_tmp;
  2269. struct item_data *item_data;
  2270. int get_count, i;
  2271. nullpo_retr(-1, sd);
  2272. memset(item_name, '\0', sizeof(item_name));
  2273. if (!message || !*message || (
  2274. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  2275. sscanf(message, "%99s %d", item_name, &number) < 1
  2276. )) {
  2277. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2278. return -1;
  2279. }
  2280. if (number <= 0)
  2281. number = 1;
  2282. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2283. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2284. {
  2285. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2286. return -1;
  2287. }
  2288. item_id = item_data->nameid;
  2289. get_count = number;
  2290. //Check if it's stackable.
  2291. if (!itemdb_isstackable2(item_data))
  2292. get_count = 1;
  2293. for (i = 0; i < number; i += get_count) {
  2294. // if not pet egg
  2295. if (!pet_create_egg(sd, item_id)) {
  2296. memset(&item_tmp, 0, sizeof(item_tmp));
  2297. item_tmp.nameid = item_id;
  2298. item_tmp.identify = 1;
  2299. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2300. clif_additem(sd, 0, 0, flag);
  2301. }
  2302. }
  2303. //Logs (A)dmins items [Lupus]
  2304. if(log_config.enable_logs&0x400)
  2305. log_pick_pc(sd, "A", item_id, number, NULL);
  2306. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2307. return 0;
  2308. }
  2309. /*==========================================
  2310. *
  2311. *------------------------------------------
  2312. */
  2313. int atcommand_item2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2314. {
  2315. struct item item_tmp;
  2316. struct item_data *item_data;
  2317. char item_name[100];
  2318. int item_id, number = 0;
  2319. int identify = 0, refine = 0, attr = 0;
  2320. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2321. int flag;
  2322. int loop, get_count, i;
  2323. nullpo_retr(-1, sd);
  2324. memset(item_name, '\0', sizeof(item_name));
  2325. if (!message || !*message || (
  2326. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  2327. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  2328. )) {
  2329. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2330. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2331. return -1;
  2332. }
  2333. if (number <= 0)
  2334. number = 1;
  2335. item_id = 0;
  2336. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2337. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2338. item_id = item_data->nameid;
  2339. if (item_id > 500) {
  2340. loop = 1;
  2341. get_count = number;
  2342. if (item_data->type == 4 || item_data->type == 5 ||
  2343. item_data->type == 7 || item_data->type == 8) {
  2344. loop = number;
  2345. get_count = 1;
  2346. if (item_data->type == 7) {
  2347. identify = 1;
  2348. refine = 0;
  2349. }
  2350. if (item_data->type == 8)
  2351. refine = 0;
  2352. if (refine > 10)
  2353. refine = 10;
  2354. } else {
  2355. identify = 1;
  2356. refine = attr = 0;
  2357. }
  2358. for (i = 0; i < loop; i++) {
  2359. memset(&item_tmp, 0, sizeof(item_tmp));
  2360. item_tmp.nameid = item_id;
  2361. item_tmp.identify = identify;
  2362. item_tmp.refine = refine;
  2363. item_tmp.attribute = attr;
  2364. item_tmp.card[0] = c1;
  2365. item_tmp.card[1] = c2;
  2366. item_tmp.card[2] = c3;
  2367. item_tmp.card[3] = c4;
  2368. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2369. clif_additem(sd, 0, 0, flag);
  2370. }
  2371. //Logs (A)dmins items [Lupus]
  2372. if(log_config.enable_logs&0x400)
  2373. log_pick_pc(sd, "A", item_tmp.nameid, number, &item_tmp);
  2374. clif_displaymessage(fd, msg_txt(18)); // Item created.
  2375. } else {
  2376. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  2377. return -1;
  2378. }
  2379. return 0;
  2380. }
  2381. /*==========================================
  2382. *
  2383. *------------------------------------------
  2384. */
  2385. int atcommand_itemreset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2386. {
  2387. int i;
  2388. nullpo_retr(-1, sd);
  2389. for (i = 0; i < MAX_INVENTORY; i++) {
  2390. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2391. //Logs (A)dmins items [Lupus]
  2392. if(log_config.enable_logs&0x400)
  2393. log_pick_pc(sd, "A", sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2394. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2395. }
  2396. }
  2397. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. * Atcommand @lvlup
  2402. *------------------------------------------
  2403. */
  2404. int atcommand_baselevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2405. {
  2406. int level=0, i=0, status_point=0;
  2407. nullpo_retr(-1, sd);
  2408. level = atoi(message);
  2409. if (!message || !*message || !level) {
  2410. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2411. return -1;
  2412. }
  2413. if (level > 0) {
  2414. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2415. clif_displaymessage(fd, msg_txt(47)); /* Base level can't go any higher. */
  2416. return -1;
  2417. } /* End Addition */
  2418. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2419. level = pc_maxbaselv(sd) - sd->status.base_level;
  2420. for (i = 1; i <= level; i++)
  2421. status_point += (sd->status.base_level + i + 14) / 5;
  2422. if (sd->status.status_point > USHRT_MAX - status_point)
  2423. sd->status.status_point = USHRT_MAX;
  2424. else
  2425. sd->status.status_point += status_point;
  2426. sd->status.base_level += (unsigned int)level;
  2427. clif_updatestatus(sd, SP_BASELEVEL);
  2428. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2429. clif_updatestatus(sd, SP_STATUSPOINT);
  2430. status_calc_pc(sd, 0);
  2431. status_percent_heal(&sd->bl, 100, 100);
  2432. clif_misceffect(&sd->bl, 0);
  2433. clif_displaymessage(fd, msg_txt(21)); /* Base level raised. */
  2434. } else {
  2435. if (sd->status.base_level == 1) {
  2436. clif_displaymessage(fd, msg_txt(158)); /* Base level can't go any lower. */
  2437. return -1;
  2438. }
  2439. level*=-1;
  2440. if ((unsigned int)level >= sd->status.base_level)
  2441. level = sd->status.base_level-1;
  2442. for (i = 0; i > -level; i--)
  2443. status_point += (sd->status.base_level + i + 14) / 5;
  2444. if (sd->status.status_point < status_point)
  2445. pc_resetstate(sd);
  2446. if (sd->status.status_point < status_point)
  2447. sd->status.status_point = 0;
  2448. else
  2449. sd->status.status_point -= status_point;
  2450. clif_updatestatus(sd, SP_STATUSPOINT);
  2451. sd->status.base_level -= (unsigned int)level;
  2452. clif_updatestatus(sd, SP_BASELEVEL);
  2453. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2454. status_calc_pc(sd, 0);
  2455. clif_displaymessage(fd, msg_txt(22)); /* Base level lowered. */
  2456. }
  2457. return 0;
  2458. }
  2459. /*==========================================
  2460. *
  2461. *------------------------------------------
  2462. */
  2463. int atcommand_joblevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2464. {
  2465. int level=0;
  2466. nullpo_retr(-1, sd);
  2467. level = atoi(message);
  2468. if (!message || !*message || !level) {
  2469. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2470. return -1;
  2471. }
  2472. if (level > 0) {
  2473. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2474. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  2475. return -1;
  2476. }
  2477. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2478. level = pc_maxjoblv(sd) - sd->status.job_level;
  2479. sd->status.job_level += (unsigned int)level;
  2480. clif_updatestatus(sd, SP_JOBLEVEL);
  2481. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2482. if (sd->status.skill_point > USHRT_MAX - level)
  2483. sd->status.skill_point = USHRT_MAX;
  2484. else
  2485. sd->status.skill_point += level;
  2486. clif_updatestatus(sd, SP_SKILLPOINT);
  2487. status_calc_pc(sd, 0);
  2488. clif_misceffect(&sd->bl, 1);
  2489. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  2490. } else {
  2491. if (sd->status.job_level == 1) {
  2492. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  2493. return -1;
  2494. }
  2495. level *=-1;
  2496. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2497. level = sd->status.job_level-1;
  2498. sd->status.job_level -= (unsigned int)level;
  2499. clif_updatestatus(sd, SP_JOBLEVEL);
  2500. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2501. if (sd->status.skill_point < level)
  2502. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2503. if (sd->status.skill_point < level)
  2504. sd->status.skill_point = 0;
  2505. else
  2506. sd->status.skill_point -= level;
  2507. clif_updatestatus(sd, SP_SKILLPOINT);
  2508. status_calc_pc(sd, 0);
  2509. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  2510. }
  2511. return 0;
  2512. }
  2513. /*==========================================
  2514. * @help
  2515. *------------------------------------------
  2516. */
  2517. int atcommand_help(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2518. {
  2519. char buf[2048], w1[2048], w2[2048];
  2520. int i, gm_level;
  2521. FILE* fp;
  2522. nullpo_retr(-1, sd);
  2523. memset(buf, '\0', sizeof(buf));
  2524. if ((fp = fopen(help_txt, "r")) != NULL) {
  2525. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2526. gm_level = pc_isGM(sd);
  2527. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2528. if (buf[0] == '/' && buf[1] == '/')
  2529. continue;
  2530. for (i = 0; buf[i] != '\0'; i++) {
  2531. if (buf[i] == '\r' || buf[i] == '\n') {
  2532. buf[i] = '\0';
  2533. break;
  2534. }
  2535. }
  2536. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2537. clif_displaymessage(fd, buf);
  2538. else if (gm_level >= atoi(w1))
  2539. clif_displaymessage(fd, w2);
  2540. }
  2541. fclose(fp);
  2542. } else {
  2543. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2544. return -1;
  2545. }
  2546. return 0;
  2547. }
  2548. /*==========================================
  2549. * @help2 - Char commands [Kayla]
  2550. *------------------------------------------
  2551. */
  2552. int atcommand_help2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2553. {
  2554. char buf[2048], w1[2048], w2[2048];
  2555. int i, gm_level;
  2556. FILE* fp;
  2557. nullpo_retr(-1, sd);
  2558. memset(buf, '\0', sizeof(buf));
  2559. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2560. clif_displaymessage(fd, msg_txt(26)); /* Help commands: */
  2561. gm_level = pc_isGM(sd);
  2562. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2563. if (buf[0] == '/' && buf[1] == '/')
  2564. continue;
  2565. for (i = 0; buf[i] != '\0'; i++) {
  2566. if (buf[i] == '\r' || buf[i] == '\n') {
  2567. buf[i] = '\0';
  2568. break;
  2569. }
  2570. }
  2571. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2572. clif_displaymessage(fd, buf);
  2573. else if (gm_level >= atoi(w1))
  2574. clif_displaymessage(fd, w2);
  2575. }
  2576. fclose(fp);
  2577. } else {
  2578. clif_displaymessage(fd, msg_txt(27)); /* File help.txt not found. */
  2579. return -1;
  2580. }
  2581. return 0;
  2582. }
  2583. /*==========================================
  2584. * @gm
  2585. *------------------------------------------
  2586. */
  2587. int atcommand_gm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2588. {
  2589. char password[100];
  2590. nullpo_retr(-1, sd);
  2591. memset(password, '\0', sizeof(password));
  2592. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2593. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2594. return -1;
  2595. }
  2596. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2597. clif_displaymessage(fd, msg_txt(50)); /* You already have some GM powers. */
  2598. return -1;
  2599. } else
  2600. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2601. return 0;
  2602. }
  2603. /*==========================================
  2604. *
  2605. *------------------------------------------
  2606. */
  2607. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) {
  2608. TBL_PC* sd = (TBL_PC*)bl;
  2609. clif_pvpset(sd, 0, 0, 2);
  2610. if (sd->pvp_timer != UINT_MAX) {
  2611. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  2612. sd->pvp_timer = UINT_MAX;
  2613. }
  2614. return 0;
  2615. }
  2616. int atcommand_pvpoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2617. {
  2618. nullpo_retr(-1, sd);
  2619. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2620. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2621. return -1;
  2622. }
  2623. if (!map[sd->bl.m].flag.pvp) {
  2624. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  2625. return -1;
  2626. }
  2627. map[sd->bl.m].flag.pvp = 0;
  2628. clif_send0199(sd->bl.m, 0);
  2629. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  2630. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  2631. return 0;
  2632. }
  2633. /*==========================================
  2634. *
  2635. *------------------------------------------
  2636. */
  2637. int atcommand_pvpon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2638. {
  2639. struct map_session_data *pl_sd, **pl_allsd;
  2640. int i, users;
  2641. nullpo_retr(-1, sd);
  2642. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2643. clif_displaymessage(fd, msg_txt(52)); // This option cannot be used in PK Mode.
  2644. return -1;
  2645. }
  2646. if (!map[sd->bl.m].flag.pvp) {
  2647. map[sd->bl.m].flag.pvp = 1;
  2648. clif_send0199(sd->bl.m, 1);
  2649. pl_allsd = map_getallusers(&users);
  2650. for (i = 0; i < users; i++) {
  2651. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2652. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2653. pl_sd->pvp_rank = 0;
  2654. pl_sd->pvp_lastusers = 0;
  2655. pl_sd->pvp_point = 5;
  2656. pl_sd->pvp_won = 0;
  2657. pl_sd->pvp_lost = 0;
  2658. }
  2659. }
  2660. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  2661. } else {
  2662. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  2663. return -1;
  2664. }
  2665. return 0;
  2666. }
  2667. /*==========================================
  2668. *
  2669. *------------------------------------------
  2670. */
  2671. int atcommand_gvgoff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2672. {
  2673. nullpo_retr(-1, sd);
  2674. if (map[sd->bl.m].flag.gvg) {
  2675. map[sd->bl.m].flag.gvg = 0;
  2676. clif_send0199(sd->bl.m, 0);
  2677. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  2678. } else {
  2679. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  2680. return -1;
  2681. }
  2682. return 0;
  2683. }
  2684. /*==========================================
  2685. *
  2686. *------------------------------------------
  2687. */
  2688. int atcommand_gvgon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2689. {
  2690. nullpo_retr(-1, sd);
  2691. if (!map[sd->bl.m].flag.gvg) {
  2692. map[sd->bl.m].flag.gvg = 1;
  2693. clif_send0199(sd->bl.m, 3);
  2694. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  2695. } else {
  2696. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  2697. return -1;
  2698. }
  2699. return 0;
  2700. }
  2701. /*==========================================
  2702. *
  2703. *------------------------------------------
  2704. */
  2705. int atcommand_model(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2706. {
  2707. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2708. nullpo_retr(-1, sd);
  2709. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2710. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2711. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2712. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2713. clif_displaymessage(fd, atcmd_output);
  2714. return -1;
  2715. }
  2716. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2717. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2718. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2719. /* Removed because this check is TOO strange. [Skotlex]
  2720. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2721. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2722. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2723. return -1;
  2724. } else {
  2725. */
  2726. pc_changelook(sd, LOOK_HAIR, hair_style);
  2727. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2728. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2729. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2730. // }
  2731. } else {
  2732. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2733. return -1;
  2734. }
  2735. return 0;
  2736. }
  2737. /*==========================================
  2738. * @dye && @ccolor
  2739. *------------------------------------------
  2740. */
  2741. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2742. {
  2743. int cloth_color = 0;
  2744. nullpo_retr(-1, sd);
  2745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2746. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2747. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2748. clif_displaymessage(fd, atcmd_output);
  2749. return -1;
  2750. }
  2751. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2752. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2753. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2754. } else {
  2755. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2756. return -1;
  2757. }
  2758. return 0;
  2759. }
  2760. /*==========================================
  2761. * @hairstyle && @hstyle
  2762. *------------------------------------------
  2763. */
  2764. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2765. {
  2766. int hair_style = 0;
  2767. nullpo_retr(-1, sd);
  2768. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2769. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2770. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2771. clif_displaymessage(fd, atcmd_output);
  2772. return -1;
  2773. }
  2774. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2775. /* Removed because this check is TOO strange. [Skotlex]
  2776. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2777. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2778. return -1;
  2779. } else {
  2780. */
  2781. pc_changelook(sd, LOOK_HAIR, hair_style);
  2782. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2783. // }
  2784. } else {
  2785. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2786. return -1;
  2787. }
  2788. return 0;
  2789. }
  2790. /*==========================================
  2791. * @haircolor && @hcolor
  2792. *------------------------------------------
  2793. */
  2794. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2795. {
  2796. int hair_color = 0;
  2797. nullpo_retr(-1, sd);
  2798. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2799. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2800. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2801. clif_displaymessage(fd, atcmd_output);
  2802. return -1;
  2803. }
  2804. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2805. /* Removed for being such a strange check. [Skotlex]
  2806. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2807. clif_displaymessage(fd, msg_txt(35)); // You can't use this command with this class.
  2808. return -1;
  2809. } else {
  2810. */
  2811. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2812. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  2813. // }
  2814. } else {
  2815. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2816. return -1;
  2817. }
  2818. return 0;
  2819. }
  2820. /*==========================================
  2821. * @go [city_number or city_name] - Updated by Harbin
  2822. *------------------------------------------
  2823. */
  2824. int atcommand_go(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2825. {
  2826. int i;
  2827. int town;
  2828. char map_name[MAP_NAME_LENGTH];
  2829. int m;
  2830. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2831. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2832. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2833. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2834. { MAP_PAYON, 162, 233 }, // 3=Payon
  2835. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2836. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2837. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2838. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2839. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2840. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2841. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2842. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2843. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2844. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2845. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2846. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  2847. { MAP_JAIL, 23, 61 }, // 16=Prison
  2848. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2849. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2850. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2851. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2852. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2853. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2854. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2855. { MAP_VEINS, 216, 123 }, // 24=Veins
  2856. };
  2857. nullpo_retr(-1, sd);
  2858. if(map[sd->bl.m].flag.nogo) {
  2859. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2860. return 0;
  2861. }
  2862. memset(map_name, '\0', sizeof(map_name));
  2863. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2864. // get the number
  2865. town = atoi(message);
  2866. // if no value, display all value
  2867. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2868. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2869. clif_displaymessage(fd, msg_txt(82)); // Please, use one of this number/name:
  2870. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2871. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2872. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2873. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2874. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2875. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2876. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2877. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2878. clif_displaymessage(fd, " 24=Veins");
  2879. return -1;
  2880. } else {
  2881. // get possible name of the city and add .gat if not in the name
  2882. map_name[MAP_NAME_LENGTH-1] = '\0';
  2883. for (i = 0; map_name[i]; i++)
  2884. map_name[i] = tolower(map_name[i]);
  2885. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2886. strcat(map_name, ".gat");
  2887. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2888. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2889. town = 0;
  2890. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2891. town = 1;
  2892. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2893. town = 2;
  2894. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2895. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2896. town = 3;
  2897. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2898. town = 4;
  2899. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2900. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2901. town = 5;
  2902. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2903. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2904. town = 6;
  2905. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2906. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2907. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2908. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2909. town = 7;
  2910. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2911. town = 8;
  2912. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2913. town = 9;
  2914. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2915. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2916. town = 10;
  2917. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2918. town = 11;
  2919. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2920. town = 12;
  2921. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2922. town = 13;
  2923. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2924. town = 14;
  2925. } else if (strncmp(map_name, "new_zone01.gat", 3) == 0 || // 3 first characters (or "newbies")
  2926. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2927. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2928. town = 15;
  2929. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2930. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2931. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2932. town = 16;
  2933. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2934. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2935. town = 17;
  2936. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2937. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2938. town = 18;
  2939. } else if (strncmp(map_name, "einbroch.gat", 5) == 0 || // 5 first characters
  2940. strncmp(map_name, "ainbroch.gat", 5) == 0) { // writing error (5 first characters)
  2941. town = 19;
  2942. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2943. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2944. town = 20;
  2945. } else if (strncmp(map_name, "einbech.gat", 3) == 0) { // 3 first characters
  2946. town = 21;
  2947. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2948. town = 22;
  2949. } else if (strncmp(map_name, "rachel.gat", 3) == 0) { // 3 first characters
  2950. town = 23;
  2951. } else if (strncmp(map_name, "veins.gat", 3) == 0) { // 3 first characters
  2952. town = 24;
  2953. }
  2954. if (town >= -3 && town <= -1) {
  2955. if (sd->status.memo_point[-town-1].map) {
  2956. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2957. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2958. clif_displaymessage(fd, msg_txt(247));
  2959. return -1;
  2960. }
  2961. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2962. clif_displaymessage(fd, msg_txt(248));
  2963. return -1;
  2964. }
  2965. 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) {
  2966. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2967. } else {
  2968. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2969. return -1;
  2970. }
  2971. } else {
  2972. sprintf(atcmd_output, msg_txt(164), -town-1); // Your memo point #%d doesn't exist.
  2973. clif_displaymessage(fd, atcmd_output);
  2974. return -1;
  2975. }
  2976. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2977. m = map_mapname2mapid((char *)data[town].map);
  2978. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2979. clif_displaymessage(fd, msg_txt(247));
  2980. return -1;
  2981. }
  2982. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2983. clif_displaymessage(fd, msg_txt(248));
  2984. return -1;
  2985. }
  2986. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2987. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2988. } else {
  2989. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2990. return -1;
  2991. }
  2992. } else { // if you arrive here, you have an error in town variable when reading of names
  2993. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2994. return -1;
  2995. }
  2996. }
  2997. return 0;
  2998. }
  2999. /*==========================================
  3000. *
  3001. *------------------------------------------
  3002. */
  3003. int atcommand_monster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3004. {
  3005. char name[NAME_LENGTH];
  3006. char monster[NAME_LENGTH];
  3007. int mob_id;
  3008. int number = 0;
  3009. int count;
  3010. int i, k, range;
  3011. short mx, my;
  3012. nullpo_retr(-1, sd);
  3013. memset(name, '\0', sizeof(name));
  3014. memset(monster, '\0', sizeof(monster));
  3015. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3016. if (!message || !*message) {
  3017. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3018. return -1;
  3019. }
  3020. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3021. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3022. //All data can be left as it is.
  3023. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3024. //Here, it is possible name was not given and we are using monster for it.
  3025. if (count < 3) //Blank mob's name.
  3026. name[0] = '\0';
  3027. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3028. //All data can be left as it is.
  3029. } else if (sscanf(message, "%23s", monster) > 0) {
  3030. //As before, name may be already filled.
  3031. name[0] = '\0';
  3032. } else {
  3033. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  3034. return -1;
  3035. }
  3036. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3037. mob_id = mobdb_checkid(atoi(monster));
  3038. if (mob_id == 0) {
  3039. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3040. return -1;
  3041. }
  3042. if (mob_id == MOBID_EMPERIUM) {
  3043. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium.
  3044. return -1;
  3045. }
  3046. if (number <= 0)
  3047. number = 1;
  3048. if (strlen(name) < 1)
  3049. strcpy(name, "--ja--");
  3050. // 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
  3051. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3052. number = battle_config.atc_spawn_quantity_limit;
  3053. if (battle_config.etc_log)
  3054. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  3055. count = 0;
  3056. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3057. for (i = 0; i < number; i++) {
  3058. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3059. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3060. count += (k != 0) ? 1 : 0;
  3061. }
  3062. if (count != 0)
  3063. if (number == count)
  3064. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  3065. else {
  3066. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  3067. clif_displaymessage(fd, atcmd_output);
  3068. }
  3069. else {
  3070. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  3071. return -1;
  3072. }
  3073. return 0;
  3074. }
  3075. // small monster spawning [Valaris]
  3076. int atcommand_monstersmall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3077. {
  3078. char name[NAME_LENGTH] = "";
  3079. char monster[NAME_LENGTH] = "";
  3080. int mob_id = 0;
  3081. int number = 0;
  3082. int x = 0;
  3083. int y = 0;
  3084. int count;
  3085. int i;
  3086. nullpo_retr(-1, sd);
  3087. if (!message || !*message) {
  3088. clif_displaymessage(fd, "Give a monster name/id please.");
  3089. return -1;
  3090. }
  3091. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3092. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3093. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3094. clif_displaymessage(fd, "Give a monster name/id please.");
  3095. return -1;
  3096. }
  3097. // If monster identifier/name argument is a name
  3098. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3099. mob_id = atoi(monster);
  3100. if (mob_id == 0) {
  3101. clif_displaymessage(fd, msg_txt(40));
  3102. return -1;
  3103. }
  3104. if (mob_id == MOBID_EMPERIUM) {
  3105. clif_displaymessage(fd, msg_txt(83));
  3106. return -1;
  3107. }
  3108. if (mobdb_checkid(mob_id) == 0) {
  3109. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3110. return -1;
  3111. }
  3112. if (number <= 0)
  3113. number = 1;
  3114. if (strlen(name) < 1)
  3115. strcpy(name, "--ja--");
  3116. // 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
  3117. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3118. number = battle_config.atc_spawn_quantity_limit;
  3119. count = 0;
  3120. for (i = 0; i < number; i++) {
  3121. int mx, my;
  3122. if (x <= 0)
  3123. mx = sd->bl.x + (rand() % 11 - 5);
  3124. else
  3125. mx = x;
  3126. if (y <= 0)
  3127. my = sd->bl.y + (rand() % 11 - 5);
  3128. else
  3129. my = y;
  3130. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3131. }
  3132. if (count != 0)
  3133. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3134. else
  3135. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3136. return 0;
  3137. }
  3138. // big monster spawning [Valaris]
  3139. int atcommand_monsterbig(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3140. {
  3141. char name[NAME_LENGTH] = "";
  3142. char monster[NAME_LENGTH] = "";
  3143. int mob_id = 0;
  3144. int number = 0;
  3145. int x = 0;
  3146. int y = 0;
  3147. int count;
  3148. int i;
  3149. nullpo_retr(-1, sd);
  3150. if (!message || !*message) {
  3151. clif_displaymessage(fd, "Give a monster name/id please.");
  3152. return -1;
  3153. }
  3154. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3155. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3156. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3157. clif_displaymessage(fd, "Give a monster name/id please.");
  3158. return -1;
  3159. }
  3160. // If monster identifier/name argument is a name
  3161. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3162. mob_id = atoi(monster);
  3163. if (mob_id == 0) {
  3164. clif_displaymessage(fd, msg_txt(40));
  3165. return -1;
  3166. }
  3167. if (mob_id == MOBID_EMPERIUM) {
  3168. clif_displaymessage(fd, msg_txt(83));
  3169. return -1;
  3170. }
  3171. if (mobdb_checkid(mob_id) == 0) {
  3172. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3173. return -1;
  3174. }
  3175. if (number <= 0)
  3176. number = 1;
  3177. if (strlen(name) < 1)
  3178. strcpy(name, "--ja--");
  3179. // 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
  3180. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3181. number = battle_config.atc_spawn_quantity_limit;
  3182. count = 0;
  3183. for (i = 0; i < number; i++) {
  3184. int mx, my;
  3185. if (x <= 0)
  3186. mx = sd->bl.x + (rand() % 11 - 5);
  3187. else
  3188. mx = x;
  3189. if (y <= 0)
  3190. my = sd->bl.y + (rand() % 11 - 5);
  3191. else
  3192. my = y;
  3193. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3194. }
  3195. if (count != 0)
  3196. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  3197. else
  3198. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  3199. return 0;
  3200. }
  3201. /*==========================================
  3202. *
  3203. *------------------------------------------
  3204. */
  3205. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  3206. {
  3207. struct mob_data *md;
  3208. int flag;
  3209. nullpo_retr(0, ap);
  3210. nullpo_retr(0, md=(struct mob_data *)bl);
  3211. flag = va_arg(ap, int);
  3212. if (md->guardian_data)
  3213. return 0; //Do not touch WoE mobs!
  3214. if (flag)
  3215. status_zap(bl,md->status.hp, 0);
  3216. else
  3217. status_kill(bl);
  3218. return 1;
  3219. }
  3220. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  3221. {
  3222. int map_id;
  3223. char map_name[MAP_NAME_LENGTH];
  3224. if (!sd) return;
  3225. memset(map_name, '\0', sizeof(map_name));
  3226. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3227. map_id = sd->bl.m;
  3228. else {
  3229. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3230. strcat(map_name, ".gat");
  3231. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3232. map_id = sd->bl.m;
  3233. }
  3234. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3235. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  3236. return;
  3237. }
  3238. int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3239. {
  3240. if (!sd) return 0;
  3241. atcommand_killmonster_sub(fd, sd, message, 1);
  3242. return 0;
  3243. }
  3244. /*==========================================
  3245. *
  3246. *------------------------------------------
  3247. */
  3248. int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3249. {
  3250. if (!sd) return 0;
  3251. atcommand_killmonster_sub(fd, sd, message, 0);
  3252. return 0;
  3253. }
  3254. /*==========================================
  3255. *
  3256. *------------------------------------------
  3257. */
  3258. int atcommand_refine(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3259. {
  3260. int i,j, position = 0, refine = 0, current_position, final_refine;
  3261. int count;
  3262. nullpo_retr(-1, sd);
  3263. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3264. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3265. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3266. return -1;
  3267. }
  3268. if (refine < -MAX_REFINE)
  3269. refine = -MAX_REFINE;
  3270. else if (refine > MAX_REFINE)
  3271. refine = MAX_REFINE;
  3272. else if (refine == 0)
  3273. refine = 1;
  3274. count = 0;
  3275. for (j = 0; j < EQI_MAX-1; j++) {
  3276. if ((i = sd->equip_index[j]) < 0)
  3277. continue;
  3278. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  3279. continue;
  3280. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  3281. continue;
  3282. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  3283. continue;
  3284. if(position && !(sd->status.inventory[i].equip & position))
  3285. continue;
  3286. final_refine = sd->status.inventory[i].refine + refine;
  3287. if (final_refine > MAX_REFINE)
  3288. final_refine = MAX_REFINE;
  3289. else if (final_refine < 0)
  3290. final_refine = 0;
  3291. if (sd->status.inventory[i].refine != final_refine) {
  3292. sd->status.inventory[i].refine = final_refine;
  3293. current_position = sd->status.inventory[i].equip;
  3294. pc_unequipitem(sd, i, 3);
  3295. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3296. clif_delitem(sd, i, 1);
  3297. clif_additem(sd, i, 1, 0);
  3298. pc_equipitem(sd, i, current_position);
  3299. clif_misceffect(&sd->bl, 3);
  3300. count++;
  3301. }
  3302. }
  3303. if (count == 0)
  3304. clif_displaymessage(fd, msg_txt(166)); // No item has been refined!
  3305. else if (count == 1)
  3306. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined!
  3307. else {
  3308. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined!
  3309. clif_displaymessage(fd, atcmd_output);
  3310. }
  3311. return 0;
  3312. }
  3313. /*==========================================
  3314. *
  3315. *------------------------------------------
  3316. */
  3317. int atcommand_produce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3318. {
  3319. char item_name[100];
  3320. int item_id, attribute = 0, star = 0;
  3321. int flag = 0;
  3322. struct item_data *item_data;
  3323. struct item tmp_item;
  3324. nullpo_retr(-1, sd);
  3325. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3326. memset(item_name, '\0', sizeof(item_name));
  3327. if (!message || !*message || (
  3328. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  3329. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  3330. )) {
  3331. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3332. return -1;
  3333. }
  3334. item_id = 0;
  3335. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  3336. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  3337. {
  3338. sprintf(atcmd_output, msg_txt(170)); // This item is not an equipment.
  3339. clif_displaymessage(fd, atcmd_output);
  3340. return -1;
  3341. }
  3342. item_id = item_data->nameid;
  3343. if (itemdb_isequip2(item_data)) {
  3344. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3345. attribute = ATTRIBUTE_NORMAL;
  3346. if (star < MIN_STAR || star > MAX_STAR)
  3347. star = 0;
  3348. memset(&tmp_item, 0, sizeof tmp_item);
  3349. tmp_item.nameid = item_id;
  3350. tmp_item.amount = 1;
  3351. tmp_item.identify = 1;
  3352. tmp_item.card[0] = CARD0_FORGE;
  3353. tmp_item.card[1] = item_data->type==IT_WEAPON?
  3354. ((star*5) << 8) + attribute:0;
  3355. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  3356. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  3357. clif_produceeffect(sd, 0, item_id);
  3358. clif_misceffect(&sd->bl, 3);
  3359. //Logs (A)dmins items [Lupus]
  3360. if(log_config.enable_logs&0x400)
  3361. log_pick_pc(sd, "A", tmp_item.nameid, 1, &tmp_item);
  3362. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3363. clif_additem(sd, 0, 0, flag);
  3364. } else {
  3365. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3366. clif_displaymessage(fd, atcmd_output);
  3367. return -1;
  3368. }
  3369. return 0;
  3370. }
  3371. /*==========================================
  3372. * Sub-function to display actual memo points
  3373. *------------------------------------------
  3374. */
  3375. void atcommand_memo_sub(struct map_session_data* sd)
  3376. {
  3377. int i;
  3378. if (!sd) return;
  3379. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3380. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3381. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3382. if (sd->status.memo_point[i].map)
  3383. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  3384. else
  3385. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  3386. clif_displaymessage(sd->fd, atcmd_output);
  3387. }
  3388. return;
  3389. }
  3390. int atcommand_memo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3391. {
  3392. int position = 0;
  3393. nullpo_retr(-1, sd);
  3394. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3395. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3396. atcommand_memo_sub(sd);
  3397. else {
  3398. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3399. if (sd->bl.m >= 0 && (map[sd->bl.m].flag.nowarpto || map[sd->bl.m].flag.nomemo) && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3400. clif_displaymessage(fd, msg_txt(253));
  3401. return -1;
  3402. }
  3403. if (sd->status.memo_point[position].map) {
  3404. sprintf(atcmd_output, msg_txt(172), position, mapindex_id2name(sd->status.memo_point[position].map), sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d).
  3405. clif_displaymessage(fd, atcmd_output);
  3406. }
  3407. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3408. sd->status.memo_point[position].x = sd->bl.x;
  3409. sd->status.memo_point[position].y = sd->bl.y;
  3410. clif_skill_memo(sd, 0);
  3411. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3412. clif_displaymessage(fd, msg_txt(173)); // Note: you don't have the 'Warp' skill level to use it.
  3413. atcommand_memo_sub(sd);
  3414. } else {
  3415. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3416. clif_displaymessage(fd, atcmd_output);
  3417. atcommand_memo_sub(sd);
  3418. return -1;
  3419. }
  3420. }
  3421. return 0;
  3422. }
  3423. /*==========================================
  3424. *
  3425. *------------------------------------------
  3426. */
  3427. int atcommand_gat(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3428. {
  3429. int y;
  3430. nullpo_retr(-1, sd);
  3431. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3432. for (y = 2; y >= -2; y--) {
  3433. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3434. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3435. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3436. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3437. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3438. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3439. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3440. clif_displaymessage(fd, atcmd_output);
  3441. }
  3442. return 0;
  3443. }
  3444. /*==========================================
  3445. *
  3446. *------------------------------------------
  3447. */
  3448. int atcommand_packet(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3449. {
  3450. static int packet_mode = 0;
  3451. int i, x = 0, y = 0;
  3452. nullpo_retr(-1, sd);
  3453. if (strstr(command, "packetmode")) {
  3454. packet_mode = atoi(message);
  3455. clif_displaymessage(fd, "Packet mode changed.");
  3456. return 0;
  3457. }
  3458. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3459. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3460. return -1;
  3461. }
  3462. if (i == 1) y = 1;
  3463. switch (packet_mode)
  3464. {
  3465. case 0:
  3466. clif_status_change(&sd->bl, x, y);
  3467. break;
  3468. case 1:
  3469. sd->status.skill[sd->cloneskill_id].id=0;
  3470. sd->status.skill[sd->cloneskill_id].lv=0;
  3471. sd->status.skill[sd->cloneskill_id].flag=0;
  3472. sd->cloneskill_id = x;
  3473. sd->status.skill[x].id = x;
  3474. sd->status.skill[x].lv = skill_get_max(x);
  3475. sd->status.skill[x].flag = 13;//cloneskill flag
  3476. clif_skillinfoblock(sd);
  3477. break;
  3478. case 2:
  3479. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3480. case 3:
  3481. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3482. default:
  3483. break;
  3484. //added later
  3485. }
  3486. return 0;
  3487. }
  3488. /*==========================================
  3489. * @waterlevel [Skotlex]
  3490. *------------------------------------------
  3491. */
  3492. int atcommand_waterlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3493. {
  3494. int newlevel;
  3495. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3496. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3497. clif_displaymessage(fd, atcmd_output);
  3498. return 0;
  3499. }
  3500. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3501. if (newlevel > 0)
  3502. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3503. else
  3504. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3505. clif_displaymessage(fd, atcmd_output);
  3506. } else {
  3507. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3508. clif_displaymessage(fd, atcmd_output);
  3509. }
  3510. return 0;
  3511. }
  3512. /*==========================================
  3513. * @stpoint (Rewritten by [Yor])
  3514. *------------------------------------------
  3515. */
  3516. int atcommand_statuspoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3517. {
  3518. int point, new_status_point;
  3519. if (!message || !*message || (point = atoi(message)) == 0) {
  3520. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3521. return -1;
  3522. }
  3523. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3524. new_status_point = USHRT_MAX;
  3525. else
  3526. if (point < 0 && sd->status.status_point < -point)
  3527. new_status_point = 0;
  3528. else
  3529. new_status_point = sd->status.status_point + point;
  3530. if (new_status_point != (int)sd->status.status_point) {
  3531. sd->status.status_point = (unsigned short)new_status_point;
  3532. clif_updatestatus(sd, SP_STATUSPOINT);
  3533. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed!
  3534. } else {
  3535. if (point < 0)
  3536. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3537. else
  3538. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3539. return -1;
  3540. }
  3541. return 0;
  3542. }
  3543. /*==========================================
  3544. * @skpoint (Rewritten by [Yor])
  3545. *------------------------------------------
  3546. */
  3547. int atcommand_skillpoint(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3548. {
  3549. int point, new_skill_point;
  3550. nullpo_retr(-1, sd);
  3551. if (!message || !*message || (point = atoi(message)) == 0) {
  3552. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3553. return -1;
  3554. }
  3555. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3556. new_skill_point = USHRT_MAX;
  3557. else if (point < 0 && sd->status.skill_point < -point)
  3558. new_skill_point = 0;
  3559. else
  3560. new_skill_point = sd->status.skill_point + point;
  3561. if (new_skill_point != (int)sd->status.skill_point) {
  3562. sd->status.skill_point = (unsigned short)new_skill_point;
  3563. clif_updatestatus(sd, SP_SKILLPOINT);
  3564. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed!
  3565. } else {
  3566. if (point < 0)
  3567. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3568. else
  3569. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3570. return -1;
  3571. }
  3572. return 0;
  3573. }
  3574. /*==========================================
  3575. * @zeny (Rewritten by [Yor])
  3576. *------------------------------------------
  3577. */
  3578. int atcommand_zeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3579. {
  3580. int zeny, new_zeny;
  3581. nullpo_retr(-1, sd);
  3582. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3583. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3584. return -1;
  3585. }
  3586. new_zeny = sd->status.zeny + zeny;
  3587. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3588. new_zeny = MAX_ZENY;
  3589. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3590. new_zeny = 0;
  3591. if (new_zeny != sd->status.zeny) {
  3592. sd->status.zeny = new_zeny;
  3593. clif_updatestatus(sd, SP_ZENY);
  3594. clif_displaymessage(fd, msg_txt(176)); // Number of zenys changed!
  3595. } else {
  3596. if (zeny < 0)
  3597. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3598. else
  3599. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3600. return -1;
  3601. }
  3602. return 0;
  3603. }
  3604. /*==========================================
  3605. *
  3606. *------------------------------------------
  3607. */
  3608. int atcommand_param(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3609. {
  3610. int i, value = 0, new_value, max;
  3611. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3612. short* status[6];
  3613. //we don't use direct initialization because it isn't part of the c standard.
  3614. nullpo_retr(-1, sd);
  3615. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3616. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3617. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3618. clif_displaymessage(fd, atcmd_output);
  3619. return -1;
  3620. }
  3621. for (i = 0; param[i] != NULL; i++)
  3622. if (strcmpi(command, param[i]) == 0)
  3623. break;
  3624. if (param[i] == NULL || i > MAX_STATUS_TYPE) { // normally impossible...
  3625. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3626. clif_displaymessage(fd, atcmd_output);
  3627. return -1;
  3628. }
  3629. status[0] = &sd->status.str;
  3630. status[1] = &sd->status.agi;
  3631. status[2] = &sd->status.vit;
  3632. status[3] = &sd->status.int_;
  3633. status[4] = &sd->status.dex;
  3634. status[5] = &sd->status.luk;
  3635. max = pc_maxparameter(sd);
  3636. new_value = cap_value(*status[i] + value, 1, max);
  3637. if (new_value != (int)*status[i]) {
  3638. *status[i] = new_value;
  3639. clif_updatestatus(sd, SP_STR + i);
  3640. clif_updatestatus(sd, SP_USTR + i);
  3641. status_calc_pc(sd, 0);
  3642. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  3643. } else {
  3644. if (value < 0)
  3645. clif_displaymessage(fd, msg_txt(41)); // Impossible to decrease the number/value.
  3646. else
  3647. clif_displaymessage(fd, msg_txt(149)); // Impossible to increase the number/value.
  3648. return -1;
  3649. }
  3650. return 0;
  3651. }
  3652. /*==========================================
  3653. * Stat all by fritz (rewritten by [Yor])
  3654. *------------------------------------------
  3655. */
  3656. int atcommand_stat_all(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3657. {
  3658. int index, count, value = 0, max, new_value;
  3659. short* status[6];
  3660. //we don't use direct initialization because it isn't part of the c standard.
  3661. nullpo_retr(-1, sd);
  3662. status[0] = &sd->status.str;
  3663. status[1] = &sd->status.agi;
  3664. status[2] = &sd->status.vit;
  3665. status[3] = &sd->status.int_;
  3666. status[4] = &sd->status.dex;
  3667. status[5] = &sd->status.luk;
  3668. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3669. value = pc_maxparameter(sd);
  3670. count = 0;
  3671. max = pc_maxparameter(sd);
  3672. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3673. if (value > 0 && *status[index] > max - value)
  3674. new_value = max;
  3675. else if (value < 0 && *status[index] <= -value)
  3676. new_value = 1;
  3677. else
  3678. new_value = *status[index] +value;
  3679. if (new_value != (int)*status[index]) {
  3680. *status[index] = new_value;
  3681. clif_updatestatus(sd, SP_STR + index);
  3682. clif_updatestatus(sd, SP_USTR + index);
  3683. count++;
  3684. }
  3685. }
  3686. if (count > 0) { // if at least 1 stat modified
  3687. status_calc_pc(sd, 0);
  3688. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  3689. } else {
  3690. if (value < 0)
  3691. clif_displaymessage(fd, msg_txt(177)); // Impossible to decrease a stat.
  3692. else
  3693. clif_displaymessage(fd, msg_txt(178)); // Impossible to increase a stat.
  3694. return -1;
  3695. }
  3696. return 0;
  3697. }
  3698. /*==========================================
  3699. *
  3700. *------------------------------------------
  3701. */
  3702. int atcommand_guildlevelup(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3703. {
  3704. int level = 0;
  3705. short added_level;
  3706. struct guild *guild_info;
  3707. nullpo_retr(-1, sd);
  3708. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3709. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3710. return -1;
  3711. }
  3712. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3713. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  3714. return -1;
  3715. }
  3716. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3717. clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  3718. return -1;
  3719. }
  3720. added_level = (short)level;
  3721. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3722. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3723. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3724. added_level = 1 - guild_info->guild_lv;
  3725. if (added_level != 0) {
  3726. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3727. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  3728. } else {
  3729. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  3730. return -1;
  3731. }
  3732. return 0;
  3733. }
  3734. /*==========================================
  3735. *
  3736. *------------------------------------------
  3737. */
  3738. int atcommand_makeegg(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3739. {
  3740. struct item_data *item_data;
  3741. int id, pet_id;
  3742. nullpo_retr(-1, sd);
  3743. if (!message || !*message) {
  3744. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3745. return -1;
  3746. }
  3747. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3748. id = item_data->nameid;
  3749. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3750. id = atoi(message);
  3751. pet_id = search_petDB_index(id, PET_CLASS);
  3752. if (pet_id < 0)
  3753. pet_id = search_petDB_index(id, PET_EGG);
  3754. if (pet_id >= 0) {
  3755. sd->catch_target_class = pet_db[pet_id].class_;
  3756. intif_create_pet(
  3757. sd->status.account_id, sd->status.char_id,
  3758. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3759. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3760. 100, 0, 1, pet_db[pet_id].jname);
  3761. } else {
  3762. clif_displaymessage(fd, msg_txt(180)); // The monter/egg name/id doesn't exist.
  3763. return -1;
  3764. }
  3765. return 0;
  3766. }
  3767. /*==========================================
  3768. *
  3769. *------------------------------------------
  3770. */
  3771. int atcommand_hatch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3772. {
  3773. nullpo_retr(-1, sd);
  3774. if (sd->status.pet_id <= 0)
  3775. clif_sendegg(sd);
  3776. else {
  3777. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  3778. return -1;
  3779. }
  3780. return 0;
  3781. }
  3782. /*==========================================
  3783. *
  3784. *------------------------------------------
  3785. */
  3786. int atcommand_petfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3787. {
  3788. int friendly;
  3789. struct pet_data *pd;
  3790. nullpo_retr(-1, sd);
  3791. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3792. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3793. return -1;
  3794. }
  3795. pd = sd->pd;
  3796. if (!pd) {
  3797. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3798. return -1;
  3799. }
  3800. if (friendly < 0 || friendly > 1000)
  3801. {
  3802. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3803. return -1;
  3804. }
  3805. if (friendly == pd->pet.intimate) {
  3806. clif_displaymessage(fd, msg_txt(183)); // Pet friendly is already the good value.
  3807. return -1;
  3808. }
  3809. pd->pet.intimate = friendly;
  3810. clif_send_petstatus(sd);
  3811. clif_displaymessage(fd, msg_txt(182)); // Pet friendly value changed!
  3812. return 0;
  3813. }
  3814. /*==========================================
  3815. *
  3816. *------------------------------------------
  3817. */
  3818. int atcommand_pethungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3819. {
  3820. int hungry;
  3821. struct pet_data *pd;
  3822. nullpo_retr(-1, sd);
  3823. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3824. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3825. return -1;
  3826. }
  3827. pd = sd->pd;
  3828. if (!sd->status.pet_id || !pd) {
  3829. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3830. return -1;
  3831. }
  3832. if (hungry < 0 || hungry > 100) {
  3833. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  3834. return -1;
  3835. }
  3836. if (hungry == pd->pet.hungry) {
  3837. clif_displaymessage(fd, msg_txt(186)); // Pet hungry is already the good value.
  3838. return -1;
  3839. }
  3840. pd->pet.hungry = hungry;
  3841. clif_send_petstatus(sd);
  3842. clif_displaymessage(fd, msg_txt(185)); // Pet hungry value changed!
  3843. return 0;
  3844. }
  3845. /*==========================================
  3846. *
  3847. *------------------------------------------
  3848. */
  3849. int atcommand_petrename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3850. {
  3851. struct pet_data *pd;
  3852. nullpo_retr(-1, sd);
  3853. if (!sd->status.pet_id || !sd->pd) {
  3854. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  3855. return -1;
  3856. }
  3857. pd = sd->pd;
  3858. if (!pd->pet.rename_flag) {
  3859. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  3860. return -1;
  3861. }
  3862. pd->pet.rename_flag = 0;
  3863. intif_save_petdata(sd->status.account_id, &pd->pet);
  3864. clif_send_petstatus(sd);
  3865. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  3866. return 0;
  3867. }
  3868. /*==========================================
  3869. *
  3870. *------------------------------------------
  3871. */
  3872. int atcommand_recall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3873. {
  3874. struct map_session_data *pl_sd = NULL;
  3875. nullpo_retr(-1, sd);
  3876. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3877. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3878. return -1;
  3879. }
  3880. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3881. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3882. return -1;
  3883. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3884. return -1;
  3885. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3886. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3887. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3888. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3889. return -1;
  3890. }
  3891. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3892. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3893. return -1;
  3894. }
  3895. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3896. sprintf(atcmd_output, msg_txt(46), atcmd_player_name); // %s recalled!
  3897. clif_displaymessage(fd, atcmd_output);
  3898. } else {
  3899. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3900. return -1;
  3901. }
  3902. } else {
  3903. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3904. return -1;
  3905. }
  3906. return 0;
  3907. }
  3908. /*==========================================
  3909. *
  3910. *------------------------------------------
  3911. */
  3912. int atcommand_revive(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3913. {
  3914. struct map_session_data *pl_sd;
  3915. nullpo_retr(-1, sd);
  3916. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3917. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3918. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3919. return -1;
  3920. }
  3921. pl_sd = map_nick2sd(atcmd_player_name);
  3922. if (!pl_sd) {
  3923. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3924. return -1;
  3925. }
  3926. if (!status_revive(&pl_sd->bl, 100, 0))
  3927. return -1;
  3928. clif_skill_nodamage(&sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  3929. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  3930. return 0;
  3931. }
  3932. /*==========================================
  3933. * charblock command (usage: charblock <player_name>)
  3934. * This command do a definitiv ban on a player
  3935. *------------------------------------------
  3936. */
  3937. int atcommand_char_block(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3938. {
  3939. nullpo_retr(-1, sd);
  3940. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3941. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  3942. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3943. return -1;
  3944. }
  3945. // check player name
  3946. if (strlen(atcmd_player_name) < 4) {
  3947. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  3948. return -1;
  3949. } else if (strlen(atcmd_player_name) > 23) {
  3950. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  3951. return -1;
  3952. } else {
  3953. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3954. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  3955. }
  3956. return 0;
  3957. }
  3958. /*==========================================
  3959. * charban command (usage: charban <time> <player_name>)
  3960. * This command do a limited ban on a player
  3961. * Time is done as follows:
  3962. * Adjustment value (-1, 1, +1, etc...)
  3963. * Modified element:
  3964. * a or y: year
  3965. * m: month
  3966. * j or d: day
  3967. * h: hour
  3968. * mn: minute
  3969. * s: second
  3970. * <example> @ban +1m-2mn1s-6y test_player
  3971. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3972. *------------------------------------------
  3973. */
  3974. int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  3975. {
  3976. char * modif_p;
  3977. int year, month, day, hour, minute, second, value;
  3978. nullpo_retr(-1, sd);
  3979. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3980. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3981. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3982. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3983. return -1;
  3984. }
  3985. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3986. modif_p = atcmd_output;
  3987. year = month = day = hour = minute = second = 0;
  3988. while (modif_p[0] != '\0') {
  3989. value = atoi(modif_p);
  3990. if (value == 0)
  3991. modif_p++;
  3992. else {
  3993. if (modif_p[0] == '-' || modif_p[0] == '+')
  3994. modif_p++;
  3995. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3996. modif_p++;
  3997. if (modif_p[0] == 's') {
  3998. second = value;
  3999. modif_p++;
  4000. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4001. minute = value;
  4002. modif_p = modif_p + 2;
  4003. } else if (modif_p[0] == 'h') {
  4004. hour = value;
  4005. modif_p++;
  4006. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4007. day = value;
  4008. modif_p++;
  4009. } else if (modif_p[0] == 'm') {
  4010. month = value;
  4011. modif_p++;
  4012. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4013. year = value;
  4014. modif_p++;
  4015. } else if (modif_p[0] != '\0') {
  4016. modif_p++;
  4017. }
  4018. }
  4019. }
  4020. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4021. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  4022. return -1;
  4023. }
  4024. // check player name
  4025. if (strlen(atcmd_player_name) < 4) {
  4026. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4027. return -1;
  4028. } else if (strlen(atcmd_player_name) > 23) {
  4029. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4030. return -1;
  4031. } else {
  4032. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4033. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4034. }
  4035. return 0;
  4036. }
  4037. /*==========================================
  4038. * charunblock command (usage: charunblock <player_name>)
  4039. *------------------------------------------
  4040. */
  4041. int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4042. {
  4043. nullpo_retr(-1, sd);
  4044. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4045. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4046. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4047. return -1;
  4048. }
  4049. // check player name
  4050. if (strlen(atcmd_player_name) < 4) {
  4051. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4052. return -1;
  4053. } else if (strlen(atcmd_player_name) > 23) {
  4054. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4055. return -1;
  4056. } else {
  4057. // send answer to login server via char-server
  4058. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4059. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4060. }
  4061. return 0;
  4062. }
  4063. /*==========================================
  4064. * charunban command (usage: charunban <player_name>)
  4065. *------------------------------------------
  4066. */
  4067. int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4068. {
  4069. nullpo_retr(-1, sd);
  4070. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4071. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4072. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4073. return -1;
  4074. }
  4075. // check player name
  4076. if (strlen(atcmd_player_name) < 4) {
  4077. clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters.
  4078. return -1;
  4079. } else if (strlen(atcmd_player_name) > 23) {
  4080. clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum.
  4081. return -1;
  4082. } else {
  4083. // send answer to login server via char-server
  4084. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4085. clif_displaymessage(fd, msg_txt(88)); // Character name sends to char-server to ask it.
  4086. }
  4087. return 0;
  4088. }
  4089. /*==========================================
  4090. *
  4091. *------------------------------------------
  4092. */
  4093. int atcommand_night(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4094. {
  4095. nullpo_retr(-1, sd);
  4096. if (night_flag != 1) {
  4097. map_night_timer(night_timer_tid, 0, 0, 1);
  4098. } else {
  4099. clif_displaymessage(fd, msg_txt(89)); // Sorry, it's already the night. Impossible to execute the command.
  4100. return -1;
  4101. }
  4102. return 0;
  4103. }
  4104. /*==========================================
  4105. *
  4106. *------------------------------------------
  4107. */
  4108. int atcommand_day(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4109. {
  4110. nullpo_retr(-1, sd);
  4111. if (night_flag != 0) {
  4112. map_day_timer(day_timer_tid, 0, 0, 1);
  4113. } else {
  4114. clif_displaymessage(fd, msg_txt(90)); // Sorry, it's already the day. Impossible to execute the command.
  4115. return -1;
  4116. }
  4117. return 0;
  4118. }
  4119. /*==========================================
  4120. *
  4121. *------------------------------------------
  4122. */
  4123. int atcommand_doom(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4124. {
  4125. struct map_session_data *pl_sd, **pl_allsd;
  4126. int i, users;
  4127. nullpo_retr(-1, sd);
  4128. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4129. pl_allsd = map_getallusers(&users);
  4130. for(i = 0; i < users; i++) {
  4131. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can doom only lower or same gm level
  4132. status_kill(&pl_sd->bl);
  4133. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4134. }
  4135. }
  4136. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4137. return 0;
  4138. }
  4139. /*==========================================
  4140. *
  4141. *------------------------------------------
  4142. */
  4143. int atcommand_doommap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4144. {
  4145. struct map_session_data *pl_sd, **pl_allsd;
  4146. int i, users;
  4147. nullpo_retr(-1, sd);
  4148. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4149. pl_allsd = map_getallusers(&users);
  4150. for (i = 0; i < users; i++) {
  4151. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4152. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4153. {
  4154. status_kill(&pl_sd->bl);
  4155. // clif_specialeffect(&pl_sd->bl,450,1);
  4156. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  4157. }
  4158. }
  4159. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  4160. return 0;
  4161. }
  4162. /*==========================================
  4163. *
  4164. *------------------------------------------
  4165. */
  4166. static void atcommand_raise_sub(struct map_session_data* sd)
  4167. {
  4168. if (!sd->state.auth || !status_isdead(&sd->bl))
  4169. return;
  4170. if(!status_revive(&sd->bl, 100, 100))
  4171. return;
  4172. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4173. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  4174. }
  4175. /*==========================================
  4176. *
  4177. *------------------------------------------
  4178. */
  4179. int atcommand_raise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4180. {
  4181. int i, users;
  4182. struct map_session_data **all_sd;
  4183. nullpo_retr(-1, sd);
  4184. all_sd = map_getallusers(&users);
  4185. for (i = 0; i < users; i++) {
  4186. atcommand_raise_sub(all_sd[i]);
  4187. }
  4188. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4189. return 0;
  4190. }
  4191. /*==========================================
  4192. *
  4193. *------------------------------------------
  4194. */
  4195. int atcommand_raisemap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4196. {
  4197. struct map_session_data **pl_allsd;
  4198. int i, users;
  4199. nullpo_retr(-1, sd);
  4200. pl_allsd = map_getallusers(&users);
  4201. for (i = 0; i < users; i++) {
  4202. if (sd->bl.m == pl_allsd[i]->bl.m)
  4203. atcommand_raise_sub(pl_allsd[i]);
  4204. }
  4205. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  4206. return 0;
  4207. }
  4208. /*==========================================
  4209. *
  4210. *------------------------------------------
  4211. */
  4212. int atcommand_kick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4213. {
  4214. struct map_session_data *pl_sd;
  4215. nullpo_retr(-1, sd);
  4216. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4217. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4218. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4219. return -1;
  4220. }
  4221. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4222. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4223. clif_GM_kick(sd, pl_sd, 1);
  4224. else {
  4225. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4226. return -1;
  4227. }
  4228. } else {
  4229. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4230. return -1;
  4231. }
  4232. return 0;
  4233. }
  4234. /*==========================================
  4235. *
  4236. *------------------------------------------
  4237. */
  4238. int atcommand_kickall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4239. {
  4240. struct map_session_data *pl_sd, **pl_allsd;
  4241. int i, users;
  4242. nullpo_retr(-1, sd);
  4243. pl_allsd = map_getallusers(&users);
  4244. for (i = 0; i < users; i++) {
  4245. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4246. if (sd->status.account_id != pl_sd->status.account_id)
  4247. clif_GM_kick(sd, pl_sd, 0);
  4248. }
  4249. }
  4250. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  4251. return 0;
  4252. }
  4253. /*==========================================
  4254. *
  4255. *------------------------------------------
  4256. */
  4257. int atcommand_allskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4258. {
  4259. nullpo_retr(-1, sd);
  4260. pc_allskillup(sd); // all skills
  4261. sd->status.skill_point = 0; // 0 skill points
  4262. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4263. clif_displaymessage(fd, msg_txt(76)); // You have received all skills.
  4264. return 0;
  4265. }
  4266. /*==========================================
  4267. *
  4268. *------------------------------------------
  4269. */
  4270. int atcommand_questskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4271. {
  4272. int skill_id;
  4273. nullpo_retr(-1, sd);
  4274. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4275. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4276. return -1;
  4277. }
  4278. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4279. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4280. if (pc_checkskill(sd, skill_id) == 0) {
  4281. pc_skill(sd, skill_id, 1, 0);
  4282. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  4283. } else {
  4284. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  4285. return -1;
  4286. }
  4287. } else {
  4288. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4289. return -1;
  4290. }
  4291. } else {
  4292. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4293. return -1;
  4294. }
  4295. return 0;
  4296. }
  4297. /*==========================================
  4298. *
  4299. *------------------------------------------
  4300. */
  4301. int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4302. {
  4303. int skill_id;
  4304. nullpo_retr(-1, sd);
  4305. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4306. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4307. return -1;
  4308. }
  4309. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4310. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4311. if (pc_checkskill(sd, skill_id) > 0) {
  4312. sd->status.skill[skill_id].lv = 0;
  4313. sd->status.skill[skill_id].flag = 0;
  4314. clif_skillinfoblock(sd);
  4315. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  4316. } else {
  4317. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  4318. return -1;
  4319. }
  4320. } else {
  4321. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  4322. return -1;
  4323. }
  4324. } else {
  4325. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  4326. return -1;
  4327. }
  4328. return 0;
  4329. }
  4330. /*==========================================
  4331. *
  4332. *------------------------------------------
  4333. */
  4334. int atcommand_spiritball(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4335. {
  4336. int number;
  4337. nullpo_retr(-1, sd);
  4338. if (!message || !*message || (number = atoi(message)) < 0) {
  4339. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4340. return -1;
  4341. }
  4342. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4343. if (number > 500)
  4344. number = 500;
  4345. if (number >= 0 && number <= 0x7FFF) {
  4346. if (sd->spiritball != number || number > 499) {
  4347. if (sd->spiritball > 0)
  4348. pc_delspiritball(sd, sd->spiritball, 1);
  4349. sd->spiritball = number;
  4350. clif_spiritball(sd);
  4351. // no message, player can look the difference
  4352. if (number > 1000)
  4353. clif_displaymessage(fd, msg_txt(204)); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4354. } else {
  4355. clif_displaymessage(fd, msg_txt(205)); // You already have this number of spiritballs.
  4356. return -1;
  4357. }
  4358. } else {
  4359. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  4360. return -1;
  4361. }
  4362. return 0;
  4363. }
  4364. /*==========================================
  4365. *
  4366. *------------------------------------------
  4367. */
  4368. int atcommand_party(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4369. {
  4370. char party[NAME_LENGTH];
  4371. nullpo_retr(-1, sd);
  4372. memset(party, '\0', sizeof(party));
  4373. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4374. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4375. return -1;
  4376. }
  4377. party_create(sd, party, 0, 0);
  4378. return 0;
  4379. }
  4380. /*==========================================
  4381. *
  4382. *------------------------------------------
  4383. */
  4384. int atcommand_guild(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4385. {
  4386. char guild[NAME_LENGTH];
  4387. int prev;
  4388. nullpo_retr(-1, sd);
  4389. memset(guild, '\0', sizeof(guild));
  4390. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4391. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4392. return -1;
  4393. }
  4394. prev = battle_config.guild_emperium_check;
  4395. battle_config.guild_emperium_check = 0;
  4396. guild_create(sd, guild);
  4397. battle_config.guild_emperium_check = prev;
  4398. return 0;
  4399. }
  4400. /*==========================================
  4401. *
  4402. *------------------------------------------
  4403. */
  4404. int atcommand_agitstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4405. {
  4406. nullpo_retr(-1, sd);
  4407. if (agit_flag == 1) {
  4408. clif_displaymessage(fd, msg_txt(73)); // Already it has started siege warfare.
  4409. return -1;
  4410. }
  4411. agit_flag = 1;
  4412. guild_agit_start();
  4413. clif_displaymessage(fd, msg_txt(72)); // Guild siege warfare start!
  4414. return 0;
  4415. }
  4416. /*==========================================
  4417. *
  4418. *------------------------------------------
  4419. */
  4420. int atcommand_agitend(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4421. {
  4422. nullpo_retr(-1, sd);
  4423. if (agit_flag == 0) {
  4424. clif_displaymessage(fd, msg_txt(75)); // Siege warfare hasn't started yet.
  4425. return -1;
  4426. }
  4427. agit_flag = 0;
  4428. guild_agit_end();
  4429. clif_displaymessage(fd, msg_txt(74)); // Guild siege warfare end!
  4430. return 0;
  4431. }
  4432. /*==========================================
  4433. * @mapexit - shuts down the map server
  4434. *------------------------------------------
  4435. */
  4436. int atcommand_mapexit(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4437. {
  4438. struct map_session_data *pl_sd, **pl_allsd;
  4439. int i, users;
  4440. nullpo_retr(-1, sd);
  4441. pl_allsd = map_getallusers(&users);
  4442. for (i = 0; i < users; i++) {
  4443. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4444. clif_GM_kick(sd, pl_sd, 0);
  4445. }
  4446. clif_GM_kick(sd, sd, 0);
  4447. flush_fifos();
  4448. runflag = 0;
  4449. return 0;
  4450. }
  4451. /*==========================================
  4452. * idsearch <part_of_name>: revrited by [Yor]
  4453. *------------------------------------------
  4454. */
  4455. int atcommand_idsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4456. {
  4457. char item_name[100];
  4458. unsigned int i, match;
  4459. struct item_data *item_array[MAX_SEARCH];
  4460. nullpo_retr(-1, sd);
  4461. memset(item_name, '\0', sizeof(item_name));
  4462. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4463. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4464. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4465. return -1;
  4466. }
  4467. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  4468. clif_displaymessage(fd, atcmd_output);
  4469. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4470. if (match > MAX_SEARCH) {
  4471. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  4472. clif_displaymessage(fd, atcmd_output);
  4473. match = MAX_SEARCH;
  4474. }
  4475. for(i = 0; i < match; i++) {
  4476. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4477. clif_displaymessage(fd, atcmd_output);
  4478. }
  4479. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  4480. clif_displaymessage(fd, atcmd_output);
  4481. return 0;
  4482. }
  4483. /*==========================================
  4484. * Recall All Characters Online To Your Location
  4485. *------------------------------------------
  4486. */
  4487. int atcommand_recallall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4488. {
  4489. struct map_session_data *pl_sd, **pl_allsd;
  4490. int i;
  4491. int count, users;
  4492. nullpo_retr(-1, sd);
  4493. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4494. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4495. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4496. return -1;
  4497. }
  4498. count = 0;
  4499. pl_allsd = map_getallusers(&users);
  4500. for (i = 0; i < users; i++) {
  4501. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4502. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4503. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4504. count++;
  4505. else {
  4506. if (pc_isdead(pl_sd)) { //Wake them up
  4507. pc_setstand(pl_sd);
  4508. pc_setrestartvalue(pl_sd,1);
  4509. }
  4510. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4511. }
  4512. }
  4513. }
  4514. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  4515. if (count) {
  4516. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4517. clif_displaymessage(fd, atcmd_output);
  4518. }
  4519. return 0;
  4520. }
  4521. /*==========================================
  4522. * Recall online characters of a guild to your location
  4523. *------------------------------------------
  4524. */
  4525. int atcommand_guildrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4526. {
  4527. struct map_session_data *pl_sd, **pl_allsd;
  4528. int i, users, count;
  4529. char guild_name[NAME_LENGTH];
  4530. struct guild *g;
  4531. nullpo_retr(-1, sd);
  4532. memset(guild_name, '\0', sizeof(guild_name));
  4533. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4534. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4535. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4536. return -1;
  4537. }
  4538. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4539. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4540. return -1;
  4541. }
  4542. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4543. (g = guild_search(atoi(message))) != NULL) {
  4544. count = 0;
  4545. pl_allsd = map_getallusers(&users);
  4546. for (i = 0; i < users; i++) {
  4547. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4548. pl_sd->status.guild_id == g->guild_id) {
  4549. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4550. continue; //Skip GMs greater than you.
  4551. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4552. count++;
  4553. else
  4554. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4555. }
  4556. }
  4557. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild are near you.
  4558. clif_displaymessage(fd, atcmd_output);
  4559. if (count) {
  4560. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4561. clif_displaymessage(fd, atcmd_output);
  4562. }
  4563. } else {
  4564. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  4565. return -1;
  4566. }
  4567. return 0;
  4568. }
  4569. /*==========================================
  4570. * Recall online characters of a party to your location
  4571. *------------------------------------------
  4572. */
  4573. int atcommand_partyrecall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4574. {
  4575. int i;
  4576. struct map_session_data *pl_sd, **pl_allsd;
  4577. char party_name[NAME_LENGTH];
  4578. struct party_data *p;
  4579. int count, users;
  4580. nullpo_retr(-1, sd);
  4581. memset(party_name, '\0', sizeof(party_name));
  4582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4583. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4584. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4585. return -1;
  4586. }
  4587. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4588. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4589. return -1;
  4590. }
  4591. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4592. (p = party_search(atoi(message))) != NULL) {
  4593. count = 0;
  4594. pl_allsd = map_getallusers(&users);
  4595. for (i = 0; i < users; i++) {
  4596. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4597. pl_sd->status.party_id == p->party.party_id) {
  4598. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4599. continue; //Skip GMs greater than you.
  4600. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4601. count++;
  4602. else
  4603. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4604. }
  4605. }
  4606. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party are near you.
  4607. clif_displaymessage(fd, atcmd_output);
  4608. if (count) {
  4609. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4610. clif_displaymessage(fd, atcmd_output);
  4611. }
  4612. } else {
  4613. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  4614. return -1;
  4615. }
  4616. return 0;
  4617. }
  4618. /*==========================================
  4619. *
  4620. *------------------------------------------
  4621. */
  4622. int atcommand_reloaditemdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4623. {
  4624. nullpo_retr(-1, sd);
  4625. itemdb_reload();
  4626. clif_displaymessage(fd, msg_txt(97)); // Item database reloaded.
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. *
  4631. *------------------------------------------
  4632. */
  4633. int atcommand_reloadmobdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4634. {
  4635. nullpo_retr(-1, sd);
  4636. mob_reload();
  4637. read_petdb();
  4638. merc_reload();
  4639. clif_displaymessage(fd, msg_txt(98)); // Monster database reloaded.
  4640. return 0;
  4641. }
  4642. /*==========================================
  4643. *
  4644. *------------------------------------------
  4645. */
  4646. int atcommand_reloadskilldb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4647. {
  4648. nullpo_retr(-1, sd);
  4649. skill_reload();
  4650. merc_skill_reload();
  4651. clif_displaymessage(fd, msg_txt(99)); // Skill database reloaded.
  4652. return 0;
  4653. }
  4654. /*==========================================
  4655. * @reloadatcommand - reloads atcommand_athena.conf
  4656. *------------------------------------------
  4657. */
  4658. int atcommand_reloadatcommand(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4659. {
  4660. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4661. clif_displaymessage(fd, msg_txt(254));
  4662. return 0;
  4663. }
  4664. /*==========================================
  4665. * @reloadbattleconf - reloads battle_athena.conf
  4666. *------------------------------------------
  4667. */
  4668. int atcommand_reloadbattleconf(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4669. {
  4670. struct Battle_Config prev_config;
  4671. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  4672. battle_config_read(BATTLE_CONF_FILENAME);
  4673. if (memcmp(&prev_config.item_rate_mvp,
  4674. &battle_config.item_rate_mvp,
  4675. sizeof(battle_config.item_rate_mvp)+
  4676. sizeof(battle_config.item_rate_common)+
  4677. sizeof(battle_config.item_rate_common_boss)+
  4678. sizeof(battle_config.item_rate_card)+
  4679. sizeof(battle_config.item_rate_card_boss)+
  4680. sizeof(battle_config.item_rate_equip)+
  4681. sizeof(battle_config.item_rate_equip_boss)+
  4682. sizeof(battle_config.item_rate_heal)+
  4683. sizeof(battle_config.item_rate_heal_boss)+
  4684. sizeof(battle_config.item_rate_use)+
  4685. sizeof(battle_config.item_rate_use_boss)+
  4686. sizeof(battle_config.item_rate_treasure)+
  4687. sizeof(battle_config.item_rate_adddrop)+
  4688. sizeof(battle_config.logarithmic_drops)+
  4689. sizeof(battle_config.item_drop_common_min)+
  4690. sizeof(battle_config.item_drop_common_max)+
  4691. sizeof(battle_config.item_drop_card_min)+
  4692. sizeof(battle_config.item_drop_card_max)+
  4693. sizeof(battle_config.item_drop_equip_min)+
  4694. sizeof(battle_config.item_drop_equip_max)+
  4695. sizeof(battle_config.item_drop_mvp_min)+
  4696. sizeof(battle_config.item_drop_mvp_max)+
  4697. sizeof(battle_config.item_drop_heal_min)+
  4698. sizeof(battle_config.item_drop_heal_max)+
  4699. sizeof(battle_config.item_drop_use_min)+
  4700. sizeof(battle_config.item_drop_use_max)+
  4701. sizeof(battle_config.item_drop_treasure_min)+
  4702. sizeof(battle_config.item_drop_treasure_max)
  4703. ) != 0)
  4704. { //Drop rates changed.
  4705. mob_reload(); //Needed as well so rate changes take effect.
  4706. #ifndef TXT_ONLY
  4707. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  4708. #endif
  4709. }
  4710. clif_displaymessage(fd, msg_txt(255));
  4711. return 0;
  4712. }
  4713. /*==========================================
  4714. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  4715. *------------------------------------------
  4716. */
  4717. int atcommand_reloadstatusdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4718. {
  4719. status_readdb();
  4720. clif_displaymessage(fd, msg_txt(256));
  4721. return 0;
  4722. }
  4723. /*==========================================
  4724. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt
  4725. *------------------------------------------
  4726. */
  4727. int atcommand_reloadpcdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4728. {
  4729. pc_readdb();
  4730. clif_displaymessage(fd, msg_txt(257));
  4731. return 0;
  4732. }
  4733. /*==========================================
  4734. * @reloadmotd - reloads motd.txt
  4735. *------------------------------------------
  4736. */
  4737. int atcommand_reloadmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4738. {
  4739. pc_read_motd();
  4740. clif_displaymessage(fd, msg_txt(268));
  4741. return 0;
  4742. }
  4743. /*==========================================
  4744. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  4745. *------------------------------------------
  4746. */
  4747. int atcommand_reloadscript(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4748. {
  4749. nullpo_retr(-1, sd);
  4750. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4751. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4752. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4753. flush_fifos();
  4754. script_reload();
  4755. npc_reload();
  4756. clif_displaymessage(fd, msg_txt(100)); // Scripts reloaded.
  4757. return 0;
  4758. }
  4759. /*==========================================
  4760. * @reloadgmdb - reloads gm levels from where they are stored (gm_account.txt / mysql database)
  4761. *------------------------------------------
  4762. */
  4763. int atcommand_reloadgmdb(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4764. {
  4765. nullpo_retr(-1, sd);
  4766. chrif_reloadGMdb();
  4767. clif_displaymessage(fd, msg_txt(101)); // Login-server asked to reload GM accounts and their level.
  4768. return 0;
  4769. }
  4770. /*==========================================
  4771. * @mapinfo <map name> [0-3] by MC_Cameri
  4772. * => Shows information about the map [map name]
  4773. * 0 = no additional information
  4774. * 1 = Show users in that map and their location
  4775. * 2 = Shows NPCs in that map
  4776. * 3 = Shows the shops/chats in that map (not implemented)
  4777. *------------------------------------------
  4778. */
  4779. int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4780. {
  4781. struct map_session_data *pl_sd, **pl_allsd;
  4782. struct npc_data *nd = NULL;
  4783. struct chat_data *cd = NULL;
  4784. char direction[12];
  4785. int m_id, i, chat_num, users, list = 0;
  4786. unsigned short m_index;
  4787. nullpo_retr(-1, sd);
  4788. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4789. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4790. memset(direction, '\0', sizeof(direction));
  4791. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4792. if (list < 0 || list > 3) {
  4793. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4794. return -1;
  4795. }
  4796. if (atcmd_player_name[0] == '\0') {
  4797. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4798. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4799. m_id = map_mapindex2mapid(sd->mapindex);
  4800. } else {
  4801. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4802. strcat(atcmd_player_name, ".gat");
  4803. m_id = map_mapname2mapid(atcmd_player_name);
  4804. }
  4805. if (m_id < 0) {
  4806. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  4807. return -1;
  4808. }
  4809. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4810. clif_displaymessage(fd, "------ Map Info ------");
  4811. chat_num = 0;
  4812. pl_allsd = map_getallusers(&users);
  4813. for (i = 0; i < users; i++) {
  4814. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4815. chat_num++;
  4816. }
  4817. }
  4818. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", atcmd_player_name, map[m_id].users, map[m_id].npc_num, chat_num);
  4819. clif_displaymessage(fd, atcmd_output);
  4820. if (map[m_id].flag.alias)
  4821. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4822. clif_displaymessage(fd, "------ Map Flags ------");
  4823. strcpy(atcmd_output,"PvP Flags: ");
  4824. if (map[m_id].flag.pvp)
  4825. strcat(atcmd_output, "Pvp ON | ");
  4826. if (map[m_id].flag.pvp_noguild)
  4827. strcat(atcmd_output, "NoGuild | ");
  4828. if (map[m_id].flag.pvp_noparty)
  4829. strcat(atcmd_output, "NoParty | ");
  4830. if (map[m_id].flag.pvp_nightmaredrop)
  4831. strcat(atcmd_output, "NightmareDrop | ");
  4832. if (map[m_id].flag.pvp_nocalcrank)
  4833. strcat(atcmd_output, "NoCalcRank | ");
  4834. clif_displaymessage(fd, atcmd_output);
  4835. strcpy(atcmd_output,"GvG Flags: ");
  4836. if (map[m_id].flag.gvg)
  4837. strcat(atcmd_output, "GvG ON | ");
  4838. if (map[m_id].flag.gvg_dungeon)
  4839. strcat(atcmd_output, "GvG Dungeon | ");
  4840. if (map[m_id].flag.gvg_castle)
  4841. strcat(atcmd_output, "GvG Castle | ");
  4842. if (map[m_id].flag.gvg_noparty)
  4843. strcat(atcmd_output, "NoParty | ");
  4844. clif_displaymessage(fd, atcmd_output);
  4845. strcpy(atcmd_output,"Teleport Flags: ");
  4846. if (map[m_id].flag.noteleport)
  4847. strcat(atcmd_output, "NoTeleport | ");
  4848. if (map[m_id].flag.monster_noteleport)
  4849. strcat(atcmd_output, "Monster NoTeleport | ");
  4850. if (map[m_id].flag.nowarp)
  4851. strcat(atcmd_output, "NoWarp | ");
  4852. if (map[m_id].flag.nowarpto)
  4853. strcat(atcmd_output, "NoWarpTo | ");
  4854. if (map[m_id].flag.noreturn)
  4855. strcat(atcmd_output, "NoReturn | ");
  4856. if (map[m_id].flag.nogo)
  4857. strcat(atcmd_output, "NoGo | ");
  4858. if (map[m_id].flag.nomemo)
  4859. strcat(atcmd_output, "NoMemo | ");
  4860. clif_displaymessage(fd, atcmd_output);
  4861. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4862. clif_displaymessage(fd, atcmd_output);
  4863. if (map[m_id].flag.nosave) {
  4864. if (!map[m_id].save.map)
  4865. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  4866. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4867. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4868. else
  4869. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4870. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4871. clif_displaymessage(fd, atcmd_output);
  4872. }
  4873. strcpy(atcmd_output,"Weather Flags: ");
  4874. if (map[m_id].flag.snow)
  4875. strcat(atcmd_output, "Snow | ");
  4876. if (map[m_id].flag.fog)
  4877. strcat(atcmd_output, "Fog | ");
  4878. if (map[m_id].flag.sakura)
  4879. strcat(atcmd_output, "Sakura | ");
  4880. if (map[m_id].flag.clouds)
  4881. strcat(atcmd_output, "Clouds | ");
  4882. if (map[m_id].flag.clouds2)
  4883. strcat(atcmd_output, "Clouds2 | ");
  4884. if (map[m_id].flag.fireworks)
  4885. strcat(atcmd_output, "Fireworks | ");
  4886. if (map[m_id].flag.leaves)
  4887. strcat(atcmd_output, "Leaves | ");
  4888. if (map[m_id].flag.rain)
  4889. strcat(atcmd_output, "Rain | ");
  4890. if (map[m_id].flag.indoors)
  4891. strcat(atcmd_output, "Indoors | ");
  4892. if (map[m_id].flag.nightenabled)
  4893. strcat(atcmd_output, "Displays Night | ");
  4894. clif_displaymessage(fd, atcmd_output);
  4895. strcpy(atcmd_output,"Other Flags: ");
  4896. if (map[m_id].flag.nobranch)
  4897. strcat(atcmd_output, "NoBranch | ");
  4898. if (map[m_id].flag.notrade)
  4899. strcat(atcmd_output, "NoTrade | ");
  4900. if (map[m_id].flag.novending)
  4901. strcat(atcmd_output, "NoVending | ");
  4902. if (map[m_id].flag.nodrop)
  4903. strcat(atcmd_output, "NoDrop | ");
  4904. if (map[m_id].flag.noskill)
  4905. strcat(atcmd_output, "NoSkill | ");
  4906. if (map[m_id].flag.noicewall)
  4907. strcat(atcmd_output, "NoIcewall | ");
  4908. clif_displaymessage(fd, atcmd_output);
  4909. strcpy(atcmd_output,"Other Flags: ");
  4910. if (map[m_id].nocommand)
  4911. strcat(atcmd_output, "NoCommand | ");
  4912. if (map[m_id].flag.nobaseexp)
  4913. strcat(atcmd_output, "NoBaseEXP | ");
  4914. if (map[m_id].flag.nojobexp)
  4915. strcat(atcmd_output, "NoJobEXP | ");
  4916. if (map[m_id].flag.nomobloot)
  4917. strcat(atcmd_output, "NoMobLoot | ");
  4918. if (map[m_id].flag.nomvploot)
  4919. strcat(atcmd_output, "NoMVPLoot | ");
  4920. if (map[m_id].flag.partylock)
  4921. strcat(atcmd_output, "PartyLock | ");
  4922. if (map[m_id].flag.guildlock)
  4923. strcat(atcmd_output, "GuildLock | ");
  4924. clif_displaymessage(fd, atcmd_output);
  4925. switch (list) {
  4926. case 0:
  4927. // Do nothing. It's list 0, no additional display.
  4928. break;
  4929. case 1:
  4930. clif_displaymessage(fd, "----- Players in Map -----");
  4931. for (i = 0; i < users; i++) {
  4932. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  4933. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  4934. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4935. clif_displaymessage(fd, atcmd_output);
  4936. }
  4937. }
  4938. break;
  4939. case 2:
  4940. clif_displaymessage(fd, "----- NPCs in Map -----");
  4941. for (i = 0; i < map[m_id].npc_num;) {
  4942. nd = map[m_id].npc[i];
  4943. switch(nd->ud.dir) {
  4944. case 0: strcpy(direction, "North"); break;
  4945. case 1: strcpy(direction, "North West"); break;
  4946. case 2: strcpy(direction, "West"); break;
  4947. case 3: strcpy(direction, "South West"); break;
  4948. case 4: strcpy(direction, "South"); break;
  4949. case 5: strcpy(direction, "South East"); break;
  4950. case 6: strcpy(direction, "East"); break;
  4951. case 7: strcpy(direction, "North East"); break;
  4952. case 9: strcpy(direction, "North"); break;
  4953. default: strcpy(direction, "Unknown"); break;
  4954. }
  4955. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  4956. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4957. clif_displaymessage(fd, atcmd_output);
  4958. }
  4959. break;
  4960. case 3:
  4961. clif_displaymessage(fd, "----- Chats in Map -----");
  4962. for (i = 0; i < users; i++) {
  4963. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  4964. pl_sd->mapindex == m_index &&
  4965. cd->usersd[0] == pl_sd) {
  4966. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  4967. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4968. clif_displaymessage(fd, atcmd_output);
  4969. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4970. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4971. clif_displaymessage(fd, atcmd_output);
  4972. }
  4973. }
  4974. break;
  4975. default: // normally impossible to arrive here
  4976. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4977. return -1;
  4978. break;
  4979. }
  4980. return 0;
  4981. }
  4982. /*==========================================
  4983. *
  4984. *------------------------------------------
  4985. */
  4986. int atcommand_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  4987. {
  4988. nullpo_retr(-1, sd);
  4989. if (!pc_isriding(sd)) { // if actually no peco
  4990. if (pc_checkskill(sd, KN_RIDING)) {
  4991. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4992. clif_displaymessage(fd, msg_txt(102)); // Mounted Peco.
  4993. } else {
  4994. clif_displaymessage(fd, msg_txt(213)); // You can not mount a peco with your job.
  4995. return -1;
  4996. }
  4997. } else { //Dismount
  4998. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4999. clif_displaymessage(fd, msg_txt(214)); // Unmounted Peco.
  5000. }
  5001. return 0;
  5002. }
  5003. /*==========================================
  5004. *
  5005. *------------------------------------------
  5006. */
  5007. int atcommand_char_mount_peco(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5008. {
  5009. struct map_session_data *pl_sd;
  5010. nullpo_retr(-1, sd);
  5011. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5012. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5013. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5014. return -1;
  5015. }
  5016. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5017. if (!pc_isriding(pl_sd)) { // if actually no peco
  5018. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5019. pc_setoption(pl_sd, pl_sd->sc.option | OPTION_RIDING);
  5020. clif_displaymessage(fd, msg_txt(216)); // Mounted Peco.
  5021. } else {
  5022. clif_displaymessage(fd, msg_txt(217)); // You can not mount a peco with your job.
  5023. return -1;
  5024. }
  5025. } else { //Dismount
  5026. pc_setoption(pl_sd, pl_sd->sc.option & ~OPTION_RIDING);
  5027. clif_displaymessage(fd, msg_txt(218)); // Unmounted Peco.
  5028. }
  5029. } else {
  5030. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5031. return -1;
  5032. }
  5033. return 0;
  5034. }
  5035. /*==========================================
  5036. *Spy Commands by Syrus22
  5037. *------------------------------------------
  5038. */
  5039. int atcommand_guildspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5040. {
  5041. char guild_name[NAME_LENGTH];
  5042. struct guild *g;
  5043. nullpo_retr(-1, sd);
  5044. memset(guild_name, '\0', sizeof(guild_name));
  5045. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5046. if (!enable_spy)
  5047. {
  5048. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5049. return -1;
  5050. }
  5051. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5052. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5053. return -1;
  5054. }
  5055. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5056. (g = guild_search(atoi(message))) != NULL) {
  5057. if (sd->guildspy == g->guild_id) {
  5058. sd->guildspy = 0;
  5059. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  5060. clif_displaymessage(fd, atcmd_output);
  5061. } else {
  5062. sd->guildspy = g->guild_id;
  5063. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  5064. clif_displaymessage(fd, atcmd_output);
  5065. }
  5066. } else {
  5067. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  5068. return -1;
  5069. }
  5070. return 0;
  5071. }
  5072. /*==========================================
  5073. *
  5074. *------------------------------------------
  5075. */
  5076. int atcommand_partyspy(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5077. {
  5078. char party_name[NAME_LENGTH];
  5079. struct party_data *p;
  5080. nullpo_retr(-1, sd);
  5081. memset(party_name, '\0', sizeof(party_name));
  5082. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5083. if (!enable_spy)
  5084. {
  5085. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5086. return -1;
  5087. }
  5088. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5089. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5090. return -1;
  5091. }
  5092. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5093. (p = party_search(atoi(message))) != NULL) {
  5094. if (sd->partyspy == p->party.party_id) {
  5095. sd->partyspy = 0;
  5096. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  5097. clif_displaymessage(fd, atcmd_output);
  5098. } else {
  5099. sd->partyspy = p->party.party_id;
  5100. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  5101. clif_displaymessage(fd, atcmd_output);
  5102. }
  5103. } else {
  5104. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  5105. return -1;
  5106. }
  5107. return 0;
  5108. }
  5109. /*==========================================
  5110. * @repairall [Valaris]
  5111. *------------------------------------------
  5112. */
  5113. int atcommand_repairall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5114. {
  5115. int count, i;
  5116. nullpo_retr(-1, sd);
  5117. count = 0;
  5118. for (i = 0; i < MAX_INVENTORY; i++) {
  5119. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5120. sd->status.inventory[i].attribute = 0;
  5121. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5122. count++;
  5123. }
  5124. }
  5125. if (count > 0) {
  5126. clif_misceffect(&sd->bl, 3);
  5127. clif_equiplist(sd);
  5128. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  5129. } else {
  5130. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  5131. return -1;
  5132. }
  5133. return 0;
  5134. }
  5135. /*==========================================
  5136. * @nuke [Valaris]
  5137. *------------------------------------------
  5138. */
  5139. int atcommand_nuke(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5140. {
  5141. struct map_session_data *pl_sd;
  5142. nullpo_retr(-1, sd);
  5143. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5144. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5145. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5146. return -1;
  5147. }
  5148. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5149. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5150. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5151. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  5152. } else {
  5153. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5154. return -1;
  5155. }
  5156. } else {
  5157. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5158. return -1;
  5159. }
  5160. return 0;
  5161. }
  5162. /*==========================================
  5163. * @tonpc
  5164. *------------------------------------------
  5165. */
  5166. int atcommand_tonpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5167. {
  5168. char npcname[NAME_LENGTH];
  5169. struct npc_data *nd;
  5170. nullpo_retr(-1, sd);
  5171. memset(npcname, 0, sizeof(npcname));
  5172. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5173. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5174. return -1;
  5175. }
  5176. if ((nd = npc_name2id(npcname)) != NULL) {
  5177. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5178. clif_displaymessage(fd, msg_txt(0)); // Warped.
  5179. else
  5180. return -1;
  5181. } else {
  5182. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5183. return -1;
  5184. }
  5185. return 0;
  5186. }
  5187. /*==========================================
  5188. *
  5189. *------------------------------------------
  5190. */
  5191. int atcommand_shownpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5192. {
  5193. char NPCname[NAME_LENGTH];
  5194. nullpo_retr(-1, sd);
  5195. memset(NPCname, '\0', sizeof(NPCname));
  5196. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5197. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5198. return -1;
  5199. }
  5200. if (npc_name2id(NPCname) != NULL) {
  5201. npc_enable(NPCname, 1);
  5202. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  5203. } else {
  5204. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5205. return -1;
  5206. }
  5207. return 0;
  5208. }
  5209. /*==========================================
  5210. *
  5211. *------------------------------------------
  5212. */
  5213. int atcommand_hidenpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5214. {
  5215. char NPCname[NAME_LENGTH];
  5216. nullpo_retr(-1, sd);
  5217. memset(NPCname, '\0', sizeof(NPCname));
  5218. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5219. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  5220. return -1;
  5221. }
  5222. if (npc_name2id(NPCname) != NULL) {
  5223. npc_enable(NPCname, 0);
  5224. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5225. } else {
  5226. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5227. return -1;
  5228. }
  5229. return 0;
  5230. }
  5231. int atcommand_loadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5232. {
  5233. FILE *fp;
  5234. if (!message || !*message) {
  5235. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5236. return -1;
  5237. }
  5238. // check if script file exists
  5239. if ((fp = fopen(message, "r")) == NULL) {
  5240. clif_displaymessage(fd, msg_txt(261));
  5241. return -1;
  5242. }
  5243. fclose(fp);
  5244. // add to list of script sources and run it
  5245. npc_addsrcfile((char *)message);
  5246. npc_parsesrcfile((char *)message);
  5247. npc_read_event_script();
  5248. clif_displaymessage(fd, msg_txt(262));
  5249. return 0;
  5250. }
  5251. int atcommand_unloadnpc(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5252. {
  5253. struct npc_data *nd;
  5254. char NPCname[NAME_LENGTH];
  5255. nullpo_retr(-1, sd);
  5256. memset(NPCname, '\0', sizeof(NPCname));
  5257. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5258. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5259. return -1;
  5260. }
  5261. if ((nd = npc_name2id(NPCname)) != NULL) {
  5262. npc_unload_duplicates(nd);
  5263. npc_unload(nd);
  5264. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  5265. } else {
  5266. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  5267. return -1;
  5268. }
  5269. return 0;
  5270. }
  5271. /*==========================================
  5272. * time in txt for time command (by [Yor])
  5273. *------------------------------------------
  5274. */
  5275. char * txt_time(unsigned int duration)
  5276. {
  5277. int days, hours, minutes, seconds;
  5278. char temp[256];
  5279. static char temp1[256];
  5280. memset(temp, '\0', sizeof(temp));
  5281. memset(temp1, '\0', sizeof(temp1));
  5282. days = duration / (60 * 60 * 24);
  5283. duration = duration - (60 * 60 * 24 * days);
  5284. hours = duration / (60 * 60);
  5285. duration = duration - (60 * 60 * hours);
  5286. minutes = duration / 60;
  5287. seconds = duration - (60 * minutes);
  5288. if (days < 2)
  5289. sprintf(temp, msg_txt(219), days); // %d day
  5290. else
  5291. sprintf(temp, msg_txt(220), days); // %d days
  5292. if (hours < 2)
  5293. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  5294. else
  5295. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  5296. if (minutes < 2)
  5297. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  5298. else
  5299. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  5300. if (seconds < 2)
  5301. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  5302. else
  5303. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  5304. return temp1;
  5305. }
  5306. /*==========================================
  5307. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5308. * Calculation management of GM modification (@day/@night GM commands) is done
  5309. *------------------------------------------
  5310. */
  5311. int atcommand_servertime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5312. {
  5313. struct TimerData * timer_data;
  5314. struct TimerData * timer_data2;
  5315. time_t time_server; // variable for number of seconds (used with time() function)
  5316. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5317. char temp[256];
  5318. nullpo_retr(-1, sd);
  5319. memset(temp, '\0', sizeof(temp));
  5320. time(&time_server); // get time in seconds since 1/1/1970
  5321. datetime = localtime(&time_server); // convert seconds in structure
  5322. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5323. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  5324. clif_displaymessage(fd, temp);
  5325. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5326. if (night_flag == 0)
  5327. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5328. else
  5329. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5330. } else if (battle_config.night_duration == 0)
  5331. if (night_flag == 1) { // we start with night
  5332. timer_data = get_timer(day_timer_tid);
  5333. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5334. clif_displaymessage(fd, temp);
  5335. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  5336. } else
  5337. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  5338. else if (battle_config.day_duration == 0)
  5339. if (night_flag == 0) { // we start with day
  5340. timer_data = get_timer(night_timer_tid);
  5341. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5342. clif_displaymessage(fd, temp);
  5343. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  5344. } else
  5345. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  5346. else {
  5347. if (night_flag == 0) {
  5348. timer_data = get_timer(night_timer_tid);
  5349. timer_data2 = get_timer(day_timer_tid);
  5350. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5351. clif_displaymessage(fd, temp);
  5352. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5353. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  5354. else
  5355. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5356. clif_displaymessage(fd, temp);
  5357. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5358. clif_displaymessage(fd, temp);
  5359. } else {
  5360. timer_data = get_timer(day_timer_tid);
  5361. timer_data2 = get_timer(night_timer_tid);
  5362. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5363. clif_displaymessage(fd, temp);
  5364. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5365. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  5366. else
  5367. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5368. clif_displaymessage(fd, temp);
  5369. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5370. clif_displaymessage(fd, temp);
  5371. }
  5372. }
  5373. return 0;
  5374. }
  5375. /*==========================================
  5376. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5377. * removes <quantity> item from a character
  5378. * item can be equiped or not.
  5379. * Inspired from a old command created by RoVeRT
  5380. *------------------------------------------
  5381. */
  5382. int atcommand_chardelitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5383. {
  5384. struct map_session_data *pl_sd;
  5385. char item_name[100];
  5386. int i, number = 0, item_id, item_position, count;
  5387. struct item_data *item_data;
  5388. nullpo_retr(-1, sd);
  5389. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5390. memset(item_name, '\0', sizeof(item_name));
  5391. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5392. if (!message || !*message || (
  5393. sscanf(message, "\"%99[^\"]\" %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 &&
  5394. sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3
  5395. ) || number < 1) {
  5396. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5397. return -1;
  5398. }
  5399. item_id = 0;
  5400. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5401. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5402. item_id = item_data->nameid;
  5403. if (item_id > 500) {
  5404. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5405. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5406. item_position = pc_search_inventory(pl_sd, item_id);
  5407. if (item_position >= 0) {
  5408. count = 0;
  5409. for(i = 0; i < number && item_position >= 0; i++) {
  5410. //Logs (A)dmins items [Lupus]
  5411. if(log_config.enable_logs&0x400)
  5412. log_pick_pc(pl_sd, "A", pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5413. pc_delitem(pl_sd, item_position, 1, 0);
  5414. count++;
  5415. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5416. }
  5417. sprintf(atcmd_output, msg_txt(113), count); // %d item(s) removed by a GM.
  5418. clif_displaymessage(pl_sd->fd, atcmd_output);
  5419. if (number == count)
  5420. sprintf(atcmd_output, msg_txt(114), count); // %d item(s) removed from the player.
  5421. else
  5422. sprintf(atcmd_output, msg_txt(115), count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5423. clif_displaymessage(fd, atcmd_output);
  5424. } else {
  5425. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  5426. return -1;
  5427. }
  5428. } else {
  5429. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5430. return -1;
  5431. }
  5432. } else {
  5433. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5434. return -1;
  5435. }
  5436. } else {
  5437. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  5438. return -1;
  5439. }
  5440. return 0;
  5441. }
  5442. //Added by Coltaro
  5443. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  5444. //Well, using time_t could still work but for some reason that looks like more coding x_x
  5445. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  5446. {
  5447. const int factor_year = 518400; //12*30*24*60 = 518400
  5448. const int factor_month = 43200; //30*24*60 = 43200
  5449. const int factor_day = 1440; //24*60 = 1440
  5450. const int factor_hour = 60;
  5451. *year = jailtime/factor_year;
  5452. jailtime -= *year*factor_year;
  5453. *month = jailtime/factor_month;
  5454. jailtime -= *month*factor_month;
  5455. *day = jailtime/factor_day;
  5456. jailtime -= *day*factor_day;
  5457. *hour = jailtime/factor_hour;
  5458. jailtime -= *hour*factor_hour;
  5459. *minute = jailtime;
  5460. *year = *year > 0? *year : 0;
  5461. *month = *month > 0? *month : 0;
  5462. *day = *day > 0? *day : 0;
  5463. *hour = *hour > 0? *hour : 0;
  5464. *minute = *minute > 0? *minute : 0;
  5465. return;
  5466. }
  5467. /*==========================================
  5468. * @jail <char_name> by [Yor]
  5469. * Special warp! No check with nowarp and nowarpto flag
  5470. *------------------------------------------
  5471. */
  5472. int atcommand_jail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5473. {
  5474. struct map_session_data *pl_sd;
  5475. int x, y;
  5476. unsigned short m_index;
  5477. nullpo_retr(-1, sd);
  5478. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5479. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5480. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5481. return -1;
  5482. }
  5483. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5484. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5485. return -1;
  5486. }
  5487. if (pc_isGM(sd) < pc_isGM(pl_sd))
  5488. { // you can jail only lower or same GM
  5489. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5490. return -1;
  5491. }
  5492. if (pl_sd->mapindex == mapindex_name2id(MAP_JAIL))
  5493. { //Already jailed
  5494. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5495. return -1;
  5496. }
  5497. switch(rand() % 2) { //Jail Locations
  5498. case 0:
  5499. m_index = mapindex_name2id(MAP_JAIL);
  5500. x = 24;
  5501. y = 75;
  5502. break;
  5503. default:
  5504. m_index = mapindex_name2id(MAP_JAIL);
  5505. x = 49;
  5506. y = 75;
  5507. break;
  5508. }
  5509. if (pc_setpos(pl_sd, m_index, x, y, 3)) {
  5510. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5511. return -1;
  5512. }
  5513. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5514. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  5515. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  5516. return 0;
  5517. }
  5518. /*==========================================
  5519. * @unjail/@discharge <char_name> by [Yor]
  5520. * Special warp! No check with nowarp and nowarpto flag
  5521. *------------------------------------------
  5522. */
  5523. int atcommand_unjail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5524. {
  5525. struct map_session_data *pl_sd;
  5526. unsigned short m_index;
  5527. int x=0, y=0;
  5528. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5529. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5530. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5531. return -1;
  5532. }
  5533. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5534. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5535. return -1;
  5536. }
  5537. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5538. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5539. return -1;
  5540. }
  5541. if (pl_sd->mapindex != mapindex_name2id(MAP_JAIL)) {
  5542. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  5543. return -1;
  5544. }
  5545. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5546. { //Retrieve return map.
  5547. m_index = pl_sd->sc.data[SC_JAILED].val3;
  5548. x = pl_sd->sc.data[SC_JAILED].val4&0xFFFF;
  5549. y = pl_sd->sc.data[SC_JAILED].val4>>16;
  5550. status_change_end(&pl_sd->bl,SC_JAILED,-1);
  5551. } else
  5552. m_index = mapindex_name2id(MAP_PRONTERA);
  5553. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0 ||
  5554. pc_setpos(pl_sd, mapindex_name2id(MAP_PRONTERA), 0, 0, 3) == 0
  5555. ) { //Send to Prontera is saved SC map fails.
  5556. pc_setsavepoint(pl_sd, m_index, x, y);
  5557. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5558. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  5559. } else {
  5560. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  5561. return -1;
  5562. }
  5563. return 0;
  5564. }
  5565. int atcommand_jailfor(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5566. {
  5567. struct map_session_data *pl_sd = NULL;
  5568. int year, month, day, hour, minute, value;
  5569. char * modif_p;
  5570. int jailtime = 0,x,y;
  5571. short m_index = 0;
  5572. nullpo_retr(-1, sd);
  5573. if (!message || !*message || sscanf(message, "%s %99[^\n]",atcmd_output,atcmd_player_name) < 2) {
  5574. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  5575. return -1;
  5576. }
  5577. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  5578. modif_p = atcmd_output;
  5579. year = month = day = hour = minute = 0;
  5580. while (modif_p[0] != '\0') {
  5581. value = atoi(modif_p);
  5582. if (value == 0)
  5583. modif_p++;
  5584. else {
  5585. if (modif_p[0] == '-' || modif_p[0] == '+')
  5586. modif_p++;
  5587. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  5588. modif_p++;
  5589. if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  5590. minute = value;
  5591. modif_p = modif_p + 2;
  5592. } else if (modif_p[0] == 'h') {
  5593. hour = value;
  5594. modif_p++;
  5595. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  5596. day = value;
  5597. modif_p++;
  5598. } else if (modif_p[0] == 'm') {
  5599. month = value;
  5600. modif_p++;
  5601. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  5602. year = value;
  5603. modif_p++;
  5604. } else if (modif_p[0] != '\0') {
  5605. modif_p++;
  5606. }
  5607. }
  5608. }
  5609. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  5610. clif_displaymessage(fd, "Invalid time for jail command.");
  5611. return -1;
  5612. }
  5613. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  5614. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5615. return -1;
  5616. }
  5617. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  5618. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5619. return -1;
  5620. }
  5621. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  5622. if(jailtime==0) {
  5623. clif_displaymessage(fd, "Invalid time for jail command.");
  5624. return -1;
  5625. }
  5626. //Added by Coltaro
  5627. if (pl_sd->sc.count && pl_sd->sc.data[SC_JAILED].timer != -1)
  5628. { //Update the player's jail time
  5629. jailtime += pl_sd->sc.data[SC_JAILED].val1;
  5630. if (jailtime <= 0) {
  5631. jailtime = 0;
  5632. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  5633. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  5634. } else {
  5635. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  5636. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  5637. clif_displaymessage(pl_sd->fd, atcmd_output);
  5638. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  5639. clif_displaymessage(fd, atcmd_output);
  5640. }
  5641. } else if (jailtime < 0) {
  5642. clif_displaymessage(fd, "Invalid time for jail command.");
  5643. return -1;
  5644. }
  5645. //Jail locations, add more as you wish.
  5646. switch(rand()%2)
  5647. {
  5648. case 1: //Jail #1
  5649. m_index = mapindex_name2id(MAP_JAIL);
  5650. x = 49; y = 75;
  5651. break;
  5652. default: //Default Jail
  5653. m_index = mapindex_name2id(MAP_JAIL);
  5654. x = 24; y = 75;
  5655. break;
  5656. }
  5657. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  5658. return 0;
  5659. }
  5660. //By Coltaro
  5661. int atcommand_jailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5662. {
  5663. int year, month, day, hour, minute;
  5664. nullpo_retr(-1, sd);
  5665. if (sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5666. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  5667. return -1;
  5668. }
  5669. if (!sd->sc.count || sd->sc.data[SC_JAILED].timer == -1 || sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  5670. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  5671. return -1;
  5672. }
  5673. //Get remaining jail time
  5674. get_jail_time(sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5675. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  5676. clif_displaymessage(fd, atcmd_output);
  5677. return 0;
  5678. }
  5679. //By Coltaro
  5680. int atcommand_charjailtime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5681. {
  5682. struct map_session_data* pl_sd;
  5683. int year, month, day, hour, minute;
  5684. nullpo_retr(-1, sd);
  5685. if (!message || !*message || sscanf(message, "%[^\n]", atcmd_player_name) < 1) {
  5686. clif_displaymessage(fd, "Please, enter a player name (usage: @charjailtime <character name>).");
  5687. return -1;
  5688. }
  5689. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5690. if (pc_isGM(pl_sd) < pc_isGM(sd)) { // only lower or same level
  5691. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5692. clif_displaymessage(fd, "This player is not in jail."); // You are not in jail.
  5693. return -1;
  5694. }
  5695. if (!pl_sd->sc.count || pl_sd->sc.data[SC_JAILED].timer == -1 || pl_sd->sc.data[SC_JAILED].val1 <= 0) { // Was not jailed with @jailfor (maybe @jail?)
  5696. clif_displaymessage(fd, "This player has been jailed for an unknown amount of time.");
  5697. return -1;
  5698. }
  5699. //Get remaining jail time
  5700. get_jail_time(pl_sd->sc.data[SC_JAILED].val1,&year,&month,&day,&hour,&minute);
  5701. sprintf(atcmd_output,msg_txt(402),"This player will remain",year,month,day,hour,minute);
  5702. clif_displaymessage(fd, atcmd_output);
  5703. } else {
  5704. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player.
  5705. return -1;
  5706. }
  5707. } else {
  5708. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5709. return -1;
  5710. }
  5711. return 0;
  5712. }
  5713. /*==========================================
  5714. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5715. *------------------------------------------
  5716. */
  5717. int atcommand_disguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5718. {
  5719. int id = 0;
  5720. nullpo_retr(-1, sd);
  5721. if (!message || !*message) {
  5722. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5723. return -1;
  5724. }
  5725. if ((id = atoi(message)) > 0)
  5726. { //Acquired an ID
  5727. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5728. id = 0; //Invalid id for either mobs or npcs.
  5729. } else { //Acquired a Name
  5730. if ((id = mobdb_searchname(message)) == 0)
  5731. {
  5732. struct npc_data* nd = npc_name2id(message);
  5733. if (nd != NULL)
  5734. id = nd->n;
  5735. }
  5736. }
  5737. if (id == 0)
  5738. { // Monster/NPC name/id hasn't been found.
  5739. clif_displaymessage(fd, msg_txt(123));
  5740. return -1;
  5741. }
  5742. pc_disguise(sd, id);
  5743. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * DisguiseAll
  5748. *------------------------------------------
  5749. */
  5750. int atcommand_disguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5751. {
  5752. int mob_id=0, i=0, users;
  5753. struct map_session_data *pl_sd, **pl_allsd;
  5754. nullpo_retr(-1, sd);
  5755. if (!message || !*message) {
  5756. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5757. return -1;
  5758. }
  5759. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5760. mob_id = atoi(message);
  5761. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5762. pl_allsd = map_getallusers(&users);
  5763. for(i=0; i < users; i++) {
  5764. if((pl_sd = pl_allsd[i]))
  5765. pc_disguise(pl_sd, mob_id);
  5766. }
  5767. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  5768. } else {
  5769. return -1;
  5770. }
  5771. return 0;
  5772. }
  5773. /*==========================================
  5774. * @undisguise by [Yor]
  5775. *------------------------------------------
  5776. */
  5777. int atcommand_undisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5778. {
  5779. nullpo_retr(-1, sd);
  5780. if (sd->disguise) {
  5781. pc_disguise(sd, 0);
  5782. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5783. } else {
  5784. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  5785. return -1;
  5786. }
  5787. return 0;
  5788. }
  5789. /*==========================================
  5790. * UndisguiseAll
  5791. *------------------------------------------
  5792. */
  5793. int atcommand_undisguiseall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5794. {
  5795. struct map_session_data *pl_sd, **pl_allsd;
  5796. int i, users;
  5797. nullpo_retr(-1, sd);
  5798. pl_allsd = map_getallusers(&users);
  5799. for(i=0; i < users; i++) {
  5800. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5801. pc_disguise(pl_sd, 0);
  5802. }
  5803. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  5804. return 0;
  5805. }
  5806. /*==========================================
  5807. * @exp by [Skotlex]
  5808. *------------------------------------------
  5809. */
  5810. int atcommand_exp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5811. {
  5812. char output[200];
  5813. double nextb, nextj;
  5814. nullpo_retr(-1, sd);
  5815. memset(output, '\0', sizeof(output));
  5816. nextb = pc_nextbaseexp(sd);
  5817. if (nextb)
  5818. nextb = sd->status.base_exp*100.0/nextb;
  5819. nextj = pc_nextjobexp(sd);
  5820. if (nextj)
  5821. nextj = sd->status.job_exp*100.0/nextj;
  5822. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5823. clif_displaymessage(fd, output);
  5824. return 0;
  5825. }
  5826. /*==========================================
  5827. * @broadcast by [Valaris]
  5828. *------------------------------------------
  5829. */
  5830. int atcommand_broadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5831. {
  5832. nullpo_retr(-1, sd);
  5833. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5834. if (!message || !*message) {
  5835. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5836. return -1;
  5837. }
  5838. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5839. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5840. return 0;
  5841. }
  5842. /*==========================================
  5843. * @localbroadcast by [Valaris]
  5844. *------------------------------------------
  5845. */
  5846. int atcommand_localbroadcast(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5847. {
  5848. nullpo_retr(-1, sd);
  5849. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5850. if (!message || !*message) {
  5851. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5852. return -1;
  5853. }
  5854. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5855. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5856. return 0;
  5857. }
  5858. /*==========================================
  5859. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5860. *------------------------------------------
  5861. */
  5862. int atcommand_chardisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5863. {
  5864. int mob_id;
  5865. char mob_name[NAME_LENGTH];
  5866. struct map_session_data* pl_sd;
  5867. nullpo_retr(-1, sd);
  5868. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5869. memset(mob_name, '\0', sizeof(mob_name));
  5870. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5871. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5872. return -1;
  5873. }
  5874. if ((mob_id = atoi(mob_name)) > 0)
  5875. { //Acquired an ID
  5876. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5877. mob_id = 0; //Invalid id for either mobs or npcs.
  5878. } else { //Acquired a Name
  5879. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5880. {
  5881. struct npc_data* nd = npc_name2id(mob_name);
  5882. if (nd != NULL)
  5883. mob_id = nd->n;
  5884. }
  5885. }
  5886. if (mob_id == 0)
  5887. {
  5888. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found.
  5889. return -1;
  5890. }
  5891. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5892. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5893. pc_disguise(pl_sd, mob_id);
  5894. clif_displaymessage(fd, msg_txt(140)); // Character's disguise applied.
  5895. } else {
  5896. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5897. return -1;
  5898. }
  5899. } else {
  5900. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5901. return -1;
  5902. }
  5903. return 0;
  5904. }
  5905. /*==========================================
  5906. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5907. *------------------------------------------
  5908. */
  5909. int atcommand_charundisguise(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5910. {
  5911. struct map_session_data* pl_sd;
  5912. nullpo_retr(-1, sd);
  5913. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5914. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5915. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5916. return -1;
  5917. }
  5918. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5919. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5920. if (pl_sd->disguise)
  5921. pc_disguise(pl_sd, 0);
  5922. else {
  5923. clif_displaymessage(fd, msg_txt(142)); // Character is not disguised.
  5924. return -1;
  5925. }
  5926. } else {
  5927. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5928. return -1;
  5929. }
  5930. } else {
  5931. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5932. return -1;
  5933. }
  5934. return 0;
  5935. }
  5936. /*==========================================
  5937. * @email <actual@email> <new@email> by [Yor]
  5938. *------------------------------------------
  5939. */
  5940. int atcommand_email(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5941. {
  5942. char actual_email[100];
  5943. char new_email[100];
  5944. nullpo_retr(-1, sd);
  5945. memset(actual_email, '\0', sizeof(actual_email));
  5946. memset(new_email, '\0', sizeof(new_email));
  5947. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5948. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5949. return -1;
  5950. }
  5951. if (e_mail_check(actual_email) == 0) {
  5952. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  5953. return -1;
  5954. } else if (e_mail_check(new_email) == 0) {
  5955. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  5956. return -1;
  5957. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5958. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  5959. return -1;
  5960. } else if (strcmpi(actual_email, new_email) == 0) {
  5961. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  5962. return -1;
  5963. } else {
  5964. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5965. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  5966. }
  5967. return 0;
  5968. }
  5969. /*==========================================
  5970. *@effect
  5971. *------------------------------------------
  5972. */
  5973. int atcommand_effect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5974. {
  5975. int type = 0, flag = 0;
  5976. nullpo_retr(-1, sd);
  5977. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5978. clif_displaymessage(fd, "Please, enter a type and a send flag (usage: @effect <type> <flag>).");
  5979. return -1;
  5980. }
  5981. clif_specialeffect(&sd->bl, type, flag);
  5982. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  5983. return 0;
  5984. }
  5985. /*==========================================
  5986. * @charcartlist <character>: Displays the items list of a player's cart.
  5987. *------------------------------------------
  5988. */
  5989. int atcommand_character_cart_list(const int fd, struct map_session_data* sd, const char* command, const char* message)
  5990. {
  5991. char outputtmp[200];
  5992. struct map_session_data *pl_sd;
  5993. struct item_data *item_data, *item_temp;
  5994. int i, j, count, counter, counter2;
  5995. nullpo_retr(-1, sd);
  5996. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5997. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5998. memset(outputtmp, '\0', sizeof(outputtmp));
  5999. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6000. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6001. return -1;
  6002. }
  6003. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6004. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6005. counter = 0;
  6006. count = 0;
  6007. for (i = 0; i < MAX_CART; i++) {
  6008. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6009. counter = counter + pl_sd->status.cart[i].amount;
  6010. count++;
  6011. if (count == 1) {
  6012. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6013. clif_displaymessage(fd, atcmd_output);
  6014. }
  6015. if (pl_sd->status.cart[i].refine)
  6016. sprintf(atcmd_output, "%d %s %+d (%s %+d, id: %d)", pl_sd->status.cart[i].amount, item_data->name, pl_sd->status.cart[i].refine, item_data->jname, pl_sd->status.cart[i].refine, pl_sd->status.cart[i].nameid);
  6017. else
  6018. sprintf(atcmd_output, "%d %s (%s, id: %d)", pl_sd->status.cart[i].amount, item_data->name, item_data->jname, pl_sd->status.cart[i].nameid);
  6019. clif_displaymessage(fd, atcmd_output);
  6020. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6021. counter2 = 0;
  6022. for (j = 0; j < item_data->slot; j++) {
  6023. if (pl_sd->status.cart[i].card[j]) {
  6024. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6025. if (atcmd_output[0] == '\0')
  6026. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6027. else
  6028. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6029. strcat(atcmd_output, outputtmp);
  6030. }
  6031. }
  6032. }
  6033. if (atcmd_output[0] != '\0') {
  6034. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6035. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6036. clif_displaymessage(fd, atcmd_output);
  6037. }
  6038. }
  6039. }
  6040. if (count == 0)
  6041. clif_displaymessage(fd, "No item found in the cart of this player.");
  6042. else {
  6043. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6044. clif_displaymessage(fd, atcmd_output);
  6045. }
  6046. } else {
  6047. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6048. return -1;
  6049. }
  6050. } else {
  6051. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6052. return -1;
  6053. }
  6054. return 0;
  6055. }
  6056. /*==========================================
  6057. * @killer by MouseJstr
  6058. * enable killing players even when not in pvp
  6059. *------------------------------------------
  6060. */
  6061. int atcommand_killer(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6062. {
  6063. nullpo_retr(-1, sd);
  6064. sd->state.killer = !sd->state.killer;
  6065. if(sd->state.killer)
  6066. clif_displaymessage(fd, msg_txt(241));
  6067. else
  6068. clif_displaymessage(fd, msg_txt(287));
  6069. return 0;
  6070. }
  6071. /*==========================================
  6072. * @killable by MouseJstr
  6073. * enable other people killing you
  6074. *------------------------------------------
  6075. */
  6076. int atcommand_killable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6077. {
  6078. nullpo_retr(-1, sd);
  6079. sd->state.killable = !sd->state.killable;
  6080. if(sd->state.killable)
  6081. clif_displaymessage(fd, msg_txt(242));
  6082. else
  6083. clif_displaymessage(fd, msg_txt(288));
  6084. return 0;
  6085. }
  6086. /*==========================================
  6087. * @charkillable by MouseJstr
  6088. * enable another player to be killed
  6089. *------------------------------------------
  6090. */
  6091. int atcommand_charkillable(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6092. {
  6093. struct map_session_data *pl_sd = NULL;
  6094. nullpo_retr(-1, sd);
  6095. if (!message || !*message)
  6096. return -1;
  6097. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6098. return -1;
  6099. pl_sd->state.killable = !pl_sd->state.killable;
  6100. if(pl_sd->state.killable)
  6101. clif_displaymessage(fd, msg_txt(289));
  6102. else
  6103. clif_displaymessage(fd, msg_txt(290));
  6104. return 0;
  6105. }
  6106. /*==========================================
  6107. * @skillon by MouseJstr
  6108. * turn skills on for the map
  6109. *------------------------------------------
  6110. */
  6111. int atcommand_skillon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6112. {
  6113. nullpo_retr(-1, sd);
  6114. map[sd->bl.m].flag.noskill = 0;
  6115. clif_displaymessage(fd, msg_txt(244));
  6116. return 0;
  6117. }
  6118. /*==========================================
  6119. * @skilloff by MouseJstr
  6120. * Turn skills off on the map
  6121. *------------------------------------------
  6122. */
  6123. int atcommand_skilloff(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6124. {
  6125. nullpo_retr(-1, sd);
  6126. map[sd->bl.m].flag.noskill = 1;
  6127. clif_displaymessage(fd, msg_txt(243));
  6128. return 0;
  6129. }
  6130. /*==========================================
  6131. * @npcmove by MouseJstr
  6132. * move a npc
  6133. *------------------------------------------
  6134. */
  6135. int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6136. {
  6137. int x = 0, y = 0, m;
  6138. struct npc_data *nd = 0;
  6139. nullpo_retr(-1, sd);
  6140. if (!message || !*message)
  6141. return -1;
  6142. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6143. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6144. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6145. return -1;
  6146. }
  6147. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6148. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6149. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6150. return -1;
  6151. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6152. return -1; //Not on a map.
  6153. if (x < 0) x = 0;
  6154. else if (x >= map[m].xs) x = map[m].xs-1;
  6155. if (y < 0) y = 0;
  6156. else if (y >= map[m].ys) y = map[m].ys-1;
  6157. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6158. map_moveblock(&nd->bl, x, y, gettick());
  6159. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6160. return 0;
  6161. }
  6162. /*==========================================
  6163. * @addwarp by MouseJstr
  6164. * Create a new static warp point.
  6165. *------------------------------------------
  6166. */
  6167. int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6168. {
  6169. char w1[64], w3[64], w4[64];
  6170. int x,y,ret;
  6171. nullpo_retr(-1, sd);
  6172. if (!message || !*message)
  6173. return -1;
  6174. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6175. return -1;
  6176. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6177. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6178. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6179. ret = npc_parse_warp(w1, "warp", w3, w4);
  6180. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6181. clif_displaymessage(fd, atcmd_output);
  6182. return ret;
  6183. }
  6184. /*==========================================
  6185. * @follow by [MouseJstr]
  6186. * Follow a player .. staying no more then 5 spaces away
  6187. *------------------------------------------
  6188. */
  6189. int atcommand_follow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6190. {
  6191. struct map_session_data *pl_sd = NULL;
  6192. nullpo_retr(-1, sd);
  6193. if (!message || !*message) {
  6194. if (sd->followtarget == -1)
  6195. return -1;
  6196. pc_stop_following (sd);
  6197. clif_displaymessage(fd, "Follow mode OFF.");
  6198. return 0;
  6199. }
  6200. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6201. if (sd->followtarget == pl_sd->bl.id) {
  6202. pc_stop_following (sd);
  6203. clif_displaymessage(fd, "Follow mode OFF.");
  6204. } else {
  6205. pc_follow(sd, pl_sd->bl.id);
  6206. clif_displaymessage(fd, "Follow mode ON.");
  6207. }
  6208. return 0;
  6209. } else {
  6210. clif_displaymessage(fd, "Character not found.");
  6211. return -1;
  6212. }
  6213. return 1;
  6214. }
  6215. /*==========================================
  6216. * @dropall by [MouseJstr]
  6217. * Drop all your possession on the ground
  6218. *------------------------------------------
  6219. */
  6220. int atcommand_dropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6221. {
  6222. int i;
  6223. nullpo_retr(-1, sd);
  6224. for (i = 0; i < MAX_INVENTORY; i++) {
  6225. if (sd->status.inventory[i].amount) {
  6226. if(sd->status.inventory[i].equip != 0)
  6227. pc_unequipitem(sd, i, 3);
  6228. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6229. }
  6230. }
  6231. return 0;
  6232. }
  6233. /*==========================================
  6234. * @chardropall by [MouseJstr]
  6235. * Drop all of the target's possessions on the ground
  6236. *------------------------------------------
  6237. */
  6238. int atcommand_chardropall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6239. {
  6240. int i;
  6241. struct map_session_data *pl_sd = NULL;
  6242. nullpo_retr(-1, sd);
  6243. if (!message || !*message)
  6244. return -1;
  6245. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6246. return -1;
  6247. for (i = 0; i < MAX_INVENTORY; i++) {
  6248. if (pl_sd->status.inventory[i].amount) {
  6249. if(pl_sd->status.inventory[i].equip != 0)
  6250. pc_unequipitem(pl_sd, i, 3);
  6251. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6252. }
  6253. }
  6254. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6255. clif_displaymessage(fd, "It is done");
  6256. return 0;
  6257. }
  6258. /*==========================================
  6259. * @storeall by [MouseJstr]
  6260. * Put everything into storage
  6261. *------------------------------------------
  6262. */
  6263. int atcommand_storeall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6264. {
  6265. int i;
  6266. nullpo_retr(-1, sd);
  6267. if (sd->state.storage_flag != 1)
  6268. { //Open storage.
  6269. switch (storage_storageopen(sd)) {
  6270. case 2: //Try again
  6271. clif_displaymessage(fd, "run this command again..");
  6272. return 0;
  6273. case 1: //Failure
  6274. clif_displaymessage(fd, "You can't open the storage currently.");
  6275. return -1;
  6276. }
  6277. }
  6278. for (i = 0; i < MAX_INVENTORY; i++) {
  6279. if (sd->status.inventory[i].amount) {
  6280. if(sd->status.inventory[i].equip != 0)
  6281. pc_unequipitem(sd, i, 3);
  6282. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6283. }
  6284. }
  6285. storage_storageclose(sd);
  6286. clif_displaymessage(fd, "It is done");
  6287. return 0;
  6288. }
  6289. /*==========================================
  6290. * @charstoreall by [MouseJstr]
  6291. * A way to screw with players who piss you off
  6292. *------------------------------------------
  6293. */
  6294. int atcommand_charstoreall(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6295. {
  6296. int i;
  6297. struct map_session_data *pl_sd = NULL;
  6298. nullpo_retr(-1, sd);
  6299. if (!message || !*message)
  6300. return -1;
  6301. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6302. return -1;
  6303. if (pl_sd->state.storage_flag != 1)
  6304. { //Open storage.
  6305. switch (storage_storageopen(pl_sd)) {
  6306. case 2: //Try again
  6307. clif_displaymessage(fd, "Had to open the characters storage window...");
  6308. clif_displaymessage(fd, "run this command again..");
  6309. return 0;
  6310. case 1: //Failure
  6311. clif_displaymessage(fd, "The character currently can't use the storage.");
  6312. return 1;
  6313. }
  6314. }
  6315. for (i = 0; i < MAX_INVENTORY; i++) {
  6316. if (pl_sd->status.inventory[i].amount) {
  6317. if(pl_sd->status.inventory[i].equip != 0)
  6318. pc_unequipitem(pl_sd, i, 3);
  6319. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6320. }
  6321. }
  6322. storage_storageclose(pl_sd);
  6323. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6324. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6325. clif_displaymessage(pl_sd->fd, " -- the management");
  6326. clif_displaymessage(fd, "It is done");
  6327. return 0;
  6328. }
  6329. /*==========================================
  6330. * @skillid by [MouseJstr]
  6331. * lookup a skill by name
  6332. *------------------------------------------
  6333. */
  6334. int atcommand_skillid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6335. {
  6336. int skillen, idx;
  6337. nullpo_retr(-1, sd);
  6338. if (!message || !*message)
  6339. return -1;
  6340. skillen = strlen(message);
  6341. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6342. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6343. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6344. {
  6345. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6346. clif_displaymessage(fd, atcmd_output);
  6347. }
  6348. }
  6349. return 0;
  6350. }
  6351. /*==========================================
  6352. * @useskill by [MouseJstr]
  6353. * A way of using skills without having to find them in the skills menu
  6354. *------------------------------------------
  6355. */
  6356. int atcommand_useskill(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6357. {
  6358. struct map_session_data *pl_sd = NULL;
  6359. struct block_list *bl;
  6360. int skillnum;
  6361. int skilllv;
  6362. char target[255];
  6363. nullpo_retr(-1, sd);
  6364. if (!message || !*message)
  6365. return -1;
  6366. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6367. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6368. return -1;
  6369. }
  6370. if((pl_sd=map_nick2sd(target)) == NULL) {
  6371. return -1;
  6372. }
  6373. if (skillnum >= HM_SKILLBASE && skillnum <= HM_SKILLBASE+MAX_HOMUNSKILL
  6374. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  6375. bl = &sd->hd->bl;
  6376. else
  6377. bl = &sd->bl;
  6378. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6379. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6380. else
  6381. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  6382. return 0;
  6383. }
  6384. /*==========================================
  6385. * @skilltree by [MouseJstr]
  6386. * prints the skill tree for a player required to get to a skill
  6387. *------------------------------------------
  6388. */
  6389. int atcommand_skilltree(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6390. {
  6391. struct map_session_data *pl_sd = NULL;
  6392. int skillnum, skillidx = -1;
  6393. int meets = 1, j, c=0;
  6394. char target[NAME_LENGTH], *tbl;
  6395. struct skill_tree_entry *ent;
  6396. nullpo_retr(-1, sd);
  6397. if (!message || !*message)
  6398. return -1;
  6399. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6400. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6401. return -1;
  6402. }
  6403. if((pl_sd=map_nick2sd(target)) == NULL)
  6404. return -1;
  6405. c = pc_calc_skilltree_normalize_job(pl_sd);
  6406. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6407. tbl = job_name(c);
  6408. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6409. tbl, pc_checkskill(pl_sd, 1));
  6410. clif_displaymessage(fd, atcmd_output);
  6411. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6412. if (skill_tree[c][j].id == skillnum) {
  6413. skillidx = j;
  6414. break;
  6415. }
  6416. }
  6417. if (skillidx == -1) {
  6418. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6419. clif_displaymessage(fd, atcmd_output);
  6420. return 0;
  6421. }
  6422. ent = &skill_tree[c][skillidx];
  6423. for(j=0;j<5;j++)
  6424. if( ent->need[j].id &&
  6425. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6426. {
  6427. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6428. sprintf(atcmd_output, "player requires level %d of skill %s",
  6429. ent->need[j].lv, desc);
  6430. clif_displaymessage(fd, atcmd_output);
  6431. meets = 0;
  6432. }
  6433. if (meets == 1) {
  6434. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6435. clif_displaymessage(fd, atcmd_output);
  6436. }
  6437. return 0;
  6438. }
  6439. // Hand a ring with partners name on it to this char
  6440. void getring (struct map_session_data *sd)
  6441. {
  6442. int flag,item_id = 0;
  6443. struct item item_tmp;
  6444. if(sd->status.sex==0)
  6445. item_id = 2635;
  6446. else
  6447. item_id = 2634;
  6448. memset(&item_tmp,0,sizeof(item_tmp));
  6449. item_tmp.nameid=item_id;
  6450. item_tmp.identify=1;
  6451. item_tmp.card[0]=255;
  6452. item_tmp.card[2]=sd->status.partner_id;
  6453. item_tmp.card[3]=sd->status.partner_id >> 16;
  6454. //Logs (A)dmins items [Lupus]
  6455. if(log_config.enable_logs&0x400)
  6456. log_pick_pc(sd, "A", item_id, 1, &item_tmp);
  6457. if((flag = pc_additem(sd,&item_tmp,1))) {
  6458. clif_additem(sd,0,0,flag);
  6459. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6460. }
  6461. }
  6462. /*==========================================
  6463. * @marry by [MouseJstr], fixed by Lupus
  6464. * Marry two players
  6465. *------------------------------------------
  6466. */
  6467. int atcommand_marry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6468. {
  6469. struct map_session_data *pl_sd1 = NULL;
  6470. struct map_session_data *pl_sd2 = NULL;
  6471. char player1[128], player2[128]; //Length used for return error msgs
  6472. nullpo_retr(-1, sd);
  6473. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  6474. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6475. return -1;
  6476. }
  6477. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6478. sprintf(player2, "Cannot find player '%s' online", player1);
  6479. clif_displaymessage(fd, player2);
  6480. return -1;
  6481. }
  6482. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6483. sprintf(player1, "Cannot find player '%s' online", player2);
  6484. clif_displaymessage(fd, player1);
  6485. return -1;
  6486. }
  6487. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6488. clif_displaymessage(fd, "They are married.. wish them well");
  6489. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6490. // Auto-give named rings (Aru)
  6491. getring (pl_sd1);
  6492. getring (pl_sd2);
  6493. return 0;
  6494. }
  6495. return -1;
  6496. }
  6497. /*==========================================
  6498. * @divorce by [MouseJstr], fixed by [Lupus]
  6499. * divorce two players
  6500. *------------------------------------------
  6501. */
  6502. int atcommand_divorce(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6503. {
  6504. struct map_session_data *pl_sd = NULL;
  6505. nullpo_retr(-1, sd);
  6506. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6507. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6508. return -1;
  6509. }
  6510. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6511. if (pc_divorce(pl_sd) != 0) {
  6512. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6513. clif_displaymessage(fd, atcmd_output);
  6514. return -1;
  6515. } else {
  6516. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6517. clif_displaymessage(fd, atcmd_output);
  6518. return 0;
  6519. }
  6520. }
  6521. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6522. clif_displaymessage(fd, atcmd_output);
  6523. return -1;
  6524. }
  6525. #ifdef DMALLOC
  6526. unsigned long dmark_;
  6527. int atcommand_dmstart(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6528. {
  6529. dmark_ = dmalloc_mark();
  6530. clif_displaymessage(fd, "debug mark set");
  6531. return 0;
  6532. }
  6533. int atcommand_dmtick(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6534. {
  6535. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6536. dmark_ = dmalloc_mark();
  6537. clif_displaymessage(fd, "malloc changes logged");
  6538. return 0;
  6539. }
  6540. #endif
  6541. /*==========================================
  6542. * @grind by [MouseJstr]
  6543. *------------------------------------------
  6544. */
  6545. int atcommand_grind(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6546. {
  6547. struct map_session_data *pl_sd = NULL;
  6548. int skillnum;
  6549. int inf;
  6550. char target[NAME_LENGTH];
  6551. nullpo_retr(-1, sd);
  6552. if (!message || !*message)
  6553. return -1;
  6554. if(sscanf(message, "%23s", target) != 1) {
  6555. clif_displaymessage(fd, "Usage: @grind <target>");
  6556. return -1;
  6557. }
  6558. if((pl_sd=map_nick2sd(target)) == NULL)
  6559. return -1;
  6560. for (skillnum = 1; skillnum < 500; skillnum++) {
  6561. sd->status.sp = sd->status.max_sp;
  6562. atcommand_alive(fd, sd, command, message);
  6563. inf = skill_get_inf(skillnum);
  6564. if (inf & INF_GROUND_SKILL)
  6565. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6566. else if (!(inf & INF_SUPPORT_SKILL))
  6567. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6568. }
  6569. return 0;
  6570. }
  6571. /*==========================================
  6572. * @grind2 by [MouseJstr]
  6573. *------------------------------------------
  6574. */
  6575. int atcommand_grind2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6576. {
  6577. int i;
  6578. short x, y;
  6579. for (i = 1000; i < MAX_MOB_DB; i++) {
  6580. if (!mobdb_checkid(i))
  6581. continue;
  6582. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6583. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6584. }
  6585. return 0;
  6586. }
  6587. /*==========================================
  6588. * @changelook by [Celest]
  6589. *------------------------------------------
  6590. */
  6591. int atcommand_changelook(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6592. {
  6593. int i, j = 0, k = 0;
  6594. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6595. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6596. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6597. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6598. return -1;
  6599. } else if (i == 2) {
  6600. if (j < 1) j = 1;
  6601. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6602. j = pos[j - 1];
  6603. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6604. k = j; // swap
  6605. j = LOOK_HEAD_TOP;
  6606. }
  6607. clif_changelook(&sd->bl,j,k);
  6608. return 0;
  6609. }
  6610. /*==========================================
  6611. * @autotrade by durf (changed by Lupus)
  6612. * Turns on/off Autotrade for a specific player
  6613. *------------------------------------------
  6614. */
  6615. int atcommand_autotrade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6616. {
  6617. nullpo_retr(-1, sd);
  6618. if (sd->vender_id) //check if player's vending
  6619. {
  6620. sd->state.autotrade = 1;
  6621. clif_authfail_fd(fd, 15);
  6622. }
  6623. else
  6624. {
  6625. //"You should be vending to use @Autotrade."
  6626. clif_displaymessage(fd, msg_txt(549));
  6627. }
  6628. return 0;
  6629. }
  6630. /*==========================================
  6631. * @changegm by durf (changed by Lupus)
  6632. * Changes Master of your Guild to a specified guild member
  6633. *------------------------------------------
  6634. */
  6635. int atcommand_changegm(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6636. {
  6637. struct guild *g;
  6638. struct map_session_data *pl_sd;
  6639. nullpo_retr(-1, sd);
  6640. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6641. {
  6642. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6643. return -1;
  6644. }
  6645. if (strlen(message)==0)
  6646. {
  6647. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6648. return -1;
  6649. }
  6650. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6651. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6652. return -1;
  6653. }
  6654. guild_gm_change(sd->status.guild_id, pl_sd);
  6655. return 0;
  6656. }
  6657. /*==========================================
  6658. * @changeleader by Skotlex
  6659. * Changes the leader of a party.
  6660. *------------------------------------------
  6661. */
  6662. int atcommand_changeleader(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6663. {
  6664. struct party_data *p;
  6665. struct map_session_data *pl_sd;
  6666. int mi, pl_mi;
  6667. nullpo_retr(-1, sd);
  6668. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6669. { //Need to be a party leader.
  6670. clif_displaymessage(fd, msg_txt(282));
  6671. return -1;
  6672. }
  6673. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6674. if (mi == MAX_PARTY)
  6675. return -1; //Shouldn't happen
  6676. if (!p->party.member[mi].leader)
  6677. { //Need to be a party leader.
  6678. clif_displaymessage(fd, msg_txt(282));
  6679. return -1;
  6680. }
  6681. if (strlen(message)==0)
  6682. {
  6683. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6684. return -1;
  6685. }
  6686. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6687. clif_displaymessage(fd, msg_txt(283));
  6688. return -1;
  6689. }
  6690. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  6691. if (pl_mi == MAX_PARTY)
  6692. return -1; //Shouldn't happen
  6693. //Change leadership.
  6694. p->party.member[mi].leader = 0;
  6695. if (p->data[mi].sd->fd)
  6696. clif_displaymessage(p->data[mi].sd->fd, msg_txt(284));
  6697. p->party.member[pl_mi].leader = 1;
  6698. if (p->data[pl_mi].sd->fd)
  6699. clif_displaymessage(p->data[pl_mi].sd->fd, msg_txt(285));
  6700. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  6701. //Update info.
  6702. clif_party_main_info(p,-1);
  6703. clif_party_info(p,-1);
  6704. return 0;
  6705. }
  6706. /*==========================================
  6707. * @partyoption by Skotlex
  6708. * Used to change the item share setting of a party.
  6709. *------------------------------------------
  6710. */
  6711. int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6712. {
  6713. struct party_data *p;
  6714. int mi, option;
  6715. char w1[15], w2[15];
  6716. nullpo_retr(-1, sd);
  6717. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6718. {
  6719. clif_displaymessage(fd, msg_txt(282));
  6720. return -1;
  6721. }
  6722. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6723. if (mi == MAX_PARTY)
  6724. return -1; //Shouldn't happen
  6725. if (!p->party.member[mi].leader)
  6726. {
  6727. clif_displaymessage(fd, msg_txt(282));
  6728. return -1;
  6729. }
  6730. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  6731. {
  6732. clif_displaymessage(fd, "Command usage: @changeoption <pickup share: yes/no> <item distribution: yes/no>");
  6733. return -1;
  6734. }
  6735. w1[14] = w2[14] = '\0'; //Assure a proper string terminator.
  6736. option = (battle_config_switch(w1)?1:0)|(battle_config_switch(w2)?2:0);
  6737. //Change item share type.
  6738. if (option != p->party.item)
  6739. party_changeoption(sd, p->party.exp, option);
  6740. else
  6741. clif_displaymessage(fd, msg_txt(286));
  6742. return 0;
  6743. }
  6744. /*==========================================
  6745. * @autoloot by Upa-Kun
  6746. * Turns on/off AutoLoot for a specific player
  6747. *------------------------------------------
  6748. */
  6749. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6750. {
  6751. int rate;
  6752. double drate;
  6753. nullpo_retr(-1, sd);
  6754. // autoloot command without value
  6755. if(!message || !*message)
  6756. {
  6757. if (sd->state.autoloot)
  6758. rate = 0;
  6759. else
  6760. rate = 10000;
  6761. } else {
  6762. drate = atof(message);
  6763. rate = (int)(drate*100);
  6764. }
  6765. if (rate < 0) rate = 0;
  6766. if (rate > 10000) rate = 10000;
  6767. sd->state.autoloot = rate;
  6768. if (sd->state.autoloot) {
  6769. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6770. clif_displaymessage(fd, atcmd_output);
  6771. }else
  6772. clif_displaymessage(fd, "Autoloot is now off.");
  6773. return 0;
  6774. }
  6775. /*==========================================
  6776. * It is made to rain.
  6777. *------------------------------------------
  6778. */
  6779. int atcommand_rain(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6780. {
  6781. nullpo_retr(-1, sd);
  6782. if (map[sd->bl.m].flag.rain) {
  6783. map[sd->bl.m].flag.rain=0;
  6784. clif_weather(sd->bl.m);
  6785. clif_displaymessage(fd, "The rain has stopped.");
  6786. } else {
  6787. map[sd->bl.m].flag.rain=1;
  6788. clif_weather(sd->bl.m);
  6789. clif_displaymessage(fd, "It is made to rain.");
  6790. }
  6791. return 0;
  6792. }
  6793. /*==========================================
  6794. * It is made to snow.
  6795. *------------------------------------------
  6796. */
  6797. int atcommand_snow(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6798. {
  6799. nullpo_retr(-1, sd);
  6800. if (map[sd->bl.m].flag.snow) {
  6801. map[sd->bl.m].flag.snow=0;
  6802. clif_weather(sd->bl.m);
  6803. clif_displaymessage(fd, "Snow has stopped falling.");
  6804. } else {
  6805. map[sd->bl.m].flag.snow=1;
  6806. clif_weather(sd->bl.m);
  6807. clif_displaymessage(fd, "It is made to snow.");
  6808. }
  6809. return 0;
  6810. }
  6811. /*==========================================
  6812. * Cherry tree snowstorm is made to fall. (Sakura)
  6813. *------------------------------------------
  6814. */
  6815. int atcommand_sakura(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6816. {
  6817. nullpo_retr(-1, sd);
  6818. if (map[sd->bl.m].flag.sakura) {
  6819. map[sd->bl.m].flag.sakura=0;
  6820. clif_weather(sd->bl.m);
  6821. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6822. } else {
  6823. map[sd->bl.m].flag.sakura=1;
  6824. clif_weather(sd->bl.m);
  6825. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6826. }
  6827. return 0;
  6828. }
  6829. /*==========================================
  6830. * Clouds appear.
  6831. *------------------------------------------
  6832. */
  6833. int atcommand_clouds(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6834. {
  6835. nullpo_retr(-1, sd);
  6836. if (map[sd->bl.m].flag.clouds) {
  6837. map[sd->bl.m].flag.clouds=0;
  6838. clif_weather(sd->bl.m);
  6839. clif_displaymessage(fd, "The clouds has disappear.");
  6840. } else {
  6841. map[sd->bl.m].flag.clouds=1;
  6842. clif_weather(sd->bl.m);
  6843. clif_displaymessage(fd, "Clouds appear.");
  6844. }
  6845. return 0;
  6846. }
  6847. /*==========================================
  6848. * Different type of clouds using effect 516
  6849. *------------------------------------------
  6850. */
  6851. int atcommand_clouds2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6852. {
  6853. nullpo_retr(-1, sd);
  6854. if (map[sd->bl.m].flag.clouds2) {
  6855. map[sd->bl.m].flag.clouds2=0;
  6856. clif_weather(sd->bl.m);
  6857. clif_displaymessage(fd, "The alternative clouds disappear.");
  6858. } else {
  6859. map[sd->bl.m].flag.clouds2=1;
  6860. clif_weather(sd->bl.m);
  6861. clif_displaymessage(fd, "Alternative clouds appear.");
  6862. }
  6863. return 0;
  6864. }
  6865. /*==========================================
  6866. * Fog hangs over.
  6867. *------------------------------------------
  6868. */
  6869. int atcommand_fog(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6870. {
  6871. nullpo_retr(-1, sd);
  6872. if (map[sd->bl.m].flag.fog) {
  6873. map[sd->bl.m].flag.fog=0;
  6874. clif_weather(sd->bl.m);
  6875. clif_displaymessage(fd, "The fog has gone.");
  6876. } else {
  6877. map[sd->bl.m].flag.fog=1;
  6878. clif_weather(sd->bl.m);
  6879. clif_displaymessage(fd, "Fog hangs over.");
  6880. }
  6881. return 0;
  6882. }
  6883. /*==========================================
  6884. * Fallen leaves fall.
  6885. *------------------------------------------
  6886. */
  6887. int atcommand_leaves(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6888. {
  6889. nullpo_retr(-1, sd);
  6890. if (map[sd->bl.m].flag.leaves) {
  6891. map[sd->bl.m].flag.leaves=0;
  6892. clif_weather(sd->bl.m);
  6893. clif_displaymessage(fd, "Leaves no longer fall.");
  6894. } else {
  6895. map[sd->bl.m].flag.leaves=1;
  6896. clif_weather(sd->bl.m);
  6897. clif_displaymessage(fd, "Fallen leaves fall.");
  6898. }
  6899. return 0;
  6900. }
  6901. /*==========================================
  6902. * Fireworks appear.
  6903. *------------------------------------------
  6904. */
  6905. int atcommand_fireworks(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6906. {
  6907. nullpo_retr(-1, sd);
  6908. if (map[sd->bl.m].flag.fireworks) {
  6909. map[sd->bl.m].flag.fireworks=0;
  6910. clif_weather(sd->bl.m);
  6911. clif_displaymessage(fd, "Fireworks are ended.");
  6912. } else {
  6913. map[sd->bl.m].flag.fireworks=1;
  6914. clif_weather(sd->bl.m);
  6915. clif_displaymessage(fd, "Fireworks are launched.");
  6916. }
  6917. return 0;
  6918. }
  6919. /*==========================================
  6920. * Clearing Weather Effects by Dexity
  6921. *------------------------------------------
  6922. */
  6923. int atcommand_clearweather(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6924. {
  6925. nullpo_retr(-1, sd);
  6926. map[sd->bl.m].flag.rain=0;
  6927. map[sd->bl.m].flag.snow=0;
  6928. map[sd->bl.m].flag.sakura=0;
  6929. map[sd->bl.m].flag.clouds=0;
  6930. map[sd->bl.m].flag.clouds2=0;
  6931. map[sd->bl.m].flag.fog=0;
  6932. map[sd->bl.m].flag.fireworks=0;
  6933. map[sd->bl.m].flag.leaves=0;
  6934. clif_weather(sd->bl.m);
  6935. clif_displaymessage(fd, msg_txt(291));
  6936. return 0;
  6937. }
  6938. /*===============================================================
  6939. * Sound Command - plays a sound for everyone! [Codemaster]
  6940. *---------------------------------------------------------------
  6941. */
  6942. int atcommand_sound(const int fd, struct map_session_data *sd, const char *command, const char *message)
  6943. {
  6944. char sound_file[100];
  6945. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6946. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6947. return -1;
  6948. }
  6949. memset(sound_file, '\0', sizeof(sound_file));
  6950. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6951. return -1;
  6952. if(strstr(sound_file, ".wav") == NULL)
  6953. strcat(sound_file, ".wav");
  6954. clif_soundeffectall(&sd->bl, sound_file,0,2);
  6955. return 0;
  6956. }
  6957. /*==========================================
  6958. * MOB Search
  6959. *------------------------------------------
  6960. */
  6961. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6962. {
  6963. int mob_id,fd;
  6964. static int number=0;
  6965. struct mob_data *md;
  6966. nullpo_retr(0, bl);
  6967. if(!ap){
  6968. number=0;
  6969. return 0;
  6970. }
  6971. mob_id = va_arg(ap,int);
  6972. fd = va_arg(ap,int);
  6973. md = (struct mob_data *)bl;
  6974. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  6975. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  6976. ++number,bl->x, bl->y,md->name);
  6977. clif_displaymessage(fd, atcmd_output);
  6978. }
  6979. return 0;
  6980. }
  6981. int atcommand_mobsearch(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6982. {
  6983. char mob_name[100];
  6984. int mob_id,map_id = 0;
  6985. nullpo_retr(-1, sd);
  6986. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  6987. return -1;
  6988. if ((mob_id = atoi(mob_name)) == 0)
  6989. mob_id = mobdb_searchname(mob_name);
  6990. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6991. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6992. clif_displaymessage(fd, atcmd_output);
  6993. return 0;
  6994. }
  6995. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6996. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6997. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6998. map_id = sd->bl.m;
  6999. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  7000. clif_displaymessage(fd, atcmd_output);
  7001. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7002. atmobsearch_sub(&sd->bl,0); // reset the counter
  7003. return 0;
  7004. }
  7005. /*==========================================
  7006. * @cleanmap - cleans items on the ground
  7007. *------------------------------------------
  7008. */
  7009. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7010. {
  7011. nullpo_retr(0, bl);
  7012. map_clearflooritem(bl->id);
  7013. return 0;
  7014. }
  7015. int atcommand_cleanmap(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7016. {
  7017. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7018. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7019. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7020. BL_ITEM);
  7021. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7022. return 0;
  7023. }
  7024. /*==========================================
  7025. * make a NPC/PET talk
  7026. *------------------------------------------
  7027. */
  7028. int atcommand_npctalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7029. {
  7030. char name[NAME_LENGTH],mes[100],temp[100];
  7031. struct npc_data *nd;
  7032. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7033. return -1;
  7034. if (!(nd = npc_name2id(name)))
  7035. return -1;
  7036. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7037. clif_message(&nd->bl, temp);
  7038. return 0;
  7039. }
  7040. int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7041. {
  7042. char mes[100],temp[100];
  7043. struct pet_data *pd;
  7044. nullpo_retr(-1, sd);
  7045. if(!sd->status.pet_id || !(pd=sd->pd))
  7046. return -1;
  7047. if (sd->sc.count && //no "chatting" while muted.
  7048. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  7049. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  7050. return -1;
  7051. if (sscanf(message, "%99[^\n]", mes) < 1)
  7052. return -1;
  7053. snprintf(temp, sizeof temp ,"%s : %s",pd->pet.name,mes);
  7054. clif_message(&pd->bl, temp);
  7055. return 0;
  7056. }
  7057. /*==========================================
  7058. * @users - displays the number of players present on each map (percentage)
  7059. *------------------------------------------
  7060. */
  7061. static struct dbt *users_db = NULL;
  7062. static int users_all;
  7063. static int atcommand_users_sub1(struct map_session_data* sd,va_list va)
  7064. {
  7065. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7066. users_all++;
  7067. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7068. return 0;
  7069. }
  7070. static int atcommand_users_sub2(DBKey key,void* val,va_list va)
  7071. {
  7072. char buf[256];
  7073. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7074. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7075. clif_displaymessage(sd->fd,buf);
  7076. return 0;
  7077. }
  7078. int atcommand_users(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7079. {
  7080. char buf[256];
  7081. users_all = 0;
  7082. users_db->clear(users_db, NULL);
  7083. clif_foreachclient(atcommand_users_sub1);
  7084. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7085. sprintf(buf,"all : %d",users_all);
  7086. clif_displaymessage(fd,buf);
  7087. return 0;
  7088. }
  7089. /*==========================================
  7090. *
  7091. *------------------------------------------
  7092. */
  7093. int atcommand_reset(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7094. {
  7095. pc_resetstate(sd);
  7096. pc_resetskill(sd,1);
  7097. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  7098. clif_displaymessage(fd, atcmd_output);
  7099. return 0;
  7100. }
  7101. /*==========================================
  7102. *
  7103. *------------------------------------------
  7104. */
  7105. int atcommand_summon(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7106. {
  7107. char name[NAME_LENGTH];
  7108. int mob_id = 0;
  7109. int duration = 0;
  7110. struct mob_data *md;
  7111. unsigned int tick=gettick();
  7112. nullpo_retr(-1, sd);
  7113. if (!message || !*message)
  7114. return -1;
  7115. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7116. return -1;
  7117. if (duration < 1)
  7118. duration =1;
  7119. else if (duration > 60)
  7120. duration =60;
  7121. if ((mob_id = atoi(name)) == 0)
  7122. mob_id = mobdb_searchname(name);
  7123. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7124. return -1;
  7125. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7126. if(md){
  7127. md->master_id=sd->bl.id;
  7128. md->special_state.ai=1;
  7129. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  7130. clif_misceffect2(&md->bl,344);
  7131. mob_spawn(md);
  7132. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7133. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7134. }
  7135. return 0;
  7136. }
  7137. /*==========================================
  7138. * @adjcmdlvl by [MouseJstr]
  7139. *
  7140. * Temp adjust the GM level required to use a GM command
  7141. * Useful during beta testing to allow players to use GM commands for short periods of time
  7142. *------------------------------------------
  7143. */
  7144. int atcommand_adjcmdlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7145. {
  7146. int i, newlev;
  7147. char cmd[100];
  7148. nullpo_retr(-1, sd);
  7149. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7150. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7151. return -1;
  7152. }
  7153. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7154. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7155. atcommand_info[i].level = newlev;
  7156. clif_displaymessage(fd, "@command level changed.");
  7157. return 0;
  7158. }
  7159. clif_displaymessage(fd, "@command not found.");
  7160. return -1;
  7161. }
  7162. /*==========================================
  7163. * @adjgmlvl by [MouseJstr]
  7164. * Create a temp GM
  7165. * Useful during beta testing to allow players to use GM commands for short periods of time
  7166. *------------------------------------------
  7167. */
  7168. int atcommand_adjgmlvl(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7169. {
  7170. int newlev;
  7171. char user[NAME_LENGTH];
  7172. struct map_session_data *pl_sd;
  7173. nullpo_retr(-1, sd);
  7174. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7175. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7176. return -1;
  7177. }
  7178. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7179. return -1;
  7180. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7181. return 0;
  7182. }
  7183. /*==========================================
  7184. * @trade by [MouseJstr]
  7185. * Open a trade window with a remote player
  7186. *------------------------------------------
  7187. */
  7188. int atcommand_trade(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7189. {
  7190. struct map_session_data *pl_sd = NULL;
  7191. nullpo_retr(-1, sd);
  7192. if (!message || !*message)
  7193. return -1;
  7194. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7195. trade_traderequest(sd, pl_sd);
  7196. return 0;
  7197. }
  7198. return -1;
  7199. }
  7200. /*==========================================
  7201. * @setbattleflag by [MouseJstr]
  7202. * set a battle_config flag without having to reboot
  7203. */
  7204. int atcommand_setbattleflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7205. {
  7206. char flag[128], value[128];
  7207. nullpo_retr(-1, sd);
  7208. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7209. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7210. return -1;
  7211. }
  7212. if (battle_set_value(flag, value) == 0)
  7213. clif_displaymessage(fd, "unknown battle_config flag");
  7214. else
  7215. clif_displaymessage(fd, "battle_config set as requested");
  7216. return 0;
  7217. }
  7218. /*===========================
  7219. * @unmute [Valaris]
  7220. *===========================
  7221. */
  7222. int atcommand_unmute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7223. {
  7224. struct map_session_data *pl_sd = NULL;
  7225. nullpo_retr(-1, sd);
  7226. if (!message || !*message)
  7227. return -1;
  7228. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7229. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7230. pl_sd->status.manner = 0;
  7231. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7232. clif_displaymessage(sd->fd,"Player unmuted");
  7233. }
  7234. else
  7235. clif_displaymessage(sd->fd,"Player is not muted");
  7236. }
  7237. return 0;
  7238. }
  7239. /*==========================================
  7240. * @uptime by MC Cameri
  7241. *------------------------------------------
  7242. */
  7243. int atcommand_uptime(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7244. {
  7245. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7246. minute = 60, days = 0, hours = 0, minutes = 0;
  7247. nullpo_retr(-1, sd);
  7248. seconds = get_uptime();
  7249. days = seconds/day;
  7250. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7251. hours = seconds/hour;
  7252. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7253. minutes = seconds/minute;
  7254. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7255. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  7256. clif_displaymessage(fd, atcmd_output);
  7257. return 0;
  7258. }
  7259. /*==========================================
  7260. * @changesex <sex>
  7261. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  7262. *------------------------------------------
  7263. */
  7264. int atcommand_changesex(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7265. {
  7266. nullpo_retr(-1, sd);
  7267. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7268. return 0;
  7269. }
  7270. /*================================================
  7271. * @mute - Mutes a player for a set amount of time
  7272. *------------------------------------------------
  7273. */
  7274. int atcommand_mute(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7275. {
  7276. struct map_session_data *pl_sd = NULL;
  7277. int manner;
  7278. nullpo_retr(-1, sd);
  7279. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7280. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7281. return -1;
  7282. }
  7283. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7284. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7285. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7286. return -1;
  7287. }
  7288. clif_GM_silence(sd, pl_sd, 0);
  7289. pl_sd->status.manner -= manner;
  7290. if(pl_sd->status.manner < 0)
  7291. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7292. }
  7293. else {
  7294. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7295. return -1;
  7296. }
  7297. return 0;
  7298. }
  7299. /*==========================================
  7300. * @refresh (like @jumpto <<yourself>>)
  7301. *------------------------------------------
  7302. */
  7303. int atcommand_refresh(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7304. {
  7305. nullpo_retr(-1, sd);
  7306. clif_refresh(sd);
  7307. return 0;
  7308. }
  7309. /*==========================================
  7310. * @petid <part of pet name>
  7311. * => Displays a list of matching pets.
  7312. *------------------------------------------
  7313. */
  7314. int atcommand_petid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7315. {
  7316. char searchtext[100];
  7317. char temp0[100];
  7318. char temp1[100];
  7319. int cnt = 0, i = 0;
  7320. nullpo_retr(-1, sd);
  7321. if (!message || !*message)
  7322. return -1;
  7323. if (sscanf(message, "%99s", searchtext) < 1)
  7324. return -1;
  7325. estr_lower(searchtext);
  7326. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7327. clif_displaymessage(fd,temp0);
  7328. while (i < MAX_PET_DB) {
  7329. strcpy(temp1,pet_db[i].name);
  7330. strcpy(temp1, estr_lower(temp1));
  7331. strcpy(temp0,pet_db[i].jname);
  7332. strcpy(temp0, estr_lower(temp1));
  7333. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7334. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7335. pet_db[i].jname);
  7336. if (cnt >= 100) { // Only if there are custom pets
  7337. clif_displaymessage(fd, "Be more specific, can't send more than"
  7338. " 100 results.");
  7339. } else {
  7340. clif_displaymessage(fd, temp0);
  7341. }
  7342. cnt++;
  7343. }
  7344. i++;
  7345. }
  7346. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7347. clif_displaymessage(fd, temp0);
  7348. return 0;
  7349. }
  7350. /*==========================================
  7351. * @identify
  7352. * => GM's magnifier.
  7353. *------------------------------------------
  7354. */
  7355. int atcommand_identify(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7356. {
  7357. int i,num;
  7358. nullpo_retr(-1, sd);
  7359. for(i=num=0;i<MAX_INVENTORY;i++){
  7360. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7361. num++;
  7362. }
  7363. }
  7364. if (num > 0) {
  7365. clif_item_identify_list(sd);
  7366. } else {
  7367. clif_displaymessage(fd,"There are no items to appraise.");
  7368. }
  7369. return 0;
  7370. }
  7371. /*==========================================
  7372. * @gmotd (Global MOTD)
  7373. * by davidsiaw :P
  7374. *------------------------------------------
  7375. */
  7376. int atcommand_gmotd(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7377. {
  7378. char buf[256];
  7379. FILE *fp;
  7380. nullpo_retr(-1, sd);
  7381. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7382. while (fgets(buf, 250, fp) != NULL){
  7383. int i;
  7384. for( i=0; buf[i]; i++){
  7385. if( buf[i]=='\r' || buf[i]=='\n'){
  7386. buf[i]=0;
  7387. break;
  7388. }
  7389. }
  7390. intif_GMmessage(buf,strlen(buf)+1,8);
  7391. }
  7392. fclose(fp);
  7393. }
  7394. return 0;
  7395. }
  7396. int atcommand_misceffect(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7397. {
  7398. int effect = 0;
  7399. nullpo_retr(-1, sd);
  7400. if (!message || !*message)
  7401. return -1;
  7402. if (sscanf(message, "%d", &effect) < 1)
  7403. return -1;
  7404. clif_misceffect(&sd->bl,effect);
  7405. return 0;
  7406. }
  7407. /*==========================================
  7408. * Jump to a player by PID number
  7409. * Original by Dino9021
  7410. * Added in by nsstrunks
  7411. *------------------------------------------
  7412. */
  7413. int atcommand_jumptoid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7414. {
  7415. int cid=0;
  7416. struct map_session_data *pl_sd;
  7417. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7418. if (!message || (cid = atoi(message)) == 0) {
  7419. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7420. return -1;
  7421. }
  7422. pl_sd = map_charid2sd(cid);
  7423. if (!pl_sd) {
  7424. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7425. return -1;
  7426. }
  7427. if (map[pl_sd->bl.m].flag.nowarpto &&
  7428. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7429. {
  7430. clif_displaymessage(fd, msg_txt(247));
  7431. return -1;
  7432. }
  7433. if (map[sd->bl.m].flag.nowarp &&
  7434. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7435. {
  7436. clif_displaymessage(fd, msg_txt(248));
  7437. return -1;
  7438. }
  7439. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7440. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7441. clif_displaymessage(fd, atcmd_output);
  7442. return 0;
  7443. }
  7444. /*==========================================
  7445. * Jump to a player by PID number
  7446. * Original by Dino9021
  7447. * Added in by nsstrunks
  7448. *------------------------------------------
  7449. */
  7450. int atcommand_jumptoid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7451. {
  7452. int aid=0;
  7453. struct map_session_data *pl_sd;
  7454. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7455. if (!message || (aid = atoi(message)) == 0) {
  7456. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7457. return -1;
  7458. }
  7459. pl_sd = map_id2sd(aid);
  7460. if (!pl_sd) {
  7461. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7462. return -1;
  7463. }
  7464. if (map[pl_sd->bl.m].flag.nowarpto &&
  7465. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7466. {
  7467. clif_displaymessage(fd, msg_txt(247));
  7468. return -1;
  7469. }
  7470. if (map[sd->bl.m].flag.nowarp &&
  7471. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7472. {
  7473. clif_displaymessage(fd, msg_txt(248));
  7474. return -1;
  7475. }
  7476. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7477. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jump to %s
  7478. clif_displaymessage(fd, atcmd_output);
  7479. return 0;
  7480. }
  7481. /*==========================================
  7482. * Recall a player by PID number
  7483. * Original by Dino9021
  7484. * Added in by nsstrunks
  7485. *------------------------------------------
  7486. */
  7487. int atcommand_recallid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7488. {
  7489. int cid=0;
  7490. struct map_session_data *pl_sd;
  7491. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7492. if (!message || (cid = atoi(message)) == 0) {
  7493. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7494. return -1;
  7495. }
  7496. pl_sd = map_charid2sd(cid);
  7497. if (!pl_sd) {
  7498. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7499. return -1;
  7500. }
  7501. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can recall only lower or same level
  7502. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7503. return -1;
  7504. }
  7505. if (map[pl_sd->bl.m].flag.nowarpto &&
  7506. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7507. {
  7508. clif_displaymessage(fd, msg_txt(247));
  7509. return -1;
  7510. }
  7511. if (map[sd->bl.m].flag.nowarp &&
  7512. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7513. {
  7514. clif_displaymessage(fd, msg_txt(248));
  7515. return -1;
  7516. }
  7517. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7518. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7519. clif_displaymessage(fd, atcmd_output);
  7520. return 0;
  7521. }
  7522. /*==========================================
  7523. * Recall a player by PID number
  7524. * Original by Dino9021
  7525. * Added in by nsstrunks
  7526. *------------------------------------------
  7527. */
  7528. int atcommand_recallid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7529. {
  7530. int aid=0;
  7531. struct map_session_data *pl_sd;
  7532. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7533. if (!message || (aid = atoi(message)) == 0) {
  7534. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7535. return -1;
  7536. }
  7537. pl_sd = map_id2sd(aid);
  7538. if (!pl_sd) {
  7539. clif_displaymessage(fd, msg_txt(154)); // Character not found.
  7540. return -1;
  7541. }
  7542. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7543. { // you can recall only lower or same level
  7544. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7545. return -1;
  7546. }
  7547. if (map[pl_sd->bl.m].flag.nowarpto &&
  7548. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7549. {
  7550. clif_displaymessage(fd, msg_txt(247));
  7551. return -1;
  7552. }
  7553. if (map[sd->bl.m].flag.nowarp &&
  7554. battle_config.any_warp_GM_min_level > pc_isGM(sd))
  7555. {
  7556. clif_displaymessage(fd, msg_txt(248));
  7557. return -1;
  7558. }
  7559. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7560. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // Jump to %s
  7561. clif_displaymessage(fd, atcmd_output);
  7562. return 0;
  7563. }
  7564. /*==========================================
  7565. * Kick a player by PID number
  7566. * Original by Dino9021
  7567. * Added in by nsstrunks
  7568. *------------------------------------------
  7569. */
  7570. int atcommand_kickid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7571. {
  7572. struct map_session_data *pl_sd;
  7573. int cid=0;
  7574. if (!message || (cid = atoi(message)) == 0) {
  7575. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7576. return -1;
  7577. }
  7578. pl_sd = map_charid2sd(cid);
  7579. if (!pl_sd) {
  7580. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7581. return -1;
  7582. }
  7583. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7584. { // you can kick only lower or same gm level
  7585. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7586. return -1;
  7587. }
  7588. clif_GM_kick(sd, pl_sd, 1);
  7589. return 0;
  7590. }
  7591. /*==========================================
  7592. * Kick a player by PID number
  7593. * Original by Dino9021
  7594. * Added in by nsstrunks
  7595. *------------------------------------------
  7596. */
  7597. int atcommand_kickid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7598. {
  7599. struct map_session_data *pl_sd;
  7600. int aid=0;
  7601. if (!message || (aid = atoi(message)) == 0) {
  7602. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7603. return -1;
  7604. }
  7605. pl_sd = map_id2sd(aid);
  7606. if (!pl_sd) {
  7607. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7608. return -1;
  7609. }
  7610. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7611. { // you can kick only lower or same gm level
  7612. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7613. return -1;
  7614. }
  7615. clif_GM_kick(sd, pl_sd, 1);
  7616. return 0;
  7617. }
  7618. /*==========================================
  7619. * Revive a player by PID number
  7620. * Original by Dino9021
  7621. * Added in by nsstrunks
  7622. *------------------------------------------
  7623. */
  7624. int atcommand_reviveid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7625. {
  7626. int cid=0;
  7627. struct map_session_data *pl_sd;
  7628. if (!message || (cid = atoi(message)) == 0) {
  7629. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7630. return -1;
  7631. }
  7632. pl_sd = map_charid2sd(cid);
  7633. if (!pl_sd) {
  7634. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7635. return -1;
  7636. }
  7637. if(!status_revive(&pl_sd->bl, 100, 100))
  7638. return -1;
  7639. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7640. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7641. return 0;
  7642. }
  7643. /*==========================================
  7644. * Revive a player by PID number
  7645. * Original by Dino9021
  7646. * Added in by nsstrunks
  7647. *------------------------------------------
  7648. */
  7649. int atcommand_reviveid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7650. {
  7651. int aid=0;
  7652. struct map_session_data *pl_sd;
  7653. if (!message || (aid = atoi(message)) == 0) {
  7654. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7655. return -1;
  7656. }
  7657. pl_sd = map_id2sd(aid);
  7658. if(!pl_sd) {
  7659. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7660. return -1;
  7661. }
  7662. if(!status_revive(&pl_sd->bl, 100, 100))
  7663. return -1;
  7664. clif_skill_nodamage(&pl_sd->bl,&pl_sd->bl,ALL_RESURRECTION,4,1);
  7665. clif_displaymessage(fd, msg_txt(51)); // Character revived.
  7666. return 0;
  7667. }
  7668. /*==========================================
  7669. * Kill a player by PID number
  7670. * Original by Dino9021
  7671. * Added in by nsstrunks
  7672. *------------------------------------------
  7673. */
  7674. int atcommand_killid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7675. {
  7676. int cid=0;
  7677. struct map_session_data *pl_sd;
  7678. if (!message || (cid = atoi(message)) == 0) {
  7679. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7680. return -1;
  7681. }
  7682. pl_sd = map_charid2sd(cid);
  7683. if (!pl_sd) {
  7684. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7685. return -1;
  7686. }
  7687. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7688. { // you can kill only lower or same level
  7689. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7690. return -1;
  7691. }
  7692. status_kill(&pl_sd->bl);
  7693. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7694. return 0;
  7695. }
  7696. /*==========================================
  7697. * Kill a player by PID number
  7698. * Original by Dino9021
  7699. * Added in by nsstrunks
  7700. *------------------------------------------
  7701. */
  7702. int atcommand_killid2(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7703. {
  7704. int aid=0;
  7705. struct map_session_data *pl_sd;
  7706. if (!message || (aid = atoi(message)) == 0) {
  7707. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7708. return -1;
  7709. }
  7710. pl_sd = map_id2sd(aid);
  7711. if (!pl_sd) {
  7712. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7713. return -1;
  7714. }
  7715. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7716. { // you can kill only lower or same level
  7717. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7718. return -1;
  7719. }
  7720. status_kill(&pl_sd->bl);
  7721. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  7722. return 0;
  7723. }
  7724. /*==========================================
  7725. * Make a player killable, by PID
  7726. * Original by Dino9021
  7727. * Added in by nsstrunks
  7728. *------------------------------------------
  7729. */
  7730. int atcommand_charkillableid(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7731. {
  7732. struct map_session_data *pl_sd = NULL;
  7733. int cid=0;
  7734. if (!message || (cid = atoi(message)) == 0) {
  7735. clif_displaymessage(fd, "Please, enter a player CID.");
  7736. return -1;
  7737. }
  7738. pl_sd = map_charid2sd(cid);
  7739. if (!pl_sd) {
  7740. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7741. return -1;
  7742. }
  7743. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7744. {
  7745. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7746. return -1;
  7747. }
  7748. pl_sd->state.killable = !pl_sd->state.killable;
  7749. if(pl_sd->state.killable)
  7750. clif_displaymessage(fd, msg_txt(289));
  7751. else
  7752. clif_displaymessage(fd, msg_txt(290));
  7753. return 0;
  7754. }
  7755. /*==========================================
  7756. * Make a player killable, by PID
  7757. * Original by Dino9021
  7758. * Added in by nsstrunks
  7759. *------------------------------------------
  7760. */
  7761. int atcommand_charkillableid2( const int fd, struct map_session_data* sd, const char* command, const char* message)
  7762. {
  7763. struct map_session_data *pl_sd = NULL;
  7764. int aid=0;
  7765. if (!message || (aid = atoi(message)) == 0) {
  7766. clif_displaymessage(fd, "Please, enter a player AID.");
  7767. return -1;
  7768. }
  7769. pl_sd = map_id2sd(aid);
  7770. if (!pl_sd) {
  7771. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7772. return -1;
  7773. }
  7774. if (pc_isGM(sd) < pc_isGM(pl_sd))
  7775. {
  7776. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  7777. return -1;
  7778. }
  7779. pl_sd->state.killable = !pl_sd->state.killable;
  7780. if(pl_sd->state.killable)
  7781. clif_displaymessage(fd, msg_txt(289));
  7782. else
  7783. clif_displaymessage(fd, msg_txt(290));
  7784. return 0;
  7785. }
  7786. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  7787. /*==========================================
  7788. * Mail System commands by [Valaris]
  7789. *------------------------------------------
  7790. */
  7791. int atcommand_listmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7792. {
  7793. if(!mail_server_enable)
  7794. return 0;
  7795. nullpo_retr(-1, sd);
  7796. if(strlen(command)==12)
  7797. mail_check(sd,3);
  7798. else if(strlen(command)==9)
  7799. mail_check(sd,2);
  7800. else
  7801. mail_check(sd,1);
  7802. return 0;
  7803. }
  7804. int atcommand_readmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7805. {
  7806. int index;
  7807. if(!mail_server_enable)
  7808. return 0;
  7809. nullpo_retr(-1, sd);
  7810. if (!message || !*message) {
  7811. clif_displaymessage(sd->fd,"You must specify a message number.");
  7812. return 0;
  7813. }
  7814. index = atoi(message);
  7815. if (index < 1) {
  7816. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  7817. return 0;
  7818. }
  7819. if(strlen(command)==11)
  7820. mail_delete(sd,index);
  7821. else
  7822. mail_read(sd,index);
  7823. return 0;
  7824. }
  7825. int atcommand_sendmail(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7826. {
  7827. char name[NAME_LENGTH],text[80];
  7828. if(!mail_server_enable)
  7829. return 0;
  7830. nullpo_retr(-1, sd);
  7831. if (!message || !*message) {
  7832. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7833. return 0;
  7834. }
  7835. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  7836. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  7837. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  7838. return 0;
  7839. }
  7840. if(strlen(command)==17)
  7841. mail_send(sd,name,text,1);
  7842. else
  7843. mail_send(sd,name,text,0);
  7844. return 0;
  7845. }
  7846. /*==========================================
  7847. * Refresh online command for SQL [Valaris]
  7848. * Will refresh and check online column of players and set correctly.
  7849. *------------------------------------------
  7850. */
  7851. int atcommand_refreshonline(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7852. {
  7853. send_users_tochar(-1, gettick(), 0, 0);
  7854. return 0;
  7855. }
  7856. #endif /* end sql only */
  7857. /*==========================================
  7858. * Show Monster DB Info v 1.0
  7859. * originally by [Lupus] eAthena
  7860. *------------------------------------------
  7861. */
  7862. int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7863. {
  7864. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  7865. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  7866. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  7867. char atcmd_output2[200];
  7868. struct item_data *item_data;
  7869. struct mob_db *mob, *mob_array[MAX_SEARCH];
  7870. int count;
  7871. int i, j, k;
  7872. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7873. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  7874. if (!message || !*message) {
  7875. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  7876. return -1;
  7877. }
  7878. // If monster identifier/name argument is a name
  7879. if ((i = mobdb_checkid(atoi(message))))
  7880. {
  7881. mob_array[0] = mob_db(i);
  7882. count = 1;
  7883. } else
  7884. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  7885. if (!count) {
  7886. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  7887. return -1;
  7888. }
  7889. if (count > MAX_SEARCH) {
  7890. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  7891. clif_displaymessage(fd, atcmd_output);
  7892. count = MAX_SEARCH;
  7893. }
  7894. for (k = 0; k < count; k++) {
  7895. mob = mob_array[k];
  7896. // stats
  7897. if (mob->mexp)
  7898. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7899. else
  7900. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  7901. clif_displaymessage(fd, atcmd_output);
  7902. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  7903. clif_displaymessage(fd, atcmd_output);
  7904. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  7905. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  7906. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  7907. clif_displaymessage(fd, atcmd_output);
  7908. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  7909. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  7910. mob->range2 , mob->range3, msize[mob->status.size],
  7911. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  7912. clif_displaymessage(fd, atcmd_output);
  7913. // drops
  7914. clif_displaymessage(fd, " Drops:");
  7915. strcpy(atcmd_output, " ");
  7916. j = 0;
  7917. for (i = 0; i < MAX_MOB_DROP; i++) {
  7918. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  7919. continue;
  7920. if (item_data->slot)
  7921. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  7922. else
  7923. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  7924. strcat(atcmd_output, atcmd_output2);
  7925. if (++j % 3 == 0) {
  7926. clif_displaymessage(fd, atcmd_output);
  7927. strcpy(atcmd_output, " ");
  7928. }
  7929. }
  7930. if (j == 0)
  7931. clif_displaymessage(fd, "This monster has no drops.");
  7932. else if (j % 3 != 0)
  7933. clif_displaymessage(fd, atcmd_output);
  7934. // mvp
  7935. if (mob->mexp) {
  7936. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  7937. clif_displaymessage(fd, atcmd_output);
  7938. strcpy(atcmd_output, " MVP Items:");
  7939. j = 0;
  7940. for (i = 0; i < 3; i++) {
  7941. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  7942. continue;
  7943. if (mob->mvpitem[i].p > 0) {
  7944. j++;
  7945. if (j == 1)
  7946. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7947. else
  7948. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  7949. strcat(atcmd_output, atcmd_output2);
  7950. }
  7951. }
  7952. if (j == 0)
  7953. clif_displaymessage(fd, "This monster has no MVP prizes.");
  7954. else
  7955. clif_displaymessage(fd, atcmd_output);
  7956. }
  7957. }
  7958. return 0;
  7959. }
  7960. /*=========================================
  7961. * @showmobs by KarLaeda
  7962. * => For 5 sec displays the mobs on minimap
  7963. *------------------------------------------
  7964. */
  7965. int atshowmobs_timer(int tid, unsigned int tick, int id, int data)
  7966. {
  7967. struct map_session_data *sd;
  7968. if (!session[id] || (sd = session[id]->session_data) == NULL)
  7969. return 0;
  7970. clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF);
  7971. return 1;
  7972. }
  7973. static int atshowmobs_sub(struct block_list *bl,va_list ap)
  7974. {
  7975. int mob_id,fd;
  7976. struct map_session_data* sd;
  7977. static int number=0;
  7978. struct mob_data *md;
  7979. if(!ap){
  7980. number=0;
  7981. return 0;
  7982. }
  7983. mob_id = va_arg(ap,int);
  7984. fd = va_arg(ap,int);
  7985. sd = va_arg(ap,struct map_session_data*);
  7986. md = (struct mob_data *)bl;
  7987. if(md->special_state.ai || md->master_id)
  7988. return 0; //Hide slaves and player summoned mobs. [Skotlex]
  7989. if(fd && (mob_id==-1 || (md->class_==mob_id))){
  7990. clif_viewpoint(sd, 1, 1, bl->x, bl->y, ++number, 0xFFFFFF);
  7991. add_timer(gettick()+5000, atshowmobs_timer, fd, number);
  7992. }
  7993. return 0;
  7994. }
  7995. int atcommand_showmobs(const int fd, struct map_session_data* sd, const char* command, const char* message)
  7996. {
  7997. char mob_name[100];
  7998. int mob_id,map_id = 0;
  7999. nullpo_retr(-1, sd);
  8000. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  8001. return -1;
  8002. if ((mob_id = atoi(mob_name)) == 0)
  8003. mob_id = mobdb_searchname(mob_name);
  8004. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  8005. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  8006. clif_displaymessage(fd, atcmd_output);
  8007. return 0;
  8008. }
  8009. // Uncomment the following line to show mini-bosses & MVP.
  8010. //#define SHOW_MVP
  8011. #ifndef SHOW_MVP
  8012. if(mob_db(mob_id)->status.mode&MD_BOSS){
  8013. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  8014. clif_displaymessage(fd, atcmd_output);
  8015. return 0;
  8016. }
  8017. #endif
  8018. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  8019. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  8020. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  8021. map_id = sd->bl.m;
  8022. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  8023. mob_name, mapindex_id2name(sd->mapindex));
  8024. clif_displaymessage(fd, atcmd_output);
  8025. map_foreachinmap(atshowmobs_sub, map_id, BL_MOB, mob_id, fd, sd);
  8026. atshowmobs_sub(&sd->bl,0);
  8027. return 0;
  8028. }
  8029. /*==========================================
  8030. * homunculus level up [orn]
  8031. *------------------------------------------
  8032. */
  8033. int atcommand_homlevel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8034. {
  8035. TBL_HOM * hd;
  8036. int level = 0, i = 0;
  8037. nullpo_retr(-1, sd);
  8038. if (!message || !*message)
  8039. return -1;
  8040. if ( !merc_is_hom_active(sd->hd) )
  8041. return 1 ;
  8042. level = atoi(message);
  8043. hd = sd->hd;
  8044. for (i = 1; i <= level && hd->exp_next; i++){
  8045. hd->homunculus.exp += hd->exp_next;
  8046. merc_hom_levelup(hd);
  8047. }
  8048. status_calc_homunculus(hd,0);
  8049. status_percent_heal(&hd->bl, 100, 100);
  8050. clif_misceffect2(&hd->bl,568);
  8051. return 0;
  8052. }
  8053. /*==========================================
  8054. * homunculus evolution H [orn]
  8055. *------------------------------------------
  8056. */
  8057. int atcommand_homevolution(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8058. {
  8059. nullpo_retr(-1, sd);
  8060. if (sd->hd && sd->hd->homunculusDB->evo_class)
  8061. {
  8062. merc_hom_evolution(sd->hd) ;
  8063. }
  8064. return 0;
  8065. }
  8066. /*==========================================
  8067. * call choosen homunculus [orn]
  8068. *------------------------------------------
  8069. */
  8070. int atcommand_makehomun(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8071. {
  8072. int homunid;
  8073. nullpo_retr(-1, sd);
  8074. if(sscanf(message, "%d", &homunid)<1)
  8075. return -1;
  8076. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  8077. return -1;
  8078. if(sd->status.hom_id == 0)
  8079. {
  8080. merc_create_homunculus_request(sd,homunid);
  8081. }
  8082. else
  8083. {
  8084. clif_displaymessage(fd,msg_txt(450));
  8085. }
  8086. return 0;
  8087. }
  8088. /*==========================================
  8089. * modify homunculus intimacy [orn]
  8090. *------------------------------------------
  8091. */
  8092. int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8093. {
  8094. int friendly = 0;
  8095. nullpo_retr(-1, sd);
  8096. if (!message || !*message)
  8097. return -1;
  8098. friendly = atoi(message);
  8099. if (merc_is_hom_active(sd->hd)) {
  8100. if (friendly > 0 && friendly <= 1000) {
  8101. sd->hd->homunculus.intimacy = friendly * 100 ;
  8102. clif_send_homdata(sd,SP_INTIMATE,friendly);
  8103. } else {
  8104. return -1;
  8105. }
  8106. }
  8107. return 0;
  8108. }
  8109. /*==========================================
  8110. * modify homunculus hunger [orn]
  8111. *------------------------------------------
  8112. */
  8113. int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8114. {
  8115. int hungry = 0;
  8116. nullpo_retr(-1, sd);
  8117. if (!message || !*message)
  8118. return -1;
  8119. hungry = atoi(message);
  8120. if (sd->status.hom_id > 0 && sd->hd) {
  8121. struct homun_data *hd = sd->hd;
  8122. if (hungry >= 0 && hungry <= 100) {
  8123. hd->homunculus.hunger = hungry;
  8124. clif_send_homdata(sd,SP_HUNGRY,hd->homunculus.hunger);
  8125. } else {
  8126. return -1;
  8127. }
  8128. }
  8129. return 0;
  8130. }
  8131. /*==========================================
  8132. * make the homunculus speak [orn]
  8133. *------------------------------------------
  8134. */
  8135. int atcommand_homtalk(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8136. {
  8137. char mes[100],temp[100];
  8138. nullpo_retr(-1, sd);
  8139. if(!merc_is_hom_active(sd->hd))
  8140. return -1;
  8141. if (sscanf(message, "%99[^\n]", mes) < 1)
  8142. return -1;
  8143. snprintf(temp, sizeof temp ,"%s : %s",sd->hd->homunculus.name,mes);
  8144. clif_message(&sd->hd->bl, temp);
  8145. return 0;
  8146. }
  8147. /*==========================================
  8148. * Show homunculus stats
  8149. *------------------------------------------
  8150. */
  8151. int atcommand_hominfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8152. {
  8153. struct homun_data *hd;
  8154. struct status_data *status;
  8155. nullpo_retr(-1, sd);
  8156. if(!merc_is_hom_active(sd->hd))
  8157. return -1;
  8158. hd = sd->hd;
  8159. status = status_get_status_data(&hd->bl);
  8160. clif_displaymessage(fd, "Homunculus stats :");
  8161. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  8162. status->hp, status->max_hp, status->sp, status->max_sp);
  8163. clif_displaymessage(fd, atcmd_output);
  8164. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  8165. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  8166. clif_displaymessage(fd, atcmd_output);
  8167. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  8168. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  8169. clif_displaymessage(fd, atcmd_output);
  8170. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8171. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  8172. status->str, status->agi, status->vit,
  8173. status->int_, status->dex, status->luk);
  8174. clif_displaymessage(fd, atcmd_output);
  8175. return 0;
  8176. }
  8177. int atcommand_homstats(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8178. {
  8179. struct homun_data *hd;
  8180. struct homunculus_db *db;
  8181. struct s_homunculus *hom;
  8182. int lv;
  8183. nullpo_retr(-1, sd);
  8184. if(!merc_is_hom_active(sd->hd))
  8185. return -1;
  8186. hd = sd->hd;
  8187. hom = &hd->homunculus;
  8188. db = hd->homunculusDB;
  8189. lv = hom->level;
  8190. snprintf(atcmd_output, sizeof(atcmd_output) ,
  8191. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  8192. clif_displaymessage(fd, atcmd_output);
  8193. lv--; //Since the first increase is at level 2.
  8194. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)",
  8195. hom->max_hp, db->basemaxHP +lv*db->gminHP, db->basemaxHP +lv*db->gmaxHP);
  8196. clif_displaymessage(fd, atcmd_output);
  8197. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)",
  8198. hom->max_sp, db->basemaxSP +lv*db->gminSP, db->basemaxSP +lv*db->gmaxSP);
  8199. clif_displaymessage(fd, atcmd_output);
  8200. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)",
  8201. hom->str/10, db->baseSTR +lv*(db->gminSTR/10), db->baseSTR +lv*(db->gmaxSTR/10));
  8202. clif_displaymessage(fd, atcmd_output);
  8203. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)",
  8204. hom->agi/10, db->baseAGI +lv*(db->gminAGI/10), db->baseAGI +lv*(db->gmaxAGI/10));
  8205. clif_displaymessage(fd, atcmd_output);
  8206. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)",
  8207. hom->vit/10, db->baseVIT +lv*(db->gminVIT/10), db->baseVIT +lv*(db->gmaxVIT/10));
  8208. clif_displaymessage(fd, atcmd_output);
  8209. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)",
  8210. hom->int_/10, db->baseINT +lv*(db->gminINT/10), db->baseINT +lv*(db->gmaxINT/10));
  8211. clif_displaymessage(fd, atcmd_output);
  8212. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)",
  8213. hom->dex/10, db->baseDEX +lv*(db->gminDEX/10), db->baseDEX +lv*(db->gmaxDEX/10));
  8214. clif_displaymessage(fd, atcmd_output);
  8215. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)",
  8216. hom->luk/10, db->baseLUK +lv*(db->gminLUK/10), db->baseLUK +lv*(db->gmaxLUK/10));
  8217. clif_displaymessage(fd, atcmd_output);
  8218. return 0;
  8219. }
  8220. int atcommand_homshuffle(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8221. {
  8222. struct homun_data *hd;
  8223. int lv, i, skillpts;
  8224. unsigned int exp;
  8225. struct skill b_skill;
  8226. TBL_PC* tsd = sd;
  8227. nullpo_retr(-1, sd);
  8228. if ((!message || !*message) && !sd->hd)
  8229. {
  8230. clif_displaymessage(fd, "usage: @homshuffle <Alchemist's name>");
  8231. clif_displaymessage(fd, "Use this to recalculate your (or someone else's) homunculus growth data");
  8232. return -1;
  8233. }
  8234. if (message && *message) {
  8235. tsd = map_nick2sd((char*)message);
  8236. if (!tsd) {
  8237. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  8238. return -1;
  8239. }
  8240. if (pc_isGM(tsd) > pc_isGM(sd)) {
  8241. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  8242. return -1;
  8243. }
  8244. }
  8245. hd = tsd->hd;
  8246. if(!merc_is_hom_active(hd))
  8247. return -1;
  8248. lv = hd->homunculus.level;
  8249. exp = hd->homunculus.exp;
  8250. memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill));
  8251. skillpts = hd->homunculus.skillpts;
  8252. //Reset values to level 1.
  8253. merc_reset_stats(hd);
  8254. //Level it back up
  8255. for (i = 1; i < lv && hd->exp_next; i++){
  8256. hd->homunculus.exp += hd->exp_next;
  8257. merc_hom_levelup(hd);
  8258. }
  8259. hd->homunculus.exp = exp;
  8260. memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill));
  8261. hd->homunculus.skillpts = skillpts;
  8262. status_calc_homunculus(hd,0);
  8263. status_percent_heal(&hd->bl, 100, 100);
  8264. clif_misceffect2(&hd->bl,568);
  8265. clif_displaymessage(fd, "Homunculus stats altered");
  8266. //Print out the new stats
  8267. //This will send the commands to the invoker since they all use this fd regardless of sd value.
  8268. atcommand_homstats(fd, tsd, command, message);
  8269. return 0;
  8270. }
  8271. /*==========================================
  8272. * Show Items DB Info v 1.0
  8273. * originally by [Lupus] eAthena
  8274. *------------------------------------------
  8275. */
  8276. int atcommand_iteminfo(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8277. {
  8278. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8279. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8280. struct item_data *item_data, *item_array[MAX_SEARCH];
  8281. int i, count = 1;
  8282. if (!message || !*message) {
  8283. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8284. return -1;
  8285. }
  8286. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8287. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8288. if (!count) {
  8289. clif_displaymessage(fd, "Item not found.");
  8290. return -1;
  8291. }
  8292. if (count > MAX_SEARCH) {
  8293. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8294. clif_displaymessage(fd, atcmd_output);
  8295. count = MAX_SEARCH;
  8296. }
  8297. for (i = 0; i < count; i++) {
  8298. item_data = item_array[i];
  8299. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8300. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8301. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8302. (item_data->script==NULL)? "None" : "With script"
  8303. );
  8304. clif_displaymessage(fd, atcmd_output);
  8305. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %.1f ", item_data->value_buy, item_data->flag.value_notdc ? "(No Discount!)":"", item_data->value_sell, item_data->flag.value_notoc ? "(No Overcharge!)":"", item_data->weight/10. );
  8306. clif_displaymessage(fd, atcmd_output);
  8307. if (item_data->maxchance == 10000)
  8308. strcpy(atcmd_output, " - Available in the shops only");
  8309. else if (item_data->maxchance)
  8310. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8311. else
  8312. strcpy(atcmd_output, " - Monsters don't drop this item");
  8313. clif_displaymessage(fd, atcmd_output);
  8314. }
  8315. return 0;
  8316. }
  8317. /*==========================================
  8318. * Show who drops the item.
  8319. *------------------------------------------
  8320. */
  8321. int atcommand_whodrops(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8322. {
  8323. struct item_data *item_data, *item_array[MAX_SEARCH];
  8324. int i,j, count = 1;
  8325. if (!message || !*message) {
  8326. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8327. return -1;
  8328. }
  8329. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8330. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8331. if (!count) {
  8332. clif_displaymessage(fd, "Item not found.");
  8333. return -1;
  8334. }
  8335. if (count > MAX_SEARCH) {
  8336. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  8337. clif_displaymessage(fd, atcmd_output);
  8338. count = MAX_SEARCH;
  8339. }
  8340. for (i = 0; i < count; i++) {
  8341. item_data = item_array[i];
  8342. sprintf(atcmd_output, "Item: '%s'[%d]",
  8343. item_data->jname,item_data->slot);
  8344. clif_displaymessage(fd, atcmd_output);
  8345. if (item_data->mob[0].chance == 0) {
  8346. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8347. clif_displaymessage(fd, atcmd_output);
  8348. } else {
  8349. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8350. clif_displaymessage(fd, atcmd_output);
  8351. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8352. {
  8353. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8354. clif_displaymessage(fd, atcmd_output);
  8355. }
  8356. }
  8357. }
  8358. return 0;
  8359. }
  8360. /*==========================================
  8361. * @adopt by [Veider]
  8362. *
  8363. * adopt a novice
  8364. *------------------------------------------
  8365. */
  8366. int atcommand_adopt(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8367. {
  8368. struct map_session_data *pl_sd1 = NULL;
  8369. struct map_session_data *pl_sd2 = NULL;
  8370. struct map_session_data *pl_sd3 = NULL;
  8371. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8372. nullpo_retr(-1, sd);
  8373. if (!message || !*message)
  8374. return -1;
  8375. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8376. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8377. return -1;
  8378. }
  8379. if (battle_config.etc_log)
  8380. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8381. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8382. sprintf(player2, "Cannot find player %s online", player1);
  8383. clif_displaymessage(fd, player2);
  8384. return -1;
  8385. }
  8386. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8387. sprintf(player1, "Cannot find player %s online", player2);
  8388. clif_displaymessage(fd, player1);
  8389. return -1;
  8390. }
  8391. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8392. sprintf(player1, "Cannot find player %s online", player3);
  8393. clif_displaymessage(fd, player1);
  8394. return -1;
  8395. }
  8396. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8397. clif_displaymessage(fd, "They are too young to be parents!");
  8398. return -1;
  8399. }
  8400. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8401. clif_displaymessage(fd, "They are family.. wish them luck");
  8402. return 0;
  8403. }
  8404. else
  8405. return -1;
  8406. }
  8407. int atcommand_version(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8408. {
  8409. const char * revision;
  8410. if ((revision = get_svn_revision()) != 0) {
  8411. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8412. clif_displaymessage(fd,atcmd_output);
  8413. } else
  8414. clif_displaymessage(fd,"Cannot determine SVN revision");
  8415. return 0;
  8416. }
  8417. /*==========================================
  8418. * @mutearea by MouseJstr
  8419. *------------------------------------------
  8420. */
  8421. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8422. {
  8423. int time, id;
  8424. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8425. if (pl_sd == NULL)
  8426. return 0;
  8427. id = va_arg(ap, int);
  8428. time = va_arg(ap, int);
  8429. if (id != bl->id && !pc_isGM(pl_sd)) {
  8430. pl_sd->status.manner -= time;
  8431. if (pl_sd->status.manner < 0)
  8432. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8433. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8434. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8435. }
  8436. return 0;
  8437. }
  8438. int atcommand_mutearea(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8439. {
  8440. int time;
  8441. nullpo_retr(0, sd);
  8442. time = atoi(message);
  8443. if (!time)
  8444. time = 15; // 15 minutes default
  8445. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8446. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8447. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8448. return 0;
  8449. }
  8450. int atcommand_rates(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8451. {
  8452. char buf[255];
  8453. nullpo_retr(0, sd);
  8454. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8455. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8456. clif_displaymessage(fd, buf);
  8457. return 0;
  8458. }
  8459. /*==========================================
  8460. * @me by lordalfa
  8461. * => Displays the OUTPUT string on top of the Visible players Heads.
  8462. *------------------------------------------
  8463. */
  8464. int atcommand_me(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8465. {
  8466. char tempmes[200];
  8467. nullpo_retr(-1, sd);
  8468. memset(tempmes, '\0', sizeof(tempmes));
  8469. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8470. if (sd->sc.count && //no "chatting" while muted.
  8471. (sd->sc.data[SC_BERSERK].timer!=-1 ||
  8472. (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)))
  8473. return -1;
  8474. if (!message || !*message) {
  8475. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8476. return -1;
  8477. }
  8478. sscanf(message, "%199[^\n]", tempmes);
  8479. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8480. clif_disp_overhead(sd, atcmd_output);
  8481. return 0;
  8482. }
  8483. /*==========================================
  8484. * @size
  8485. * => Resize your character sprite. [Valaris]
  8486. *------------------------------------------
  8487. */
  8488. int atcommand_size(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8489. {
  8490. int size=0;
  8491. nullpo_retr(-1, sd);
  8492. if (!message || !*message)
  8493. return -1;
  8494. if (sscanf(message,"%d", &size) < 1)
  8495. return -1;
  8496. if(sd->state.size) {
  8497. sd->state.size=0;
  8498. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8499. }
  8500. if(size==1) {
  8501. sd->state.size=1;
  8502. clif_specialeffect(&sd->bl,420,AREA);
  8503. } else if(size==2) {
  8504. sd->state.size=2;
  8505. clif_specialeffect(&sd->bl,422,AREA);
  8506. }
  8507. return 0;
  8508. }
  8509. /*==========================================
  8510. * @monsterignore
  8511. * => Makes monsters ignore you. [Valaris]
  8512. *------------------------------------------
  8513. */
  8514. int atcommand_monsterignore(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8515. {
  8516. nullpo_retr(-1, sd);
  8517. if (!sd->state.monster_ignore) {
  8518. sd->state.monster_ignore = 1;
  8519. clif_displaymessage(sd->fd, "You are now inmune to attacks.");
  8520. } else {
  8521. sd->state.monster_ignore = 0;
  8522. clif_displaymessage(sd->fd, "Returned to normal state.");
  8523. }
  8524. return 0;
  8525. }
  8526. /*==========================================
  8527. * @fakename
  8528. * => Gives your character a fake name. [Valaris]
  8529. *------------------------------------------
  8530. */
  8531. int atcommand_fakename(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8532. {
  8533. char name[NAME_LENGTH];
  8534. nullpo_retr(-1, sd);
  8535. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8536. sd->fakename[0]='\0';
  8537. clif_charnameack(0, &sd->bl);
  8538. clif_displaymessage(sd->fd,"Returned to real name.");
  8539. return 0;
  8540. }
  8541. if (!message || !*message) {
  8542. clif_displaymessage(sd->fd,"You must enter a name.");
  8543. return 0;
  8544. }
  8545. if (sscanf(message, "%23[^\n]", name) < 1) {
  8546. return 0;
  8547. }
  8548. if(strlen(name) < 2) {
  8549. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8550. return 0;
  8551. }
  8552. memcpy(sd->fakename,name,NAME_LENGTH);
  8553. sd->fakename[NAME_LENGTH-1] = '\0';
  8554. clif_charnameack(0, &sd->bl);
  8555. clif_displaymessage(sd->fd,"Fake name enabled.");
  8556. return 0;
  8557. }
  8558. /*==========================================
  8559. * @mapflag [flag name] [1|0|on|off] [map name] by Lupus
  8560. * => Shows information about the map flags [map name]
  8561. * Also set flags
  8562. *------------------------------------------
  8563. */
  8564. int atcommand_mapflag(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8565. {
  8566. // WIP
  8567. return 0;
  8568. }
  8569. /*===================================
  8570. * Remove some messages
  8571. *-----------------------------------
  8572. */
  8573. int atcommand_showexp(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8574. {
  8575. if (sd->state.showexp) {
  8576. sd->state.showexp = 0;
  8577. clif_displaymessage(fd, "Gained exp will not be shown.");
  8578. return 0;
  8579. }
  8580. sd->state.showexp = 1;
  8581. clif_displaymessage(fd, "Gained exp is now shown");
  8582. return 0;
  8583. }
  8584. int atcommand_showzeny(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8585. {
  8586. if (sd->state.showzeny) {
  8587. sd->state.showzeny = 0;
  8588. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8589. return 0;
  8590. }
  8591. sd->state.showzeny = 1;
  8592. clif_displaymessage(fd, "Gained zeny is now shown");
  8593. return 0;
  8594. }
  8595. int atcommand_showdelay(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8596. {
  8597. if (sd->state.showdelay) {
  8598. sd->state.showdelay = 0;
  8599. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8600. return 0;
  8601. }
  8602. sd->state.showdelay = 1;
  8603. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8604. return 0;
  8605. }
  8606. /*==========================================
  8607. * Duel organizing functions [LuzZza]
  8608. *
  8609. * @duel [limit|nick] - create a duel
  8610. * @invite <nick> - invite player
  8611. * @accept - accept invitation
  8612. * @reject - reject invitation
  8613. * @leave - leave duel
  8614. *------------------------------------------
  8615. */
  8616. int atcommand_invite(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8617. {
  8618. unsigned int did = sd->duel_group;
  8619. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8620. if(did <= 0) {
  8621. // "Duel: @invite without @duel."
  8622. clif_displaymessage(fd, msg_txt(350));
  8623. return 0;
  8624. }
  8625. if(duel_list[did].max_players_limit > 0 &&
  8626. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8627. // "Duel: Limit of players is reached."
  8628. clif_displaymessage(fd, msg_txt(351));
  8629. return 0;
  8630. }
  8631. if(target_sd == NULL) {
  8632. // "Duel: Player not found."
  8633. clif_displaymessage(fd, msg_txt(352));
  8634. return 0;
  8635. }
  8636. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8637. // "Duel: Player already in duel."
  8638. clif_displaymessage(fd, msg_txt(353));
  8639. return 0;
  8640. }
  8641. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  8642. {
  8643. sprintf(atcmd_output, msg_txt(364), message);
  8644. clif_displaymessage(fd, atcmd_output);
  8645. return 0;
  8646. }
  8647. duel_invite(did, sd, target_sd);
  8648. // "Duel: Invitation has been sent."
  8649. clif_displaymessage(fd, msg_txt(354));
  8650. return 0;
  8651. }
  8652. int atcommand_duel(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8653. {
  8654. char output[256];
  8655. unsigned int maxpl=0, newduel;
  8656. struct map_session_data *target_sd;
  8657. /* // Commnted because it can be disabled in at-comms conf.
  8658. if(!battle_config.duel_enable) {
  8659. clif_displaymessage(fd, "Duel: duel is disable.");
  8660. return 0;
  8661. }
  8662. */
  8663. if(sd->duel_group > 0) {
  8664. duel_showinfo(sd->duel_group, sd);
  8665. return 0;
  8666. }
  8667. if(sd->duel_invite > 0) {
  8668. // "Duel: @duel without @reject."
  8669. clif_displaymessage(fd, msg_txt(355));
  8670. return 0;
  8671. }
  8672. if(!duel_checktime(sd)) {
  8673. // "Duel: You can take part in duel only one time per %d minutes."
  8674. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8675. clif_displaymessage(fd, output);
  8676. return 0;
  8677. }
  8678. if(strlen(message) > 0) {
  8679. if(sscanf(message, "%d", &maxpl) >= 1) {
  8680. if(maxpl < 2 || maxpl > 65535) {
  8681. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8682. return 0;
  8683. }
  8684. duel_create(sd, maxpl);
  8685. } else {
  8686. target_sd = map_nick2sd((char *)message);
  8687. if(target_sd != NULL) {
  8688. if((newduel = duel_create(sd, 2)) != -1) {
  8689. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8690. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8691. return 0;
  8692. }
  8693. duel_invite(newduel, sd, target_sd);
  8694. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8695. }
  8696. } else {
  8697. // "Duel: Player not found."
  8698. clif_displaymessage(fd, msg_txt(352));
  8699. return 0;
  8700. }
  8701. }
  8702. } else
  8703. duel_create(sd, 0);
  8704. return 0;
  8705. }
  8706. int atcommand_leave(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8707. {
  8708. if(sd->duel_group <= 0) {
  8709. // "Duel: @leave without @duel."
  8710. clif_displaymessage(fd, msg_txt(358));
  8711. return 0;
  8712. }
  8713. duel_leave(sd->duel_group, sd);
  8714. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8715. return 0;
  8716. }
  8717. int atcommand_accept(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8718. {
  8719. char output[256];
  8720. if(!duel_checktime(sd)) {
  8721. // "Duel: You can take part in duel only one time per %d minutes."
  8722. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8723. clif_displaymessage(fd, output);
  8724. return 0;
  8725. }
  8726. if(sd->duel_invite <= 0) {
  8727. // "Duel: @accept without invititation."
  8728. clif_displaymessage(fd, msg_txt(360));
  8729. return 0;
  8730. }
  8731. duel_accept(sd->duel_invite, sd);
  8732. // "Duel: Invitation has been accepted."
  8733. clif_displaymessage(fd, msg_txt(361));
  8734. return 0;
  8735. }
  8736. int atcommand_reject(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8737. {
  8738. if(sd->duel_invite <= 0) {
  8739. // "Duel: @reject without invititation."
  8740. clif_displaymessage(fd, msg_txt(362));
  8741. return 0;
  8742. }
  8743. duel_reject(sd->duel_invite, sd);
  8744. // "Duel: Invitation has been rejected."
  8745. clif_displaymessage(fd, msg_txt(363));
  8746. return 0;
  8747. }
  8748. /*===================================
  8749. * Away message (@away, @aw) [LuzZza]
  8750. *-----------------------------------
  8751. */
  8752. int atcommand_away(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8753. {
  8754. if(strlen(message) > 0) {
  8755. if(strlen(message) > 128)
  8756. return -1;
  8757. strcpy(sd->away_message, message);
  8758. //"Away automessage has been activated."
  8759. clif_displaymessage(fd, msg_txt(546));
  8760. } else {
  8761. if(strlen(sd->away_message) > 0) {
  8762. sd->away_message[0] = 0;
  8763. //"Away automessage has been disabled."
  8764. clif_displaymessage(fd, msg_txt(547));
  8765. return 0;
  8766. }
  8767. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8768. clif_displaymessage(fd, msg_txt(548));
  8769. }
  8770. return 0;
  8771. }
  8772. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8773. int atcommand_clone(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8774. {
  8775. int x=0,y=0,flag=0,master=0,i=0;
  8776. struct map_session_data *pl_sd=NULL;
  8777. if (!message || !*message) {
  8778. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8779. return 0;
  8780. }
  8781. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8782. clif_displaymessage(fd, msg_txt(3));
  8783. return 0;
  8784. }
  8785. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8786. clif_displaymessage(fd, msg_txt(126));
  8787. return 0;
  8788. }
  8789. if (strcmpi(command, "@clone") == 0)
  8790. flag = 1;
  8791. else if (strcmpi(command, "@slaveclone") == 0) {
  8792. flag = 2;
  8793. master = sd->bl.id;
  8794. if (battle_config.atc_slave_clone_limit
  8795. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8796. clif_displaymessage(fd, msg_txt(127));
  8797. return 0;
  8798. }
  8799. }
  8800. do {
  8801. x = sd->bl.x + (rand() % 10 - 5);
  8802. y = sd->bl.y + (rand() % 10 - 5);
  8803. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8804. if (i >= 10) {
  8805. x = sd->bl.x;
  8806. y = sd->bl.y;
  8807. }
  8808. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8809. clif_displaymessage(fd, msg_txt(128+flag*2));
  8810. return 0;
  8811. }
  8812. clif_displaymessage(fd, msg_txt(129+flag*2));
  8813. return 0;
  8814. }
  8815. /*===================================
  8816. * Main chat [LuzZza]
  8817. * Usage: @main <on|off|message>
  8818. *-----------------------------------
  8819. */
  8820. int atcommand_main(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8821. {
  8822. if(strlen(message) > 0) {
  8823. if(strcmpi(message, "on") == 0) {
  8824. if(!sd->state.mainchat) {
  8825. sd->state.mainchat = 1;
  8826. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8827. } else {
  8828. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8829. }
  8830. } else if(strcmpi(message, "off") == 0) {
  8831. if(sd->state.mainchat) {
  8832. sd->state.mainchat = 0;
  8833. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8834. } else {
  8835. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8836. }
  8837. } else {
  8838. if(!sd->state.mainchat) {
  8839. sd->state.mainchat = 1;
  8840. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8841. }
  8842. if (sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) {
  8843. clif_displaymessage(fd, msg_txt(387));
  8844. return -1;
  8845. }
  8846. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8847. // I use 0xFE000000 color for signalizing that this message is
  8848. // main chat message. 0xFE000000 is invalid color, same using
  8849. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8850. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8851. }
  8852. } else {
  8853. if(sd->state.mainchat)
  8854. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8855. clif_displaymessage(fd, msg_txt(384));
  8856. else
  8857. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8858. clif_displaymessage(fd, msg_txt(385));
  8859. }
  8860. return 0;
  8861. }
  8862. /*=====================================
  8863. * Autorejecting Invites/Deals [LuzZza]
  8864. * Usage: @noask
  8865. *-------------------------------------
  8866. */
  8867. int atcommand_noask(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8868. {
  8869. if(sd->state.noask) {
  8870. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8871. sd->state.noask = 0;
  8872. } else {
  8873. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8874. sd->state.noask = 1;
  8875. }
  8876. return 0;
  8877. }
  8878. /*=====================================
  8879. * Send a @request message to all GMs of lowest_gm_level.
  8880. * Usage: @request <petition>
  8881. *-------------------------------------
  8882. */
  8883. int atcommand_request(const int fd, struct map_session_data* sd, const char* command, const char* message)
  8884. {
  8885. if (!message || !*message) {
  8886. clif_displaymessage(sd->fd,msg_txt(277));
  8887. return -1;
  8888. }
  8889. sprintf(atcmd_output, msg_txt(278), message);
  8890. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8891. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8892. clif_displaymessage(sd->fd,msg_txt(279));
  8893. return 0;
  8894. }
  8895. void do_init_atcommand()
  8896. {
  8897. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8898. duel_count = 0;
  8899. memset(&duel_list[0], 0, sizeof(duel_list));
  8900. add_timer_func_list(atshowmobs_timer, "atshowmobs_timer");
  8901. return;
  8902. }
  8903. void do_final_atcommand()
  8904. {
  8905. users_db->destroy(users_db,NULL);
  8906. }