atcommand.c 310 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include <limits.h>
  9. #include "../common/socket.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "log.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "pet.h"
  26. #include "battle.h"
  27. #include "party.h"
  28. #include "guild.h"
  29. #include "atcommand.h"
  30. #include "script.h"
  31. #include "npc.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. static char command_symbol = '@'; // first char of the commands (by [Yor])
  38. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  39. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  40. ACMD_FUNC(broadcast);
  41. ACMD_FUNC(localbroadcast);
  42. ACMD_FUNC(rura);
  43. ACMD_FUNC(where);
  44. ACMD_FUNC(jumpto);
  45. ACMD_FUNC(jump);
  46. ACMD_FUNC(who);
  47. ACMD_FUNC(who2);
  48. ACMD_FUNC(who3);
  49. ACMD_FUNC(whomap);
  50. ACMD_FUNC(whomap2);
  51. ACMD_FUNC(whomap3);
  52. ACMD_FUNC(whogm); // by Yor
  53. ACMD_FUNC(whozeny); // [Valaris]
  54. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  55. ACMD_FUNC(save);
  56. ACMD_FUNC(load);
  57. ACMD_FUNC(speed);
  58. ACMD_FUNC(storage);
  59. ACMD_FUNC(guildstorage);
  60. ACMD_FUNC(option);
  61. ACMD_FUNC(hide);
  62. ACMD_FUNC(jobchange);
  63. ACMD_FUNC(die);
  64. ACMD_FUNC(kill);
  65. ACMD_FUNC(alive);
  66. ACMD_FUNC(kami);
  67. ACMD_FUNC(heal);
  68. ACMD_FUNC(item);
  69. ACMD_FUNC(item2);
  70. ACMD_FUNC(itemreset);
  71. ACMD_FUNC(itemcheck);
  72. ACMD_FUNC(baselevelup);
  73. ACMD_FUNC(joblevelup);
  74. ACMD_FUNC(help);
  75. ACMD_FUNC(help2);
  76. ACMD_FUNC(gm);
  77. ACMD_FUNC(pvpoff);
  78. ACMD_FUNC(pvpon);
  79. ACMD_FUNC(gvgoff);
  80. ACMD_FUNC(gvgon);
  81. ACMD_FUNC(model);
  82. ACMD_FUNC(go);
  83. ACMD_FUNC(monster);
  84. ACMD_FUNC(monstersmall);
  85. ACMD_FUNC(monsterbig);
  86. ACMD_FUNC(spawn);
  87. ACMD_FUNC(killmonster);
  88. ACMD_FUNC(killmonster2);
  89. ACMD_FUNC(refine);
  90. ACMD_FUNC(produce);
  91. ACMD_FUNC(memo);
  92. ACMD_FUNC(gat);
  93. ACMD_FUNC(packet);
  94. ACMD_FUNC(waterlevel);
  95. ACMD_FUNC(statuspoint);
  96. ACMD_FUNC(skillpoint);
  97. ACMD_FUNC(zeny);
  98. ACMD_FUNC(param);
  99. ACMD_FUNC(guildlevelup);
  100. ACMD_FUNC(makeegg);
  101. ACMD_FUNC(hatch);
  102. ACMD_FUNC(petfriendly);
  103. ACMD_FUNC(pethungry);
  104. ACMD_FUNC(petrename);
  105. ACMD_FUNC(recall);
  106. ACMD_FUNC(recallall);
  107. ACMD_FUNC(revive);
  108. ACMD_FUNC(night);
  109. ACMD_FUNC(day);
  110. ACMD_FUNC(doom);
  111. ACMD_FUNC(doommap);
  112. ACMD_FUNC(raise);
  113. ACMD_FUNC(raisemap);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(agitstart);
  123. ACMD_FUNC(agitend);
  124. ACMD_FUNC(reloaditemdb);
  125. ACMD_FUNC(reloadmobdb);
  126. ACMD_FUNC(reloadskilldb);
  127. ACMD_FUNC(reloadscript);
  128. ACMD_FUNC(reloadgmdb); // by Yor
  129. ACMD_FUNC(reloadatcommand);
  130. ACMD_FUNC(reloadbattleconf);
  131. ACMD_FUNC(reloadstatusdb);
  132. ACMD_FUNC(reloadpcdb);
  133. ACMD_FUNC(reloadmotd); // [Valaris]
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_block); // by Yor
  142. ACMD_FUNC(char_ban); // by Yor
  143. ACMD_FUNC(char_unblock); // by Yor
  144. ACMD_FUNC(char_unban); // by Yor
  145. ACMD_FUNC(mount_peco); // by Valaris
  146. ACMD_FUNC(char_mount_peco); // by Yor
  147. ACMD_FUNC(guildspy); // [Syrus22]
  148. ACMD_FUNC(partyspy); // [Syrus22]
  149. ACMD_FUNC(repairall); // [Valaris]
  150. ACMD_FUNC(guildrecall); // by Yor
  151. ACMD_FUNC(partyrecall); // by Yor
  152. ACMD_FUNC(nuke); // [Valaris]
  153. ACMD_FUNC(shownpc);
  154. ACMD_FUNC(hidenpc);
  155. ACMD_FUNC(loadnpc);
  156. ACMD_FUNC(unloadnpc);
  157. ACMD_FUNC(servertime); // by Yor
  158. ACMD_FUNC(chardelitem); // by Yor
  159. ACMD_FUNC(jail); // by Yor
  160. ACMD_FUNC(unjail); // by Yor
  161. ACMD_FUNC(disguise); // [Valaris]
  162. ACMD_FUNC(undisguise); // by Yor
  163. ACMD_FUNC(chardisguise); // Kalaspuff
  164. ACMD_FUNC(charundisguise); // Kalaspuff
  165. ACMD_FUNC(email); // by Yor
  166. ACMD_FUNC(effect);//by Apple
  167. ACMD_FUNC(character_cart_list); // by Yor
  168. ACMD_FUNC(addwarp); // by MouseJstr
  169. ACMD_FUNC(follow); // by MouseJstr
  170. ACMD_FUNC(skillon); // by MouseJstr
  171. ACMD_FUNC(skilloff); // by MouseJstr
  172. ACMD_FUNC(killer); // by MouseJstr
  173. ACMD_FUNC(npcmove); // by MouseJstr
  174. ACMD_FUNC(killable); // by MouseJstr
  175. ACMD_FUNC(charkillable); // by MouseJstr
  176. ACMD_FUNC(dropall); // by MouseJstr
  177. ACMD_FUNC(chardropall); // by MouseJstr
  178. ACMD_FUNC(storeall); // by MouseJstr
  179. ACMD_FUNC(charstoreall); // by MouseJstr
  180. ACMD_FUNC(skillid); // by MouseJstr
  181. ACMD_FUNC(useskill); // by MouseJstr
  182. ACMD_FUNC(summon);
  183. ACMD_FUNC(rain);
  184. ACMD_FUNC(snow);
  185. ACMD_FUNC(sakura);
  186. ACMD_FUNC(clouds);
  187. ACMD_FUNC(clouds2); // [Valaris]
  188. ACMD_FUNC(fog);
  189. ACMD_FUNC(fireworks);
  190. ACMD_FUNC(leaves);
  191. ACMD_FUNC(adjgmlvl); // by MouseJstr
  192. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  193. ACMD_FUNC(trade); // by MouseJstr
  194. ACMD_FUNC(send); // by davidsiaw
  195. ACMD_FUNC(setbattleflag); // by MouseJstr
  196. ACMD_FUNC(unmute); // [Valaris]
  197. ACMD_FUNC(clearweather); // Dexity
  198. ACMD_FUNC(uptime); // by MC Cameri
  199. ACMD_FUNC(changesex); // by MC Cameri
  200. ACMD_FUNC(mute); // celest
  201. ACMD_FUNC(refresh); // by MC Cameri
  202. ACMD_FUNC(petid); // by MC Cameri
  203. ACMD_FUNC(identify); // by MC Cameri
  204. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  205. ACMD_FUNC(misceffect); // by MC Cameri
  206. ACMD_FUNC(mobsearch);
  207. ACMD_FUNC(cleanmap);
  208. ACMD_FUNC(npctalk);
  209. ACMD_FUNC(pettalk);
  210. ACMD_FUNC(users);
  211. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  212. #ifndef TXT_ONLY
  213. ACMD_FUNC(checkmail); // [Valaris]
  214. ACMD_FUNC(listmail); // [Valaris]
  215. ACMD_FUNC(listnewmail); // [Valaris]
  216. ACMD_FUNC(readmail); // [Valaris]
  217. ACMD_FUNC(sendmail); // [Valaris]
  218. ACMD_FUNC(sendprioritymail); // [Valaris]
  219. ACMD_FUNC(deletemail); // [Valaris]
  220. ACMD_FUNC(refreshonline); // [Valaris]
  221. #endif /* TXT_ONLY */
  222. ACMD_FUNC(skilltree); // by MouseJstr
  223. ACMD_FUNC(marry); // by MouseJstr
  224. ACMD_FUNC(divorce); // by MouseJstr
  225. ACMD_FUNC(grind); // by MouseJstr
  226. ACMD_FUNC(grind2); // by MouseJstr
  227. #ifdef DMALLOC
  228. ACMD_FUNC(dmstart); // by MouseJstr
  229. ACMD_FUNC(dmtick); // by MouseJstr
  230. #endif
  231. ACMD_FUNC(jumptoid); // by Dino9021
  232. ACMD_FUNC(jumptoid2); // by Dino9021
  233. ACMD_FUNC(recallid); // by Dino9021
  234. ACMD_FUNC(recallid2); // by Dino9021
  235. ACMD_FUNC(kickid); // by Dino9021
  236. ACMD_FUNC(kickid2); // by Dino9021
  237. ACMD_FUNC(reviveid); // by Dino9021
  238. ACMD_FUNC(reviveid2); // by Dino9021
  239. ACMD_FUNC(killid); // by Dino9021
  240. ACMD_FUNC(killid2); // by Dino9021
  241. ACMD_FUNC(charkillableid); // by Dino9021
  242. ACMD_FUNC(charkillableid2); // by Dino9021
  243. ACMD_FUNC(sound);
  244. ACMD_FUNC(undisguiseall);
  245. ACMD_FUNC(disguiseall);
  246. ACMD_FUNC(changelook);
  247. ACMD_FUNC(mobinfo); //by Lupus
  248. ACMD_FUNC(exp); // by Skotlex
  249. ACMD_FUNC(adopt); // by Veider
  250. ACMD_FUNC(version); // by Ancyker
  251. ACMD_FUNC(mutearea); // by MouseJstr
  252. ACMD_FUNC(shuffle); // by MouseJstr
  253. ACMD_FUNC(rates); // by MouseJstr
  254. ACMD_FUNC(iteminfo); // Lupus
  255. ACMD_FUNC(whodrops); //Skotlex
  256. ACMD_FUNC(mapflag); // Lupus
  257. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  258. ACMD_FUNC(monsterignore); // [Valaris]
  259. ACMD_FUNC(fakename); //[Valaris]
  260. ACMD_FUNC(size); //[Valaris]
  261. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  262. ACMD_FUNC(showzeny);
  263. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  264. ACMD_FUNC(autotrade);// durf
  265. ACMD_FUNC(changeleader);// [Skotlex]
  266. ACMD_FUNC(changegm);// durf
  267. // Duel [LuzZza]
  268. ACMD_FUNC(invite);
  269. ACMD_FUNC(duel);
  270. ACMD_FUNC(leave);
  271. ACMD_FUNC(accept);
  272. ACMD_FUNC(reject);
  273. ACMD_FUNC(away); // LuzZza
  274. ACMD_FUNC(main); // LuzZza
  275. ACMD_FUNC(clone); // [Valaris]
  276. ACMD_FUNC(tonpc); // LuzZza
  277. ACMD_FUNC(commands); // [Skotlex]
  278. ACMD_FUNC(noask); //LuzZza
  279. ACMD_FUNC(request); //[Skotlex]
  280. /*==========================================
  281. *AtCommandInfo atcommand_info[]構造体の定義
  282. *------------------------------------------
  283. */
  284. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  285. // to set default level, read atcommand_athena.conf first please.
  286. static AtCommandInfo atcommand_info[] = {
  287. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  288. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  289. { AtCommand_Where, "@where", 1, atcommand_where },
  290. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  291. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  292. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  293. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  294. { AtCommand_Who, "@who", 20, atcommand_who },
  295. { AtCommand_Who, "@whois", 20, atcommand_who },
  296. { AtCommand_Who, "@w", 20, atcommand_who },
  297. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  298. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  299. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  300. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  301. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  302. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  303. { AtCommand_Save, "@save", 40, atcommand_save },
  304. { AtCommand_Load, "@return", 40, atcommand_load },
  305. { AtCommand_Load, "@load", 40, atcommand_load },
  306. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  307. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  308. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  309. { AtCommand_Option, "@option", 40, atcommand_option },
  310. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  311. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  312. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  313. { AtCommand_Die, "@die", 1, atcommand_die },
  314. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  315. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  316. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  317. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  318. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  319. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  320. { AtCommand_Item, "@item", 60, atcommand_item },
  321. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  322. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  323. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  324. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  325. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  326. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  327. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  328. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  329. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  330. { AtCommand_H, "@h", 20, atcommand_help },
  331. { AtCommand_Help, "@help", 20, atcommand_help },
  332. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  333. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  334. { AtCommand_GM, "@gm", 100,atcommand_gm },
  335. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  336. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  337. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  338. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  339. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  340. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  341. { AtCommand_Model, "@model", 20, atcommand_model },
  342. { AtCommand_Go, "@go", 10, atcommand_go },
  343. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  344. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  345. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  346. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  347. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  348. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  349. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  350. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  351. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  352. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  353. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  354. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  355. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  356. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  357. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  358. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  359. { AtCommand_Strength, "@str", 60, atcommand_param },
  360. { AtCommand_Agility, "@agi", 60, atcommand_param },
  361. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  362. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  363. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  364. { AtCommand_Luck, "@luk", 60, atcommand_param },
  365. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  366. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  367. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  368. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  369. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  370. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  371. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  372. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  373. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  374. { AtCommand_Night, "@night", 80, atcommand_night },
  375. { AtCommand_Day, "@day", 80, atcommand_day },
  376. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  377. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  378. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  379. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  380. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  381. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  382. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  383. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  384. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  385. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  386. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  387. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  388. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  389. { AtCommand_Party, "@party", 1, atcommand_party },
  390. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  391. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  392. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  393. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  394. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  395. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  396. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  397. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  398. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  399. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  400. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  401. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  402. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  403. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  404. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  405. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  406. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  407. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  408. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  409. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  410. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  411. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  412. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  413. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  414. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  415. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  416. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  417. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  418. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  419. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  420. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  421. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  422. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  423. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  424. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  425. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  426. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  427. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  428. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  429. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  430. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  431. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  432. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  433. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  434. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  435. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  436. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  437. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  438. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  439. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  440. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  441. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  442. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  443. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  444. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  446. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  447. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  448. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  449. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  450. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  451. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  452. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  453. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  454. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  455. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  456. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  457. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  458. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  459. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  460. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  461. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  462. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  463. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  464. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  465. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  466. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  467. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  468. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  469. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  470. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  471. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  472. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  473. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  474. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  475. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  476. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  477. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  478. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  479. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  480. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  481. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  482. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  483. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  484. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  485. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  486. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  487. { AtCommand_Send, "@send", 60, atcommand_send },
  488. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  489. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  490. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  491. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  492. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  493. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  494. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  495. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  496. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  497. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  498. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  499. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  500. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  501. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  502. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  503. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  504. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  505. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  506. { AtCommand_Users, "@users", 40, atcommand_users },
  507. { AtCommand_ResetState, "/reset", 40, NULL },
  508. #ifndef TXT_ONLY // sql-only commands
  509. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  510. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  511. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  512. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  513. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  514. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  515. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  516. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  517. #endif /* TXT_ONLY */
  518. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  519. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  520. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  521. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  522. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  523. #ifdef DMALLOC
  524. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  525. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  526. #endif
  527. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  528. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  529. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  530. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  531. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  532. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  533. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  534. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  535. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  536. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  537. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  538. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  539. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  540. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  541. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  542. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  543. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  544. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  545. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  546. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  547. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  548. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  549. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  550. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  551. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  552. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  553. { AtCommand_Version, "@version", 1, atcommand_version },
  554. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  555. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  556. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  557. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  558. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  559. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  560. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  561. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  562. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  563. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  564. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  565. { AtCommand_Size, "@size", 20, atcommand_size },
  566. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  567. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  568. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  569. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  570. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  571. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  572. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  573. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  574. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  575. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  576. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  577. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  578. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  579. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  580. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  581. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  582. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  583. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  584. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  585. { AtCommand_Commands, "@commands", 1, atcommand_commands }, // [Skotlex]
  586. { AtCommand_NoAsk, "@noask", 1, atcommand_noask }, // [LuzZza]
  587. { AtCommand_Request, "@request", 20, atcommand_request }, // [Skotlex]
  588. // add new commands before this line
  589. { AtCommand_Unknown, NULL, 1, NULL }
  590. };
  591. /*=========================================
  592. * Generic variables
  593. *-----------------------------------------
  594. */
  595. char atcmd_output[200];
  596. char atcmd_player_name[100];
  597. char atcmd_temp[100];
  598. /*==========================================
  599. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  600. *------------------------------------------
  601. */
  602. char *estr_lower(char *str)
  603. {
  604. int i;
  605. for (i=0; str[i]; i++)
  606. if ((str[i] >= 65) && (str[i] <= 90))
  607. str[i] += 32;
  608. return str;
  609. }
  610. // compare function for sorting high to lowest
  611. int hightolow_compare (const void * a, const void * b)
  612. {
  613. return ( *(int*)b - *(int*)a );
  614. }
  615. // compare function for sorting lowest to highest
  616. int lowtohigh_compare (const void * a, const void * b)
  617. {
  618. return ( *(int*)a - *(int*)b );
  619. }
  620. //-----------------------------------------------------------
  621. // Return the message string of the specified number by [Yor]
  622. //-----------------------------------------------------------
  623. char * msg_txt(int msg_number) {
  624. if (msg_number >= 0 && msg_number < MAX_MSG &&
  625. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  626. return msg_table[msg_number];
  627. return "??";
  628. }
  629. //-----------------------------------------------------------
  630. // Returns Players title (from msg_athena.conf) [Lupus]
  631. //-----------------------------------------------------------
  632. char * player_title_txt(int level) {
  633. if (level < battle_config.title_lvl1)
  634. return ""; //w/o any titles
  635. if (level >= battle_config.title_lvl8)
  636. sprintf(atcmd_temp, msg_table[332], level);
  637. else
  638. if (level >= battle_config.title_lvl7)
  639. sprintf(atcmd_temp, msg_table[331], level);
  640. else
  641. if (level >= battle_config.title_lvl6)
  642. sprintf(atcmd_temp, msg_table[330], level);
  643. else
  644. if (level >= battle_config.title_lvl5)
  645. sprintf(atcmd_temp, msg_table[329], level);
  646. else
  647. if (level >= battle_config.title_lvl4)
  648. sprintf(atcmd_temp, msg_table[328], level);
  649. else
  650. if (level >= battle_config.title_lvl3)
  651. sprintf(atcmd_temp, msg_table[327], level);
  652. else
  653. if (level >= battle_config.title_lvl2)
  654. sprintf(atcmd_temp, msg_table[326], level);
  655. else
  656. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  657. return atcmd_temp;
  658. }
  659. //------------------------------------------------------------
  660. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  661. //------------------------------------------------------------
  662. int e_mail_check(char *email) {
  663. char ch;
  664. char* last_arobas;
  665. // athena limits
  666. if (strlen(email) < 3 || strlen(email) > 39)
  667. return 0;
  668. // part of RFC limits (official reference of e-mail description)
  669. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  670. return 0;
  671. if (email[strlen(email)-1] == '.')
  672. return 0;
  673. last_arobas = strrchr(email, '@');
  674. if (strstr(last_arobas, "@.") != NULL ||
  675. strstr(last_arobas, "..") != NULL)
  676. return 0;
  677. for(ch = 1; ch < 32; ch++) {
  678. if (strchr(last_arobas, ch) != NULL) {
  679. return 0;
  680. break;
  681. }
  682. }
  683. if (strchr(last_arobas, ' ') != NULL ||
  684. strchr(last_arobas, ';') != NULL)
  685. return 0;
  686. // all correct
  687. return 1;
  688. }
  689. /*==========================================
  690. * get_atcommand_level @コマンドの必要レベルを取得
  691. *------------------------------------------
  692. */
  693. int get_atcommand_level(const AtCommandType type) {
  694. int i;
  695. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  696. if (atcommand_info[i].type == type)
  697. return atcommand_info[i].level;
  698. return 100; // 100: command can not be used
  699. }
  700. /*==========================================
  701. *is_atcommand @コマンドに存在するかどうか確認する
  702. *------------------------------------------
  703. */
  704. AtCommandType
  705. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  706. const char* str = message;
  707. int s_flag = 0;
  708. AtCommandInfo info;
  709. AtCommandType type;
  710. nullpo_retr(AtCommand_None, sd);
  711. if (!battle_config.allow_atcommand_when_mute &&
  712. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  713. return AtCommand_Unknown;
  714. }
  715. if (!message || !*message)
  716. return AtCommand_None;
  717. memset(&info, 0, sizeof(info));
  718. str += strlen(sd->status.name);
  719. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  720. if (*str == ':')
  721. s_flag = 1;
  722. str++;
  723. }
  724. if (!*str)
  725. return AtCommand_None;
  726. if (map[sd->bl.m].flag.nocommand &&
  727. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  728. { //Command not allowed on this map.
  729. sprintf(atcmd_output, msg_table[143]);
  730. clif_displaymessage(fd, atcmd_output);
  731. return AtCommand_None;
  732. }
  733. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  734. if (type != AtCommand_None) {
  735. char command[100];
  736. const char* p = str;
  737. memset(command, '\0', sizeof(command));
  738. memset(atcmd_output, '\0', sizeof(atcmd_output));
  739. while (*p && !isspace(*p))
  740. p++;
  741. if (p - str >= sizeof(command)) // too long
  742. return AtCommand_Unknown;
  743. strncpy(command, str, p - str);
  744. while (isspace(*p))
  745. p++;
  746. if (type == AtCommand_Unknown || info.proc == NULL) {
  747. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  748. clif_displaymessage(fd, atcmd_output);
  749. } else {
  750. if (info.proc(fd, sd, command, p) != 0) {
  751. // Command can not be executed
  752. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  753. clif_displaymessage(fd, atcmd_output);
  754. }
  755. }
  756. return info.type;
  757. }
  758. return AtCommand_None;
  759. }
  760. /*==========================================
  761. *
  762. *------------------------------------------
  763. */
  764. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  765. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  766. if (!info)
  767. return AtCommand_None;
  768. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  769. return AtCommand_None;
  770. if (!p || !*p) {
  771. ShowError("at command message is empty\n");
  772. return AtCommand_None;
  773. }
  774. if (*p == command_symbol) { // check first char.
  775. char command[101];
  776. int i = 0;
  777. memset(info, 0, sizeof(AtCommandInfo));
  778. sscanf(p, "%100s", command);
  779. command[sizeof(command)-1] = '\0';
  780. while (atcommand_info[i].type != AtCommand_Unknown) {
  781. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  782. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  783. break;
  784. }
  785. i++;
  786. }
  787. if (atcommand_info[i].type == AtCommand_Unknown) {
  788. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  789. if (level == 0)
  790. return AtCommand_None;
  791. else
  792. return AtCommand_Unknown;
  793. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  794. log_atcommand(sd, message);
  795. }
  796. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  797. } else {
  798. return AtCommand_None;
  799. }
  800. return info->type;
  801. }
  802. /*==========================================
  803. * Read Message Data
  804. *------------------------------------------
  805. */
  806. int msg_config_read(const char *cfgName) {
  807. int msg_number;
  808. char line[1024], w1[1024], w2[1024];
  809. FILE *fp;
  810. static int called = 1;
  811. if ((fp = fopen(cfgName, "r")) == NULL) {
  812. ShowError("Messages file not found: %s\n", cfgName);
  813. return 1;
  814. }
  815. if ((--called) == 0)
  816. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  817. while(fgets(line, sizeof(line)-1, fp)) {
  818. if (line[0] == '/' && line[1] == '/')
  819. continue;
  820. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  821. if (strcmpi(w1, "import") == 0) {
  822. msg_config_read(w2);
  823. } else {
  824. msg_number = atoi(w1);
  825. if (msg_number >= 0 && msg_number < MAX_MSG) {
  826. if (msg_table[msg_number] != NULL)
  827. aFree(msg_table[msg_number]);
  828. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  829. strcpy(msg_table[msg_number],w2);
  830. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  831. }
  832. }
  833. }
  834. }
  835. fclose(fp);
  836. return 0;
  837. }
  838. /*==========================================
  839. * Cleanup Message Data
  840. *------------------------------------------
  841. */
  842. void do_final_msg (void) {
  843. int i;
  844. for (i = 0; i < MAX_MSG; i++)
  845. aFree(msg_table[i]);
  846. return;
  847. }
  848. /*==========================================
  849. *
  850. *------------------------------------------
  851. */
  852. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  853. int i;
  854. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  855. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  856. return &atcommand_info[i];
  857. return NULL;
  858. }
  859. /*==========================================
  860. *
  861. *------------------------------------------
  862. */
  863. int atcommand_config_read(const char *cfgName) {
  864. char line[1024], w1[1024], w2[1024];
  865. AtCommandInfo* p;
  866. FILE* fp;
  867. if ((fp = fopen(cfgName, "r")) == NULL) {
  868. ShowError("At commands configuration file not found: %s\n", cfgName);
  869. return 1;
  870. }
  871. while (fgets(line, sizeof(line)-1, fp)) {
  872. if (line[0] == '/' && line[1] == '/')
  873. continue;
  874. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  875. continue;
  876. p = get_atcommandinfo_byname(w1);
  877. if (p != NULL) {
  878. p->level = atoi(w2);
  879. if (p->level > 100)
  880. p->level = 100;
  881. else if (p->level < 0)
  882. p->level = 0;
  883. }
  884. if (strcmpi(w1, "import") == 0)
  885. atcommand_config_read(w2);
  886. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  887. w2[0] != '/' && // symbol of standard ragnarok GM commands
  888. w2[0] != '%' && // symbol of party chat speaking
  889. w2[0] != '$' && // symbol of guild chat
  890. w2[0] != '#') // symbol of charcommand
  891. command_symbol = w2[0];
  892. }
  893. fclose(fp);
  894. return 0;
  895. }
  896. /*==========================================
  897. * Duel organizing functions [LuzZza]
  898. *------------------------------------------
  899. */
  900. void duel_msg_foreach_sameduel_wos(
  901. const unsigned int did, struct map_session_data* sd, char *output)
  902. {
  903. int i;
  904. struct map_session_data* msg_sd;
  905. for(i=0; i<fd_max; i++)
  906. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  907. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  908. clif_disp_onlyself(msg_sd, output, strlen(output));
  909. return;
  910. }
  911. void duel_savetime(struct map_session_data* sd) {
  912. time_t timer;
  913. struct tm *t;
  914. time(&timer);
  915. t = localtime(&timer);
  916. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  917. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  918. return;
  919. }
  920. int duel_checktime(struct map_session_data* sd) {
  921. int diff;
  922. time_t timer;
  923. struct tm *t;
  924. time(&timer);
  925. t = localtime(&timer);
  926. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  927. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  928. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  929. }
  930. int duel_showinfo(
  931. const unsigned int did, struct map_session_data* sd)
  932. {
  933. int i, p=0;
  934. char output[256];
  935. struct map_session_data* msg_sd;
  936. if(duel_list[did].max_players_limit > 0)
  937. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  938. did, duel_count,
  939. duel_list[did].members_count,
  940. duel_list[did].members_count + duel_list[did].invites_count,
  941. duel_list[did].max_players_limit);
  942. else
  943. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  944. did, duel_count,
  945. duel_list[did].members_count,
  946. duel_list[did].members_count + duel_list[did].invites_count);
  947. clif_disp_onlyself(sd, output, strlen(output));
  948. for(i=0; i<fd_max; i++)
  949. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  950. && msg_sd->state.auth && msg_sd->duel_group == did) {
  951. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  952. clif_disp_onlyself(sd, output, strlen(output));
  953. }
  954. return 0;
  955. }
  956. int duel_create(
  957. struct map_session_data* sd, const unsigned int maxpl)
  958. {
  959. int i=1;
  960. char output[256];
  961. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  962. if(i == MAX_DUEL) return 0;
  963. duel_count++;
  964. sd->duel_group = i;
  965. duel_list[i].members_count++;
  966. duel_list[i].invites_count = 0;
  967. duel_list[i].max_players_limit = maxpl;
  968. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  969. clif_disp_onlyself(sd, output, strlen(output));
  970. clif_set0199(sd->fd, 1);
  971. //clif_misceffect2(&sd->bl, 159);
  972. return i;
  973. }
  974. int duel_invite(
  975. const unsigned int did, struct map_session_data* sd,
  976. struct map_session_data* target_sd)
  977. {
  978. char output[256];
  979. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  980. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  981. duel_msg_foreach_sameduel_wos(did, sd, output);
  982. target_sd->duel_invite = did;
  983. duel_list[did].invites_count++;
  984. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  985. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  986. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  987. return 0;
  988. }
  989. int duel_leave(
  990. const unsigned int did, struct map_session_data* sd)
  991. {
  992. int i;
  993. char output[256];
  994. struct map_session_data* msg_sd;
  995. // " <- Player %s has left duel --"
  996. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  997. duel_msg_foreach_sameduel_wos(did, sd, output);
  998. duel_list[did].members_count--;
  999. if(duel_list[did].members_count == 0) {
  1000. for (i=0; i<fd_max; i++)
  1001. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  1002. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  1003. msg_sd->duel_invite = 0;
  1004. }
  1005. duel_count--;
  1006. }
  1007. sd->duel_group = 0;
  1008. duel_savetime(sd);
  1009. clif_set0199(sd->fd, 0);
  1010. return 0;
  1011. }
  1012. int duel_accept(
  1013. const unsigned int did, struct map_session_data* sd)
  1014. {
  1015. char output[256];
  1016. // " -> Player %s has accepted duel --"
  1017. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1018. duel_msg_foreach_sameduel_wos(did, sd, output);
  1019. duel_list[did].members_count++;
  1020. sd->duel_group = sd->duel_invite;
  1021. duel_list[did].invites_count--;
  1022. sd->duel_invite = 0;
  1023. clif_set0199(sd->fd, 1);
  1024. //clif_misceffect2(&sd->bl, 159);
  1025. return 0;
  1026. }
  1027. int duel_reject(
  1028. const unsigned int did, struct map_session_data* sd)
  1029. {
  1030. char output[256];
  1031. // " -- Player %s has rejected duel --"
  1032. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1033. duel_msg_foreach_sameduel_wos(did, sd, output);
  1034. duel_list[did].invites_count--;
  1035. sd->duel_invite = 0;
  1036. return 0;
  1037. }
  1038. /*==========================================
  1039. // @ command processing functions
  1040. *------------------------------------------
  1041. */
  1042. /*==========================================
  1043. * @commands Lists available @ commands to you (code 98% from Meruru)
  1044. *------------------------------------------
  1045. */
  1046. int atcommand_commands(
  1047. const int fd, struct map_session_data* sd,
  1048. const char* command, const char* message)
  1049. {
  1050. char cz_line_buff[MESSAGE_SIZE+1];
  1051. register char *lpcz_cur = cz_line_buff;
  1052. register unsigned int ui_slen;
  1053. int i_cur_cmd,gm_lvl = pc_isGM(sd), count = 0;
  1054. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1055. cz_line_buff[MESSAGE_SIZE] = 0;
  1056. clif_displaymessage(fd, msg_txt(273));
  1057. for (i_cur_cmd = 0;atcommand_info[i_cur_cmd].type != AtCommand_Unknown;i_cur_cmd++)
  1058. {
  1059. if(gm_lvl < atcommand_info[i_cur_cmd].level)
  1060. continue;
  1061. count++;
  1062. ui_slen = (unsigned int)strlen(atcommand_info[i_cur_cmd].command);
  1063. //rember not <= bc we need null terminator
  1064. if(((MESSAGE_SIZE+(int)cz_line_buff)-(int)lpcz_cur) < (int)ui_slen)
  1065. {
  1066. clif_displaymessage(fd,(char*)cz_line_buff);
  1067. lpcz_cur = cz_line_buff;
  1068. memset(cz_line_buff,' ',MESSAGE_SIZE);
  1069. cz_line_buff[MESSAGE_SIZE] = 0;
  1070. }
  1071. memcpy(lpcz_cur,atcommand_info[i_cur_cmd].command,ui_slen);
  1072. lpcz_cur += ui_slen+(10-ui_slen%10);
  1073. }
  1074. clif_displaymessage(fd,(char*)cz_line_buff);
  1075. sprintf(atcmd_output, msg_txt(274), count); //There will always be at least 1 command (@commands)
  1076. clif_displaymessage(fd, atcmd_output);
  1077. return 0;
  1078. }
  1079. /*==========================================
  1080. * @send (used for testing packet sends from the client)
  1081. *------------------------------------------
  1082. */
  1083. int atcommand_send(
  1084. const int fd, struct map_session_data* sd,
  1085. const char* command, const char* message)
  1086. {
  1087. int i,type=0;
  1088. int info[20];
  1089. if (!message || !*message || sscanf(message, "%x %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d", &type, &info[1], &info[2], &info[3], &info[4], &info[5], &info[6], &info[7], &info[8], &info[9], &info[10], &info[11], &info[12], &info[13], &info[14], &info[15], &info[16], &info[17], &info[18], &info[19], &info[20]) < 1) {
  1090. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1091. return -1;
  1092. }
  1093. if (type > 0 && type < MAX_PACKET_DB) {
  1094. switch (type)
  1095. {
  1096. case 0x209: {
  1097. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1098. WFIFOW(fd,0) = 0x209;
  1099. WFIFOW(fd,2) = 2;
  1100. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1101. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1102. break;
  1103. }
  1104. case 0x1b1:
  1105. case 0x1c2:
  1106. //case xxx:
  1107. // add others here
  1108. // break;
  1109. default: {
  1110. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1111. WFIFOW(fd,0) = type;
  1112. for(i=1;i<=sizeof(info);i++)
  1113. if(info[i])
  1114. WFIFOW(fd,i) = info[i];
  1115. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1116. break;
  1117. }
  1118. }
  1119. sprintf (atcmd_output, msg_table[258], type, type);
  1120. clif_displaymessage(fd, atcmd_output);
  1121. } else {
  1122. clif_displaymessage(fd, msg_table[259]);
  1123. }
  1124. return 0;
  1125. }
  1126. // @rura
  1127. /*==========================================
  1128. *
  1129. *------------------------------------------
  1130. */
  1131. int atcommand_rura(
  1132. const int fd, struct map_session_data* sd,
  1133. const char* command, const char* message)
  1134. {
  1135. char map_name[MAP_NAME_LENGTH];
  1136. unsigned short mapindex;
  1137. int x = 0, y = 0;
  1138. int m = -1;
  1139. nullpo_retr(-1, sd);
  1140. memset(map_name, '\0', sizeof(map_name));
  1141. if (!message || !*message ||
  1142. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1143. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1144. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1145. return -1;
  1146. }
  1147. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1148. strcat(map_name, ".gat");
  1149. mapindex = mapindex_name2id(map_name);
  1150. if (mapindex)
  1151. m = map_mapindex2mapid(mapindex);
  1152. if (!mapindex || m < 0) {
  1153. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1154. return -1;
  1155. }
  1156. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1157. clif_displaymessage(fd, msg_table[2]);
  1158. x = y = 0; //Invalid cell, use random spot.
  1159. }
  1160. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1161. clif_displaymessage(fd, msg_table[247]);
  1162. return -1;
  1163. }
  1164. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1165. clif_displaymessage(fd, msg_table[248]);
  1166. return -1;
  1167. }
  1168. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1169. clif_displaymessage(fd, msg_table[0]); // Warped.
  1170. else {
  1171. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1172. return -1;
  1173. }
  1174. return 0;
  1175. }
  1176. /*==========================================
  1177. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1178. *------------------------------------------
  1179. */
  1180. int atcommand_where(
  1181. const int fd, struct map_session_data* sd,
  1182. const char* command, const char* message)
  1183. {
  1184. struct map_session_data *pl_sd = NULL;
  1185. int GM_level, pl_GM_level;
  1186. nullpo_retr(-1, sd);
  1187. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1188. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1189. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1190. return -1;
  1191. }
  1192. pl_sd = map_nick2sd(atcmd_player_name);
  1193. if (pl_sd == NULL)
  1194. return -1;
  1195. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1196. return -1;
  1197. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1198. pl_GM_level = pc_isGM(pl_sd);
  1199. if (battle_config.hide_GM_session) {
  1200. if(GM_level < pl_GM_level) {
  1201. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1202. return -1;
  1203. }
  1204. }
  1205. }
  1206. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1207. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1208. clif_displaymessage(fd, atcmd_output);
  1209. return 0;
  1210. }
  1211. /*==========================================
  1212. *
  1213. *------------------------------------------
  1214. */
  1215. int atcommand_jumpto(
  1216. const int fd, struct map_session_data* sd,
  1217. const char* command, const char* message)
  1218. {
  1219. struct map_session_data *pl_sd = NULL;
  1220. nullpo_retr(-1, sd);
  1221. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1222. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1223. return -1;
  1224. }
  1225. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1226. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1227. return -1;
  1228. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1229. return -1;
  1230. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1231. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1232. clif_displaymessage(fd, msg_table[247]);
  1233. return -1;
  1234. }
  1235. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1236. clif_displaymessage(fd, msg_table[248]);
  1237. return -1;
  1238. }
  1239. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1240. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1241. clif_displaymessage(fd, atcmd_output);
  1242. } else {
  1243. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1244. return -1;
  1245. }
  1246. return 0;
  1247. }
  1248. /*==========================================
  1249. *
  1250. *------------------------------------------
  1251. */
  1252. int atcommand_jump(
  1253. const int fd, struct map_session_data* sd,
  1254. const char* command, const char* message)
  1255. {
  1256. int x = 0, y = 0;
  1257. nullpo_retr(-1, sd);
  1258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1259. sscanf(message, "%d %d", &x, &y);
  1260. if (x <= 0) //If coordinates are 'wrong', random jump.
  1261. x = -1;
  1262. if (y <= 0)
  1263. y = -1;
  1264. 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)) {
  1265. clif_displaymessage(fd, msg_table[248]);
  1266. return -1;
  1267. }
  1268. pc_setpos(sd, sd->mapindex, x, y, 3);
  1269. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1270. clif_displaymessage(fd, atcmd_output);
  1271. return 0;
  1272. }
  1273. /*==========================================
  1274. * @who3 = Player name, his location
  1275. *------------------------------------------
  1276. */
  1277. int atcommand_who3(
  1278. const int fd, struct map_session_data* sd,
  1279. const char* command, const char* message)
  1280. {
  1281. char temp0[100];
  1282. struct map_session_data *pl_sd, **pl_allsd;
  1283. int i, j, count, users;
  1284. int pl_GM_level, GM_level;
  1285. char match_text[100];
  1286. char player_name[NAME_LENGTH];
  1287. nullpo_retr(-1, sd);
  1288. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1289. memset(match_text, '\0', sizeof(match_text));
  1290. memset(player_name, '\0', sizeof(player_name));
  1291. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1292. strcpy(match_text, "");
  1293. for (j = 0; match_text[j]; j++)
  1294. match_text[j] = tolower(match_text[j]);
  1295. count = 0;
  1296. GM_level = pc_isGM(sd);
  1297. pl_allsd = map_getallusers(&users);
  1298. for (i = 0; i < users; i++) {
  1299. if ((pl_sd = pl_allsd[i])) {
  1300. pl_GM_level = pc_isGM(pl_sd);
  1301. 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
  1302. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1303. for (j = 0; player_name[j]; j++)
  1304. player_name[j] = tolower(player_name[j]);
  1305. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1306. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1307. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1308. } else {
  1309. atcmd_output[0]=0;
  1310. }
  1311. //Player name
  1312. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1313. strcat(atcmd_output,temp0);
  1314. //Player title, if exists
  1315. if (pl_GM_level > 0) {
  1316. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1317. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1318. strcat(atcmd_output,temp0);
  1319. }
  1320. //Players Location: map x y
  1321. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1322. strcat(atcmd_output,temp0);
  1323. clif_displaymessage(fd, atcmd_output);
  1324. count++;
  1325. }
  1326. }
  1327. }
  1328. }
  1329. if (count == 0)
  1330. clif_displaymessage(fd, msg_table[28]); // No player found.
  1331. else if (count == 1)
  1332. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1333. else {
  1334. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1335. clif_displaymessage(fd, atcmd_output);
  1336. }
  1337. return 0;
  1338. }
  1339. /*==========================================
  1340. * Player name, BLevel, Job,
  1341. *------------------------------------------
  1342. */
  1343. int atcommand_who2(
  1344. const int fd, struct map_session_data* sd,
  1345. const char* command, const char* message)
  1346. {
  1347. char temp0[100];
  1348. struct map_session_data *pl_sd, **pl_allsd;
  1349. int i, j, count, users;
  1350. int pl_GM_level, GM_level;
  1351. char match_text[100];
  1352. char player_name[NAME_LENGTH];
  1353. nullpo_retr(-1, sd);
  1354. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1355. memset(match_text, '\0', sizeof(match_text));
  1356. memset(player_name, '\0', sizeof(player_name));
  1357. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1358. strcpy(match_text, "");
  1359. for (j = 0; match_text[j]; j++)
  1360. match_text[j] = tolower(match_text[j]);
  1361. count = 0;
  1362. GM_level = pc_isGM(sd);
  1363. pl_allsd = map_getallusers(&users);
  1364. for (i = 0; i < users; i++) {
  1365. if ((pl_sd = pl_allsd[i])) {
  1366. pl_GM_level = pc_isGM(pl_sd);
  1367. 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
  1368. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1369. for (j = 0; player_name[j]; j++)
  1370. player_name[j] = tolower(player_name[j]);
  1371. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1372. //Players Name
  1373. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1374. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1375. //Player title, if exists
  1376. if (pl_GM_level > 0) {
  1377. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1378. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1379. strcat(atcmd_output,temp0);
  1380. }
  1381. //Players Base Level / Job name
  1382. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1383. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1384. strcat(atcmd_output,temp0);
  1385. clif_displaymessage(fd, atcmd_output);
  1386. count++;
  1387. }
  1388. }
  1389. }
  1390. }
  1391. if (count == 0)
  1392. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1393. else if (count == 1)
  1394. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1395. else {
  1396. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1397. clif_displaymessage(fd, atcmd_output);
  1398. }
  1399. return 0;
  1400. }
  1401. /*==========================================
  1402. * Player name, Playrs Party / Guild name
  1403. *------------------------------------------
  1404. */
  1405. int atcommand_who(
  1406. const int fd, struct map_session_data* sd,
  1407. const char* command, const char* message)
  1408. {
  1409. char temp0[100];
  1410. struct map_session_data *pl_sd, **pl_allsd;
  1411. int i, j, count, users;
  1412. int pl_GM_level, GM_level;
  1413. char match_text[100];
  1414. char player_name[NAME_LENGTH];
  1415. struct guild *g;
  1416. struct party_data *p;
  1417. nullpo_retr(-1, sd);
  1418. memset(temp0, '\0', sizeof(temp0));
  1419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1420. memset(match_text, '\0', sizeof(match_text));
  1421. memset(player_name, '\0', sizeof(player_name));
  1422. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1423. strcpy(match_text, "");
  1424. for (j = 0; match_text[j]; j++)
  1425. match_text[j] = tolower(match_text[j]);
  1426. count = 0;
  1427. GM_level = pc_isGM(sd);
  1428. pl_allsd = map_getallusers(&users);
  1429. for (i = 0; i < users; i++) {
  1430. if ((pl_sd = pl_allsd[i])) {
  1431. pl_GM_level = pc_isGM(pl_sd);
  1432. 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
  1433. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1434. for (j = 0; player_name[j]; j++)
  1435. player_name[j] = tolower(player_name[j]);
  1436. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1437. g = guild_search(pl_sd->status.guild_id);
  1438. p = party_search(pl_sd->status.party_id);
  1439. //Players Name
  1440. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1441. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1442. //Player title, if exists
  1443. if (pl_GM_level > 0) {
  1444. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1445. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1446. strcat(atcmd_output,temp0);
  1447. }
  1448. //Players Party if exists
  1449. if (p != NULL) {
  1450. //sprintf(temp0," | Party: '%s'", p->name);
  1451. sprintf(temp0, msg_txt(335), p->party.name);
  1452. strcat(atcmd_output,temp0);
  1453. }
  1454. //Players Guild if exists
  1455. if (g != NULL) {
  1456. //sprintf(temp0," | Guild: '%s'", g->name);
  1457. sprintf(temp0, msg_txt(336), g->name);
  1458. strcat(atcmd_output,temp0);
  1459. }
  1460. clif_displaymessage(fd, atcmd_output);
  1461. count++;
  1462. }
  1463. }
  1464. }
  1465. }
  1466. if (count == 0)
  1467. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1468. else if (count == 1)
  1469. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1470. else {
  1471. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1472. clif_displaymessage(fd, atcmd_output);
  1473. }
  1474. return 0;
  1475. }
  1476. /*==========================================
  1477. *
  1478. *------------------------------------------
  1479. */
  1480. int atcommand_whomap3(
  1481. const int fd, struct map_session_data* sd,
  1482. const char* command, const char* message)
  1483. {
  1484. struct map_session_data *pl_sd, **pl_allsd;
  1485. int i, count, users;
  1486. int pl_GM_level, GM_level;
  1487. int map_id;
  1488. char map_name[MAP_NAME_LENGTH];
  1489. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1490. memset(map_name, '\0', sizeof(map_name));
  1491. if (!message || !*message)
  1492. map_id = sd->bl.m;
  1493. else {
  1494. sscanf(message, "%15s", map_name);
  1495. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1496. strcat(map_name, ".gat");
  1497. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1498. map_id = sd->bl.m;
  1499. }
  1500. count = 0;
  1501. GM_level = pc_isGM(sd);
  1502. pl_allsd = map_getallusers(&users);
  1503. for (i = 0; i < users; i++) {
  1504. if ((pl_sd = pl_allsd[i])) {
  1505. pl_GM_level = pc_isGM(pl_sd);
  1506. 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
  1507. if (pl_sd->bl.m == map_id) {
  1508. if (pl_GM_level > 0)
  1509. 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);
  1510. else
  1511. 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);
  1512. clif_displaymessage(fd, atcmd_output);
  1513. count++;
  1514. }
  1515. }
  1516. }
  1517. }
  1518. if (count == 0)
  1519. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1520. else if (count == 1)
  1521. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1522. else {
  1523. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1524. }
  1525. clif_displaymessage(fd, atcmd_output);
  1526. return 0;
  1527. }
  1528. /*==========================================
  1529. *
  1530. *------------------------------------------
  1531. */
  1532. int atcommand_whomap2(
  1533. const int fd, struct map_session_data* sd,
  1534. const char* command, const char* message)
  1535. {
  1536. struct map_session_data *pl_sd, **pl_allsd;
  1537. int i, count, users;
  1538. int pl_GM_level, GM_level;
  1539. int map_id = 0;
  1540. char map_name[MAP_NAME_LENGTH];
  1541. nullpo_retr(-1, sd);
  1542. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1543. memset(map_name, '\0', sizeof(map_name));
  1544. if (!message || !*message)
  1545. map_id = sd->bl.m;
  1546. else {
  1547. sscanf(message, "%15s", map_name);
  1548. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1549. strcat(map_name, ".gat");
  1550. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1551. map_id = sd->bl.m;
  1552. }
  1553. count = 0;
  1554. GM_level = pc_isGM(sd);
  1555. pl_allsd = map_getallusers(&users);
  1556. for (i = 0; i < users; i++) {
  1557. if ((pl_sd = pl_allsd[i])) {
  1558. pl_GM_level = pc_isGM(pl_sd);
  1559. 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
  1560. if (pl_sd->bl.m == map_id) {
  1561. if (pl_GM_level > 0)
  1562. 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);
  1563. else
  1564. 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);
  1565. clif_displaymessage(fd, atcmd_output);
  1566. count++;
  1567. }
  1568. }
  1569. }
  1570. }
  1571. if (count == 0)
  1572. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1573. else if (count == 1)
  1574. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1575. else {
  1576. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1577. }
  1578. clif_displaymessage(fd, atcmd_output);
  1579. return 0;
  1580. }
  1581. /*==========================================
  1582. *
  1583. *------------------------------------------
  1584. */
  1585. int atcommand_whomap(
  1586. const int fd, struct map_session_data* sd,
  1587. const char* command, const char* message)
  1588. {
  1589. char temp0[100];
  1590. char temp1[100];
  1591. struct map_session_data *pl_sd, **pl_allsd;
  1592. int i, count, users;
  1593. int pl_GM_level, GM_level;
  1594. int map_id = 0;
  1595. char map_name[MAP_NAME_LENGTH];
  1596. struct guild *g;
  1597. struct party_data *p;
  1598. nullpo_retr(-1, sd);
  1599. memset(temp0, '\0', sizeof(temp0));
  1600. memset(temp1, '\0', sizeof(temp1));
  1601. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1602. memset(map_name, '\0', sizeof(map_name));
  1603. if (!message || !*message)
  1604. map_id = sd->bl.m;
  1605. else {
  1606. sscanf(message, "%15s", map_name);
  1607. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1608. strcat(map_name, ".gat");
  1609. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1610. map_id = sd->bl.m;
  1611. }
  1612. count = 0;
  1613. GM_level = pc_isGM(sd);
  1614. pl_allsd = map_getallusers(&users);
  1615. for (i = 0; i < users; i++) {
  1616. if ((pl_sd = pl_allsd[i])) {
  1617. pl_GM_level = pc_isGM(pl_sd);
  1618. 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
  1619. if (pl_sd->bl.m == map_id) {
  1620. g = guild_search(pl_sd->status.guild_id);
  1621. if (g == NULL)
  1622. sprintf(temp1, "None");
  1623. else
  1624. sprintf(temp1, "%s", g->name);
  1625. p = party_search(pl_sd->status.party_id);
  1626. if (p == NULL)
  1627. sprintf(temp0, "None");
  1628. else
  1629. sprintf(temp0, "%s", p->party.name);
  1630. if (pl_GM_level > 0)
  1631. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1632. else
  1633. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1634. clif_displaymessage(fd, atcmd_output);
  1635. count++;
  1636. }
  1637. }
  1638. }
  1639. }
  1640. if (count == 0)
  1641. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1642. else if (count == 1)
  1643. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1644. else {
  1645. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1646. }
  1647. clif_displaymessage(fd, atcmd_output);
  1648. return 0;
  1649. }
  1650. /*==========================================
  1651. *
  1652. *------------------------------------------
  1653. */
  1654. int atcommand_whogm(
  1655. const int fd, struct map_session_data* sd,
  1656. const char* command, const char* message)
  1657. {
  1658. char temp0[100];
  1659. char temp1[100];
  1660. struct map_session_data *pl_sd, **pl_allsd;
  1661. int i, j, count, users;
  1662. int pl_GM_level, GM_level;
  1663. char match_text[100];
  1664. char player_name[NAME_LENGTH];
  1665. struct guild *g;
  1666. struct party_data *p;
  1667. nullpo_retr(-1, sd);
  1668. memset(temp0, '\0', sizeof(temp0));
  1669. memset(temp1, '\0', sizeof(temp1));
  1670. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1671. memset(match_text, '\0', sizeof(match_text));
  1672. memset(player_name, '\0', sizeof(player_name));
  1673. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1674. strcpy(match_text, "");
  1675. for (j = 0; match_text[j]; j++)
  1676. match_text[j] = tolower(match_text[j]);
  1677. count = 0;
  1678. GM_level = pc_isGM(sd);
  1679. pl_allsd = map_getallusers(&users);
  1680. for (i = 0; i < users; i++) {
  1681. if ((pl_sd = pl_allsd[i])) {
  1682. pl_GM_level = pc_isGM(pl_sd);
  1683. if (pl_GM_level > 0) {
  1684. 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
  1685. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1686. for (j = 0; player_name[j]; j++)
  1687. player_name[j] = tolower(player_name[j]);
  1688. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1689. 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);
  1690. clif_displaymessage(fd, atcmd_output);
  1691. 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);
  1692. clif_displaymessage(fd, atcmd_output);
  1693. g = guild_search(pl_sd->status.guild_id);
  1694. if (g == NULL)
  1695. sprintf(temp1, "None");
  1696. else
  1697. sprintf(temp1, "%s", g->name);
  1698. p = party_search(pl_sd->status.party_id);
  1699. if (p == NULL)
  1700. sprintf(temp0, "None");
  1701. else
  1702. sprintf(temp0, "%s", p->party.name);
  1703. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1704. clif_displaymessage(fd, atcmd_output);
  1705. count++;
  1706. }
  1707. }
  1708. }
  1709. }
  1710. }
  1711. if (count == 0)
  1712. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1713. else if (count == 1)
  1714. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1715. else {
  1716. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1717. clif_displaymessage(fd, atcmd_output);
  1718. }
  1719. return 0;
  1720. }
  1721. int atcommand_whozeny(
  1722. const int fd, struct map_session_data* sd,
  1723. const char* command, const char* message)
  1724. {
  1725. struct map_session_data *pl_sd, **pl_allsd;
  1726. int i, j, count,c, users;
  1727. char match_text[100];
  1728. char player_name[NAME_LENGTH];
  1729. int *zeny;
  1730. int *counted;
  1731. nullpo_retr(-1, sd);
  1732. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1733. memset(match_text, '\0', sizeof(match_text));
  1734. memset(player_name, '\0', sizeof(player_name));
  1735. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1736. strcpy(match_text, "");
  1737. for (j = 0; match_text[j]; j++)
  1738. match_text[j] = tolower(match_text[j]);
  1739. count = 0;
  1740. pl_allsd = map_getallusers(&users);
  1741. if (users < 1)
  1742. {
  1743. clif_displaymessage(fd, msg_table[28]); // No player found.
  1744. return 0;
  1745. }
  1746. zeny = (int *)aMallocA(users*sizeof(int));
  1747. counted = (int *)aMallocA(users*sizeof(int));
  1748. for (i = 0; i < users; i++) {
  1749. if ((pl_sd = pl_allsd[i])) {
  1750. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1751. for (j = 0; player_name[j]; j++)
  1752. player_name[j] = tolower(player_name[j]);
  1753. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1754. zeny[count]=pl_sd->status.zeny;
  1755. counted[i]=0;
  1756. count++;
  1757. }
  1758. }
  1759. }
  1760. qsort(zeny, count, sizeof(int), hightolow_compare);
  1761. for (c = 0; c < count && c < 50; c++) {
  1762. if(!zeny[c])
  1763. continue;
  1764. for (i = 0; i < users; i++) {
  1765. if(!zeny[c])
  1766. continue;
  1767. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1768. if(pl_sd->status.zeny==zeny[c]) {
  1769. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1770. clif_displaymessage(fd, atcmd_output);
  1771. zeny[c]=0;
  1772. counted[i]=1;
  1773. }
  1774. }
  1775. }
  1776. }
  1777. if (count == 0)
  1778. clif_displaymessage(fd, msg_table[28]); // No player found.
  1779. else if (count == 1)
  1780. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1781. else {
  1782. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1783. clif_displaymessage(fd, atcmd_output);
  1784. }
  1785. aFree(zeny);
  1786. aFree(counted);
  1787. return 0;
  1788. }
  1789. // cause random emote on all online players [Valaris]
  1790. int atcommand_happyhappyjoyjoy(
  1791. const int fd, struct map_session_data* sd,
  1792. const char* command, const char* message)
  1793. {
  1794. struct map_session_data *pl_sd, **pl_allsd;
  1795. int i,e, users;
  1796. nullpo_retr(-1, sd);
  1797. pl_allsd = map_getallusers(&users);
  1798. for (i = 0; i < users; i++) {
  1799. if ((pl_sd = pl_allsd[i])) {
  1800. e=rand()%40;
  1801. if(e==34)
  1802. e = 0;
  1803. clif_emotion(&pl_sd->bl,e);
  1804. }
  1805. }
  1806. return 0;
  1807. }
  1808. /*==========================================
  1809. *
  1810. *------------------------------------------
  1811. */
  1812. int atcommand_save(
  1813. const int fd, struct map_session_data* sd,
  1814. const char* command, const char* message)
  1815. {
  1816. nullpo_retr(-1, sd);
  1817. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1818. if (sd->status.pet_id > 0 && sd->pd)
  1819. intif_save_petdata(sd->status.account_id, &sd->pet);
  1820. chrif_save(sd,0);
  1821. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1822. return 0;
  1823. }
  1824. /*==========================================
  1825. *
  1826. *------------------------------------------
  1827. */
  1828. int atcommand_load(
  1829. const int fd, struct map_session_data* sd,
  1830. const char* command, const char* message)
  1831. {
  1832. int m;
  1833. nullpo_retr(-1, sd);
  1834. m = map_mapindex2mapid(sd->status.save_point.map);
  1835. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1836. clif_displaymessage(fd, msg_table[249]);
  1837. return -1;
  1838. }
  1839. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1840. clif_displaymessage(fd, msg_table[248]);
  1841. return -1;
  1842. }
  1843. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1844. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1845. return 0;
  1846. }
  1847. /*==========================================
  1848. *
  1849. *------------------------------------------
  1850. */
  1851. int atcommand_speed(
  1852. const int fd, struct map_session_data* sd,
  1853. const char* command, const char* message)
  1854. {
  1855. int speed;
  1856. nullpo_retr(-1, sd);
  1857. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1858. if (!message || !*message) {
  1859. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1860. clif_displaymessage(fd, atcmd_output);
  1861. return -1;
  1862. }
  1863. speed = atoi(message);
  1864. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1865. sd->battle_status.speed = speed;
  1866. clif_updatestatus(sd, SP_SPEED);
  1867. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1868. } else {
  1869. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1870. clif_displaymessage(fd, atcmd_output);
  1871. return -1;
  1872. }
  1873. return 0;
  1874. }
  1875. /*==========================================
  1876. *
  1877. *------------------------------------------
  1878. */
  1879. int atcommand_storage(
  1880. const int fd, struct map_session_data* sd,
  1881. const char* command, const char* message)
  1882. {
  1883. struct storage *stor; //changes from Freya/Yor
  1884. nullpo_retr(-1, sd);
  1885. if (sd->state.storage_flag) {
  1886. clif_displaymessage(fd, msg_table[250]);
  1887. return -1;
  1888. }
  1889. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1890. clif_displaymessage(fd, msg_table[250]);
  1891. return -1;
  1892. }
  1893. storage_storageopen(sd);
  1894. return 0;
  1895. }
  1896. /*==========================================
  1897. *
  1898. *------------------------------------------
  1899. */
  1900. int atcommand_guildstorage(
  1901. const int fd, struct map_session_data* sd,
  1902. const char* command, const char* message)
  1903. {
  1904. struct storage *stor; //changes from Freya/Yor
  1905. nullpo_retr(-1, sd);
  1906. if (sd->status.guild_id > 0) {
  1907. if (sd->state.storage_flag) {
  1908. clif_displaymessage(fd, msg_table[251]);
  1909. return -1;
  1910. }
  1911. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1912. clif_displaymessage(fd, msg_table[251]);
  1913. return -1;
  1914. }
  1915. storage_guild_storageopen(sd);
  1916. } else {
  1917. clif_displaymessage(fd, msg_table[252]);
  1918. return -1;
  1919. }
  1920. return 0;
  1921. }
  1922. /*==========================================
  1923. *
  1924. *------------------------------------------
  1925. */
  1926. int atcommand_option(
  1927. const int fd, struct map_session_data* sd,
  1928. const char* command, const char* message)
  1929. {
  1930. int param1 = 0, param2 = 0, param3 = 0;
  1931. nullpo_retr(-1, sd);
  1932. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1933. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1934. return -1;
  1935. }
  1936. sd->sc.opt1 = param1;
  1937. sd->sc.opt2 = param2;
  1938. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1939. clif_cartlist(sd);
  1940. clif_updatestatus(sd, SP_CARTINFO);
  1941. }
  1942. pc_setoption(sd, param3);
  1943. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1944. return 0;
  1945. }
  1946. /*==========================================
  1947. *
  1948. *------------------------------------------
  1949. */
  1950. int atcommand_hide(
  1951. const int fd, struct map_session_data* sd,
  1952. const char* command, const char* message)
  1953. {
  1954. nullpo_retr(-1, sd);
  1955. if (sd->sc.option & OPTION_INVISIBLE) {
  1956. sd->sc.option &= ~OPTION_INVISIBLE;
  1957. if (sd->disguise)
  1958. status_set_viewdata(&sd->bl, sd->disguise);
  1959. else
  1960. status_set_viewdata(&sd->bl, sd->status.class_);
  1961. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1962. } else {
  1963. sd->sc.option |= OPTION_INVISIBLE;
  1964. sd->vd.class_ = INVISIBLE_CLASS;
  1965. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1966. }
  1967. clif_changeoption(&sd->bl);
  1968. return 0;
  1969. }
  1970. /*==========================================
  1971. * 転職する upperを指定すると転生や養子にもなれる
  1972. *------------------------------------------
  1973. */
  1974. int atcommand_jobchange(
  1975. const int fd, struct map_session_data* sd,
  1976. const char* command, const char* message)
  1977. {
  1978. int job = 0, upper = 0;
  1979. nullpo_retr(-1, sd);
  1980. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1981. int i, found = 0;
  1982. const struct { char name[16]; int id; } jobs[] = {
  1983. { "novice", 0 },
  1984. { "swordsman", 1 },
  1985. { "mage", 2 },
  1986. { "archer", 3 },
  1987. { "acolyte", 4 },
  1988. { "merchant", 5 },
  1989. { "thief", 6 },
  1990. { "knight", 7 },
  1991. { "priest", 8 },
  1992. { "priestess", 8 },
  1993. { "wizard", 9 },
  1994. { "blacksmith", 10 },
  1995. { "hunter", 11 },
  1996. { "assassin", 12 },
  1997. { "crusader", 14 },
  1998. { "monk", 15 },
  1999. { "sage", 16 },
  2000. { "rogue", 17 },
  2001. { "alchemist", 18 },
  2002. { "bard", 19 },
  2003. { "dancer", 20 },
  2004. { "super novice", 23 },
  2005. { "supernovice", 23 },
  2006. { "gunslinger", 24 },
  2007. { "gunner", 24 },
  2008. { "ninja", 25 },
  2009. { "high novice", 4001 },
  2010. { "swordsman high", 4002 },
  2011. { "mage high", 4003 },
  2012. { "archer high", 4004 },
  2013. { "acolyte high", 4005 },
  2014. { "merchant high", 4006 },
  2015. { "thief high", 4007 },
  2016. { "lord knight", 4008 },
  2017. { "high priest", 4009 },
  2018. { "high priestess", 4009 },
  2019. { "high wizard", 4010 },
  2020. { "whitesmith", 4011 },
  2021. { "sniper", 4012 },
  2022. { "assassin cross", 4013 },
  2023. { "paladin", 4015 },
  2024. { "champion", 4016 },
  2025. { "professor", 4017 },
  2026. { "stalker", 4018 },
  2027. { "creator", 4019 },
  2028. { "clown", 4020 },
  2029. { "gypsy", 4021 },
  2030. { "baby novice", 4023 },
  2031. { "baby swordsman", 4024 },
  2032. { "baby mage", 4025 },
  2033. { "baby archer", 4026 },
  2034. { "baby acolyte", 4027 },
  2035. { "baby merchant", 4028 },
  2036. { "baby thief", 4029 },
  2037. { "baby knight", 4030 },
  2038. { "baby priest", 4031 },
  2039. { "baby priestess", 4031 },
  2040. { "baby wizard", 4032 },
  2041. { "baby blacksmith",4033 },
  2042. { "baby hunter", 4034 },
  2043. { "baby assassin", 4035 },
  2044. { "baby crusader", 4037 },
  2045. { "baby monk", 4038 },
  2046. { "baby sage", 4039 },
  2047. { "baby rogue", 4040 },
  2048. { "baby alchemist", 4041 },
  2049. { "baby bard", 4042 },
  2050. { "baby dancer", 4043 },
  2051. { "super baby", 4045 },
  2052. { "taekwon", 4046 },
  2053. { "taekwon boy", 4046 },
  2054. { "taekwon girl", 4046 },
  2055. { "star gladiator", 4047 },
  2056. { "soul linker", 4049 },
  2057. };
  2058. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2059. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2060. job = jobs[i].id;
  2061. upper = 0;
  2062. found = 1;
  2063. break;
  2064. }
  2065. }
  2066. if (!found) {
  2067. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2068. return -1;
  2069. }
  2070. }
  2071. if (job == 37 ||job == 45)
  2072. return 0;
  2073. if ((job >= 0 && job < MAX_PC_CLASS))
  2074. {
  2075. int j;
  2076. for (j=0; j < MAX_INVENTORY; j++) {
  2077. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2078. pc_unequipitem(sd, j, 3);
  2079. }
  2080. if (pc_jobchange(sd, job, upper) == 0)
  2081. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2082. else {
  2083. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2084. return -1;
  2085. }
  2086. } else {
  2087. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2088. return -1;
  2089. }
  2090. return 0;
  2091. }
  2092. /*==========================================
  2093. *
  2094. *------------------------------------------
  2095. */
  2096. int atcommand_die(
  2097. const int fd, struct map_session_data* sd,
  2098. const char* command, const char* message)
  2099. {
  2100. nullpo_retr(-1, sd);
  2101. clif_specialeffect(&sd->bl,450,SELF);
  2102. status_kill(&sd->bl);
  2103. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2104. return 0;
  2105. }
  2106. /*==========================================
  2107. *
  2108. *------------------------------------------
  2109. */
  2110. int atcommand_kill(
  2111. const int fd, struct map_session_data* sd,
  2112. const char* command, const char* message)
  2113. {
  2114. struct map_session_data *pl_sd;
  2115. nullpo_retr(-1, sd);
  2116. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2117. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2118. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2119. return -1;
  2120. }
  2121. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2122. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2123. status_kill(&pl_sd->bl);
  2124. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2125. } else {
  2126. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2127. return -1;
  2128. }
  2129. } else {
  2130. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2131. return -1;
  2132. }
  2133. return 0;
  2134. }
  2135. /*==========================================
  2136. *
  2137. *------------------------------------------
  2138. */
  2139. int atcommand_alive(
  2140. const int fd, struct map_session_data* sd,
  2141. const char* command, const char* message)
  2142. {
  2143. nullpo_retr(-1, sd);
  2144. if (!status_revive(&sd->bl, 100, 100))
  2145. return -1;
  2146. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2147. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2148. return 0;
  2149. }
  2150. /*==========================================
  2151. * +kamic [LuzZza]
  2152. *------------------------------------------
  2153. */
  2154. int atcommand_kami(
  2155. const int fd, struct map_session_data* sd,
  2156. const char* command, const char* message)
  2157. {
  2158. unsigned long color=0;
  2159. nullpo_retr(-1, sd);
  2160. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2161. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2162. if (!message || !*message) {
  2163. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2164. return -1;
  2165. }
  2166. sscanf(message, "%199[^\n]", atcmd_output);
  2167. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2168. } else {
  2169. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2170. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2171. return -1;
  2172. }
  2173. if(color > 0xFFFFFF) {
  2174. clif_displaymessage(fd, "Invalid color.");
  2175. return -1;
  2176. }
  2177. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2178. }
  2179. return 0;
  2180. }
  2181. /*==========================================
  2182. *
  2183. *------------------------------------------
  2184. */
  2185. int atcommand_heal(
  2186. const int fd, struct map_session_data* sd,
  2187. const char* command, const char* message)
  2188. {
  2189. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2190. nullpo_retr(-1, sd);
  2191. sscanf(message, "%d %d", &hp, &sp);
  2192. if (hp == 0 && sp == 0) {
  2193. if (!status_percent_heal(&sd->bl, 100, 100))
  2194. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2195. else
  2196. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2197. return 0;
  2198. }
  2199. if(hp > 0 && sp >= 0) {
  2200. if(!status_heal(&sd->bl, hp, sp, 0))
  2201. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2202. else
  2203. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2204. return 0;
  2205. }
  2206. if(hp < 0 && sp <= 0) {
  2207. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  2208. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2209. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2210. return 0;
  2211. }
  2212. //Opposing signs.
  2213. if (hp) {
  2214. if (hp > 0)
  2215. status_heal(&sd->bl, hp, 0, 0);
  2216. else {
  2217. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  2218. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2219. }
  2220. }
  2221. if (sp) {
  2222. if (sp > 0)
  2223. status_heal(&sd->bl, 0, sp, 0);
  2224. else
  2225. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  2226. }
  2227. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2228. return 0;
  2229. }
  2230. /*==========================================
  2231. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2232. *------------------------------------------
  2233. */
  2234. int atcommand_item(
  2235. const int fd, struct map_session_data* sd,
  2236. const char* command, const char* message)
  2237. {
  2238. char item_name[100];
  2239. int number = 0, item_id, flag;
  2240. struct item item_tmp;
  2241. struct item_data *item_data;
  2242. int get_count, i, pet_id;
  2243. nullpo_retr(-1, sd);
  2244. memset(item_name, '\0', sizeof(item_name));
  2245. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2246. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2247. return -1;
  2248. }
  2249. if (number <= 0)
  2250. number = 1;
  2251. item_id = 0;
  2252. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2253. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2254. item_id = item_data->nameid;
  2255. if (item_id >= 500) {
  2256. get_count = number;
  2257. // check pet egg
  2258. pet_id = search_petDB_index(item_id, PET_EGG);
  2259. if (item_data->type == 4 || item_data->type == 5 ||
  2260. item_data->type == 7 || item_data->type == 8) {
  2261. get_count = 1;
  2262. }
  2263. for (i = 0; i < number; i += get_count) {
  2264. // if pet egg
  2265. if (pet_id >= 0) {
  2266. sd->catch_target_class = pet_db[pet_id].class_;
  2267. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2268. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2269. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2270. 100, 0, 1, pet_db[pet_id].jname);
  2271. // if not pet egg
  2272. } else {
  2273. memset(&item_tmp, 0, sizeof(item_tmp));
  2274. item_tmp.nameid = item_id;
  2275. item_tmp.identify = 1;
  2276. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2277. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2278. }
  2279. }
  2280. //Logs (A)dmins items [Lupus]
  2281. if(log_config.pick > 0 ) {
  2282. log_pick(sd, "A", 0, item_id, number, NULL);
  2283. }
  2284. //Logs
  2285. clif_displaymessage(fd, msg_table[18]); // Item created.
  2286. } else {
  2287. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2288. return -1;
  2289. }
  2290. return 0;
  2291. }
  2292. /*==========================================
  2293. *
  2294. *------------------------------------------
  2295. */
  2296. int atcommand_item2(
  2297. const int fd, struct map_session_data* sd,
  2298. const char* command, const char* message)
  2299. {
  2300. struct item item_tmp;
  2301. struct item_data *item_data;
  2302. char item_name[100];
  2303. int item_id, number = 0;
  2304. int identify = 0, refine = 0, attr = 0;
  2305. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2306. int flag;
  2307. int loop, get_count, i;
  2308. nullpo_retr(-1, sd);
  2309. memset(item_name, '\0', sizeof(item_name));
  2310. if (!message || !*message || sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9) {
  2311. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2312. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2313. return -1;
  2314. }
  2315. if (number <= 0)
  2316. number = 1;
  2317. item_id = 0;
  2318. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2319. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2320. item_id = item_data->nameid;
  2321. if (item_id > 500) {
  2322. loop = 1;
  2323. get_count = number;
  2324. if (item_data->type == 4 || item_data->type == 5 ||
  2325. item_data->type == 7 || item_data->type == 8) {
  2326. loop = number;
  2327. get_count = 1;
  2328. if (item_data->type == 7) {
  2329. identify = 1;
  2330. refine = 0;
  2331. }
  2332. if (item_data->type == 8)
  2333. refine = 0;
  2334. if (refine > 10)
  2335. refine = 10;
  2336. } else {
  2337. identify = 1;
  2338. refine = attr = 0;
  2339. }
  2340. for (i = 0; i < loop; i++) {
  2341. memset(&item_tmp, 0, sizeof(item_tmp));
  2342. item_tmp.nameid = item_id;
  2343. item_tmp.identify = identify;
  2344. item_tmp.refine = refine;
  2345. item_tmp.attribute = attr;
  2346. item_tmp.card[0] = c1;
  2347. item_tmp.card[1] = c2;
  2348. item_tmp.card[2] = c3;
  2349. item_tmp.card[3] = c4;
  2350. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2351. clif_additem(sd, 0, 0, flag);
  2352. }
  2353. //Logs (A)dmins items [Lupus]
  2354. if(log_config.pick > 0 ) {
  2355. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2356. }
  2357. //Logs
  2358. clif_displaymessage(fd, msg_table[18]); // Item created.
  2359. } else {
  2360. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2361. return -1;
  2362. }
  2363. return 0;
  2364. }
  2365. /*==========================================
  2366. *
  2367. *------------------------------------------
  2368. */
  2369. int atcommand_itemreset(
  2370. const int fd, struct map_session_data* sd,
  2371. const char* command, const char* message)
  2372. {
  2373. int i;
  2374. nullpo_retr(-1, sd);
  2375. for (i = 0; i < MAX_INVENTORY; i++) {
  2376. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2377. //Logs (A)dmins items [Lupus]
  2378. if(log_config.pick > 0 ) {
  2379. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2380. }
  2381. //Logs
  2382. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2383. }
  2384. }
  2385. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2386. return 0;
  2387. }
  2388. /*==========================================
  2389. *
  2390. *------------------------------------------
  2391. */
  2392. int atcommand_itemcheck(
  2393. const int fd, struct map_session_data* sd,
  2394. const char* command, const char* message)
  2395. {
  2396. nullpo_retr(-1, sd);
  2397. pc_checkitem(sd);
  2398. return 0;
  2399. }
  2400. /*==========================================
  2401. * Atcommand @lvlup
  2402. *------------------------------------------
  2403. */
  2404. int atcommand_baselevelup(
  2405. const int fd, struct map_session_data* sd,
  2406. const char* command, const char* message)
  2407. {
  2408. int level=0, i=0, status_point=0;
  2409. nullpo_retr(-1, sd);
  2410. level = atoi(message);
  2411. if (!message || !*message || !level) {
  2412. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2413. return -1;
  2414. }
  2415. if (level > 0) {
  2416. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2417. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2418. return -1;
  2419. } /* End Addition */
  2420. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2421. level = pc_maxbaselv(sd) - sd->status.base_level;
  2422. for (i = 1; i <= level; i++)
  2423. status_point += (sd->status.base_level + i + 14) / 5;
  2424. if (sd->status.status_point > USHRT_MAX - status_point)
  2425. sd->status.status_point = USHRT_MAX;
  2426. else
  2427. sd->status.status_point += status_point;
  2428. sd->status.base_level += (unsigned int)level;
  2429. clif_updatestatus(sd, SP_BASELEVEL);
  2430. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2431. clif_updatestatus(sd, SP_STATUSPOINT);
  2432. status_calc_pc(sd, 0);
  2433. status_percent_heal(&sd->bl, 100, 100);
  2434. clif_misceffect(&sd->bl, 0);
  2435. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2436. } else {
  2437. if (sd->status.base_level == 1) {
  2438. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2439. return -1;
  2440. }
  2441. level*=-1;
  2442. if ((unsigned int)level >= sd->status.base_level)
  2443. level = sd->status.base_level-1;
  2444. if (sd->status.status_point > 0) {
  2445. for (i = 0; i > -level; i--)
  2446. status_point += (sd->status.base_level + i + 14) / 5;
  2447. if (sd->status.status_point < status_point)
  2448. pc_resetstate(sd);
  2449. if (sd->status.status_point < status_point)
  2450. sd->status.status_point = 0;
  2451. else
  2452. sd->status.status_point -= status_point;
  2453. clif_updatestatus(sd, SP_STATUSPOINT);
  2454. } /* to add: remove status points from stats */
  2455. sd->status.base_level -= (unsigned int)level;
  2456. clif_updatestatus(sd, SP_BASELEVEL);
  2457. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2458. status_calc_pc(sd, 0);
  2459. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2460. }
  2461. return 0;
  2462. }
  2463. /*==========================================
  2464. *
  2465. *------------------------------------------
  2466. */
  2467. int atcommand_joblevelup(
  2468. const int fd, struct map_session_data* sd,
  2469. const char* command, const char* message)
  2470. {
  2471. int level=0;
  2472. nullpo_retr(-1, sd);
  2473. level = atoi(message);
  2474. if (!message || !*message || !level) {
  2475. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2476. return -1;
  2477. }
  2478. if (level > 0) {
  2479. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2480. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2481. return -1;
  2482. }
  2483. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2484. level = pc_maxjoblv(sd) - sd->status.job_level;
  2485. sd->status.job_level += (unsigned int)level;
  2486. clif_updatestatus(sd, SP_JOBLEVEL);
  2487. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2488. if (sd->status.skill_point > USHRT_MAX - level)
  2489. sd->status.skill_point = USHRT_MAX;
  2490. else
  2491. sd->status.skill_point += level;
  2492. clif_updatestatus(sd, SP_SKILLPOINT);
  2493. status_calc_pc(sd, 0);
  2494. clif_misceffect(&sd->bl, 1);
  2495. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2496. } else {
  2497. if (sd->status.job_level == 1) {
  2498. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2499. return -1;
  2500. }
  2501. level *=-1;
  2502. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2503. level = sd->status.job_level-1;
  2504. sd->status.job_level -= (unsigned int)level;
  2505. clif_updatestatus(sd, SP_JOBLEVEL);
  2506. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2507. if (sd->status.skill_point < level)
  2508. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2509. if (sd->status.skill_point < level)
  2510. sd->status.skill_point = 0;
  2511. else
  2512. sd->status.skill_point -= level;
  2513. clif_updatestatus(sd, SP_SKILLPOINT);
  2514. status_calc_pc(sd, 0);
  2515. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2516. }
  2517. return 0;
  2518. }
  2519. /*==========================================
  2520. * @help
  2521. *------------------------------------------
  2522. */
  2523. int atcommand_help(
  2524. const int fd, struct map_session_data* sd,
  2525. const char* command, const char* message)
  2526. {
  2527. char buf[2048], w1[2048], w2[2048];
  2528. int i, gm_level;
  2529. FILE* fp;
  2530. nullpo_retr(-1, sd);
  2531. memset(buf, '\0', sizeof(buf));
  2532. if ((fp = fopen(help_txt, "r")) != NULL) {
  2533. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2534. gm_level = pc_isGM(sd);
  2535. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2536. if (buf[0] == '/' && buf[1] == '/')
  2537. continue;
  2538. for (i = 0; buf[i] != '\0'; i++) {
  2539. if (buf[i] == '\r' || buf[i] == '\n') {
  2540. buf[i] = '\0';
  2541. break;
  2542. }
  2543. }
  2544. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2545. clif_displaymessage(fd, buf);
  2546. else if (gm_level >= atoi(w1))
  2547. clif_displaymessage(fd, w2);
  2548. }
  2549. fclose(fp);
  2550. } else {
  2551. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2552. return -1;
  2553. }
  2554. return 0;
  2555. }
  2556. /*==========================================
  2557. * @help2 - Char commands [Kayla]
  2558. *------------------------------------------
  2559. */
  2560. int atcommand_help2(
  2561. const int fd, struct map_session_data* sd,
  2562. const char* command, const char* message)
  2563. {
  2564. char buf[2048], w1[2048], w2[2048];
  2565. int i, gm_level;
  2566. FILE* fp;
  2567. nullpo_retr(-1, sd);
  2568. memset(buf, '\0', sizeof(buf));
  2569. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2570. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2571. gm_level = pc_isGM(sd);
  2572. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2573. if (buf[0] == '/' && buf[1] == '/')
  2574. continue;
  2575. for (i = 0; buf[i] != '\0'; i++) {
  2576. if (buf[i] == '\r' || buf[i] == '\n') {
  2577. buf[i] = '\0';
  2578. break;
  2579. }
  2580. }
  2581. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2582. clif_displaymessage(fd, buf);
  2583. else if (gm_level >= atoi(w1))
  2584. clif_displaymessage(fd, w2);
  2585. }
  2586. fclose(fp);
  2587. } else {
  2588. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2589. return -1;
  2590. }
  2591. return 0;
  2592. }
  2593. /*==========================================
  2594. * @gm
  2595. *------------------------------------------
  2596. */
  2597. int atcommand_gm(
  2598. const int fd, struct map_session_data* sd,
  2599. const char* command, const char* message)
  2600. {
  2601. char password[100];
  2602. nullpo_retr(-1, sd);
  2603. memset(password, '\0', sizeof(password));
  2604. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2605. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2606. return -1;
  2607. }
  2608. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2609. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2610. return -1;
  2611. } else
  2612. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2613. return 0;
  2614. }
  2615. /*==========================================
  2616. *
  2617. *------------------------------------------
  2618. */
  2619. int atcommand_pvpoff(
  2620. const int fd, struct map_session_data* sd,
  2621. const char* command, const char* message)
  2622. {
  2623. struct map_session_data *pl_sd, **pl_allsd;
  2624. int i, users;
  2625. nullpo_retr(-1, sd);
  2626. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2627. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2628. return -1;
  2629. }
  2630. if (map[sd->bl.m].flag.pvp) {
  2631. map[sd->bl.m].flag.pvp = 0;
  2632. clif_send0199(sd->bl.m, 0);
  2633. pl_allsd = map_getallusers(&users);
  2634. for (i = 0; i < users; i++) { //人数分ループ
  2635. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2636. clif_pvpset(pl_sd, 0, 0, 2);
  2637. if (pl_sd->pvp_timer != -1) {
  2638. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2639. pl_sd->pvp_timer = -1;
  2640. }
  2641. }
  2642. }
  2643. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2644. } else {
  2645. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2646. return -1;
  2647. }
  2648. return 0;
  2649. }
  2650. /*==========================================
  2651. *
  2652. *------------------------------------------
  2653. */
  2654. int atcommand_pvpon(
  2655. const int fd, struct map_session_data* sd,
  2656. const char* command, const char* message)
  2657. {
  2658. struct map_session_data *pl_sd, **pl_allsd;
  2659. int i, users;
  2660. nullpo_retr(-1, sd);
  2661. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2662. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2663. return -1;
  2664. }
  2665. if (!map[sd->bl.m].flag.pvp) {
  2666. map[sd->bl.m].flag.pvp = 1;
  2667. clif_send0199(sd->bl.m, 1);
  2668. pl_allsd = map_getallusers(&users);
  2669. for (i = 0; i < users; i++) {
  2670. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2671. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2672. pl_sd->pvp_rank = 0;
  2673. pl_sd->pvp_lastusers = 0;
  2674. pl_sd->pvp_point = 5;
  2675. pl_sd->pvp_won = 0;
  2676. pl_sd->pvp_lost = 0;
  2677. }
  2678. }
  2679. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2680. } else {
  2681. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2682. return -1;
  2683. }
  2684. return 0;
  2685. }
  2686. /*==========================================
  2687. *
  2688. *------------------------------------------
  2689. */
  2690. int atcommand_gvgoff(
  2691. const int fd, struct map_session_data* sd,
  2692. const char* command, const char* message)
  2693. {
  2694. nullpo_retr(-1, sd);
  2695. if (map[sd->bl.m].flag.gvg) {
  2696. map[sd->bl.m].flag.gvg = 0;
  2697. clif_send0199(sd->bl.m, 0);
  2698. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2699. } else {
  2700. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2701. return -1;
  2702. }
  2703. return 0;
  2704. }
  2705. /*==========================================
  2706. *
  2707. *------------------------------------------
  2708. */
  2709. int atcommand_gvgon(
  2710. const int fd, struct map_session_data* sd,
  2711. const char* command, const char* message)
  2712. {
  2713. nullpo_retr(-1, sd);
  2714. if (!map[sd->bl.m].flag.gvg) {
  2715. map[sd->bl.m].flag.gvg = 1;
  2716. clif_send0199(sd->bl.m, 3);
  2717. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2718. } else {
  2719. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2720. return -1;
  2721. }
  2722. return 0;
  2723. }
  2724. /*==========================================
  2725. *
  2726. *------------------------------------------
  2727. */
  2728. int atcommand_model(
  2729. const int fd, struct map_session_data* sd,
  2730. const char* command, const char* message)
  2731. {
  2732. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2733. nullpo_retr(-1, sd);
  2734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2735. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2736. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2737. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2738. clif_displaymessage(fd, atcmd_output);
  2739. return -1;
  2740. }
  2741. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2742. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2743. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2744. /* Removed because this check is TOO strange. [Skotlex]
  2745. //秒フ色変更
  2746. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2747. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2748. //秒フ色未実装職の判定
  2749. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2750. return -1;
  2751. } else {
  2752. */
  2753. pc_changelook(sd, LOOK_HAIR, hair_style);
  2754. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2755. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2756. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2757. // }
  2758. } else {
  2759. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2760. return -1;
  2761. }
  2762. return 0;
  2763. }
  2764. /*==========================================
  2765. * @dye && @ccolor
  2766. *------------------------------------------
  2767. */
  2768. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2769. {
  2770. int cloth_color = 0;
  2771. nullpo_retr(-1, sd);
  2772. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2773. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2774. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2775. clif_displaymessage(fd, atcmd_output);
  2776. return -1;
  2777. }
  2778. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2779. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2780. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2781. } else {
  2782. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2783. return -1;
  2784. }
  2785. return 0;
  2786. }
  2787. /*==========================================
  2788. * @hairstyle && @hstyle
  2789. *------------------------------------------
  2790. */
  2791. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2792. {
  2793. int hair_style = 0;
  2794. nullpo_retr(-1, sd);
  2795. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2796. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2797. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2798. clif_displaymessage(fd, atcmd_output);
  2799. return -1;
  2800. }
  2801. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2802. /* Removed because this check is TOO strange. [Skotlex]
  2803. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2804. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2805. return -1;
  2806. } else {
  2807. */
  2808. pc_changelook(sd, LOOK_HAIR, hair_style);
  2809. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2810. // }
  2811. } else {
  2812. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2813. return -1;
  2814. }
  2815. return 0;
  2816. }
  2817. /*==========================================
  2818. * @charhairstyle by [MouseJstr]
  2819. *------------------------------------------
  2820. */
  2821. int
  2822. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2823. const char* command, const char* message)
  2824. {
  2825. nullpo_retr(-1, sd);
  2826. return 0;
  2827. }
  2828. /*==========================================
  2829. * @haircolor && @hcolor
  2830. *------------------------------------------
  2831. */
  2832. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2833. {
  2834. int hair_color = 0;
  2835. nullpo_retr(-1, sd);
  2836. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2837. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2838. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2839. clif_displaymessage(fd, atcmd_output);
  2840. return -1;
  2841. }
  2842. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2843. /* Removed for being such a strange check. [Skotlex]
  2844. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2845. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2846. return -1;
  2847. } else {
  2848. */
  2849. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2850. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2851. // }
  2852. } else {
  2853. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2854. return -1;
  2855. }
  2856. return 0;
  2857. }
  2858. /*==========================================
  2859. * @go [city_number or city_name] - Updated by Harbin
  2860. *------------------------------------------
  2861. */
  2862. int atcommand_go(
  2863. const int fd, struct map_session_data* sd,
  2864. const char* command, const char* message)
  2865. {
  2866. int i;
  2867. int town;
  2868. char map_name[MAP_NAME_LENGTH];
  2869. int m;
  2870. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2871. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2872. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2873. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2874. { MAP_PAYON, 162, 233 }, // 3=Payon
  2875. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2876. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2877. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2878. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2879. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2880. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2881. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2882. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2883. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2884. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2885. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2886. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2887. { MAP_JAIL, 23, 61 }, // 16=Prison
  2888. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2889. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2890. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2891. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2892. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2893. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2894. };
  2895. nullpo_retr(-1, sd);
  2896. if(map[sd->bl.m].flag.nogo) {
  2897. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2898. return 0;
  2899. }
  2900. memset(map_name, '\0', sizeof(map_name));
  2901. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2902. // get the number
  2903. town = atoi(message);
  2904. // if no value, display all value
  2905. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2906. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2907. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2908. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2909. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2910. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2911. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2912. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2913. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2914. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2915. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2916. return -1;
  2917. } else {
  2918. // get possible name of the city and add .gat if not in the name
  2919. map_name[MAP_NAME_LENGTH-1] = '\0';
  2920. for (i = 0; map_name[i]; i++)
  2921. map_name[i] = tolower(map_name[i]);
  2922. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2923. strcat(map_name, ".gat");
  2924. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2925. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2926. town = 0;
  2927. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2928. town = 1;
  2929. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2930. town = 2;
  2931. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2932. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2933. town = 3;
  2934. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2935. town = 4;
  2936. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2937. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2938. town = 5;
  2939. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2940. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2941. town = 6;
  2942. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2943. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2944. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2945. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2946. town = 7;
  2947. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2948. town = 8;
  2949. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2950. town = 9;
  2951. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2952. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2953. town = 10;
  2954. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2955. town = 11;
  2956. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2957. town = 12;
  2958. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2959. town = 13;
  2960. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2961. town = 14;
  2962. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2963. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2964. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2965. town = 15;
  2966. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2967. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2968. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2969. town = 16;
  2970. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2971. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2972. town = 17;
  2973. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2974. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2975. town = 18;
  2976. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2977. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2978. town = 19;
  2979. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2980. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2981. town = 20;
  2982. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2983. town = 21;
  2984. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2985. town = 22;
  2986. }
  2987. if (town >= -3 && town <= -1) {
  2988. if (sd->status.memo_point[-town-1].map) {
  2989. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2990. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2991. clif_displaymessage(fd, msg_table[247]);
  2992. return -1;
  2993. }
  2994. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2995. clif_displaymessage(fd, msg_table[248]);
  2996. return -1;
  2997. }
  2998. 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) {
  2999. clif_displaymessage(fd, msg_table[0]); // Warped.
  3000. } else {
  3001. clif_displaymessage(fd, msg_table[1]); // Map not found.
  3002. return -1;
  3003. }
  3004. } else {
  3005. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  3006. clif_displaymessage(fd, atcmd_output);
  3007. return -1;
  3008. }
  3009. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  3010. m = map_mapname2mapid((char *)data[town].map);
  3011. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3012. clif_displaymessage(fd, msg_table[247]);
  3013. return -1;
  3014. }
  3015. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3016. clif_displaymessage(fd, msg_table[248]);
  3017. return -1;
  3018. }
  3019. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  3020. clif_displaymessage(fd, msg_table[0]); // Warped.
  3021. } else {
  3022. clif_displaymessage(fd, msg_table[1]); // Map not found.
  3023. return -1;
  3024. }
  3025. } else { // if you arrive here, you have an error in town variable when reading of names
  3026. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  3027. return -1;
  3028. }
  3029. }
  3030. return 0;
  3031. }
  3032. /*==========================================
  3033. *
  3034. *------------------------------------------
  3035. */
  3036. int atcommand_monster(
  3037. const int fd, struct map_session_data* sd,
  3038. const char* command, const char* message)
  3039. {
  3040. char name[NAME_LENGTH];
  3041. char monster[NAME_LENGTH];
  3042. int mob_id;
  3043. int number = 0;
  3044. int count;
  3045. int i, k, range;
  3046. short mx, my;
  3047. nullpo_retr(-1, sd);
  3048. memset(name, '\0', sizeof(name));
  3049. memset(monster, '\0', sizeof(monster));
  3050. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3051. if (!message || !*message) {
  3052. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3053. return -1;
  3054. }
  3055. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3056. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3057. //All data can be left as it is.
  3058. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3059. //Here, it is possible name was not given and we are using monster for it.
  3060. if (count < 3) //Blank mob's name.
  3061. name[0] = '\0';
  3062. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3063. //All data can be left as it is.
  3064. } else if (sscanf(message, "%23s", monster) > 0) {
  3065. //As before, name may be already filled.
  3066. name[0] = '\0';
  3067. } else {
  3068. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3069. return -1;
  3070. }
  3071. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3072. mob_id = mobdb_checkid(atoi(monster));
  3073. if (mob_id == 0) {
  3074. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3075. return -1;
  3076. }
  3077. if (mob_id == MOBID_EMPERIUM) {
  3078. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3079. return -1;
  3080. }
  3081. if (number <= 0)
  3082. number = 1;
  3083. if (strlen(name) < 1)
  3084. strcpy(name, "--ja--");
  3085. // 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
  3086. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3087. number = battle_config.atc_spawn_quantity_limit;
  3088. if (battle_config.etc_log)
  3089. 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);
  3090. count = 0;
  3091. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3092. for (i = 0; i < number; i++) {
  3093. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3094. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3095. count += (k != 0) ? 1 : 0;
  3096. }
  3097. if (count != 0)
  3098. if (number == count)
  3099. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3100. else {
  3101. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3102. clif_displaymessage(fd, atcmd_output);
  3103. }
  3104. else {
  3105. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3106. return -1;
  3107. }
  3108. return 0;
  3109. }
  3110. // small monster spawning [Valaris]
  3111. int atcommand_monstersmall(
  3112. const int fd, struct map_session_data* sd,
  3113. const char* command, const char* message) {
  3114. char name[NAME_LENGTH] = "";
  3115. char monster[NAME_LENGTH] = "";
  3116. int mob_id = 0;
  3117. int number = 0;
  3118. int x = 0;
  3119. int y = 0;
  3120. int count;
  3121. int i;
  3122. nullpo_retr(-1, sd);
  3123. if (!message || !*message) {
  3124. clif_displaymessage(fd, "Give a monster name/id please.");
  3125. return -1;
  3126. }
  3127. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3128. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3129. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3130. clif_displaymessage(fd, "Give a monster name/id please.");
  3131. return -1;
  3132. }
  3133. // If monster identifier/name argument is a name
  3134. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3135. mob_id = atoi(monster);
  3136. if (mob_id == 0) {
  3137. clif_displaymessage(fd, msg_table[40]);
  3138. return -1;
  3139. }
  3140. if (mob_id == MOBID_EMPERIUM) {
  3141. clif_displaymessage(fd, msg_table[83]);
  3142. return -1;
  3143. }
  3144. if (mobdb_checkid(mob_id) == 0) {
  3145. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3146. return -1;
  3147. }
  3148. if (number <= 0)
  3149. number = 1;
  3150. if (strlen(name) < 1)
  3151. strcpy(name, "--ja--");
  3152. // 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
  3153. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3154. number = battle_config.atc_spawn_quantity_limit;
  3155. count = 0;
  3156. for (i = 0; i < number; i++) {
  3157. int mx, my;
  3158. if (x <= 0)
  3159. mx = sd->bl.x + (rand() % 11 - 5);
  3160. else
  3161. mx = x;
  3162. if (y <= 0)
  3163. my = sd->bl.y + (rand() % 11 - 5);
  3164. else
  3165. my = y;
  3166. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3167. }
  3168. if (count != 0)
  3169. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3170. else
  3171. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3172. return 0;
  3173. }
  3174. // big monster spawning [Valaris]
  3175. int atcommand_monsterbig(
  3176. const int fd, struct map_session_data* sd,
  3177. const char* command, const char* message) {
  3178. char name[NAME_LENGTH] = "";
  3179. char monster[NAME_LENGTH] = "";
  3180. int mob_id = 0;
  3181. int number = 0;
  3182. int x = 0;
  3183. int y = 0;
  3184. int count;
  3185. int i;
  3186. nullpo_retr(-1, sd);
  3187. if (!message || !*message) {
  3188. clif_displaymessage(fd, "Give a monster name/id please.");
  3189. return -1;
  3190. }
  3191. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3192. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3193. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3194. clif_displaymessage(fd, "Give a monster name/id please.");
  3195. return -1;
  3196. }
  3197. // If monster identifier/name argument is a name
  3198. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3199. mob_id = atoi(monster);
  3200. if (mob_id == 0) {
  3201. clif_displaymessage(fd, msg_table[40]);
  3202. return -1;
  3203. }
  3204. if (mob_id == MOBID_EMPERIUM) {
  3205. clif_displaymessage(fd, msg_table[83]);
  3206. return -1;
  3207. }
  3208. if (mobdb_checkid(mob_id) == 0) {
  3209. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3210. return -1;
  3211. }
  3212. if (number <= 0)
  3213. number = 1;
  3214. if (strlen(name) < 1)
  3215. strcpy(name, "--ja--");
  3216. // 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
  3217. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3218. number = battle_config.atc_spawn_quantity_limit;
  3219. count = 0;
  3220. for (i = 0; i < number; i++) {
  3221. int mx, my;
  3222. if (x <= 0)
  3223. mx = sd->bl.x + (rand() % 11 - 5);
  3224. else
  3225. mx = x;
  3226. if (y <= 0)
  3227. my = sd->bl.y + (rand() % 11 - 5);
  3228. else
  3229. my = y;
  3230. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3231. }
  3232. if (count != 0)
  3233. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3234. else
  3235. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3236. return 0;
  3237. }
  3238. /*==========================================
  3239. *
  3240. *------------------------------------------
  3241. */
  3242. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3243. struct mob_data *md;
  3244. int flag;
  3245. nullpo_retr(0, ap);
  3246. nullpo_retr(0, md=(struct mob_data *)bl);
  3247. flag = va_arg(ap, int);
  3248. if (md->guardian_data)
  3249. return 0; //Do not touch WoE mobs!
  3250. if (flag)
  3251. status_kill(bl);
  3252. else //FIXME: Eh.. what exactly is the difference here?
  3253. status_kill(bl);
  3254. return 1;
  3255. }
  3256. void atcommand_killmonster_sub(
  3257. const int fd, struct map_session_data* sd, const char* message,
  3258. const int drop)
  3259. {
  3260. int map_id;
  3261. char map_name[MAP_NAME_LENGTH];
  3262. if (!sd) return;
  3263. memset(map_name, '\0', sizeof(map_name));
  3264. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3265. map_id = sd->bl.m;
  3266. else {
  3267. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3268. strcat(map_name, ".gat");
  3269. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3270. map_id = sd->bl.m;
  3271. }
  3272. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3273. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3274. return;
  3275. }
  3276. /*==========================================
  3277. *
  3278. *------------------------------------------
  3279. */
  3280. int atcommand_killmonster(
  3281. const int fd, struct map_session_data* sd,
  3282. const char* command, const char* message)
  3283. {
  3284. if (!sd) return 0;
  3285. atcommand_killmonster_sub(fd, sd, message, 1);
  3286. return 0;
  3287. }
  3288. /*==========================================
  3289. *
  3290. *------------------------------------------
  3291. */
  3292. int atcommand_killmonster2(
  3293. const int fd, struct map_session_data* sd,
  3294. const char* command, const char* message)
  3295. {
  3296. if (!sd) return 0;
  3297. atcommand_killmonster_sub(fd, sd, message, 0);
  3298. return 0;
  3299. }
  3300. /*==========================================
  3301. *
  3302. *------------------------------------------
  3303. */
  3304. int atcommand_refine(
  3305. const int fd, struct map_session_data* sd,
  3306. const char* command, const char* message)
  3307. {
  3308. int i, position = 0, refine = 0, current_position, final_refine;
  3309. int count;
  3310. nullpo_retr(-1, sd);
  3311. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3312. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3313. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3314. return -1;
  3315. }
  3316. if (refine < -10)
  3317. refine = -10;
  3318. else if (refine > 10)
  3319. refine = 10;
  3320. else if (refine == 0)
  3321. refine = 1;
  3322. count = 0;
  3323. for (i = 0; i < MAX_INVENTORY; i++) {
  3324. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3325. (sd->status.inventory[i].equip & position ||
  3326. (sd->status.inventory[i].equip && !position))) {
  3327. final_refine = sd->status.inventory[i].refine + refine;
  3328. if (final_refine > 10)
  3329. final_refine = 10;
  3330. else if (final_refine < 0)
  3331. final_refine = 0;
  3332. if (sd->status.inventory[i].refine != final_refine) {
  3333. sd->status.inventory[i].refine = final_refine;
  3334. current_position = sd->status.inventory[i].equip;
  3335. pc_unequipitem(sd, i, 3);
  3336. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3337. clif_delitem(sd, i, 1);
  3338. clif_additem(sd, i, 1, 0);
  3339. pc_equipitem(sd, i, current_position);
  3340. clif_misceffect((struct block_list*)&sd->bl, 3);
  3341. count++;
  3342. }
  3343. }
  3344. }
  3345. if (count == 0)
  3346. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3347. else if (count == 1)
  3348. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3349. else {
  3350. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3351. clif_displaymessage(fd, atcmd_output);
  3352. }
  3353. return 0;
  3354. }
  3355. /*==========================================
  3356. *
  3357. *------------------------------------------
  3358. */
  3359. int atcommand_produce(
  3360. const int fd, struct map_session_data* sd,
  3361. const char* command, const char* message)
  3362. {
  3363. char item_name[100];
  3364. int item_id, attribute = 0, star = 0;
  3365. int flag = 0;
  3366. struct item_data *item_data;
  3367. struct item tmp_item;
  3368. nullpo_retr(-1, sd);
  3369. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3370. memset(item_name, '\0', sizeof(item_name));
  3371. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3372. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3373. return -1;
  3374. }
  3375. item_id = 0;
  3376. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3377. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3378. item_id = item_data->nameid;
  3379. if (itemdb_exists(item_id) &&
  3380. (item_id <= 500 || item_id > 1099) &&
  3381. (item_id < 4001 || item_id > 4148) &&
  3382. (item_id < 7001 || item_id > 10019) &&
  3383. itemdb_isequip(item_id)) {
  3384. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3385. attribute = ATTRIBUTE_NORMAL;
  3386. if (star < MIN_STAR || star > MAX_STAR)
  3387. star = 0;
  3388. memset(&tmp_item, 0, sizeof tmp_item);
  3389. tmp_item.nameid = item_id;
  3390. tmp_item.amount = 1;
  3391. tmp_item.identify = 1;
  3392. tmp_item.card[0] = 0x00ff;
  3393. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3394. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3395. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3396. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3397. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3398. //Logs (A)dmins items [Lupus]
  3399. if(log_config.pick > 0 ) {
  3400. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3401. }
  3402. //Logs
  3403. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3404. clif_additem(sd, 0, 0, flag);
  3405. } else {
  3406. if (battle_config.error_log)
  3407. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3408. if (item_id != 0 && itemdb_exists(item_id))
  3409. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3410. else
  3411. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3412. clif_displaymessage(fd, atcmd_output);
  3413. return -1;
  3414. }
  3415. return 0;
  3416. }
  3417. /*==========================================
  3418. * Sub-function to display actual memo points
  3419. *------------------------------------------
  3420. */
  3421. void atcommand_memo_sub(struct map_session_data* sd) {
  3422. int i;
  3423. if (!sd) return;
  3424. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3425. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3426. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3427. if (sd->status.memo_point[i].map)
  3428. 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);
  3429. else
  3430. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3431. clif_displaymessage(sd->fd, atcmd_output);
  3432. }
  3433. return;
  3434. }
  3435. /*==========================================
  3436. *
  3437. *------------------------------------------
  3438. */
  3439. int atcommand_memo(
  3440. const int fd, struct map_session_data* sd,
  3441. const char* command, const char* message)
  3442. {
  3443. int position = 0;
  3444. nullpo_retr(-1, sd);
  3445. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3446. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3447. atcommand_memo_sub(sd);
  3448. else {
  3449. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3450. 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)) {
  3451. clif_displaymessage(fd, msg_table[253]);
  3452. return -1;
  3453. }
  3454. if (sd->status.memo_point[position].map) {
  3455. sprintf(atcmd_output, msg_table[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).
  3456. clif_displaymessage(fd, atcmd_output);
  3457. }
  3458. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3459. sd->status.memo_point[position].x = sd->bl.x;
  3460. sd->status.memo_point[position].y = sd->bl.y;
  3461. clif_skill_memo(sd, 0);
  3462. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3463. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3464. atcommand_memo_sub(sd);
  3465. } else {
  3466. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3467. clif_displaymessage(fd, atcmd_output);
  3468. atcommand_memo_sub(sd);
  3469. return -1;
  3470. }
  3471. }
  3472. return 0;
  3473. }
  3474. /*==========================================
  3475. *
  3476. *------------------------------------------
  3477. */
  3478. int atcommand_gat(
  3479. const int fd, struct map_session_data* sd,
  3480. const char* command, const char* message)
  3481. {
  3482. int y;
  3483. nullpo_retr(-1, sd);
  3484. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3485. for (y = 2; y >= -2; y--) {
  3486. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3487. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3488. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3489. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3490. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3491. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3492. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3493. clif_displaymessage(fd, atcmd_output);
  3494. }
  3495. return 0;
  3496. }
  3497. /*==========================================
  3498. *
  3499. *------------------------------------------
  3500. */
  3501. int atcommand_packet(
  3502. const int fd, struct map_session_data* sd,
  3503. const char* command, const char* message)
  3504. {
  3505. static int packet_mode = 0;
  3506. int i, x = 0, y = 0;
  3507. nullpo_retr(-1, sd);
  3508. if (strstr(command, "packetmode")) {
  3509. packet_mode = atoi(message);
  3510. clif_displaymessage(fd, "Packet mode changed.");
  3511. return 0;
  3512. }
  3513. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3514. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3515. return -1;
  3516. }
  3517. if (i == 1) y = 1;
  3518. switch (packet_mode)
  3519. {
  3520. case 0:
  3521. clif_status_change(&sd->bl, x, y);
  3522. break;
  3523. case 1:
  3524. sd->status.skill[sd->cloneskill_id].id=0;
  3525. sd->status.skill[sd->cloneskill_id].lv=0;
  3526. sd->status.skill[sd->cloneskill_id].flag=0;
  3527. sd->cloneskill_id = x;
  3528. sd->status.skill[x].id = x;
  3529. sd->status.skill[x].lv = skill_get_max(x);
  3530. sd->status.skill[x].flag = 13;//cloneskill flag
  3531. clif_skillinfoblock(sd);
  3532. break;
  3533. case 2:
  3534. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3535. case 3:
  3536. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3537. default:
  3538. break;
  3539. //added later
  3540. }
  3541. return 0;
  3542. }
  3543. /*==========================================
  3544. * @waterlevel [Skotlex]
  3545. *------------------------------------------
  3546. */
  3547. int atcommand_waterlevel(
  3548. const int fd, struct map_session_data* sd,
  3549. const char* command, const char* message)
  3550. {
  3551. int newlevel;
  3552. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3553. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3554. clif_displaymessage(fd, atcmd_output);
  3555. return 0;
  3556. }
  3557. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3558. if (newlevel > 0)
  3559. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3560. else
  3561. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3562. clif_displaymessage(fd, atcmd_output);
  3563. } else {
  3564. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3565. clif_displaymessage(fd, atcmd_output);
  3566. }
  3567. return 0;
  3568. }
  3569. /*==========================================
  3570. * @stpoint (Rewritten by [Yor])
  3571. *------------------------------------------
  3572. */
  3573. int atcommand_statuspoint(
  3574. const int fd, struct map_session_data* sd,
  3575. const char* command, const char* message)
  3576. {
  3577. int point, new_status_point;
  3578. if (!message || !*message || (point = atoi(message)) == 0) {
  3579. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3580. return -1;
  3581. }
  3582. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3583. new_status_point = USHRT_MAX;
  3584. else
  3585. if (point < 0 && sd->status.status_point < -point)
  3586. new_status_point = 0;
  3587. else
  3588. new_status_point = sd->status.status_point + point;
  3589. if (new_status_point != (int)sd->status.status_point) {
  3590. sd->status.status_point = (unsigned short)new_status_point;
  3591. clif_updatestatus(sd, SP_STATUSPOINT);
  3592. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3593. } else {
  3594. if (point < 0)
  3595. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3596. else
  3597. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3598. return -1;
  3599. }
  3600. return 0;
  3601. }
  3602. /*==========================================
  3603. * @skpoint (Rewritten by [Yor])
  3604. *------------------------------------------
  3605. */
  3606. int atcommand_skillpoint(
  3607. const int fd, struct map_session_data* sd,
  3608. const char* command, const char* message)
  3609. {
  3610. int point, new_skill_point;
  3611. nullpo_retr(-1, sd);
  3612. if (!message || !*message || (point = atoi(message)) == 0) {
  3613. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3614. return -1;
  3615. }
  3616. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3617. new_skill_point = USHRT_MAX;
  3618. else if (point < 0 && sd->status.skill_point < -point)
  3619. new_skill_point = 0;
  3620. else
  3621. new_skill_point = sd->status.skill_point + point;
  3622. if (new_skill_point != (int)sd->status.skill_point) {
  3623. sd->status.skill_point = (unsigned short)new_skill_point;
  3624. clif_updatestatus(sd, SP_SKILLPOINT);
  3625. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3626. } else {
  3627. if (point < 0)
  3628. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3629. else
  3630. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3631. return -1;
  3632. }
  3633. return 0;
  3634. }
  3635. /*==========================================
  3636. * @zeny (Rewritten by [Yor])
  3637. *------------------------------------------
  3638. */
  3639. int atcommand_zeny(
  3640. const int fd, struct map_session_data* sd,
  3641. const char* command, const char* message)
  3642. {
  3643. int zeny, new_zeny;
  3644. nullpo_retr(-1, sd);
  3645. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3646. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3647. return -1;
  3648. }
  3649. new_zeny = sd->status.zeny + zeny;
  3650. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3651. new_zeny = MAX_ZENY;
  3652. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3653. new_zeny = 0;
  3654. if (new_zeny != sd->status.zeny) {
  3655. sd->status.zeny = new_zeny;
  3656. clif_updatestatus(sd, SP_ZENY);
  3657. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3658. } else {
  3659. if (zeny < 0)
  3660. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3661. else
  3662. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3663. return -1;
  3664. }
  3665. return 0;
  3666. }
  3667. /*==========================================
  3668. *
  3669. *------------------------------------------
  3670. */
  3671. int atcommand_param(
  3672. const int fd, struct map_session_data* sd,
  3673. const char* command, const char* message)
  3674. {
  3675. int index, value = 0, new_value, max;
  3676. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3677. short* status[6];
  3678. //we don't use direct initialization because it isn't part of the c standard.
  3679. nullpo_retr(-1, sd);
  3680. status[0] = &sd->status.str;
  3681. status[1] = &sd->status.agi;
  3682. status[2] = &sd->status.vit;
  3683. status[3] = &sd->status.int_;
  3684. status[4] = &sd->status.dex;
  3685. status[5] = &sd->status.luk;
  3686. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3687. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3688. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3689. clif_displaymessage(fd, atcmd_output);
  3690. return -1;
  3691. }
  3692. index = -1;
  3693. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3694. if (strcmpi(command, param[index]) == 0)
  3695. break;
  3696. }
  3697. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3698. // normaly impossible...
  3699. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3700. clif_displaymessage(fd, atcmd_output);
  3701. return -1;
  3702. }
  3703. max = pc_maxparameter(sd);
  3704. if (value > 0 && *status[index] > max - value)
  3705. new_value = max;
  3706. else if (value < 0 && *status[index] <= -value)
  3707. new_value = 1;
  3708. else
  3709. new_value = *status[index] + value;
  3710. if (new_value != (int)*status[index]) {
  3711. *status[index] = new_value;
  3712. clif_updatestatus(sd, SP_STR + index);
  3713. clif_updatestatus(sd, SP_USTR + index);
  3714. status_calc_pc(sd, 0);
  3715. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3716. } else {
  3717. if (value < 0)
  3718. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3719. else
  3720. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3721. return -1;
  3722. }
  3723. return 0;
  3724. }
  3725. /*==========================================
  3726. *
  3727. *------------------------------------------
  3728. */
  3729. //** Stat all by fritz (rewritten by [Yor])
  3730. int atcommand_stat_all(
  3731. const int fd, struct map_session_data* sd,
  3732. const char* command, const char* message)
  3733. {
  3734. int index, count, value = 0, max, new_value;
  3735. short* status[6];
  3736. //we don't use direct initialization because it isn't part of the c standard.
  3737. nullpo_retr(-1, sd);
  3738. status[0] = &sd->status.str;
  3739. status[1] = &sd->status.agi;
  3740. status[2] = &sd->status.vit;
  3741. status[3] = &sd->status.int_;
  3742. status[4] = &sd->status.dex;
  3743. status[5] = &sd->status.luk;
  3744. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3745. value = pc_maxparameter(sd);
  3746. count = 0;
  3747. max = pc_maxparameter(sd);
  3748. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3749. if (value > 0 && *status[index] > max - value)
  3750. new_value = max;
  3751. else if (value < 0 && *status[index] <= -value)
  3752. new_value = 1;
  3753. else
  3754. new_value = *status[index] +value;
  3755. if (new_value != (int)*status[index]) {
  3756. *status[index] = new_value;
  3757. clif_updatestatus(sd, SP_STR + index);
  3758. clif_updatestatus(sd, SP_USTR + index);
  3759. status_calc_pc(sd, 0);
  3760. count++;
  3761. }
  3762. }
  3763. if (count > 0) // if at least 1 stat modified
  3764. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3765. else {
  3766. if (value < 0)
  3767. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3768. else
  3769. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3770. return -1;
  3771. }
  3772. return 0;
  3773. }
  3774. /*==========================================
  3775. *
  3776. *------------------------------------------
  3777. */
  3778. int atcommand_guildlevelup(
  3779. const int fd, struct map_session_data* sd,
  3780. const char* command, const char* message)
  3781. {
  3782. int level = 0;
  3783. short added_level;
  3784. struct guild *guild_info;
  3785. nullpo_retr(-1, sd);
  3786. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3787. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3788. return -1;
  3789. }
  3790. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3791. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3792. return -1;
  3793. }
  3794. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3795. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3796. return -1;
  3797. }
  3798. added_level = (short)level;
  3799. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3800. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3801. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3802. added_level = 1 - guild_info->guild_lv;
  3803. if (added_level != 0) {
  3804. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3805. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3806. } else {
  3807. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3808. return -1;
  3809. }
  3810. return 0;
  3811. }
  3812. /*==========================================
  3813. *
  3814. *------------------------------------------
  3815. */
  3816. int atcommand_makeegg(
  3817. const int fd, struct map_session_data* sd,
  3818. const char* command, const char* message)
  3819. {
  3820. struct item_data *item_data;
  3821. int id, pet_id;
  3822. nullpo_retr(-1, sd);
  3823. if (!message || !*message) {
  3824. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3825. return -1;
  3826. }
  3827. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3828. id = item_data->nameid;
  3829. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3830. id = atoi(message);
  3831. pet_id = search_petDB_index(id, PET_CLASS);
  3832. if (pet_id < 0)
  3833. pet_id = search_petDB_index(id, PET_EGG);
  3834. if (pet_id >= 0) {
  3835. sd->catch_target_class = pet_db[pet_id].class_;
  3836. intif_create_pet(
  3837. sd->status.account_id, sd->status.char_id,
  3838. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3839. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3840. 100, 0, 1, pet_db[pet_id].jname);
  3841. } else {
  3842. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3843. return -1;
  3844. }
  3845. return 0;
  3846. }
  3847. /*==========================================
  3848. *
  3849. *------------------------------------------
  3850. */
  3851. int atcommand_hatch(
  3852. const int fd, struct map_session_data* sd,
  3853. const char* command, const char* message)
  3854. {
  3855. nullpo_retr(-1, sd);
  3856. if (sd->status.pet_id <= 0)
  3857. clif_sendegg(sd);
  3858. else {
  3859. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3860. return -1;
  3861. }
  3862. return 0;
  3863. }
  3864. /*==========================================
  3865. *
  3866. *------------------------------------------
  3867. */
  3868. int atcommand_petfriendly(
  3869. const int fd, struct map_session_data* sd,
  3870. const char* command, const char* message)
  3871. {
  3872. int friendly;
  3873. nullpo_retr(-1, sd);
  3874. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3875. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3876. return -1;
  3877. }
  3878. if (!sd->pd) {
  3879. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3880. return -1;
  3881. }
  3882. if (friendly < 0 || friendly > 1000)
  3883. {
  3884. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3885. return -1;
  3886. }
  3887. if (friendly == sd->pet.intimate) {
  3888. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3889. return -1;
  3890. }
  3891. sd->pet.intimate = friendly;
  3892. clif_send_petstatus(sd);
  3893. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3894. return 0;
  3895. }
  3896. /*==========================================
  3897. *
  3898. *------------------------------------------
  3899. */
  3900. int atcommand_pethungry(
  3901. const int fd, struct map_session_data* sd,
  3902. const char* command, const char* message)
  3903. {
  3904. int hungry;
  3905. nullpo_retr(-1, sd);
  3906. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3907. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3908. return -1;
  3909. }
  3910. if (sd->status.pet_id > 0 && sd->pd) {
  3911. if (hungry >= 0 && hungry <= 100) {
  3912. if (hungry != sd->pet.hungry) {
  3913. sd->pet.hungry = hungry;
  3914. clif_send_petstatus(sd);
  3915. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3916. } else {
  3917. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3918. return -1;
  3919. }
  3920. } else {
  3921. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3922. return -1;
  3923. }
  3924. } else {
  3925. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3926. return -1;
  3927. }
  3928. return 0;
  3929. }
  3930. /*==========================================
  3931. *
  3932. *------------------------------------------
  3933. */
  3934. int atcommand_petrename(
  3935. const int fd, struct map_session_data* sd,
  3936. const char* command, const char* message)
  3937. {
  3938. nullpo_retr(-1, sd);
  3939. if (sd->status.pet_id > 0 && sd->pd) {
  3940. if (sd->pet.rename_flag != 0) {
  3941. sd->pet.rename_flag = 0;
  3942. intif_save_petdata(sd->status.account_id, &sd->pet);
  3943. clif_send_petstatus(sd);
  3944. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3945. } else {
  3946. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3947. return -1;
  3948. }
  3949. } else {
  3950. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3951. return -1;
  3952. }
  3953. return 0;
  3954. }
  3955. /*==========================================
  3956. *
  3957. *------------------------------------------
  3958. */
  3959. int
  3960. atcommand_recall(
  3961. const int fd, struct map_session_data* sd,
  3962. const char* command, const char* message)
  3963. {
  3964. struct map_session_data *pl_sd = NULL;
  3965. nullpo_retr(-1, sd);
  3966. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3967. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3968. return -1;
  3969. }
  3970. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3971. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3972. return -1;
  3973. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3974. return -1;
  3975. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3976. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3977. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3978. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3979. return -1;
  3980. }
  3981. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3982. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3983. return -1;
  3984. }
  3985. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3986. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3987. clif_displaymessage(fd, atcmd_output);
  3988. } else {
  3989. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3990. return -1;
  3991. }
  3992. } else {
  3993. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3994. return -1;
  3995. }
  3996. return 0;
  3997. }
  3998. /*==========================================
  3999. *
  4000. *------------------------------------------
  4001. */
  4002. int atcommand_revive(
  4003. const int fd, struct map_session_data* sd,
  4004. const char* command, const char* message)
  4005. {
  4006. struct map_session_data *pl_sd;
  4007. nullpo_retr(-1, sd);
  4008. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4009. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4010. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  4011. return -1;
  4012. }
  4013. pl_sd = map_nick2sd(atcmd_player_name);
  4014. if (!pl_sd) {
  4015. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4016. return -1;
  4017. }
  4018. if (!status_revive(&sd->bl, 100, 0))
  4019. return -1;
  4020. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4021. clif_displaymessage(fd, msg_table[51]); // Character revived.
  4022. return 0;
  4023. }
  4024. /*==========================================
  4025. * charblock command (usage: charblock <player_name>)
  4026. * This command do a definitiv ban on a player
  4027. *------------------------------------------
  4028. */
  4029. int atcommand_char_block(
  4030. const int fd, struct map_session_data* sd,
  4031. const char* command, const char* message)
  4032. {
  4033. nullpo_retr(-1, sd);
  4034. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4035. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4036. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4037. return -1;
  4038. }
  4039. // check player name
  4040. if (strlen(atcmd_player_name) < 4) {
  4041. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4042. return -1;
  4043. } else if (strlen(atcmd_player_name) > 23) {
  4044. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4045. return -1;
  4046. } else {
  4047. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4048. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4049. }
  4050. return 0;
  4051. }
  4052. /*==========================================
  4053. * charban command (usage: charban <time> <player_name>)
  4054. * This command do a limited ban on a player
  4055. * Time is done as follows:
  4056. * Adjustment value (-1, 1, +1, etc...)
  4057. * Modified element:
  4058. * a or y: year
  4059. * m: month
  4060. * j or d: day
  4061. * h: hour
  4062. * mn: minute
  4063. * s: second
  4064. * <example> @ban +1m-2mn1s-6y test_player
  4065. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4066. *------------------------------------------
  4067. */
  4068. int atcommand_char_ban(
  4069. const int fd, struct map_session_data* sd,
  4070. const char* command, const char* message)
  4071. {
  4072. char * modif_p;
  4073. int year, month, day, hour, minute, second, value;
  4074. nullpo_retr(-1, sd);
  4075. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4076. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4077. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4078. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4079. return -1;
  4080. }
  4081. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4082. modif_p = atcmd_output;
  4083. year = month = day = hour = minute = second = 0;
  4084. while (modif_p[0] != '\0') {
  4085. value = atoi(modif_p);
  4086. if (value == 0)
  4087. modif_p++;
  4088. else {
  4089. if (modif_p[0] == '-' || modif_p[0] == '+')
  4090. modif_p++;
  4091. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4092. modif_p++;
  4093. if (modif_p[0] == 's') {
  4094. second = value;
  4095. modif_p++;
  4096. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4097. minute = value;
  4098. modif_p = modif_p + 2;
  4099. } else if (modif_p[0] == 'h') {
  4100. hour = value;
  4101. modif_p++;
  4102. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4103. day = value;
  4104. modif_p++;
  4105. } else if (modif_p[0] == 'm') {
  4106. month = value;
  4107. modif_p++;
  4108. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4109. year = value;
  4110. modif_p++;
  4111. } else if (modif_p[0] != '\0') {
  4112. modif_p++;
  4113. }
  4114. }
  4115. }
  4116. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4117. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4118. return -1;
  4119. }
  4120. // check player name
  4121. if (strlen(atcmd_player_name) < 4) {
  4122. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4123. return -1;
  4124. } else if (strlen(atcmd_player_name) > 23) {
  4125. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4126. return -1;
  4127. } else {
  4128. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4129. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4130. }
  4131. return 0;
  4132. }
  4133. /*==========================================
  4134. * charunblock command (usage: charunblock <player_name>)
  4135. *------------------------------------------
  4136. */
  4137. int atcommand_char_unblock(
  4138. const int fd, struct map_session_data* sd,
  4139. const char* command, const char* message)
  4140. {
  4141. nullpo_retr(-1, sd);
  4142. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4143. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4144. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4145. return -1;
  4146. }
  4147. // check player name
  4148. if (strlen(atcmd_player_name) < 4) {
  4149. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4150. return -1;
  4151. } else if (strlen(atcmd_player_name) > 23) {
  4152. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4153. return -1;
  4154. } else {
  4155. // send answer to login server via char-server
  4156. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4157. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4158. }
  4159. return 0;
  4160. }
  4161. /*==========================================
  4162. * charunban command (usage: charunban <player_name>)
  4163. *------------------------------------------
  4164. */
  4165. int atcommand_char_unban(
  4166. const int fd, struct map_session_data* sd,
  4167. const char* command, const char* message)
  4168. {
  4169. nullpo_retr(-1, sd);
  4170. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4171. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4172. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4173. return -1;
  4174. }
  4175. // check player name
  4176. if (strlen(atcmd_player_name) < 4) {
  4177. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4178. return -1;
  4179. } else if (strlen(atcmd_player_name) > 23) {
  4180. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4181. return -1;
  4182. } else {
  4183. // send answer to login server via char-server
  4184. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4185. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4186. }
  4187. return 0;
  4188. }
  4189. /*==========================================
  4190. *
  4191. *------------------------------------------
  4192. */
  4193. int atcommand_night(
  4194. const int fd, struct map_session_data* sd,
  4195. const char* command, const char* message)
  4196. {
  4197. nullpo_retr(-1, sd);
  4198. if (night_flag != 1) {
  4199. map_night_timer(night_timer_tid, 0, 0, 1);
  4200. } else {
  4201. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4202. return -1;
  4203. }
  4204. return 0;
  4205. }
  4206. /*==========================================
  4207. *
  4208. *------------------------------------------
  4209. */
  4210. int atcommand_day(
  4211. const int fd, struct map_session_data* sd,
  4212. const char* command, const char* message)
  4213. {
  4214. nullpo_retr(-1, sd);
  4215. if (night_flag != 0) {
  4216. map_day_timer(day_timer_tid, 0, 0, 1);
  4217. } else {
  4218. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4219. return -1;
  4220. }
  4221. return 0;
  4222. }
  4223. /*==========================================
  4224. *
  4225. *------------------------------------------
  4226. */
  4227. int atcommand_doom(
  4228. const int fd, struct map_session_data* sd,
  4229. const char* command, const char* message)
  4230. {
  4231. struct map_session_data *pl_sd, **pl_allsd;
  4232. int i, users;
  4233. nullpo_retr(-1, sd);
  4234. clif_specialeffect(&sd->bl,450,ALL_SAMEMAP);
  4235. pl_allsd = map_getallusers(&users);
  4236. for(i = 0; i < users; i++) {
  4237. 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
  4238. status_kill(&pl_sd->bl);
  4239. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4240. }
  4241. }
  4242. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4243. return 0;
  4244. }
  4245. /*==========================================
  4246. *
  4247. *------------------------------------------
  4248. */
  4249. int atcommand_doommap(
  4250. const int fd, struct map_session_data* sd,
  4251. const char* command, const char* message)
  4252. {
  4253. struct map_session_data *pl_sd, **pl_allsd;
  4254. int i, users;
  4255. nullpo_retr(-1, sd);
  4256. clif_specialeffect(&sd->bl,450,ALL_CLIENT);
  4257. pl_allsd = map_getallusers(&users);
  4258. for (i = 0; i < users; i++) {
  4259. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4260. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4261. {
  4262. status_kill(&pl_sd->bl);
  4263. // clif_specialeffect(&pl_sd->bl,450,1);
  4264. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4265. }
  4266. }
  4267. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4268. return 0;
  4269. }
  4270. /*==========================================
  4271. *
  4272. *------------------------------------------
  4273. */
  4274. static void atcommand_raise_sub(struct map_session_data* sd)
  4275. {
  4276. if (!sd->state.auth || !status_isdead(&sd->bl))
  4277. return;
  4278. if(!status_revive(&sd->bl, 100, 100))
  4279. return;
  4280. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4281. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4282. }
  4283. /*==========================================
  4284. *
  4285. *------------------------------------------
  4286. */
  4287. int atcommand_raise(
  4288. const int fd, struct map_session_data* sd,
  4289. const char* command, const char* message)
  4290. {
  4291. int i, users;
  4292. struct map_session_data **all_sd;
  4293. nullpo_retr(-1, sd);
  4294. all_sd = map_getallusers(&users);
  4295. for (i = 0; i < users; i++) {
  4296. atcommand_raise_sub(all_sd[i]);
  4297. }
  4298. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4299. return 0;
  4300. }
  4301. /*==========================================
  4302. *
  4303. *------------------------------------------
  4304. */
  4305. int atcommand_raisemap(
  4306. const int fd, struct map_session_data* sd,
  4307. const char* command, const char* message)
  4308. {
  4309. struct map_session_data **pl_allsd;
  4310. int i, users;
  4311. nullpo_retr(-1, sd);
  4312. pl_allsd = map_getallusers(&users);
  4313. for (i = 0; i < users; i++) {
  4314. if (sd->bl.m == pl_allsd[i]->bl.m)
  4315. atcommand_raise_sub(pl_allsd[i]);
  4316. }
  4317. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4318. return 0;
  4319. }
  4320. /*==========================================
  4321. *
  4322. *------------------------------------------
  4323. */
  4324. int atcommand_kick(
  4325. const int fd, struct map_session_data* sd,
  4326. const char* command, const char* message)
  4327. {
  4328. struct map_session_data *pl_sd;
  4329. nullpo_retr(-1, sd);
  4330. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4331. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4332. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4333. return -1;
  4334. }
  4335. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4336. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4337. clif_GM_kick(sd, pl_sd, 1);
  4338. else {
  4339. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4340. return -1;
  4341. }
  4342. } else {
  4343. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4344. return -1;
  4345. }
  4346. return 0;
  4347. }
  4348. /*==========================================
  4349. *
  4350. *------------------------------------------
  4351. */
  4352. int atcommand_kickall(
  4353. const int fd, struct map_session_data* sd,
  4354. const char* command, const char* message)
  4355. {
  4356. struct map_session_data *pl_sd, **pl_allsd;
  4357. int i, users;
  4358. nullpo_retr(-1, sd);
  4359. pl_allsd = map_getallusers(&users);
  4360. for (i = 0; i < users; i++) {
  4361. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4362. if (sd->status.account_id != pl_sd->status.account_id)
  4363. clif_GM_kick(sd, pl_sd, 0);
  4364. }
  4365. }
  4366. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4367. return 0;
  4368. }
  4369. /*==========================================
  4370. *
  4371. *------------------------------------------
  4372. */
  4373. int atcommand_allskill(
  4374. const int fd, struct map_session_data* sd,
  4375. const char* command, const char* message)
  4376. {
  4377. nullpo_retr(-1, sd);
  4378. pc_allskillup(sd); // all skills
  4379. sd->status.skill_point = 0; // 0 skill points
  4380. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4381. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4382. return 0;
  4383. }
  4384. /*==========================================
  4385. *
  4386. *------------------------------------------
  4387. */
  4388. int atcommand_questskill(
  4389. const int fd, struct map_session_data* sd,
  4390. const char* command, const char* message)
  4391. {
  4392. int skill_id;
  4393. nullpo_retr(-1, sd);
  4394. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4395. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4396. return -1;
  4397. }
  4398. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4399. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4400. if (pc_checkskill(sd, skill_id) == 0) {
  4401. pc_skill(sd, skill_id, 1, 0);
  4402. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4403. } else {
  4404. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4405. return -1;
  4406. }
  4407. } else {
  4408. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4409. return -1;
  4410. }
  4411. } else {
  4412. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4413. return -1;
  4414. }
  4415. return 0;
  4416. }
  4417. /*==========================================
  4418. *
  4419. *------------------------------------------
  4420. */
  4421. int atcommand_lostskill(
  4422. const int fd, struct map_session_data* sd,
  4423. const char* command, const char* message)
  4424. {
  4425. int skill_id;
  4426. nullpo_retr(-1, sd);
  4427. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4428. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4429. return -1;
  4430. }
  4431. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4432. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4433. if (pc_checkskill(sd, skill_id) > 0) {
  4434. sd->status.skill[skill_id].lv = 0;
  4435. sd->status.skill[skill_id].flag = 0;
  4436. clif_skillinfoblock(sd);
  4437. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4438. } else {
  4439. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4440. return -1;
  4441. }
  4442. } else {
  4443. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4444. return -1;
  4445. }
  4446. } else {
  4447. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4448. return -1;
  4449. }
  4450. return 0;
  4451. }
  4452. /*==========================================
  4453. *
  4454. *------------------------------------------
  4455. */
  4456. int atcommand_spiritball(
  4457. const int fd, struct map_session_data* sd,
  4458. const char* command, const char* message)
  4459. {
  4460. int number;
  4461. nullpo_retr(-1, sd);
  4462. if (!message || !*message || (number = atoi(message)) < 0) {
  4463. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4464. return -1;
  4465. }
  4466. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4467. if (number > 500)
  4468. number = 500;
  4469. if (number >= 0 && number <= 0x7FFF) {
  4470. if (sd->spiritball != number || number > 499) {
  4471. if (sd->spiritball > 0)
  4472. pc_delspiritball(sd, sd->spiritball, 1);
  4473. sd->spiritball = number;
  4474. clif_spiritball(sd);
  4475. // no message, player can look the difference
  4476. if (number > 1000)
  4477. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4478. } else {
  4479. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4480. return -1;
  4481. }
  4482. } else {
  4483. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4484. return -1;
  4485. }
  4486. return 0;
  4487. }
  4488. /*==========================================
  4489. *
  4490. *------------------------------------------
  4491. */
  4492. int atcommand_party(
  4493. const int fd, struct map_session_data* sd,
  4494. const char* command, const char* message)
  4495. {
  4496. char party[NAME_LENGTH];
  4497. nullpo_retr(-1, sd);
  4498. memset(party, '\0', sizeof(party));
  4499. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4500. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4501. return -1;
  4502. }
  4503. party_create(sd, party, 0, 0);
  4504. return 0;
  4505. }
  4506. /*==========================================
  4507. *
  4508. *------------------------------------------
  4509. */
  4510. int atcommand_guild(
  4511. const int fd, struct map_session_data* sd,
  4512. const char* command, const char* message)
  4513. {
  4514. char guild[NAME_LENGTH];
  4515. int prev;
  4516. nullpo_retr(-1, sd);
  4517. memset(guild, '\0', sizeof(guild));
  4518. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4519. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4520. return -1;
  4521. }
  4522. prev = battle_config.guild_emperium_check;
  4523. battle_config.guild_emperium_check = 0;
  4524. guild_create(sd, guild);
  4525. battle_config.guild_emperium_check = prev;
  4526. return 0;
  4527. }
  4528. /*==========================================
  4529. *
  4530. *------------------------------------------
  4531. */
  4532. int atcommand_agitstart(
  4533. const int fd, struct map_session_data* sd,
  4534. const char* command, const char* message)
  4535. {
  4536. nullpo_retr(-1, sd);
  4537. if (agit_flag == 1) {
  4538. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4539. return -1;
  4540. }
  4541. agit_flag = 1;
  4542. guild_agit_start();
  4543. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4544. return 0;
  4545. }
  4546. /*==========================================
  4547. *
  4548. *------------------------------------------
  4549. */
  4550. int atcommand_agitend(
  4551. const int fd, struct map_session_data* sd,
  4552. const char* command, const char* message)
  4553. {
  4554. nullpo_retr(-1, sd);
  4555. if (agit_flag == 0) {
  4556. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4557. return -1;
  4558. }
  4559. agit_flag = 0;
  4560. guild_agit_end();
  4561. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4562. return 0;
  4563. }
  4564. /*==========================================
  4565. * @mapexitでマップサーバーを終了させる
  4566. *------------------------------------------
  4567. */
  4568. int atcommand_mapexit(
  4569. const int fd, struct map_session_data* sd,
  4570. const char* command, const char* message)
  4571. {
  4572. struct map_session_data *pl_sd, **pl_allsd;
  4573. int i, users;
  4574. nullpo_retr(-1, sd);
  4575. pl_allsd = map_getallusers(&users);
  4576. for (i = 0; i < users; i++) {
  4577. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4578. clif_GM_kick(sd, pl_sd, 0);
  4579. }
  4580. clif_GM_kick(sd, sd, 0);
  4581. flush_fifos();
  4582. runflag = 0;
  4583. return 0;
  4584. }
  4585. /*==========================================
  4586. * idsearch <part_of_name>: revrited by [Yor]
  4587. *------------------------------------------
  4588. */
  4589. int atcommand_idsearch(
  4590. const int fd, struct map_session_data* sd,
  4591. const char* command, const char* message)
  4592. {
  4593. char item_name[100];
  4594. unsigned int i, match;
  4595. struct item_data *item_array[MAX_SEARCH];
  4596. nullpo_retr(-1, sd);
  4597. memset(item_name, '\0', sizeof(item_name));
  4598. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4599. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4600. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4601. return -1;
  4602. }
  4603. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4604. clif_displaymessage(fd, atcmd_output);
  4605. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4606. if (match > MAX_SEARCH) {
  4607. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
  4608. clif_displaymessage(fd, atcmd_output);
  4609. match = MAX_SEARCH;
  4610. }
  4611. for(i = 0; i < match; i++) {
  4612. sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4613. clif_displaymessage(fd, atcmd_output);
  4614. }
  4615. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4616. clif_displaymessage(fd, atcmd_output);
  4617. return 0;
  4618. }
  4619. /*==========================================
  4620. * Recall All Characters Online To Your Location
  4621. *------------------------------------------
  4622. */
  4623. int atcommand_recallall(
  4624. const int fd, struct map_session_data* sd,
  4625. const char* command, const char* message)
  4626. {
  4627. struct map_session_data *pl_sd, **pl_allsd;
  4628. int i;
  4629. int count, users;
  4630. nullpo_retr(-1, sd);
  4631. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4632. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4633. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4634. return -1;
  4635. }
  4636. count = 0;
  4637. pl_allsd = map_getallusers(&users);
  4638. for (i = 0; i < users; i++) {
  4639. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4640. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4641. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4642. count++;
  4643. else {
  4644. if (pc_isdead(pl_sd)) { //Wake them up
  4645. pc_setstand(pl_sd);
  4646. pc_setrestartvalue(pl_sd,1);
  4647. }
  4648. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4649. }
  4650. }
  4651. }
  4652. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4653. if (count) {
  4654. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4655. clif_displaymessage(fd, atcmd_output);
  4656. }
  4657. return 0;
  4658. }
  4659. /*==========================================
  4660. * Recall online characters of a guild to your location
  4661. *------------------------------------------
  4662. */
  4663. int atcommand_guildrecall(
  4664. const int fd, struct map_session_data* sd,
  4665. const char* command, const char* message)
  4666. {
  4667. struct map_session_data *pl_sd, **pl_allsd;
  4668. int i, users, count;
  4669. char guild_name[NAME_LENGTH];
  4670. struct guild *g;
  4671. nullpo_retr(-1, sd);
  4672. memset(guild_name, '\0', sizeof(guild_name));
  4673. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4674. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4675. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4676. return -1;
  4677. }
  4678. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4679. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4680. return -1;
  4681. }
  4682. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4683. (g = guild_search(atoi(message))) != NULL) {
  4684. count = 0;
  4685. pl_allsd = map_getallusers(&users);
  4686. for (i = 0; i < users; i++) {
  4687. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4688. pl_sd->status.guild_id == g->guild_id) {
  4689. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4690. continue; //Skip GMs greater than you.
  4691. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4692. count++;
  4693. else
  4694. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4695. }
  4696. }
  4697. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4698. clif_displaymessage(fd, atcmd_output);
  4699. if (count) {
  4700. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4701. clif_displaymessage(fd, atcmd_output);
  4702. }
  4703. } else {
  4704. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4705. return -1;
  4706. }
  4707. return 0;
  4708. }
  4709. /*==========================================
  4710. * Recall online characters of a party to your location
  4711. *------------------------------------------
  4712. */
  4713. int atcommand_partyrecall(
  4714. const int fd, struct map_session_data* sd,
  4715. const char* command, const char* message)
  4716. {
  4717. int i;
  4718. struct map_session_data *pl_sd, **pl_allsd;
  4719. char party_name[NAME_LENGTH];
  4720. struct party_data *p;
  4721. int count, users;
  4722. nullpo_retr(-1, sd);
  4723. memset(party_name, '\0', sizeof(party_name));
  4724. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4725. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4726. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4727. return -1;
  4728. }
  4729. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4730. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4731. return -1;
  4732. }
  4733. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4734. (p = party_search(atoi(message))) != NULL) {
  4735. count = 0;
  4736. pl_allsd = map_getallusers(&users);
  4737. for (i = 0; i < users; i++) {
  4738. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4739. pl_sd->status.party_id == p->party.party_id) {
  4740. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4741. continue; //Skip GMs greater than you.
  4742. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4743. count++;
  4744. else
  4745. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4746. }
  4747. }
  4748. sprintf(atcmd_output, msg_table[95], p->party.name); // All online characters of the %s party are near you.
  4749. clif_displaymessage(fd, atcmd_output);
  4750. if (count) {
  4751. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4752. clif_displaymessage(fd, atcmd_output);
  4753. }
  4754. } else {
  4755. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4756. return -1;
  4757. }
  4758. return 0;
  4759. }
  4760. /*==========================================
  4761. *
  4762. *------------------------------------------
  4763. */
  4764. int atcommand_reloaditemdb(
  4765. const int fd, struct map_session_data* sd,
  4766. const char* command, const char* message)
  4767. {
  4768. nullpo_retr(-1, sd);
  4769. itemdb_reload();
  4770. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4771. return 0;
  4772. }
  4773. /*==========================================
  4774. *
  4775. *------------------------------------------
  4776. */
  4777. int atcommand_reloadmobdb(
  4778. const int fd, struct map_session_data* sd,
  4779. const char* command, const char* message)
  4780. {
  4781. nullpo_retr(-1, sd);
  4782. mob_reload();
  4783. do_final_pet();
  4784. read_petdb();
  4785. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4786. return 0;
  4787. }
  4788. /*==========================================
  4789. *
  4790. *------------------------------------------
  4791. */
  4792. int atcommand_reloadskilldb(
  4793. const int fd, struct map_session_data* sd,
  4794. const char* command, const char* message)
  4795. {
  4796. nullpo_retr(-1, sd);
  4797. skill_reload();
  4798. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4799. return 0;
  4800. }
  4801. /*==========================================
  4802. * @reloadatcommand
  4803. * atcommand_athena.conf のリロード
  4804. *------------------------------------------
  4805. */
  4806. int
  4807. atcommand_reloadatcommand(
  4808. const int fd, struct map_session_data* sd,
  4809. const char* command, const char* message)
  4810. {
  4811. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4812. clif_displaymessage(fd, msg_table[254]);
  4813. return 0;
  4814. }
  4815. /*==========================================
  4816. * @reloadbattleconf
  4817. * battle_athena.conf のリロード
  4818. *------------------------------------------
  4819. */
  4820. int
  4821. atcommand_reloadbattleconf(
  4822. const int fd, struct map_session_data* sd,
  4823. const char* command, const char* message)
  4824. {
  4825. battle_config_read(BATTLE_CONF_FILENAME);
  4826. mob_reload(); //Needed as well so rate changes take effect.
  4827. clif_displaymessage(fd, msg_table[255]);
  4828. return 0;
  4829. }
  4830. /*==========================================
  4831. * @reloadstatusdb
  4832. * job_db1.txt job_db2.txt job_db2-2.txt
  4833. * refine_db.txt size_fix.txt
  4834. * のリロード
  4835. *------------------------------------------
  4836. */
  4837. int
  4838. atcommand_reloadstatusdb(
  4839. const int fd, struct map_session_data* sd,
  4840. const char* command, const char* message)
  4841. {
  4842. status_readdb();
  4843. clif_displaymessage(fd, msg_table[256]);
  4844. return 0;
  4845. }
  4846. /*==========================================
  4847. * @reloadpcdb
  4848. * exp.txt skill_tree.txt attr_fix.txt
  4849. * のリロード
  4850. *------------------------------------------
  4851. */
  4852. int
  4853. atcommand_reloadpcdb(
  4854. const int fd, struct map_session_data* sd,
  4855. const char* command, const char* message)
  4856. {
  4857. pc_readdb();
  4858. clif_displaymessage(fd, msg_table[257]);
  4859. return 0;
  4860. }
  4861. /*==========================================
  4862. * @reloadmotd [Valaris]
  4863. * Reloads motd.txt
  4864. *------------------------------------------
  4865. */
  4866. int
  4867. atcommand_reloadmotd(
  4868. const int fd, struct map_session_data* sd,
  4869. const char* command, const char* message)
  4870. {
  4871. pc_read_motd();
  4872. clif_displaymessage(fd, msg_table[268]);
  4873. return 0;
  4874. }
  4875. /*==========================================
  4876. *
  4877. *------------------------------------------
  4878. */
  4879. int atcommand_reloadscript(
  4880. const int fd, struct map_session_data* sd,
  4881. const char* command, const char* message)
  4882. {
  4883. nullpo_retr(-1, sd);
  4884. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4885. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4886. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4887. flush_fifos();
  4888. //do_init_npc();
  4889. script_reload();
  4890. npc_reload();
  4891. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4892. return 0;
  4893. }
  4894. /*==========================================
  4895. *
  4896. *------------------------------------------
  4897. */
  4898. int atcommand_reloadgmdb( // by [Yor]
  4899. const int fd, struct map_session_data* sd,
  4900. const char* command, const char* message)
  4901. {
  4902. nullpo_retr(-1, sd);
  4903. chrif_reloadGMdb();
  4904. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4905. return 0;
  4906. }
  4907. /*==========================================
  4908. * @mapinfo <map name> [0-3] by MC_Cameri
  4909. * => Shows information about the map [map name]
  4910. * 0 = no additional information
  4911. * 1 = Show users in that map and their location
  4912. * 2 = Shows NPCs in that map
  4913. * 3 = Shows the shops/chats in that map (not implemented)
  4914. *------------------------------------------
  4915. */
  4916. int atcommand_mapinfo(
  4917. const int fd, struct map_session_data* sd,
  4918. const char* command, const char* message)
  4919. {
  4920. struct map_session_data *pl_sd, **pl_allsd;
  4921. struct npc_data *nd = NULL;
  4922. struct chat_data *cd = NULL;
  4923. char direction[12];
  4924. int m_id, i, chat_num, users, list = 0;
  4925. unsigned short m_index;
  4926. nullpo_retr(-1, sd);
  4927. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4928. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4929. memset(direction, '\0', sizeof(direction));
  4930. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4931. if (list < 0 || list > 3) {
  4932. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4933. return -1;
  4934. }
  4935. if (atcmd_player_name[0] == '\0') {
  4936. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4937. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4938. m_id = map_mapindex2mapid(sd->mapindex);
  4939. } else {
  4940. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4941. strcat(atcmd_player_name, ".gat");
  4942. m_id = map_mapname2mapid(atcmd_player_name);
  4943. }
  4944. if (m_id < 0) {
  4945. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4946. return -1;
  4947. }
  4948. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4949. clif_displaymessage(fd, "------ Map Info ------");
  4950. chat_num = 0;
  4951. pl_allsd = map_getallusers(&users);
  4952. for (i = 0; i < users; i++) {
  4953. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4954. chat_num++;
  4955. }
  4956. }
  4957. 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);
  4958. clif_displaymessage(fd, atcmd_output);
  4959. if (map[m_id].flag.alias)
  4960. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4961. clif_displaymessage(fd, "------ Map Flags ------");
  4962. strcpy(atcmd_output,"PvP Flags: ");
  4963. if (map[m_id].flag.pvp)
  4964. strcat(atcmd_output, "Pvp ON | ");
  4965. if (map[m_id].flag.pvp_noguild)
  4966. strcat(atcmd_output, "NoGuild | ");
  4967. if (map[m_id].flag.pvp_noparty)
  4968. strcat(atcmd_output, "NoParty | ");
  4969. if (map[m_id].flag.pvp_nightmaredrop)
  4970. strcat(atcmd_output, "NightmareDrop | ");
  4971. if (map[m_id].flag.pvp_nocalcrank)
  4972. strcat(atcmd_output, "NoCalcRank | ");
  4973. clif_displaymessage(fd, atcmd_output);
  4974. strcpy(atcmd_output,"GvG Flags: ");
  4975. if (map[m_id].flag.gvg)
  4976. strcat(atcmd_output, "GvG ON | ");
  4977. if (map[m_id].flag.gvg_dungeon)
  4978. strcat(atcmd_output, "GvG Dungeon | ");
  4979. if (map[m_id].flag.gvg_castle)
  4980. strcat(atcmd_output, "GvG Castle | ");
  4981. if (map[m_id].flag.gvg_noparty)
  4982. strcat(atcmd_output, "NoParty | ");
  4983. clif_displaymessage(fd, atcmd_output);
  4984. strcpy(atcmd_output,"Teleport Flags: ");
  4985. if (map[m_id].flag.noteleport)
  4986. strcat(atcmd_output, "NoTeleport | ");
  4987. if (map[m_id].flag.monster_noteleport)
  4988. strcat(atcmd_output, "Monster NoTeleport | ");
  4989. if (map[m_id].flag.nowarp)
  4990. strcat(atcmd_output, "NoWarp | ");
  4991. if (map[m_id].flag.nowarpto)
  4992. strcat(atcmd_output, "NoWarpTo | ");
  4993. if (map[m_id].flag.noreturn)
  4994. strcat(atcmd_output, "NoReturn | ");
  4995. if (map[m_id].flag.nogo)
  4996. strcat(atcmd_output, "NoGo | ");
  4997. if (map[m_id].flag.nomemo)
  4998. strcat(atcmd_output, "NoMemo | ");
  4999. clif_displaymessage(fd, atcmd_output);
  5000. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  5001. clif_displaymessage(fd, atcmd_output);
  5002. if (map[m_id].flag.nosave) {
  5003. if (!map[m_id].save.map)
  5004. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  5005. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  5006. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  5007. else
  5008. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  5009. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  5010. clif_displaymessage(fd, atcmd_output);
  5011. }
  5012. strcpy(atcmd_output,"Weather Flags: ");
  5013. if (map[m_id].flag.snow)
  5014. strcat(atcmd_output, "Snow | ");
  5015. if (map[m_id].flag.fog)
  5016. strcat(atcmd_output, "Fog | ");
  5017. if (map[m_id].flag.sakura)
  5018. strcat(atcmd_output, "Sakura | ");
  5019. if (map[m_id].flag.clouds)
  5020. strcat(atcmd_output, "Clouds | ");
  5021. if (map[m_id].flag.clouds2)
  5022. strcat(atcmd_output, "Clouds2 | ");
  5023. if (map[m_id].flag.fireworks)
  5024. strcat(atcmd_output, "Fireworks | ");
  5025. if (map[m_id].flag.leaves)
  5026. strcat(atcmd_output, "Leaves | ");
  5027. if (map[m_id].flag.rain)
  5028. strcat(atcmd_output, "Rain | ");
  5029. if (map[m_id].flag.indoors)
  5030. strcat(atcmd_output, "Indoors | ");
  5031. if (map[m_id].flag.nightenabled)
  5032. strcat(atcmd_output, "Displays Night | ");
  5033. clif_displaymessage(fd, atcmd_output);
  5034. strcpy(atcmd_output,"Other Flags: ");
  5035. if (map[m_id].flag.nobranch)
  5036. strcat(atcmd_output, "NoBranch | ");
  5037. if (map[m_id].flag.notrade)
  5038. strcat(atcmd_output, "NoTrade | ");
  5039. if (map[m_id].flag.novending)
  5040. strcat(atcmd_output, "NoVending | ");
  5041. if (map[m_id].flag.nodrop)
  5042. strcat(atcmd_output, "NoDrop | ");
  5043. if (map[m_id].flag.noskill)
  5044. strcat(atcmd_output, "NoSkill | ");
  5045. if (map[m_id].flag.noicewall)
  5046. strcat(atcmd_output, "NoIcewall | ");
  5047. clif_displaymessage(fd, atcmd_output);
  5048. strcpy(atcmd_output,"Other Flags: ");
  5049. if (map[m_id].flag.nocommand)
  5050. strcat(atcmd_output, "NoCommand | ");
  5051. if (map[m_id].flag.nobaseexp)
  5052. strcat(atcmd_output, "NoBaseEXP | ");
  5053. if (map[m_id].flag.nojobexp)
  5054. strcat(atcmd_output, "NoJobEXP | ");
  5055. if (map[m_id].flag.nomobloot)
  5056. strcat(atcmd_output, "NoMobLoot | ");
  5057. if (map[m_id].flag.nomvploot)
  5058. strcat(atcmd_output, "NoMVPLoot | ");
  5059. clif_displaymessage(fd, atcmd_output);
  5060. switch (list) {
  5061. case 0:
  5062. // Do nothing. It's list 0, no additional display.
  5063. break;
  5064. case 1:
  5065. clif_displaymessage(fd, "----- Players in Map -----");
  5066. for (i = 0; i < users; i++) {
  5067. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5068. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5069. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5070. clif_displaymessage(fd, atcmd_output);
  5071. }
  5072. }
  5073. break;
  5074. case 2:
  5075. clif_displaymessage(fd, "----- NPCs in Map -----");
  5076. for (i = 0; i < map[m_id].npc_num;) {
  5077. nd = map[m_id].npc[i];
  5078. switch(nd->ud.dir) {
  5079. case 0: strcpy(direction, "North"); break;
  5080. case 1: strcpy(direction, "North West"); break;
  5081. case 2: strcpy(direction, "West"); break;
  5082. case 3: strcpy(direction, "South West"); break;
  5083. case 4: strcpy(direction, "South"); break;
  5084. case 5: strcpy(direction, "South East"); break;
  5085. case 6: strcpy(direction, "East"); break;
  5086. case 7: strcpy(direction, "North East"); break;
  5087. case 9: strcpy(direction, "North"); break;
  5088. default: strcpy(direction, "Unknown"); break;
  5089. }
  5090. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5091. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5092. clif_displaymessage(fd, atcmd_output);
  5093. }
  5094. break;
  5095. case 3:
  5096. clif_displaymessage(fd, "----- Chats in Map -----");
  5097. for (i = 0; i < users; i++) {
  5098. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5099. pl_sd->mapindex == m_index &&
  5100. cd->usersd[0] == pl_sd) {
  5101. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5102. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5103. clif_displaymessage(fd, atcmd_output);
  5104. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5105. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5106. clif_displaymessage(fd, atcmd_output);
  5107. }
  5108. }
  5109. break;
  5110. default: // normally impossible to arrive here
  5111. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5112. return -1;
  5113. break;
  5114. }
  5115. return 0;
  5116. }
  5117. /*==========================================
  5118. *
  5119. *------------------------------------------
  5120. */
  5121. int atcommand_mount_peco(
  5122. const int fd, struct map_session_data* sd,
  5123. const char* command, const char* message)
  5124. {
  5125. nullpo_retr(-1, sd);
  5126. if (!pc_isriding(sd)) { // if actually no peco
  5127. if (pc_checkskill(sd, KN_RIDING)) {
  5128. pc_setoption(sd, sd->sc.option | 0x0020);
  5129. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5130. } else {
  5131. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5132. return -1;
  5133. }
  5134. } else { //Dismount
  5135. pc_setoption(sd, sd->sc.option & ~0x0020);
  5136. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5137. }
  5138. return 0;
  5139. }
  5140. /*==========================================
  5141. *
  5142. *------------------------------------------
  5143. */
  5144. int atcommand_char_mount_peco(
  5145. const int fd, struct map_session_data* sd,
  5146. const char* command, const char* message)
  5147. {
  5148. struct map_session_data *pl_sd;
  5149. nullpo_retr(-1, sd);
  5150. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5151. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5152. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5153. return -1;
  5154. }
  5155. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5156. if (!pc_isriding(pl_sd)) { // if actually no peco
  5157. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5158. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5159. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5160. } else {
  5161. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5162. return -1;
  5163. }
  5164. } else { //Dismount
  5165. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5166. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5167. }
  5168. } else {
  5169. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5170. return -1;
  5171. }
  5172. return 0;
  5173. }
  5174. /*==========================================
  5175. *Spy Commands by Syrus22
  5176. *------------------------------------------
  5177. */
  5178. int atcommand_guildspy(
  5179. const int fd, struct map_session_data* sd,
  5180. const char* command, const char* message)
  5181. {
  5182. char guild_name[NAME_LENGTH];
  5183. struct guild *g;
  5184. nullpo_retr(-1, sd);
  5185. memset(guild_name, '\0', sizeof(guild_name));
  5186. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5187. if (!enable_spy)
  5188. {
  5189. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5190. return -1;
  5191. }
  5192. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5193. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5194. return -1;
  5195. }
  5196. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5197. (g = guild_search(atoi(message))) != NULL) {
  5198. if (sd->guildspy == g->guild_id) {
  5199. sd->guildspy = 0;
  5200. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5201. clif_displaymessage(fd, atcmd_output);
  5202. } else {
  5203. sd->guildspy = g->guild_id;
  5204. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5205. clif_displaymessage(fd, atcmd_output);
  5206. }
  5207. } else {
  5208. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5209. return -1;
  5210. }
  5211. return 0;
  5212. }
  5213. /*==========================================
  5214. *
  5215. *------------------------------------------
  5216. */
  5217. int atcommand_partyspy(
  5218. const int fd, struct map_session_data* sd,
  5219. const char* command, const char* message)
  5220. {
  5221. char party_name[NAME_LENGTH];
  5222. struct party_data *p;
  5223. nullpo_retr(-1, sd);
  5224. memset(party_name, '\0', sizeof(party_name));
  5225. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5226. if (!enable_spy)
  5227. {
  5228. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5229. return -1;
  5230. }
  5231. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5232. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5233. return -1;
  5234. }
  5235. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5236. (p = party_search(atoi(message))) != NULL) {
  5237. if (sd->partyspy == p->party.party_id) {
  5238. sd->partyspy = 0;
  5239. sprintf(atcmd_output, msg_table[105], p->party.name); // No longer spying on the %s party.
  5240. clif_displaymessage(fd, atcmd_output);
  5241. } else {
  5242. sd->partyspy = p->party.party_id;
  5243. sprintf(atcmd_output, msg_table[106], p->party.name); // Spying on the %s party.
  5244. clif_displaymessage(fd, atcmd_output);
  5245. }
  5246. } else {
  5247. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5248. return -1;
  5249. }
  5250. return 0;
  5251. }
  5252. /*==========================================
  5253. * @repairall [Valaris]
  5254. *------------------------------------------
  5255. */
  5256. int atcommand_repairall(
  5257. const int fd, struct map_session_data* sd,
  5258. const char* command, const char* message)
  5259. {
  5260. int count, i;
  5261. nullpo_retr(-1, sd);
  5262. count = 0;
  5263. for (i = 0; i < MAX_INVENTORY; i++) {
  5264. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5265. sd->status.inventory[i].attribute = 0;
  5266. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5267. count++;
  5268. }
  5269. }
  5270. if (count > 0) {
  5271. clif_misceffect(&sd->bl, 3);
  5272. clif_equiplist(sd);
  5273. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5274. } else {
  5275. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5276. return -1;
  5277. }
  5278. return 0;
  5279. }
  5280. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5281. int atcommand_nuke(
  5282. const int fd, struct map_session_data* sd,
  5283. const char* command, const char* message)
  5284. {
  5285. struct map_session_data *pl_sd;
  5286. nullpo_retr(-1, sd);
  5287. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5288. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5289. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5290. return -1;
  5291. }
  5292. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5293. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5294. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5295. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5296. } else {
  5297. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5298. return -1;
  5299. }
  5300. } else {
  5301. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5302. return -1;
  5303. }
  5304. return 0;
  5305. }
  5306. /*==========================================
  5307. * @tonpc
  5308. *------------------------------------------
  5309. */
  5310. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5311. const char* command, const char* message)
  5312. {
  5313. char npcname[NAME_LENGTH];
  5314. struct npc_data *nd;
  5315. nullpo_retr(-1, sd);
  5316. memset(npcname, 0, sizeof(npcname));
  5317. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5318. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5319. return -1;
  5320. }
  5321. if ((nd = npc_name2id(npcname)) != NULL) {
  5322. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5323. clif_displaymessage(fd, msg_table[0]); // Warped.
  5324. else
  5325. return -1;
  5326. } else {
  5327. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5328. return -1;
  5329. }
  5330. return 0;
  5331. }
  5332. /*==========================================
  5333. *
  5334. *------------------------------------------
  5335. */
  5336. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5337. const char* command, const char* message)
  5338. {
  5339. char NPCname[NAME_LENGTH];
  5340. nullpo_retr(-1, sd);
  5341. memset(NPCname, '\0', sizeof(NPCname));
  5342. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5343. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5344. return -1;
  5345. }
  5346. if (npc_name2id(NPCname) != NULL) {
  5347. npc_enable(NPCname, 1);
  5348. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5349. } else {
  5350. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5351. return -1;
  5352. }
  5353. return 0;
  5354. }
  5355. /*==========================================
  5356. *
  5357. *------------------------------------------
  5358. */
  5359. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5360. const char* command, const char* message)
  5361. {
  5362. char NPCname[NAME_LENGTH];
  5363. nullpo_retr(-1, sd);
  5364. memset(NPCname, '\0', sizeof(NPCname));
  5365. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5366. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5367. return -1;
  5368. }
  5369. if (npc_name2id(NPCname) != NULL) {
  5370. npc_enable(NPCname, 0);
  5371. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5372. } else {
  5373. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5374. return -1;
  5375. }
  5376. return 0;
  5377. }
  5378. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5379. const char* command, const char* message)
  5380. {
  5381. FILE *fp;
  5382. if (!message || !*message) {
  5383. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5384. return -1;
  5385. }
  5386. // check if script file exists
  5387. if ((fp = fopen(message, "r")) == NULL) {
  5388. clif_displaymessage(fd, msg_table[261]);
  5389. return -1;
  5390. }
  5391. fclose(fp);
  5392. // add to list of script sources and run it
  5393. npc_addsrcfile((char *)message);
  5394. npc_parsesrcfile((char *)message);
  5395. clif_displaymessage(fd, msg_table[262]);
  5396. return 0;
  5397. }
  5398. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5399. const char* command, const char* message)
  5400. {
  5401. struct npc_data *nd;
  5402. char NPCname[NAME_LENGTH];
  5403. nullpo_retr(-1, sd);
  5404. memset(NPCname, '\0', sizeof(NPCname));
  5405. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5406. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5407. return -1;
  5408. }
  5409. if ((nd = npc_name2id(NPCname)) != NULL) {
  5410. npc_unload(nd);
  5411. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5412. } else {
  5413. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5414. return -1;
  5415. }
  5416. return 0;
  5417. }
  5418. /*==========================================
  5419. * time in txt for time command (by [Yor])
  5420. *------------------------------------------
  5421. */
  5422. char * txt_time(unsigned int duration) {
  5423. int days, hours, minutes, seconds;
  5424. char temp[256];
  5425. static char temp1[256];
  5426. memset(temp, '\0', sizeof(temp));
  5427. memset(temp1, '\0', sizeof(temp1));
  5428. days = duration / (60 * 60 * 24);
  5429. duration = duration - (60 * 60 * 24 * days);
  5430. hours = duration / (60 * 60);
  5431. duration = duration - (60 * 60 * hours);
  5432. minutes = duration / 60;
  5433. seconds = duration - (60 * minutes);
  5434. if (days < 2)
  5435. sprintf(temp, msg_table[219], days); // %d day
  5436. else
  5437. sprintf(temp, msg_table[220], days); // %d days
  5438. if (hours < 2)
  5439. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5440. else
  5441. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5442. if (minutes < 2)
  5443. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5444. else
  5445. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5446. if (seconds < 2)
  5447. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5448. else
  5449. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5450. return temp1;
  5451. }
  5452. /*==========================================
  5453. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5454. * Calculation management of GM modification (@day/@night GM commands) is done
  5455. *------------------------------------------
  5456. */
  5457. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5458. const char* command, const char* message)
  5459. {
  5460. struct TimerData * timer_data;
  5461. struct TimerData * timer_data2;
  5462. time_t time_server; // variable for number of seconds (used with time() function)
  5463. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5464. char temp[256];
  5465. nullpo_retr(-1, sd);
  5466. memset(temp, '\0', sizeof(temp));
  5467. time(&time_server); // get time in seconds since 1/1/1970
  5468. datetime = localtime(&time_server); // convert seconds in structure
  5469. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5470. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5471. clif_displaymessage(fd, temp);
  5472. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5473. if (night_flag == 0)
  5474. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5475. else
  5476. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5477. } else if (battle_config.night_duration == 0)
  5478. if (night_flag == 1) { // we start with night
  5479. timer_data = get_timer(day_timer_tid);
  5480. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5481. clif_displaymessage(fd, temp);
  5482. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5483. } else
  5484. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5485. else if (battle_config.day_duration == 0)
  5486. if (night_flag == 0) { // we start with day
  5487. timer_data = get_timer(night_timer_tid);
  5488. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5489. clif_displaymessage(fd, temp);
  5490. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5491. } else
  5492. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5493. else {
  5494. if (night_flag == 0) {
  5495. timer_data = get_timer(night_timer_tid);
  5496. timer_data2 = get_timer(day_timer_tid);
  5497. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5498. clif_displaymessage(fd, temp);
  5499. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5500. sprintf(temp, msg_table[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.
  5501. else
  5502. sprintf(temp, msg_table[237], txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  5503. clif_displaymessage(fd, temp);
  5504. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5505. clif_displaymessage(fd, temp);
  5506. } else {
  5507. timer_data = get_timer(day_timer_tid);
  5508. timer_data2 = get_timer(night_timer_tid);
  5509. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5510. clif_displaymessage(fd, temp);
  5511. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5512. sprintf(temp, msg_table[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.
  5513. else
  5514. sprintf(temp, msg_table[239], txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  5515. clif_displaymessage(fd, temp);
  5516. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5517. clif_displaymessage(fd, temp);
  5518. }
  5519. }
  5520. return 0;
  5521. }
  5522. /*==========================================
  5523. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5524. * removes <quantity> item from a character
  5525. * item can be equiped or not.
  5526. * Inspired from a old command created by RoVeRT
  5527. *------------------------------------------
  5528. */
  5529. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5530. const char* command, const char* message)
  5531. {
  5532. struct map_session_data *pl_sd;
  5533. char item_name[100];
  5534. int i, number = 0, item_id, item_position, count;
  5535. struct item_data *item_data;
  5536. nullpo_retr(-1, sd);
  5537. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5538. memset(item_name, '\0', sizeof(item_name));
  5539. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5540. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5541. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5542. return -1;
  5543. }
  5544. item_id = 0;
  5545. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5546. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5547. item_id = item_data->nameid;
  5548. if (item_id > 500) {
  5549. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5550. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5551. item_position = pc_search_inventory(pl_sd, item_id);
  5552. if (item_position >= 0) {
  5553. count = 0;
  5554. for(i = 0; i < number && item_position >= 0; i++) {
  5555. //Logs (A)dmins items [Lupus]
  5556. if(log_config.pick > 0 ) {
  5557. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5558. }
  5559. //Logs
  5560. pc_delitem(pl_sd, item_position, 1, 0);
  5561. count++;
  5562. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5563. }
  5564. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5565. clif_displaymessage(pl_sd->fd, atcmd_output);
  5566. if (number == count)
  5567. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5568. else
  5569. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5570. clif_displaymessage(fd, atcmd_output);
  5571. } else {
  5572. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5573. return -1;
  5574. }
  5575. } else {
  5576. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5577. return -1;
  5578. }
  5579. } else {
  5580. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5581. return -1;
  5582. }
  5583. } else {
  5584. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5585. return -1;
  5586. }
  5587. return 0;
  5588. }
  5589. /*==========================================
  5590. * @jail <char_name> by [Yor]
  5591. * Special warp! No check with nowarp and nowarpto flag
  5592. *------------------------------------------
  5593. */
  5594. int atcommand_jail(
  5595. const int fd, struct map_session_data* sd,
  5596. const char* command, const char* message)
  5597. {
  5598. struct map_session_data *pl_sd;
  5599. int x, y;
  5600. unsigned short m_index;
  5601. nullpo_retr(-1, sd);
  5602. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5603. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5604. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5605. return -1;
  5606. }
  5607. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5608. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5609. switch(rand() % 2) {
  5610. case 0:
  5611. x = 24;
  5612. y = 75;
  5613. break;
  5614. default:
  5615. x = 49;
  5616. y = 75;
  5617. break;
  5618. }
  5619. m_index = mapindex_name2id(MAP_JAIL);
  5620. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5621. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5622. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5623. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5624. } else {
  5625. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5626. return -1;
  5627. }
  5628. } else {
  5629. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5630. return -1;
  5631. }
  5632. } else {
  5633. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5634. return -1;
  5635. }
  5636. return 0;
  5637. }
  5638. /*==========================================
  5639. * @unjail/@discharge <char_name> by [Yor]
  5640. * Special warp! No check with nowarp and nowarpto flag
  5641. *------------------------------------------
  5642. */
  5643. int atcommand_unjail(
  5644. const int fd, struct map_session_data* sd,
  5645. const char* command, const char* message)
  5646. {
  5647. struct map_session_data *pl_sd;
  5648. unsigned short m_index;
  5649. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5650. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5651. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5652. return -1;
  5653. }
  5654. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5655. m_index = mapindex_name2id(MAP_PRONTERA);
  5656. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5657. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5658. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5659. return -1;
  5660. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5661. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5662. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5663. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5664. } else {
  5665. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5666. return -1;
  5667. }
  5668. } else {
  5669. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5670. return -1;
  5671. }
  5672. } else {
  5673. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5674. return -1;
  5675. }
  5676. return 0;
  5677. }
  5678. /*==========================================
  5679. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5680. *------------------------------------------
  5681. */
  5682. int atcommand_disguise(
  5683. const int fd, struct map_session_data* sd,
  5684. const char* command, const char* message)
  5685. {
  5686. int id = 0;
  5687. nullpo_retr(-1, sd);
  5688. if (!message || !*message) {
  5689. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5690. return -1;
  5691. }
  5692. if ((id = atoi(message)) > 0)
  5693. { //Acquired an ID
  5694. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5695. id = 0; //Invalid id for either mobs or npcs.
  5696. } else { //Acquired a Name
  5697. if ((id = mobdb_searchname(message)) == 0)
  5698. {
  5699. struct npc_data* nd = npc_name2id(message);
  5700. if (nd != NULL)
  5701. id = nd->n;
  5702. }
  5703. }
  5704. if (id == 0)
  5705. { // Monster/NPC name/id hasn't been found.
  5706. clif_displaymessage(fd, msg_table[123]);
  5707. return -1;
  5708. }
  5709. pc_disguise(sd, id);
  5710. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5711. return 0;
  5712. }
  5713. /*==========================================
  5714. * DisguiseAll
  5715. *------------------------------------------
  5716. */
  5717. int atcommand_disguiseall(
  5718. const int fd, struct map_session_data* sd,
  5719. const char* command, const char* message)
  5720. {
  5721. int mob_id=0, i=0, users;
  5722. struct map_session_data *pl_sd, **pl_allsd;
  5723. nullpo_retr(-1, sd);
  5724. if (!message || !*message) {
  5725. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5726. return -1;
  5727. }
  5728. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5729. mob_id = atoi(message);
  5730. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5731. pl_allsd = map_getallusers(&users);
  5732. for(i=0; i < users; i++) {
  5733. if((pl_sd = pl_allsd[i]))
  5734. pc_disguise(pl_sd, mob_id);
  5735. }
  5736. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5737. } else {
  5738. return -1;
  5739. }
  5740. return 0;
  5741. }
  5742. /*==========================================
  5743. * @undisguise by [Yor]
  5744. *------------------------------------------
  5745. */
  5746. int atcommand_undisguise(
  5747. const int fd, struct map_session_data* sd,
  5748. const char* command, const char* message)
  5749. {
  5750. nullpo_retr(-1, sd);
  5751. if (sd->disguise) {
  5752. pc_disguise(sd, 0);
  5753. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5754. } else {
  5755. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5756. return -1;
  5757. }
  5758. return 0;
  5759. }
  5760. /*==========================================
  5761. * UndisguiseAll
  5762. *------------------------------------------
  5763. */
  5764. int atcommand_undisguiseall(
  5765. const int fd, struct map_session_data* sd,
  5766. const char* command, const char* message)
  5767. {
  5768. struct map_session_data *pl_sd, **pl_allsd;
  5769. int i, users;
  5770. nullpo_retr(-1, sd);
  5771. pl_allsd = map_getallusers(&users);
  5772. for(i=0; i < users; i++) {
  5773. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5774. pc_disguise(pl_sd, 0);
  5775. }
  5776. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5777. return 0;
  5778. }
  5779. /*==========================================
  5780. * @exp by [Skotlex]
  5781. *------------------------------------------
  5782. */
  5783. int atcommand_exp(
  5784. const int fd, struct map_session_data* sd,
  5785. const char* command, const char* message)
  5786. {
  5787. char output[200];
  5788. double nextb, nextj;
  5789. nullpo_retr(-1, sd);
  5790. memset(output, '\0', sizeof(output));
  5791. nextb = pc_nextbaseexp(sd);
  5792. if (nextb)
  5793. nextb = sd->status.base_exp*100.0/nextb;
  5794. nextj = pc_nextjobexp(sd);
  5795. if (nextj)
  5796. nextj = sd->status.job_exp*100.0/nextj;
  5797. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5798. clif_displaymessage(fd, output);
  5799. return 0;
  5800. }
  5801. /*==========================================
  5802. * @broadcast by [Valaris]
  5803. *------------------------------------------
  5804. */
  5805. int atcommand_broadcast(
  5806. const int fd, struct map_session_data* sd,
  5807. const char* command, const char* message)
  5808. {
  5809. nullpo_retr(-1, sd);
  5810. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5811. if (!message || !*message) {
  5812. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5813. return -1;
  5814. }
  5815. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5816. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5817. return 0;
  5818. }
  5819. /*==========================================
  5820. * @localbroadcast by [Valaris]
  5821. *------------------------------------------
  5822. */
  5823. int atcommand_localbroadcast(
  5824. const int fd, struct map_session_data* sd,
  5825. const char* command, const char* message)
  5826. {
  5827. nullpo_retr(-1, sd);
  5828. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5829. if (!message || !*message) {
  5830. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5831. return -1;
  5832. }
  5833. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5834. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5835. return 0;
  5836. }
  5837. /*==========================================
  5838. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5839. *------------------------------------------
  5840. */
  5841. int atcommand_chardisguise(
  5842. const int fd, struct map_session_data* sd,
  5843. const char* command, const char* message)
  5844. {
  5845. int mob_id;
  5846. char mob_name[NAME_LENGTH];
  5847. struct map_session_data* pl_sd;
  5848. nullpo_retr(-1, sd);
  5849. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5850. memset(mob_name, '\0', sizeof(mob_name));
  5851. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5852. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5853. return -1;
  5854. }
  5855. if ((mob_id = atoi(mob_name)) > 0)
  5856. { //Acquired an ID
  5857. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5858. mob_id = 0; //Invalid id for either mobs or npcs.
  5859. } else { //Acquired a Name
  5860. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5861. {
  5862. struct npc_data* nd = npc_name2id(mob_name);
  5863. if (nd != NULL)
  5864. mob_id = nd->n;
  5865. }
  5866. }
  5867. if (mob_id == 0)
  5868. {
  5869. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5870. return -1;
  5871. }
  5872. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5873. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5874. pc_disguise(pl_sd, mob_id);
  5875. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5876. } else {
  5877. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5878. return -1;
  5879. }
  5880. } else {
  5881. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5882. return -1;
  5883. }
  5884. return 0;
  5885. }
  5886. /*==========================================
  5887. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5888. *------------------------------------------
  5889. */
  5890. int atcommand_charundisguise(
  5891. const int fd, struct map_session_data* sd,
  5892. const char* command, const char* message)
  5893. {
  5894. struct map_session_data* pl_sd;
  5895. nullpo_retr(-1, sd);
  5896. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5897. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5898. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5899. return -1;
  5900. }
  5901. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5902. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5903. if (pl_sd->disguise)
  5904. pc_disguise(pl_sd, 0);
  5905. else {
  5906. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5907. return -1;
  5908. }
  5909. } else {
  5910. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5911. return -1;
  5912. }
  5913. } else {
  5914. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5915. return -1;
  5916. }
  5917. return 0;
  5918. }
  5919. /*==========================================
  5920. * @email <actual@email> <new@email> by [Yor]
  5921. *------------------------------------------
  5922. */
  5923. int atcommand_email(
  5924. const int fd, struct map_session_data* sd,
  5925. const char* command, const char* message)
  5926. {
  5927. char actual_email[100];
  5928. char new_email[100];
  5929. nullpo_retr(-1, sd);
  5930. memset(actual_email, '\0', sizeof(actual_email));
  5931. memset(new_email, '\0', sizeof(new_email));
  5932. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5933. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5934. return -1;
  5935. }
  5936. if (e_mail_check(actual_email) == 0) {
  5937. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5938. return -1;
  5939. } else if (e_mail_check(new_email) == 0) {
  5940. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5941. return -1;
  5942. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5943. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5944. return -1;
  5945. } else if (strcmpi(actual_email, new_email) == 0) {
  5946. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5947. return -1;
  5948. } else {
  5949. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5950. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5951. }
  5952. return 0;
  5953. }
  5954. /*==========================================
  5955. *@effect
  5956. *------------------------------------------
  5957. */
  5958. int atcommand_effect(
  5959. const int fd, struct map_session_data* sd,
  5960. const char* command, const char* message)
  5961. {
  5962. int type = 0, flag = 0;
  5963. nullpo_retr(-1, sd);
  5964. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5965. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5966. return -1;
  5967. }
  5968. clif_specialeffect(&sd->bl, type, flag);
  5969. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5970. return 0;
  5971. }
  5972. /*==========================================
  5973. * @charcartlist <character>: Displays the items list of a player's cart.
  5974. *------------------------------------------
  5975. */
  5976. int
  5977. atcommand_character_cart_list(
  5978. const int fd, struct map_session_data* sd,
  5979. const char* command, const char* message)
  5980. {
  5981. char outputtmp[200];
  5982. struct map_session_data *pl_sd;
  5983. struct item_data *item_data, *item_temp;
  5984. int i, j, count, counter, counter2;
  5985. nullpo_retr(-1, sd);
  5986. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5987. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5988. memset(outputtmp, '\0', sizeof(outputtmp));
  5989. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5990. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5991. return -1;
  5992. }
  5993. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5994. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5995. counter = 0;
  5996. count = 0;
  5997. for (i = 0; i < MAX_CART; i++) {
  5998. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5999. counter = counter + pl_sd->status.cart[i].amount;
  6000. count++;
  6001. if (count == 1) {
  6002. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6003. clif_displaymessage(fd, atcmd_output);
  6004. }
  6005. if (pl_sd->status.cart[i].refine)
  6006. 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);
  6007. else
  6008. 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);
  6009. clif_displaymessage(fd, atcmd_output);
  6010. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6011. counter2 = 0;
  6012. for (j = 0; j < item_data->slot; j++) {
  6013. if (pl_sd->status.cart[i].card[j]) {
  6014. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6015. if (atcmd_output[0] == '\0')
  6016. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6017. else
  6018. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6019. strcat(atcmd_output, outputtmp);
  6020. }
  6021. }
  6022. }
  6023. if (atcmd_output[0] != '\0') {
  6024. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6025. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6026. clif_displaymessage(fd, atcmd_output);
  6027. }
  6028. }
  6029. }
  6030. if (count == 0)
  6031. clif_displaymessage(fd, "No item found in the cart of this player.");
  6032. else {
  6033. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6034. clif_displaymessage(fd, atcmd_output);
  6035. }
  6036. } else {
  6037. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6038. return -1;
  6039. }
  6040. } else {
  6041. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6042. return -1;
  6043. }
  6044. return 0;
  6045. }
  6046. /*==========================================
  6047. * @killer by MouseJstr
  6048. * enable killing players even when not in pvp
  6049. *------------------------------------------
  6050. */
  6051. int
  6052. atcommand_killer(
  6053. const int fd, struct map_session_data* sd,
  6054. const char* command, const char* message)
  6055. {
  6056. nullpo_retr(-1, sd);
  6057. sd->special_state.killer = !sd->special_state.killer;
  6058. if(sd->special_state.killer)
  6059. clif_displaymessage(fd, msg_table[241]);
  6060. else
  6061. clif_displaymessage(fd, msg_table[242]);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * @killable by MouseJstr
  6066. * enable other people killing you
  6067. *------------------------------------------
  6068. */
  6069. int
  6070. atcommand_killable(
  6071. const int fd, struct map_session_data* sd,
  6072. const char* command, const char* message)
  6073. {
  6074. nullpo_retr(-1, sd);
  6075. sd->special_state.killable = !sd->special_state.killable;
  6076. if(sd->special_state.killable)
  6077. clif_displaymessage(fd, msg_table[242]);
  6078. else
  6079. clif_displaymessage(fd, msg_table[241]);
  6080. return 0;
  6081. }
  6082. /*==========================================
  6083. * @charkillable by MouseJstr
  6084. * enable another player to be killed
  6085. *------------------------------------------
  6086. */
  6087. int
  6088. atcommand_charkillable(
  6089. const int fd, struct map_session_data* sd,
  6090. const char* command, const char* message)
  6091. {
  6092. struct map_session_data *pl_sd = NULL;
  6093. nullpo_retr(-1, sd);
  6094. if (!message || !*message)
  6095. return -1;
  6096. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6097. return -1;
  6098. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6099. if(pl_sd->special_state.killable)
  6100. clif_displaymessage(fd, "The player is now killable");
  6101. else
  6102. clif_displaymessage(fd, "The player is no longer killable");
  6103. return 0;
  6104. }
  6105. /*==========================================
  6106. * @skillon by MouseJstr
  6107. * turn skills on for the map
  6108. *------------------------------------------
  6109. */
  6110. int
  6111. atcommand_skillon(
  6112. const int fd, struct map_session_data* sd,
  6113. const char* command, const char* message)
  6114. {
  6115. nullpo_retr(-1, sd);
  6116. map[sd->bl.m].flag.noskill = 0;
  6117. clif_displaymessage(fd, msg_table[244]);
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * @skilloff by MouseJstr
  6122. * Turn skills off on the map
  6123. *------------------------------------------
  6124. */
  6125. int
  6126. atcommand_skilloff(
  6127. const int fd, struct map_session_data* sd,
  6128. const char* command, const char* message)
  6129. {
  6130. nullpo_retr(-1, sd);
  6131. map[sd->bl.m].flag.noskill = 1;
  6132. clif_displaymessage(fd, msg_table[243]);
  6133. return 0;
  6134. }
  6135. /*==========================================
  6136. * @npcmove by MouseJstr
  6137. *
  6138. * move a npc
  6139. *------------------------------------------
  6140. */
  6141. int
  6142. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6143. const char* command, const char* message)
  6144. {
  6145. int x = 0, y = 0, m;
  6146. struct npc_data *nd = 0;
  6147. nullpo_retr(-1, sd);
  6148. if (!message || !*message)
  6149. return -1;
  6150. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6151. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6152. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6153. return -1;
  6154. }
  6155. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6156. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6157. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6158. return -1;
  6159. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6160. return -1; //Not on a map.
  6161. if (x < 0) x = 0;
  6162. else if (x >= map[m].xs) x = map[m].xs-1;
  6163. if (y < 0) y = 0;
  6164. else if (y >= map[m].ys) y = map[m].ys-1;
  6165. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6166. map_moveblock(&nd->bl, x, y, gettick());
  6167. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6168. return 0;
  6169. }
  6170. /*==========================================
  6171. * @addwarp by MouseJstr
  6172. *
  6173. * Create a new static warp point.
  6174. *------------------------------------------
  6175. */
  6176. int
  6177. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6178. const char* command, const char* message)
  6179. {
  6180. char w1[64], w3[64], w4[64];
  6181. int x,y,ret;
  6182. nullpo_retr(-1, sd);
  6183. if (!message || !*message)
  6184. return -1;
  6185. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6186. return -1;
  6187. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6188. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6189. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6190. ret = npc_parse_warp(w1, "warp", w3, w4);
  6191. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6192. clif_displaymessage(fd, atcmd_output);
  6193. return ret;
  6194. }
  6195. /*==========================================
  6196. * @follow by [MouseJstr]
  6197. *
  6198. * Follow a player .. staying no more then 5 spaces away
  6199. *------------------------------------------
  6200. */
  6201. int
  6202. atcommand_follow(const int fd, struct map_session_data* sd,
  6203. const char* command, const char* message)
  6204. {
  6205. struct map_session_data *pl_sd = NULL;
  6206. nullpo_retr(-1, sd);
  6207. if (!message || !*message) {
  6208. if (sd->followtarget == -1)
  6209. return -1;
  6210. pc_stop_following (sd);
  6211. clif_displaymessage(fd, "Stop following");
  6212. return 0;
  6213. }
  6214. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6215. if (sd->followtarget == pl_sd->bl.id)
  6216. pc_stop_following (sd);
  6217. else
  6218. pc_follow(sd, pl_sd->bl.id);
  6219. return 0;
  6220. }
  6221. return 1;
  6222. }
  6223. /*==========================================
  6224. * @dropall by [MouseJstr]
  6225. *
  6226. * Drop all your possession on the ground
  6227. *------------------------------------------
  6228. */
  6229. int
  6230. atcommand_dropall(const int fd, struct map_session_data* sd,
  6231. const char* command, const char* message)
  6232. {
  6233. int i;
  6234. nullpo_retr(-1, sd);
  6235. for (i = 0; i < MAX_INVENTORY; i++) {
  6236. if (sd->status.inventory[i].amount) {
  6237. if(sd->status.inventory[i].equip != 0)
  6238. pc_unequipitem(sd, i, 3);
  6239. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6240. }
  6241. }
  6242. return 0;
  6243. }
  6244. /*==========================================
  6245. * @chardropall by [MouseJstr]
  6246. *
  6247. * Throw all the characters possessions on the ground. Normally
  6248. * done in response to them being disrespectful of a GM
  6249. *------------------------------------------
  6250. */
  6251. int
  6252. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6253. const char* command, const char* message)
  6254. {
  6255. int i;
  6256. struct map_session_data *pl_sd = NULL;
  6257. nullpo_retr(-1, sd);
  6258. if (!message || !*message)
  6259. return -1;
  6260. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6261. return -1;
  6262. for (i = 0; i < MAX_INVENTORY; i++) {
  6263. if (pl_sd->status.inventory[i].amount) {
  6264. if(pl_sd->status.inventory[i].equip != 0)
  6265. pc_unequipitem(pl_sd, i, 3);
  6266. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6267. }
  6268. }
  6269. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6270. clif_displaymessage(fd, "It is done");
  6271. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6272. return 0;
  6273. }
  6274. /*==========================================
  6275. * @storeall by [MouseJstr]
  6276. *
  6277. * Put everything into storage to simplify your inventory to make
  6278. * debugging easie
  6279. *------------------------------------------
  6280. */
  6281. int
  6282. atcommand_storeall(const int fd, struct map_session_data* sd,
  6283. const char* command, const char* message)
  6284. {
  6285. int i;
  6286. nullpo_retr(-1, sd);
  6287. if (storage_storageopen(sd) == 1) {
  6288. clif_displaymessage(fd, "run this command again..");
  6289. return 0;
  6290. }
  6291. for (i = 0; i < MAX_INVENTORY; i++) {
  6292. if (sd->status.inventory[i].amount) {
  6293. if(sd->status.inventory[i].equip != 0)
  6294. pc_unequipitem(sd, i, 3);
  6295. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6296. }
  6297. }
  6298. storage_storageclose(sd);
  6299. clif_displaymessage(fd, "It is done");
  6300. return 0;
  6301. }
  6302. /*==========================================
  6303. * @charstoreall by [MouseJstr]
  6304. *
  6305. * A way to screw with players who piss you off
  6306. *------------------------------------------
  6307. */
  6308. int
  6309. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6310. const char* command, const char* message)
  6311. {
  6312. int i;
  6313. struct map_session_data *pl_sd = NULL;
  6314. nullpo_retr(-1, sd);
  6315. if (!message || !*message)
  6316. return -1;
  6317. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6318. return -1;
  6319. if (storage_storageopen(pl_sd) == 1) {
  6320. clif_displaymessage(fd, "Had to open the characters storage window...");
  6321. clif_displaymessage(fd, "run this command again..");
  6322. return 0;
  6323. }
  6324. for (i = 0; i < MAX_INVENTORY; i++) {
  6325. if (pl_sd->status.inventory[i].amount) {
  6326. if(pl_sd->status.inventory[i].equip != 0)
  6327. pc_unequipitem(pl_sd, i, 3);
  6328. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6329. }
  6330. }
  6331. storage_storageclose(pl_sd);
  6332. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6333. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6334. clif_displaymessage(pl_sd->fd, " -- the management");
  6335. clif_displaymessage(fd, "It is done");
  6336. return 0;
  6337. }
  6338. /*==========================================
  6339. * @skillid by [MouseJstr]
  6340. *
  6341. * lookup a skill by name
  6342. *------------------------------------------
  6343. */
  6344. int
  6345. atcommand_skillid(const int fd, struct map_session_data* sd,
  6346. const char* command, const char* message)
  6347. {
  6348. int skillen, idx;
  6349. nullpo_retr(-1, sd);
  6350. if (!message || !*message)
  6351. return -1;
  6352. skillen = strlen(message);
  6353. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6354. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6355. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6356. {
  6357. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6358. clif_displaymessage(fd, atcmd_output);
  6359. }
  6360. }
  6361. return 0;
  6362. }
  6363. /*==========================================
  6364. * @useskill by [MouseJstr]
  6365. *
  6366. * A way of using skills without having to find them in the skills menu
  6367. *------------------------------------------
  6368. */
  6369. int
  6370. atcommand_useskill(const int fd, struct map_session_data* sd,
  6371. const char* command, const char* message)
  6372. {
  6373. struct map_session_data *pl_sd = NULL;
  6374. int skillnum;
  6375. int skilllv;
  6376. char target[255];
  6377. nullpo_retr(-1, sd);
  6378. if (!message || !*message)
  6379. return -1;
  6380. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6381. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6382. return -1;
  6383. }
  6384. if((pl_sd=map_nick2sd(target)) == NULL) {
  6385. return -1;
  6386. }
  6387. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6388. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6389. else
  6390. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, skilllv);
  6391. return 0;
  6392. }
  6393. /*==========================================
  6394. * @skilltree by [MouseJstr]
  6395. *
  6396. * prints the skill tree for a player required to get to a skill
  6397. *------------------------------------------
  6398. */
  6399. int
  6400. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6401. const char* command, const char* message)
  6402. {
  6403. struct map_session_data *pl_sd = NULL;
  6404. int skillnum, skillidx = -1;
  6405. int meets = 1, j, c=0;
  6406. char target[NAME_LENGTH], *tbl;
  6407. struct skill_tree_entry *ent;
  6408. nullpo_retr(-1, sd);
  6409. if (!message || !*message)
  6410. return -1;
  6411. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6412. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6413. return -1;
  6414. }
  6415. if((pl_sd=map_nick2sd(target)) == NULL)
  6416. return -1;
  6417. c = pc_calc_skilltree_normalize_job(pl_sd);
  6418. c = pc_mapid2jobid(c, pl_sd->status.sex);
  6419. tbl = job_name(c);
  6420. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6421. tbl, pc_checkskill(pl_sd, 1));
  6422. clif_displaymessage(fd, atcmd_output);
  6423. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6424. if (skill_tree[c][j].id == skillnum) {
  6425. skillidx = j;
  6426. break;
  6427. }
  6428. }
  6429. if (skillidx == -1) {
  6430. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6431. clif_displaymessage(fd, atcmd_output);
  6432. return 0;
  6433. }
  6434. ent = &skill_tree[c][skillidx];
  6435. for(j=0;j<5;j++)
  6436. if( ent->need[j].id &&
  6437. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6438. {
  6439. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6440. sprintf(atcmd_output, "player requires level %d of skill %s",
  6441. ent->need[j].lv, desc);
  6442. clif_displaymessage(fd, atcmd_output);
  6443. meets = 0;
  6444. }
  6445. if (meets == 1) {
  6446. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6447. clif_displaymessage(fd, atcmd_output);
  6448. }
  6449. return 0;
  6450. }
  6451. // Hand a ring with partners name on it to this char
  6452. void getring (struct map_session_data *sd)
  6453. {
  6454. int flag,item_id = 0;
  6455. struct item item_tmp;
  6456. if(sd->status.sex==0)
  6457. item_id = 2635;
  6458. else
  6459. item_id = 2634;
  6460. memset(&item_tmp,0,sizeof(item_tmp));
  6461. item_tmp.nameid=item_id;
  6462. item_tmp.identify=1;
  6463. item_tmp.card[0]=255;
  6464. item_tmp.card[2]=sd->status.partner_id;
  6465. item_tmp.card[3]=sd->status.partner_id >> 16;
  6466. //Logs (A)dmins items [Lupus]
  6467. if(log_config.pick > 0 ) {
  6468. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6469. }
  6470. //Logs
  6471. if((flag = pc_additem(sd,&item_tmp,1))) {
  6472. clif_additem(sd,0,0,flag);
  6473. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6474. }
  6475. }
  6476. /*==========================================
  6477. * @marry by [MouseJstr], fixed by Lupus
  6478. *
  6479. * Marry two players
  6480. *------------------------------------------
  6481. */
  6482. int
  6483. atcommand_marry(const int fd, struct map_session_data* sd,
  6484. const char* command, const char* message)
  6485. {
  6486. struct map_session_data *pl_sd1 = NULL;
  6487. struct map_session_data *pl_sd2 = NULL;
  6488. char player1[128], player2[128]; //Length used for return error msgs
  6489. nullpo_retr(-1, sd);
  6490. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6491. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6492. return -1;
  6493. }
  6494. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6495. sprintf(player2, "Cannot find player '%s' online", player1);
  6496. clif_displaymessage(fd, player2);
  6497. return -1;
  6498. }
  6499. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6500. sprintf(player1, "Cannot find player '%s' online", player2);
  6501. clif_displaymessage(fd, player1);
  6502. return -1;
  6503. }
  6504. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6505. clif_displaymessage(fd, "They are married.. wish them well");
  6506. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6507. // Auto-give named rings (Aru)
  6508. getring (pl_sd1);
  6509. getring (pl_sd2);
  6510. return 0;
  6511. }
  6512. return -1;
  6513. }
  6514. /*==========================================
  6515. * @divorce by [MouseJstr], fixed by [Lupus]
  6516. *
  6517. * divorce two players
  6518. *------------------------------------------
  6519. */
  6520. int
  6521. atcommand_divorce(const int fd, struct map_session_data* sd,
  6522. const char* command, const char* message)
  6523. {
  6524. struct map_session_data *pl_sd = NULL;
  6525. nullpo_retr(-1, sd);
  6526. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6527. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6528. return -1;
  6529. }
  6530. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6531. if (pc_divorce(pl_sd) != 0) {
  6532. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6533. clif_displaymessage(fd, atcmd_output);
  6534. return -1;
  6535. } else {
  6536. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6537. clif_displaymessage(fd, atcmd_output);
  6538. return 0;
  6539. }
  6540. }
  6541. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6542. clif_displaymessage(fd, atcmd_output);
  6543. return -1;
  6544. }
  6545. #ifdef DMALLOC
  6546. unsigned long dmark_;
  6547. int
  6548. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6549. const char* command, const char* message)
  6550. {
  6551. dmark_ = dmalloc_mark();
  6552. clif_displaymessage(fd, "debug mark set");
  6553. return 0;
  6554. }
  6555. int
  6556. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6557. const char* command, const char* message)
  6558. {
  6559. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6560. dmark_ = dmalloc_mark();
  6561. clif_displaymessage(fd, "malloc changes logged");
  6562. return 0;
  6563. }
  6564. #endif
  6565. /*==========================================
  6566. * @grind by [MouseJstr]
  6567. *------------------------------------------
  6568. */
  6569. int
  6570. atcommand_grind(const int fd, struct map_session_data* sd,
  6571. const char* command, const char* message)
  6572. {
  6573. struct map_session_data *pl_sd = NULL;
  6574. int skillnum;
  6575. int inf;
  6576. char target[NAME_LENGTH];
  6577. nullpo_retr(-1, sd);
  6578. if (!message || !*message)
  6579. return -1;
  6580. if(sscanf(message, "%23s", target) != 1) {
  6581. clif_displaymessage(fd, "Usage: @grind <target>");
  6582. return -1;
  6583. }
  6584. if((pl_sd=map_nick2sd(target)) == NULL)
  6585. return -1;
  6586. for (skillnum = 1; skillnum < 500; skillnum++) {
  6587. sd->status.sp = sd->status.max_sp;
  6588. atcommand_alive(fd, sd, command, message);
  6589. inf = skill_get_inf(skillnum);
  6590. if (inf & INF_GROUND_SKILL)
  6591. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6592. else if (!(inf & INF_SUPPORT_SKILL))
  6593. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6594. }
  6595. return 0;
  6596. }
  6597. /*==========================================
  6598. * @grind2 by [MouseJstr]
  6599. *------------------------------------------
  6600. */
  6601. int
  6602. atcommand_grind2(const int fd, struct map_session_data* sd,
  6603. const char* command, const char* message)
  6604. {
  6605. int i;
  6606. short x, y;
  6607. for (i = 1000; i < MAX_MOB_DB; i++) {
  6608. if (!mobdb_checkid(i))
  6609. continue;
  6610. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6611. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6612. }
  6613. return 0;
  6614. }
  6615. /*==========================================
  6616. * @changelook by [Celest]
  6617. *------------------------------------------
  6618. */
  6619. int
  6620. atcommand_changelook(const int fd, struct map_session_data* sd,
  6621. const char* command, const char* message)
  6622. {
  6623. int i, j = 0, k = 0;
  6624. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6625. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6626. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6627. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6628. return -1;
  6629. } else if (i == 2) {
  6630. if (j < 1) j = 1;
  6631. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6632. j = pos[j - 1];
  6633. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6634. k = j; // swap
  6635. j = LOOK_HEAD_TOP;
  6636. }
  6637. clif_changelook(&sd->bl,j,k);
  6638. return 0;
  6639. }
  6640. /*==========================================
  6641. *Turns on/off Autotrade for a specific player
  6642. *------------------------------------------
  6643. *by durf (changed by Lupus)
  6644. */
  6645. int
  6646. atcommand_autotrade(
  6647. const int fd, struct map_session_data* sd,
  6648. const char* command, const char* message)
  6649. {
  6650. nullpo_retr(-1, sd);
  6651. if (sd->vender_id) //check if player's vending
  6652. {
  6653. sd->state.autotrade = 1;
  6654. clif_authfail_fd(fd, 15);
  6655. }
  6656. else
  6657. {
  6658. //"You should be vending to use @Autotrade."
  6659. clif_displaymessage(fd, msg_txt(549));
  6660. }
  6661. return 0;
  6662. }
  6663. /*==========================================
  6664. * Changes Master of your Guild to a specified guild member
  6665. *------------------------------------------
  6666. *by durf (changed by Lupus)
  6667. */
  6668. int
  6669. atcommand_changegm(
  6670. const int fd, struct map_session_data* sd,
  6671. const char* command, const char* message)
  6672. {
  6673. struct guild *g;
  6674. struct map_session_data *pl_sd;
  6675. nullpo_retr(-1, sd);
  6676. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6677. {
  6678. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6679. return -1;
  6680. }
  6681. if (strlen(message)==0)
  6682. {
  6683. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6684. return -1;
  6685. }
  6686. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6687. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6688. return -1;
  6689. }
  6690. guild_gm_change(sd->status.guild_id, pl_sd);
  6691. return 0;
  6692. }
  6693. /*==========================================
  6694. *Changes the leader of a party.
  6695. *------------------------------------------
  6696. *by Skotlex
  6697. */
  6698. int
  6699. atcommand_changeleader(
  6700. const int fd, struct map_session_data* sd,
  6701. const char* command, const char* message)
  6702. {
  6703. struct party_data *p;
  6704. struct map_session_data *pl_sd;
  6705. int mi, pl_mi;
  6706. nullpo_retr(-1, sd);
  6707. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6708. {
  6709. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6710. return -1;
  6711. }
  6712. for (mi = 0; mi < MAX_PARTY && p->data[mi].sd != sd; mi++);
  6713. if (mi == MAX_PARTY)
  6714. return -1; //Shouldn't happen
  6715. if (!p->party.member[mi].leader)
  6716. {
  6717. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6718. return -1;
  6719. }
  6720. if (strlen(message)==0)
  6721. {
  6722. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6723. return -1;
  6724. }
  6725. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6726. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6727. return -1;
  6728. }
  6729. for (pl_mi = 0; pl_mi < MAX_PARTY && p->data[pl_mi].sd != pl_sd; pl_mi++);
  6730. if (pl_mi == MAX_PARTY)
  6731. return -1; //Shouldn't happen
  6732. //Change leadership.
  6733. p->party.member[mi].leader = 0;
  6734. if (p->data[mi].sd->fd)
  6735. clif_displaymessage(p->data[mi].sd->fd, "Leadership transferred.");
  6736. p->party.member[pl_mi].leader = 1;
  6737. if (p->data[pl_mi].sd->fd)
  6738. clif_displaymessage(p->data[pl_mi].sd->fd, "You've become the party leader.");
  6739. intif_party_leaderchange(p->party.party_id,p->party.member[pl_mi].account_id,p->party.member[pl_mi].char_id);
  6740. //Update info.
  6741. clif_party_main_info(p,-1);
  6742. clif_party_info(p,-1);
  6743. return 0;
  6744. }
  6745. /*==========================================
  6746. *Turns on/off AutoLoot for a specific player
  6747. *------------------------------------------
  6748. *by Upa-Kun
  6749. */
  6750. int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
  6751. {
  6752. // autoloot command with value
  6753. unsigned int rate;
  6754. nullpo_retr(-1, sd);
  6755. // autoloot command without value
  6756. if(!message || !*message)
  6757. {
  6758. // autoloot on -> off
  6759. if(sd->state.autoloot)
  6760. {
  6761. clif_displaymessage(fd, "Autoloot is now off.");
  6762. sd->state.autoloot = 0;
  6763. return 0;
  6764. // autoloot off -> on
  6765. } else {
  6766. clif_displaymessage(fd, "Autoloot is now on.");
  6767. sd->state.autoloot = 10000;
  6768. return 0;
  6769. }
  6770. }
  6771. // autoloot command with value
  6772. //unsigned int rate; // Moved to top due to decleration error after executional block. [Zido]
  6773. // get maximum droprate limit
  6774. rate = atoi(message) * 100;
  6775. // check for invalid value
  6776. if(rate > 10000)
  6777. {
  6778. clif_displaymessage(fd, "Invalid value. Choose value between 0 and 100.");
  6779. return 0;
  6780. }
  6781. // autoloot value is 0, turn autoloot off
  6782. if(rate == 0)
  6783. {
  6784. if(sd->state.autoloot == 0)
  6785. {
  6786. clif_displaymessage(fd, "Autoloot is already off.");
  6787. return 0;
  6788. } else {
  6789. clif_displaymessage(fd, "Autoloot is now off.");
  6790. sd->state.autoloot = 0;
  6791. return 0;
  6792. }
  6793. }
  6794. // autoloot value is 100, turn autoloot on
  6795. if(rate == 10000)
  6796. {
  6797. if(sd->state.autoloot == 10000)
  6798. {
  6799. clif_displaymessage(fd, "Autoloot is already on.");
  6800. return 0;
  6801. } else {
  6802. clif_displaymessage(fd, "Autoloot is now on.");
  6803. sd->state.autoloot = 10000;
  6804. return 0;
  6805. }
  6806. }
  6807. // autoloot value is between 0 and 100
  6808. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %d percent and below.", (rate / 100));
  6809. clif_displaymessage(fd, atcmd_output);
  6810. sd->state.autoloot = rate;
  6811. return 0;
  6812. }
  6813. /*==========================================
  6814. * It is made to rain.
  6815. *------------------------------------------
  6816. */
  6817. int
  6818. atcommand_rain(
  6819. const int fd, struct map_session_data* sd,
  6820. const char* command, const char* message)
  6821. {
  6822. nullpo_retr(-1, sd);
  6823. if (map[sd->bl.m].flag.rain) {
  6824. map[sd->bl.m].flag.rain=0;
  6825. clif_weather(sd->bl.m);
  6826. clif_displaymessage(fd, "The rain has stopped.");
  6827. } else {
  6828. map[sd->bl.m].flag.rain=1;
  6829. clif_weather(sd->bl.m);
  6830. clif_displaymessage(fd, "It is made to rain.");
  6831. }
  6832. return 0;
  6833. }
  6834. /*==========================================
  6835. * It is made to snow.
  6836. *------------------------------------------
  6837. */
  6838. int
  6839. atcommand_snow(
  6840. const int fd, struct map_session_data* sd,
  6841. const char* command, const char* message)
  6842. {
  6843. nullpo_retr(-1, sd);
  6844. if (map[sd->bl.m].flag.snow) {
  6845. map[sd->bl.m].flag.snow=0;
  6846. clif_weather(sd->bl.m);
  6847. clif_displaymessage(fd, "Snow has stopped falling.");
  6848. } else {
  6849. map[sd->bl.m].flag.snow=1;
  6850. clif_weather(sd->bl.m);
  6851. clif_displaymessage(fd, "It is made to snow.");
  6852. }
  6853. return 0;
  6854. }
  6855. /*==========================================
  6856. * Cherry tree snowstorm is made to fall. (Sakura)
  6857. *------------------------------------------
  6858. */
  6859. int
  6860. atcommand_sakura(
  6861. const int fd, struct map_session_data* sd,
  6862. const char* command, const char* message)
  6863. {
  6864. nullpo_retr(-1, sd);
  6865. if (map[sd->bl.m].flag.sakura) {
  6866. map[sd->bl.m].flag.sakura=0;
  6867. clif_weather(sd->bl.m);
  6868. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6869. } else {
  6870. map[sd->bl.m].flag.sakura=1;
  6871. clif_weather(sd->bl.m);
  6872. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6873. }
  6874. return 0;
  6875. }
  6876. /*==========================================
  6877. * Clouds appear.
  6878. *------------------------------------------
  6879. */
  6880. int
  6881. atcommand_clouds(
  6882. const int fd, struct map_session_data* sd,
  6883. const char* command, const char* message)
  6884. {
  6885. nullpo_retr(-1, sd);
  6886. if (map[sd->bl.m].flag.clouds) {
  6887. map[sd->bl.m].flag.clouds=0;
  6888. clif_weather(sd->bl.m);
  6889. clif_displaymessage(fd, "The clouds has disappear.");
  6890. } else {
  6891. map[sd->bl.m].flag.clouds=1;
  6892. clif_weather(sd->bl.m);
  6893. clif_displaymessage(fd, "Clouds appear.");
  6894. }
  6895. return 0;
  6896. }
  6897. /*==========================================
  6898. * Different type of clouds using effect 516
  6899. *------------------------------------------
  6900. */
  6901. int
  6902. atcommand_clouds2(
  6903. const int fd, struct map_session_data* sd,
  6904. const char* command, const char* message)
  6905. {
  6906. nullpo_retr(-1, sd);
  6907. if (map[sd->bl.m].flag.clouds2) {
  6908. map[sd->bl.m].flag.clouds2=0;
  6909. clif_weather(sd->bl.m);
  6910. clif_displaymessage(fd, "The alternative clouds disappear.");
  6911. } else {
  6912. map[sd->bl.m].flag.clouds2=1;
  6913. clif_weather(sd->bl.m);
  6914. clif_displaymessage(fd, "Alternative clouds appear.");
  6915. }
  6916. return 0;
  6917. }
  6918. /*==========================================
  6919. * Fog hangs over.
  6920. *------------------------------------------
  6921. */
  6922. int
  6923. atcommand_fog(
  6924. const int fd, struct map_session_data* sd,
  6925. const char* command, const char* message)
  6926. {
  6927. nullpo_retr(-1, sd);
  6928. if (map[sd->bl.m].flag.fog) {
  6929. map[sd->bl.m].flag.fog=0;
  6930. clif_weather(sd->bl.m);
  6931. clif_displaymessage(fd, "The fog has gone.");
  6932. } else {
  6933. map[sd->bl.m].flag.fog=1;
  6934. clif_weather(sd->bl.m);
  6935. clif_displaymessage(fd, "Fog hangs over.");
  6936. }
  6937. return 0;
  6938. }
  6939. /*==========================================
  6940. * Fallen leaves fall.
  6941. *------------------------------------------
  6942. */
  6943. int
  6944. atcommand_leaves(
  6945. const int fd, struct map_session_data* sd,
  6946. const char* command, const char* message)
  6947. {
  6948. nullpo_retr(-1, sd);
  6949. if (map[sd->bl.m].flag.leaves) {
  6950. map[sd->bl.m].flag.leaves=0;
  6951. clif_weather(sd->bl.m);
  6952. clif_displaymessage(fd, "Leaves no longer fall.");
  6953. } else {
  6954. map[sd->bl.m].flag.leaves=1;
  6955. clif_weather(sd->bl.m);
  6956. clif_displaymessage(fd, "Fallen leaves fall.");
  6957. }
  6958. return 0;
  6959. }
  6960. /*==========================================
  6961. * Fireworks appear.
  6962. *------------------------------------------
  6963. */
  6964. int
  6965. atcommand_fireworks(
  6966. const int fd, struct map_session_data* sd,
  6967. const char* command, const char* message)
  6968. {
  6969. nullpo_retr(-1, sd);
  6970. if (map[sd->bl.m].flag.fireworks) {
  6971. map[sd->bl.m].flag.fireworks=0;
  6972. clif_weather(sd->bl.m);
  6973. clif_displaymessage(fd, "Fireworks are ended.");
  6974. } else {
  6975. map[sd->bl.m].flag.fireworks=1;
  6976. clif_weather(sd->bl.m);
  6977. clif_displaymessage(fd, "Fireworks are launched.");
  6978. }
  6979. return 0;
  6980. }
  6981. /*==========================================
  6982. * Clearing Weather Effects by Dexity
  6983. *------------------------------------------
  6984. */
  6985. int
  6986. atcommand_clearweather(
  6987. const int fd, struct map_session_data* sd,
  6988. const char* command, const char* message)
  6989. {
  6990. nullpo_retr(-1, sd);
  6991. map[sd->bl.m].flag.rain=0;
  6992. map[sd->bl.m].flag.snow=0;
  6993. map[sd->bl.m].flag.sakura=0;
  6994. map[sd->bl.m].flag.clouds=0;
  6995. map[sd->bl.m].flag.clouds2=0;
  6996. map[sd->bl.m].flag.fog=0;
  6997. map[sd->bl.m].flag.fireworks=0;
  6998. map[sd->bl.m].flag.leaves=0;
  6999. clif_weather(sd->bl.m);
  7000. return 0;
  7001. }
  7002. /*===============================================================
  7003. * Sound Command - plays a sound for everyone! [Codemaster]
  7004. *---------------------------------------------------------------
  7005. */
  7006. int
  7007. atcommand_sound(
  7008. const int fd, struct map_session_data *sd,
  7009. const char *command, const char *message)
  7010. {
  7011. char sound_file[100];
  7012. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  7013. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  7014. return -1;
  7015. }
  7016. memset(sound_file, '\0', sizeof(sound_file));
  7017. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7018. return -1;
  7019. if(strstr(sound_file, ".wav") == NULL)
  7020. strcat(sound_file, ".wav");
  7021. clif_soundeffectall(&sd->bl, sound_file,0,2);
  7022. return 0;
  7023. }
  7024. /*==========================================
  7025. * MOB Search
  7026. *------------------------------------------
  7027. */
  7028. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7029. {
  7030. int mob_id,fd;
  7031. static int number=0;
  7032. struct mob_data *md;
  7033. nullpo_retr(0, bl);
  7034. if(!ap){
  7035. number=0;
  7036. return 0;
  7037. }
  7038. mob_id = va_arg(ap,int);
  7039. fd = va_arg(ap,int);
  7040. md = (struct mob_data *)bl;
  7041. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7042. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7043. ++number,bl->x, bl->y,md->name);
  7044. clif_displaymessage(fd, atcmd_output);
  7045. }
  7046. return 0;
  7047. }
  7048. int atcommand_mobsearch(
  7049. const int fd, struct map_session_data* sd,
  7050. const char* command, const char* message)
  7051. {
  7052. char mob_name[100];
  7053. int mob_id,map_id = 0;
  7054. nullpo_retr(-1, sd);
  7055. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7056. return -1;
  7057. if ((mob_id = atoi(mob_name)) == 0)
  7058. mob_id = mobdb_searchname(mob_name);
  7059. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7060. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7061. clif_displaymessage(fd, atcmd_output);
  7062. return 0;
  7063. }
  7064. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7065. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7066. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7067. map_id = sd->bl.m;
  7068. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7069. mob_name, mapindex_id2name(sd->mapindex));
  7070. clif_displaymessage(fd, atcmd_output);
  7071. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7072. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7073. return 0;
  7074. }
  7075. /*==========================================
  7076. * ドロップアイテムの掃除
  7077. *------------------------------------------
  7078. */
  7079. /*==========================================
  7080. * cleanmap
  7081. *------------------------------------------
  7082. */
  7083. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7084. {
  7085. nullpo_retr(0, bl);
  7086. map_clearflooritem(bl->id);
  7087. return 0;
  7088. }
  7089. int
  7090. atcommand_cleanmap(
  7091. const int fd, struct map_session_data* sd,
  7092. const char* command, const char* message)
  7093. {
  7094. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7095. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7096. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7097. BL_ITEM);
  7098. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7099. return 0;
  7100. }
  7101. /*==========================================
  7102. * NPC/PETに話させる
  7103. *------------------------------------------
  7104. */
  7105. int
  7106. atcommand_npctalk(
  7107. const int fd, struct map_session_data* sd,
  7108. const char* command, const char* message)
  7109. {
  7110. char name[NAME_LENGTH],mes[100],temp[100];
  7111. struct npc_data *nd;
  7112. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7113. return -1;
  7114. if (!(nd = npc_name2id(name)))
  7115. return -1;
  7116. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7117. clif_message(&nd->bl, temp);
  7118. return 0;
  7119. }
  7120. int
  7121. atcommand_pettalk(
  7122. const int fd, struct map_session_data* sd,
  7123. const char* command, const char* message)
  7124. {
  7125. char mes[100],temp[100];
  7126. struct pet_data *pd;
  7127. nullpo_retr(-1, sd);
  7128. if(!sd->status.pet_id || !(pd=sd->pd))
  7129. return -1;
  7130. if (sscanf(message, "%99[^\n]", mes) < 1)
  7131. return -1;
  7132. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7133. clif_message(&pd->bl, temp);
  7134. return 0;
  7135. }
  7136. /*==========================================
  7137. * @users
  7138. * サーバー内の人数マップを表示させる
  7139. * 手抜きのため汚くなっているのは仕様です。
  7140. *------------------------------------------
  7141. */
  7142. static struct dbt *users_db = NULL;
  7143. static int users_all;
  7144. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7145. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7146. users_all++;
  7147. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7148. return 0;
  7149. }
  7150. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7151. char buf[256];
  7152. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7153. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7154. clif_displaymessage(sd->fd,buf);
  7155. return 0;
  7156. }
  7157. int
  7158. atcommand_users(
  7159. const int fd, struct map_session_data* sd,
  7160. const char* command, const char* message)
  7161. {
  7162. char buf[256];
  7163. users_all = 0;
  7164. users_db->clear(users_db, NULL);
  7165. clif_foreachclient(atcommand_users_sub1);
  7166. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7167. sprintf(buf,"all : %d",users_all);
  7168. clif_displaymessage(fd,buf);
  7169. return 0;
  7170. }
  7171. /*==========================================
  7172. *
  7173. *------------------------------------------
  7174. */
  7175. int
  7176. atcommand_summon(
  7177. const int fd, struct map_session_data* sd,
  7178. const char* command, const char* message)
  7179. {
  7180. char name[NAME_LENGTH];
  7181. int mob_id = 0;
  7182. int id = 0;
  7183. int duration = 0;
  7184. struct mob_data *md;
  7185. unsigned int tick=gettick();
  7186. nullpo_retr(-1, sd);
  7187. if (!message || !*message)
  7188. return -1;
  7189. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7190. return -1;
  7191. if (duration < 1)
  7192. duration =1;
  7193. else if (duration > 60)
  7194. duration =60;
  7195. if ((mob_id = atoi(name)) == 0)
  7196. mob_id = mobdb_searchname(name);
  7197. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7198. return -1;
  7199. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  7200. if(md){
  7201. md->master_id=sd->bl.id;
  7202. md->special_state.ai=1;
  7203. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7204. clif_misceffect2(&md->bl,344);
  7205. mob_spawn(md);
  7206. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  7207. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  7208. }
  7209. return 0;
  7210. }
  7211. /*==========================================
  7212. * @adjcmdlvl by [MouseJstr]
  7213. *
  7214. * Temp adjust the GM level required to use a GM command
  7215. *
  7216. * Used during beta testing to allow players to use GM commands
  7217. * for short periods of time
  7218. *------------------------------------------
  7219. */
  7220. int
  7221. atcommand_adjcmdlvl(
  7222. const int fd, struct map_session_data* sd,
  7223. const char* command, const char* message)
  7224. {
  7225. int i, newlev;
  7226. char cmd[100];
  7227. nullpo_retr(-1, sd);
  7228. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7229. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7230. return -1;
  7231. }
  7232. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7233. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7234. atcommand_info[i].level = newlev;
  7235. clif_displaymessage(fd, "@command level changed.");
  7236. return 0;
  7237. }
  7238. clif_displaymessage(fd, "@command not found.");
  7239. return -1;
  7240. }
  7241. /*==========================================
  7242. * @adjgmlvl by [MouseJstr]
  7243. *
  7244. * Create a temp GM
  7245. *
  7246. * Used during beta testing to allow players to use GM commands
  7247. * for short periods of time
  7248. *------------------------------------------
  7249. */
  7250. int
  7251. atcommand_adjgmlvl(
  7252. const int fd, struct map_session_data* sd,
  7253. const char* command, const char* message)
  7254. {
  7255. int newlev;
  7256. char user[NAME_LENGTH];
  7257. struct map_session_data *pl_sd;
  7258. nullpo_retr(-1, sd);
  7259. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7260. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7261. return -1;
  7262. }
  7263. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7264. return -1;
  7265. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7266. return 0;
  7267. }
  7268. /*==========================================
  7269. * @trade by [MouseJstr]
  7270. *
  7271. * Open a trade window with a remote player
  7272. *
  7273. * If I have to jump to a remote player one more time, I am
  7274. * gonna scream!
  7275. *------------------------------------------
  7276. */
  7277. int
  7278. atcommand_trade(
  7279. const int fd, struct map_session_data* sd,
  7280. const char* command, const char* message)
  7281. {
  7282. struct map_session_data *pl_sd = NULL;
  7283. nullpo_retr(-1, sd);
  7284. if (!message || !*message)
  7285. return -1;
  7286. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7287. trade_traderequest(sd, pl_sd);
  7288. return 0;
  7289. }
  7290. return -1;
  7291. }
  7292. /*==========================================
  7293. * @setbattleflag by [MouseJstr]
  7294. *
  7295. * set a battle_config flag without having to reboot
  7296. */
  7297. int
  7298. atcommand_setbattleflag(
  7299. const int fd, struct map_session_data* sd,
  7300. const char* command, const char* message)
  7301. {
  7302. char flag[128], value[128];
  7303. nullpo_retr(-1, sd);
  7304. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7305. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7306. return -1;
  7307. }
  7308. if (battle_set_value(flag, value) == 0)
  7309. clif_displaymessage(fd, "unknown battle_config flag");
  7310. else
  7311. clif_displaymessage(fd, "battle_config set as requested");
  7312. return 0;
  7313. }
  7314. /*===========================
  7315. * @unmute [Valaris]
  7316. *===========================
  7317. */
  7318. int atcommand_unmute(
  7319. const int fd, struct map_session_data* sd,
  7320. const char* command, const char* message)
  7321. {
  7322. struct map_session_data *pl_sd = NULL;
  7323. nullpo_retr(-1, sd);
  7324. if(!battle_config.muting_players) {
  7325. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7326. return 0;
  7327. }
  7328. if (!message || !*message)
  7329. return -1;
  7330. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7331. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7332. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7333. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7334. clif_displaymessage(sd->fd,"Player unmuted");
  7335. }
  7336. else
  7337. clif_displaymessage(sd->fd,"Player is not muted");
  7338. }
  7339. return 0;
  7340. }
  7341. /*==========================================
  7342. * @uptime by MC Cameri
  7343. *------------------------------------------
  7344. */
  7345. int
  7346. atcommand_uptime(
  7347. const int fd, struct map_session_data* sd,
  7348. const char* command, const char* message)
  7349. {
  7350. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7351. minute = 60, days = 0, hours = 0, minutes = 0;
  7352. nullpo_retr(-1, sd);
  7353. seconds = get_uptime();
  7354. days = seconds/day;
  7355. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7356. hours = seconds/hour;
  7357. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7358. minutes = seconds/minute;
  7359. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7360. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7361. clif_displaymessage(fd, atcmd_output);
  7362. return 0;
  7363. }
  7364. /*==========================================
  7365. * @changesex <sex>
  7366. * => Changes one's sex. Argument sex can be
  7367. * 0 or 1, m or f, male or female.
  7368. *------------------------------------------
  7369. */
  7370. int
  7371. atcommand_changesex(
  7372. const int fd, struct map_session_data* sd,
  7373. const char* command, const char* message)
  7374. {
  7375. nullpo_retr(-1, sd);
  7376. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7377. return 0;
  7378. }
  7379. /*================================================
  7380. * @mute - Mutes a player for a set amount of time
  7381. *------------------------------------------------
  7382. */
  7383. int atcommand_mute(
  7384. const int fd, struct map_session_data* sd,
  7385. const char* command, const char* message)
  7386. {
  7387. struct map_session_data *pl_sd = NULL;
  7388. int manner;
  7389. nullpo_retr(-1, sd);
  7390. if(!battle_config.muting_players) {
  7391. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7392. return 0;
  7393. }
  7394. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7395. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7396. return -1;
  7397. }
  7398. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7399. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7400. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7401. return -1;
  7402. }
  7403. clif_GM_silence(sd, pl_sd, 0);
  7404. pl_sd->status.manner -= manner;
  7405. if(pl_sd->status.manner < 0)
  7406. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7407. }
  7408. else {
  7409. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7410. return -1;
  7411. }
  7412. return 0;
  7413. }
  7414. /*==========================================
  7415. * @refresh (like @jumpto <<yourself>>)
  7416. *------------------------------------------
  7417. */
  7418. int atcommand_refresh(
  7419. const int fd, struct map_session_data* sd,
  7420. const char* command, const char* message)
  7421. {
  7422. nullpo_retr(-1, sd);
  7423. clif_refresh(sd);
  7424. return 0;
  7425. }
  7426. /*==========================================
  7427. * @petid <part of pet name>
  7428. * => Displays a list of matching pets.
  7429. *------------------------------------------
  7430. */
  7431. int
  7432. atcommand_petid(const int fd, struct map_session_data* sd,
  7433. const char* command, const char* message)
  7434. {
  7435. char searchtext[100];
  7436. char temp0[100];
  7437. char temp1[100];
  7438. int cnt = 0, i = 0;
  7439. nullpo_retr(-1, sd);
  7440. if (!message || !*message)
  7441. return -1;
  7442. if (sscanf(message, "%99s", searchtext) < 1)
  7443. return -1;
  7444. estr_lower(searchtext);
  7445. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7446. clif_displaymessage(fd,temp0);
  7447. while (i < MAX_PET_DB) {
  7448. strcpy(temp1,pet_db[i].name);
  7449. strcpy(temp1, estr_lower(temp1));
  7450. strcpy(temp0,pet_db[i].jname);
  7451. strcpy(temp0, estr_lower(temp1));
  7452. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7453. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7454. pet_db[i].jname);
  7455. if (cnt >= 100) { // Only if there are custom pets
  7456. clif_displaymessage(fd, "Be more specific, can't send more than"
  7457. " 100 results.");
  7458. } else {
  7459. clif_displaymessage(fd, temp0);
  7460. }
  7461. cnt++;
  7462. }
  7463. i++;
  7464. }
  7465. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7466. clif_displaymessage(fd, temp0);
  7467. return 0;
  7468. }
  7469. /*==========================================
  7470. * @identify
  7471. * => GM's magnifier.
  7472. *------------------------------------------
  7473. */
  7474. int
  7475. atcommand_identify(
  7476. const int fd, struct map_session_data* sd,
  7477. const char* command, const char* message)
  7478. {
  7479. int i,num;
  7480. nullpo_retr(-1, sd);
  7481. for(i=num=0;i<MAX_INVENTORY;i++){
  7482. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7483. num++;
  7484. }
  7485. }
  7486. if (num > 0) {
  7487. clif_item_identify_list(sd);
  7488. } else {
  7489. clif_displaymessage(fd,"There are no items to appraise.");
  7490. }
  7491. return 0;
  7492. }
  7493. /*==========================================
  7494. * @gmotd (Global MOTD)
  7495. * by davidsiaw :P
  7496. *------------------------------------------
  7497. */
  7498. int
  7499. atcommand_gmotd(
  7500. const int fd, struct map_session_data* sd,
  7501. const char* command, const char* message)
  7502. {
  7503. char buf[256];
  7504. FILE *fp;
  7505. nullpo_retr(-1, sd);
  7506. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7507. while (fgets(buf, 250, fp) != NULL){
  7508. int i;
  7509. for( i=0; buf[i]; i++){
  7510. if( buf[i]=='\r' || buf[i]=='\n'){
  7511. buf[i]=0;
  7512. break;
  7513. }
  7514. }
  7515. intif_GMmessage(buf,strlen(buf)+1,8);
  7516. }
  7517. fclose(fp);
  7518. }
  7519. return 0;
  7520. }
  7521. int atcommand_misceffect(
  7522. const int fd, struct map_session_data* sd,
  7523. const char* command, const char* message)
  7524. {
  7525. int effect = 0;
  7526. nullpo_retr(-1, sd);
  7527. if (!message || !*message)
  7528. return -1;
  7529. if (sscanf(message, "%d", &effect) < 1)
  7530. return -1;
  7531. clif_misceffect(&sd->bl,effect);
  7532. return 0;
  7533. }
  7534. int charid2sessionid(int charid)
  7535. {
  7536. struct map_session_data *pl_sd = NULL;
  7537. pl_sd = map_charid2sd(charid);
  7538. if (pl_sd) return pl_sd->fd;
  7539. return 0;
  7540. }
  7541. int accountid2sessionid(int accountid)
  7542. {
  7543. struct map_session_data *pl_sd = NULL;
  7544. pl_sd = map_id2sd(accountid);
  7545. if (pl_sd) return pl_sd->fd;
  7546. return 0;
  7547. }
  7548. /*==========================================
  7549. * Jump to a player by PID number
  7550. * Original by Dino9021
  7551. * Added in by nsstrunks
  7552. *------------------------------------------
  7553. */
  7554. int atcommand_jumptoid(
  7555. const int fd, struct map_session_data* sd,
  7556. const char* command, const char* message)
  7557. {
  7558. int cid=0;
  7559. int session_id=0;
  7560. struct map_session_data *pl_sd;
  7561. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7562. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7563. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7564. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7565. return -1;
  7566. }
  7567. cid=atoi(message);
  7568. if ((session_id=charid2sessionid(cid))!=0)
  7569. {
  7570. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7571. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7572. clif_displaymessage(fd, msg_table[247]);
  7573. return -1;
  7574. }
  7575. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7576. clif_displaymessage(fd, msg_table[248]);
  7577. return -1;
  7578. }
  7579. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7580. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7581. clif_displaymessage(fd, atcmd_output);
  7582. } else {
  7583. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7584. return -1;
  7585. }
  7586. }
  7587. else
  7588. {
  7589. clif_displaymessage(fd,msg_table[3]);
  7590. }
  7591. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7592. return 0;
  7593. }
  7594. /*==========================================
  7595. * Jump to a player by PID number
  7596. * Original by Dino9021
  7597. * Added in by nsstrunks
  7598. *------------------------------------------
  7599. */
  7600. int atcommand_jumptoid2(
  7601. const int fd, struct map_session_data* sd,
  7602. const char* command, const char* message)
  7603. {
  7604. int aid=0;
  7605. int session_id=0;
  7606. struct map_session_data *pl_sd;
  7607. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7608. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7609. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7610. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7611. return -1;
  7612. }
  7613. aid=atoi(message);
  7614. if ((session_id=accountid2sessionid(aid))!=0)
  7615. {
  7616. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7617. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7618. clif_displaymessage(fd, msg_table[247]);
  7619. return -1;
  7620. }
  7621. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7622. clif_displaymessage(fd, msg_table[248]);
  7623. return -1;
  7624. }
  7625. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7626. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7627. clif_displaymessage(fd, atcmd_output);
  7628. } else {
  7629. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7630. return -1;
  7631. }
  7632. }
  7633. else
  7634. {
  7635. clif_displaymessage(fd,msg_table[3]);
  7636. }
  7637. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7638. return 0;
  7639. }
  7640. /*==========================================
  7641. * Recall a player by PID number
  7642. * Original by Dino9021
  7643. * Added in by nsstrunks
  7644. *------------------------------------------
  7645. */
  7646. int atcommand_recallid(
  7647. const int fd, struct map_session_data* sd,
  7648. const char* command, const char* message)
  7649. {
  7650. int cid=0;
  7651. int session_id=0;
  7652. struct map_session_data *pl_sd;
  7653. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7654. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7655. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7656. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7657. return -1;
  7658. }
  7659. cid=atoi(message);
  7660. if ((session_id=charid2sessionid(cid))!=0)
  7661. {
  7662. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7663. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7664. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7665. clif_displaymessage(fd, msg_table[247]);
  7666. return -1;
  7667. }
  7668. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7669. clif_displaymessage(fd, msg_table[248]);
  7670. return -1;
  7671. }
  7672. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7673. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7674. clif_displaymessage(fd, atcmd_output);
  7675. } else {
  7676. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7677. return -1;
  7678. }
  7679. } else {
  7680. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7681. return -1;
  7682. }
  7683. }
  7684. else
  7685. {
  7686. clif_displaymessage(fd,msg_table[3]);
  7687. }
  7688. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7689. return 0;
  7690. }
  7691. /*==========================================
  7692. * Recall a player by PID number
  7693. * Original by Dino9021
  7694. * Added in by nsstrunks
  7695. *------------------------------------------
  7696. */
  7697. int atcommand_recallid2(
  7698. const int fd, struct map_session_data* sd,
  7699. const char* command, const char* message)
  7700. {
  7701. int aid=0;
  7702. int session_id=0;
  7703. struct map_session_data *pl_sd;
  7704. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7705. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7706. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7707. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7708. return -1;
  7709. }
  7710. aid=atoi(message);
  7711. if ((session_id=accountid2sessionid(aid))!=0)
  7712. {
  7713. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7714. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7715. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7716. clif_displaymessage(fd, msg_table[247]);
  7717. return -1;
  7718. }
  7719. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7720. clif_displaymessage(fd, msg_table[248]);
  7721. return -1;
  7722. }
  7723. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7724. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7725. clif_displaymessage(fd, atcmd_output);
  7726. } else {
  7727. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7728. return -1;
  7729. }
  7730. } else {
  7731. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7732. return -1;
  7733. }
  7734. }
  7735. else
  7736. {
  7737. clif_displaymessage(fd,msg_table[3]);
  7738. }
  7739. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7740. return 0;
  7741. }
  7742. /*==========================================
  7743. * Kick a player by PID number
  7744. * Original by Dino9021
  7745. * Added in by nsstrunks
  7746. *------------------------------------------
  7747. */
  7748. int atcommand_kickid(
  7749. const int fd, struct map_session_data* sd,
  7750. const char* command, const char* message)
  7751. {
  7752. struct map_session_data *pl_sd;
  7753. int cid=0;
  7754. int session_id=0;
  7755. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7756. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7757. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7758. return -1;
  7759. }
  7760. cid=atoi(message);
  7761. if ((session_id=charid2sessionid(cid))!=0)
  7762. {
  7763. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7764. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7765. clif_GM_kick(sd, pl_sd, 1);
  7766. else {
  7767. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7768. return -1;
  7769. }
  7770. } else {
  7771. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7772. return -1;
  7773. }
  7774. }
  7775. else
  7776. {
  7777. clif_displaymessage(fd,msg_table[3]);
  7778. }
  7779. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7780. return 0;
  7781. }
  7782. /*==========================================
  7783. * Kick a player by PID number
  7784. * Original by Dino9021
  7785. * Added in by nsstrunks
  7786. *------------------------------------------
  7787. */
  7788. int atcommand_kickid2(
  7789. const int fd, struct map_session_data* sd,
  7790. const char* command, const char* message)
  7791. {
  7792. struct map_session_data *pl_sd;
  7793. int aid=0;
  7794. int session_id=0;
  7795. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7796. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7797. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7798. return -1;
  7799. }
  7800. aid=atoi(message);
  7801. if ((session_id=accountid2sessionid(aid))!=0)
  7802. {
  7803. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7804. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7805. clif_GM_kick(sd, pl_sd, 1);
  7806. else {
  7807. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7808. return -1;
  7809. }
  7810. } else {
  7811. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7812. return -1;
  7813. }
  7814. }
  7815. else
  7816. {
  7817. clif_displaymessage(fd,msg_table[3]);
  7818. }
  7819. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7820. return 0;
  7821. }
  7822. /*==========================================
  7823. * Revive a player by PID number
  7824. * Original by Dino9021
  7825. * Added in by nsstrunks
  7826. *------------------------------------------
  7827. */
  7828. int atcommand_reviveid(
  7829. const int fd, struct map_session_data* sd,
  7830. const char* command, const char* message)
  7831. {
  7832. int cid=0;
  7833. int session_id=0;
  7834. struct map_session_data *pl_sd;
  7835. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7836. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7837. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7838. return -1;
  7839. }
  7840. cid=atoi(message);
  7841. if ((session_id=charid2sessionid(cid))!=0)
  7842. {
  7843. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7844. pl_sd->status.hp = pl_sd->status.max_hp;
  7845. pc_setstand(pl_sd);
  7846. if (battle_config.pc_invincible_time > 0)
  7847. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7848. clif_updatestatus(pl_sd, SP_HP);
  7849. clif_updatestatus(pl_sd, SP_SP);
  7850. clif_resurrection(&pl_sd->bl, 1);
  7851. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7852. } else {
  7853. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7854. return -1;
  7855. }
  7856. }
  7857. else
  7858. {
  7859. clif_displaymessage(fd,msg_table[3]);
  7860. }
  7861. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7862. return 0;
  7863. }
  7864. /*==========================================
  7865. * Revive a player by PID number
  7866. * Original by Dino9021
  7867. * Added in by nsstrunks
  7868. *------------------------------------------
  7869. */
  7870. int atcommand_reviveid2(
  7871. const int fd, struct map_session_data* sd,
  7872. const char* command, const char* message)
  7873. {
  7874. int aid=0;
  7875. int session_id=0;
  7876. struct map_session_data *pl_sd;
  7877. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7878. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7879. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7880. return -1;
  7881. }
  7882. aid=atoi(message);
  7883. if ((session_id=accountid2sessionid(aid))!=0)
  7884. {
  7885. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7886. pl_sd->status.hp = pl_sd->status.max_hp;
  7887. pc_setstand(pl_sd);
  7888. if (battle_config.pc_invincible_time > 0)
  7889. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7890. clif_updatestatus(pl_sd, SP_HP);
  7891. clif_updatestatus(pl_sd, SP_SP);
  7892. clif_resurrection(&pl_sd->bl, 1);
  7893. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7894. } else {
  7895. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7896. return -1;
  7897. }
  7898. }
  7899. else
  7900. {
  7901. clif_displaymessage(fd,msg_table[3]);
  7902. }
  7903. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7904. return 0;
  7905. }
  7906. /*==========================================
  7907. * Kill a player by PID number
  7908. * Original by Dino9021
  7909. * Added in by nsstrunks
  7910. *------------------------------------------
  7911. */
  7912. int atcommand_killid(
  7913. const int fd, struct map_session_data* sd,
  7914. const char* command, const char* message)
  7915. {
  7916. int cid=0;
  7917. int session_id=0;
  7918. struct map_session_data *pl_sd;
  7919. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7920. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7921. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7922. return -1;
  7923. }
  7924. cid=atoi(message);
  7925. if ((session_id=charid2sessionid(cid))!=0)
  7926. {
  7927. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7928. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7929. status_kill(&pl_sd->bl);
  7930. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7931. } else {
  7932. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7933. return -1;
  7934. }
  7935. } else {
  7936. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7937. return -1;
  7938. }
  7939. }
  7940. else
  7941. {
  7942. clif_displaymessage(fd,msg_table[3]);
  7943. }
  7944. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7945. return 0;
  7946. }
  7947. /*==========================================
  7948. * Kill a player by PID number
  7949. * Original by Dino9021
  7950. * Added in by nsstrunks
  7951. *------------------------------------------
  7952. */
  7953. int atcommand_killid2(
  7954. const int fd, struct map_session_data* sd,
  7955. const char* command, const char* message)
  7956. {
  7957. int aid=0;
  7958. int session_id=0;
  7959. struct map_session_data *pl_sd;
  7960. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7961. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7962. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7963. return -1;
  7964. }
  7965. aid=atoi(message);
  7966. if ((session_id=accountid2sessionid(aid))!=0)
  7967. {
  7968. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7969. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7970. status_kill(&pl_sd->bl);
  7971. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7972. } else {
  7973. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7974. return -1;
  7975. }
  7976. } else {
  7977. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7978. return -1;
  7979. }
  7980. }
  7981. else
  7982. {
  7983. clif_displaymessage(fd,msg_table[3]);
  7984. }
  7985. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7986. return 0;
  7987. }
  7988. /*==========================================
  7989. * Make a player killable, by PID
  7990. * Original by Dino9021
  7991. * Added in by nsstrunks
  7992. *------------------------------------------
  7993. */
  7994. int
  7995. atcommand_charkillableid(
  7996. const int fd, struct map_session_data* sd,
  7997. const char* command, const char* message)
  7998. {
  7999. struct map_session_data *pl_sd = NULL;
  8000. int cid=0;
  8001. int session_id=0;
  8002. if (!message || (cid = atoi(message)) == 0 || !*message)
  8003. return -1;
  8004. cid=atoi(message);
  8005. if ((session_id=charid2sessionid(cid))!=0)
  8006. {
  8007. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8008. return -1;
  8009. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8010. if(pl_sd->special_state.killable)
  8011. clif_displaymessage(fd, "The player is now killable");
  8012. else
  8013. clif_displaymessage(fd, "The player is no longer killable");
  8014. }
  8015. else
  8016. {
  8017. clif_displaymessage(fd,msg_table[3]);
  8018. }
  8019. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8020. return 0;
  8021. }
  8022. /*==========================================
  8023. * Make a player killable, by PID
  8024. * Original by Dino9021
  8025. * Added in by nsstrunks
  8026. *------------------------------------------
  8027. */
  8028. int
  8029. atcommand_charkillableid2(
  8030. const int fd, struct map_session_data* sd,
  8031. const char* command, const char* message)
  8032. {
  8033. struct map_session_data *pl_sd = NULL;
  8034. int aid=0;
  8035. int session_id=0;
  8036. if (!message || (aid = atoi(message)) == 0 || !*message)
  8037. return -1;
  8038. aid=atoi(message);
  8039. if ((session_id=accountid2sessionid(aid))!=0)
  8040. {
  8041. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8042. return -1;
  8043. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8044. if(pl_sd->special_state.killable)
  8045. clif_displaymessage(fd, "The player is now killable");
  8046. else
  8047. clif_displaymessage(fd, "The player is no longer killable");
  8048. }
  8049. else
  8050. {
  8051. clif_displaymessage(fd,msg_table[3]);
  8052. }
  8053. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8054. return 0;
  8055. }
  8056. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8057. /*==========================================
  8058. * Mail System commands by [Valaris]
  8059. *------------------------------------------
  8060. */
  8061. int atcommand_listmail(
  8062. const int fd, struct map_session_data* sd,
  8063. const char* command, const char* message)
  8064. {
  8065. if(!mail_server_enable)
  8066. return 0;
  8067. nullpo_retr(-1, sd);
  8068. if(strlen(command)==12)
  8069. mail_check(sd,3);
  8070. else if(strlen(command)==9)
  8071. mail_check(sd,2);
  8072. else
  8073. mail_check(sd,1);
  8074. return 0;
  8075. }
  8076. int atcommand_readmail(
  8077. const int fd, struct map_session_data* sd,
  8078. const char* command, const char* message)
  8079. {
  8080. int index;
  8081. if(!mail_server_enable)
  8082. return 0;
  8083. nullpo_retr(-1, sd);
  8084. if (!message || !*message) {
  8085. clif_displaymessage(sd->fd,"You must specify a message number.");
  8086. return 0;
  8087. }
  8088. index = atoi(message);
  8089. if (index < 1) {
  8090. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8091. return 0;
  8092. }
  8093. if(strlen(command)==11)
  8094. mail_delete(sd,index);
  8095. else
  8096. mail_read(sd,index);
  8097. return 0;
  8098. }
  8099. int atcommand_sendmail(
  8100. const int fd, struct map_session_data* sd,
  8101. const char* command, const char* message)
  8102. {
  8103. char name[NAME_LENGTH],text[80];
  8104. if(!mail_server_enable)
  8105. return 0;
  8106. nullpo_retr(-1, sd);
  8107. if (!message || !*message) {
  8108. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8109. return 0;
  8110. }
  8111. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8112. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8113. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8114. return 0;
  8115. }
  8116. if(strlen(command)==17)
  8117. mail_send(sd,name,text,1);
  8118. else
  8119. mail_send(sd,name,text,0);
  8120. return 0;
  8121. }
  8122. /*==========================================
  8123. * Refresh online command for SQL [Valaris]
  8124. * Will refresh and check online column of
  8125. * players and set correctly.
  8126. *------------------------------------------
  8127. */
  8128. int atcommand_refreshonline(
  8129. const int fd, struct map_session_data* sd,
  8130. const char* command, const char* message)
  8131. {
  8132. send_users_tochar(-1, gettick(), 0, 0);
  8133. return 0;
  8134. }
  8135. #endif /* end sql only */
  8136. /*==========================================
  8137. * Show Monster DB Info v 1.0
  8138. * originally by [Lupus] eAthena
  8139. *------------------------------------------
  8140. */
  8141. int atcommand_mobinfo(
  8142. const int fd, struct map_session_data* sd,
  8143. const char* command, const char* message)
  8144. {
  8145. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8146. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8147. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8148. char atcmd_output2[200];
  8149. struct item_data *item_data;
  8150. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8151. int mob_id, count;
  8152. int i, j, k;
  8153. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8154. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8155. if (!message || !*message) {
  8156. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8157. return -1;
  8158. }
  8159. // If monster identifier/name argument is a name
  8160. if ((mob_id = mobdb_checkid(atoi(message))))
  8161. {
  8162. mob_array[0] = mob_db(mob_id);
  8163. count = 1;
  8164. } else
  8165. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8166. if (!count) {
  8167. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8168. return -1;
  8169. }
  8170. if (count > MAX_SEARCH) {
  8171. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8172. clif_displaymessage(fd, atcmd_output);
  8173. count = MAX_SEARCH;
  8174. }
  8175. for (k = 0; k < count; k++) {
  8176. mob = mob_array[k];
  8177. // stats
  8178. if (mob->mexp)
  8179. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob_id);
  8180. else
  8181. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob_id);
  8182. clif_displaymessage(fd, atcmd_output);
  8183. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  8184. clif_displaymessage(fd, atcmd_output);
  8185. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  8186. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  8187. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  8188. clif_displaymessage(fd, atcmd_output);
  8189. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  8190. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  8191. mob->range2 , mob->range3, msize[mob->status.size],
  8192. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  8193. clif_displaymessage(fd, atcmd_output);
  8194. // drops
  8195. clif_displaymessage(fd, " Drops:");
  8196. strcpy(atcmd_output, " ");
  8197. j = 0;
  8198. for (i = 0; i < MAX_MOB_DROP; i++) {
  8199. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8200. continue;
  8201. if (mob->dropitem[i].p > 0) {
  8202. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  8203. strcat(atcmd_output, atcmd_output2);
  8204. if (++j % 3 == 0) {
  8205. clif_displaymessage(fd, atcmd_output);
  8206. strcpy(atcmd_output, " ");
  8207. }
  8208. }
  8209. }
  8210. if (j == 0)
  8211. clif_displaymessage(fd, "This monster has no drops.");
  8212. else if (j % 3 != 0)
  8213. clif_displaymessage(fd, atcmd_output);
  8214. // mvp
  8215. if (mob->mexp) {
  8216. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8217. clif_displaymessage(fd, atcmd_output);
  8218. strcpy(atcmd_output, " MVP Items:");
  8219. j = 0;
  8220. for (i = 0; i < 3; i++) {
  8221. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8222. continue;
  8223. if (mob->mvpitem[i].p > 0) {
  8224. j++;
  8225. if (j == 1)
  8226. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8227. else
  8228. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8229. strcat(atcmd_output, atcmd_output2);
  8230. }
  8231. }
  8232. if (j == 0)
  8233. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8234. else
  8235. clif_displaymessage(fd, atcmd_output);
  8236. }
  8237. }
  8238. return 0;
  8239. }
  8240. /*==========================================
  8241. * Show Items DB Info v 1.0
  8242. * originally by [Lupus] eAthena
  8243. *------------------------------------------
  8244. */
  8245. int atcommand_iteminfo(
  8246. const int fd, struct map_session_data* sd,
  8247. const char* command, const char* message)
  8248. {
  8249. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8250. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8251. struct item_data *item_data, *item_array[MAX_SEARCH];
  8252. int i, count = 1;
  8253. if (!message || !*message) {
  8254. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8255. return -1;
  8256. }
  8257. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8258. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8259. if (!count) {
  8260. clif_displaymessage(fd, "Item not found.");
  8261. return -1;
  8262. }
  8263. if (count > MAX_SEARCH) {
  8264. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8265. clif_displaymessage(fd, atcmd_output);
  8266. count = MAX_SEARCH;
  8267. }
  8268. for (i = 0; i < count; i++) {
  8269. item_data = item_array[i];
  8270. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8271. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  8272. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8273. (item_data->script==NULL)? "None" : "With script"
  8274. );
  8275. clif_displaymessage(fd, atcmd_output);
  8276. 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. );
  8277. clif_displaymessage(fd, atcmd_output);
  8278. if (item_data->maxchance == 10000)
  8279. strcpy(atcmd_output, " - Available in the shops only");
  8280. else if (item_data->maxchance)
  8281. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8282. else
  8283. strcpy(atcmd_output, " - Monsters don't drop this item");
  8284. clif_displaymessage(fd, atcmd_output);
  8285. }
  8286. return 0;
  8287. }
  8288. /*==========================================
  8289. * Show who drops the item.
  8290. *------------------------------------------
  8291. */
  8292. int atcommand_whodrops(
  8293. const int fd, struct map_session_data* sd,
  8294. const char* command, const char* message)
  8295. {
  8296. struct item_data *item_data, *item_array[MAX_SEARCH];
  8297. int i,j, count = 1;
  8298. if (!message || !*message) {
  8299. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8300. return -1;
  8301. }
  8302. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8303. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8304. if (!count) {
  8305. clif_displaymessage(fd, "Item not found.");
  8306. return -1;
  8307. }
  8308. if (count > MAX_SEARCH) {
  8309. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8310. clif_displaymessage(fd, atcmd_output);
  8311. count = MAX_SEARCH;
  8312. }
  8313. for (i = 0; i < count; i++) {
  8314. item_data = item_array[i];
  8315. sprintf(atcmd_output, "Item: '%s'[%d]",
  8316. item_data->jname,item_data->slot);
  8317. clif_displaymessage(fd, atcmd_output);
  8318. if (item_data->mob[0].chance == 0) {
  8319. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8320. clif_displaymessage(fd, atcmd_output);
  8321. } else {
  8322. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8323. clif_displaymessage(fd, atcmd_output);
  8324. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8325. {
  8326. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8327. clif_displaymessage(fd, atcmd_output);
  8328. }
  8329. }
  8330. }
  8331. return 0;
  8332. }
  8333. /*==========================================
  8334. * @adopt by [Veider]
  8335. *
  8336. * adopt a novice
  8337. *------------------------------------------
  8338. */
  8339. int
  8340. atcommand_adopt(const int fd, struct map_session_data* sd,
  8341. const char* command, const char* message)
  8342. {
  8343. struct map_session_data *pl_sd1 = NULL;
  8344. struct map_session_data *pl_sd2 = NULL;
  8345. struct map_session_data *pl_sd3 = NULL;
  8346. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8347. nullpo_retr(-1, sd);
  8348. if (!message || !*message)
  8349. return -1;
  8350. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8351. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8352. return -1;
  8353. }
  8354. if (battle_config.etc_log)
  8355. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8356. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8357. sprintf(player2, "Cannot find player %s online", player1);
  8358. clif_displaymessage(fd, player2);
  8359. return -1;
  8360. }
  8361. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8362. sprintf(player1, "Cannot find player %s online", player2);
  8363. clif_displaymessage(fd, player1);
  8364. return -1;
  8365. }
  8366. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8367. sprintf(player1, "Cannot find player %s online", player3);
  8368. clif_displaymessage(fd, player1);
  8369. return -1;
  8370. }
  8371. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8372. clif_displaymessage(fd, "They are too young to be parents!");
  8373. return -1;
  8374. }
  8375. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8376. clif_displaymessage(fd, "They are family.. wish them luck");
  8377. return 0;
  8378. }
  8379. else
  8380. return -1;
  8381. }
  8382. int atcommand_version(
  8383. const int fd, struct map_session_data* sd,
  8384. const char* command, const char* message)
  8385. {
  8386. const char * revision;
  8387. if ((revision = get_svn_revision()) != 0) {
  8388. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8389. clif_displaymessage(fd,atcmd_output);
  8390. } else
  8391. clif_displaymessage(fd,"Cannot determine SVN revision");
  8392. return 0;
  8393. }
  8394. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8395. {
  8396. int time, id;
  8397. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8398. if (pl_sd == NULL)
  8399. return 0;
  8400. id = va_arg(ap, int);
  8401. time = va_arg(ap, int);
  8402. if (id != bl->id && !pc_isGM(pl_sd)) {
  8403. pl_sd->status.manner -= time;
  8404. if (pl_sd->status.manner < 0)
  8405. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8406. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8407. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8408. }
  8409. return 0;
  8410. }
  8411. /*==========================================
  8412. * @mutearea by MouseJstr
  8413. *------------------------------------------
  8414. */
  8415. int atcommand_mutearea(
  8416. const int fd, struct map_session_data* sd,
  8417. const char* command, const char* message)
  8418. {
  8419. int time;
  8420. nullpo_retr(0, sd);
  8421. if(!battle_config.muting_players) {
  8422. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8423. return 0;
  8424. }
  8425. time = atoi(message);
  8426. if (!time)
  8427. time = 15; // 15 minutes default
  8428. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8429. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8430. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8431. return 0;
  8432. }
  8433. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8434. {
  8435. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8436. if (bl == NULL)
  8437. return 0;
  8438. if (!pc_isGM(pl_sd))
  8439. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8440. return 0;
  8441. }
  8442. /*==========================================
  8443. * @shuffle by MouseJstr
  8444. *------------------------------------------
  8445. */
  8446. int atcommand_shuffle(
  8447. const int fd, struct map_session_data* sd,
  8448. const char* command, const char* message)
  8449. {
  8450. nullpo_retr(0, sd);
  8451. if (strcmp(message, "area")== 0) {
  8452. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8453. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8454. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8455. } else if (strcmp(message, "map")== 0) {
  8456. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8457. } else if (strcmp(message, "world") == 0) {
  8458. struct map_session_data **pl_allsd;
  8459. int i, users;
  8460. pl_allsd = map_getallusers(&users);
  8461. for (i = 0; i < users; i++)
  8462. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8463. } else
  8464. clif_displaymessage(fd, "options are area, map, or world");
  8465. return 0;
  8466. }
  8467. int atcommand_rates(
  8468. const int fd, struct map_session_data* sd,
  8469. const char* command, const char* message)
  8470. {
  8471. char buf[255];
  8472. nullpo_retr(0, sd);
  8473. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8474. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8475. clif_displaymessage(fd, buf);
  8476. return 0;
  8477. }
  8478. /*==========================================
  8479. * @me by lordalfa
  8480. * => Displays the OUTPUT string on top of
  8481. * the Visible players Heads.
  8482. *------------------------------------------
  8483. */
  8484. int atcommand_me(
  8485. const int fd, struct map_session_data* sd,
  8486. const char* command, const char* message)
  8487. {
  8488. char tempmes[200];
  8489. nullpo_retr(-1, sd);
  8490. memset(tempmes, '\0', sizeof(tempmes));
  8491. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8492. if (!message || !*message) {
  8493. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8494. return -1;
  8495. }
  8496. sscanf(message, "%199[^\n]", tempmes);
  8497. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8498. clif_disp_overhead(sd, atcmd_output);
  8499. return 0;
  8500. }
  8501. /*==========================================
  8502. * @size
  8503. * => Resize your character sprite. [Valaris]
  8504. *------------------------------------------
  8505. */
  8506. int atcommand_size(
  8507. const int fd, struct map_session_data* sd,
  8508. const char* command, const char* message)
  8509. {
  8510. int size=0;
  8511. nullpo_retr(-1, sd);
  8512. if (!message || !*message)
  8513. return -1;
  8514. if (sscanf(message,"%d", &size) < 1)
  8515. return -1;
  8516. if(sd->state.size) {
  8517. sd->state.size=0;
  8518. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8519. }
  8520. if(size==1) {
  8521. sd->state.size=1;
  8522. clif_specialeffect(&sd->bl,420,AREA);
  8523. } else if(size==2) {
  8524. sd->state.size=2;
  8525. clif_specialeffect(&sd->bl,422,AREA);
  8526. }
  8527. return 0;
  8528. }
  8529. /*==========================================
  8530. * @monsterignore
  8531. * => Makes monsters ignore you. [Valaris]
  8532. *------------------------------------------
  8533. */
  8534. int atcommand_monsterignore(
  8535. const int fd, struct map_session_data* sd,
  8536. const char* command, const char* message)
  8537. {
  8538. nullpo_retr(-1, sd);
  8539. if (!sd->state.monster_ignore) {
  8540. sd->state.monster_ignore = 1;
  8541. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8542. } else {
  8543. sd->state.monster_ignore = 0;
  8544. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8545. }
  8546. return 0;
  8547. }
  8548. /*==========================================
  8549. * @fakename
  8550. * => Gives your character a fake name. [Valaris]
  8551. *------------------------------------------
  8552. */
  8553. int atcommand_fakename(
  8554. const int fd, struct map_session_data* sd,
  8555. const char* command, const char* message)
  8556. {
  8557. char name[NAME_LENGTH];
  8558. nullpo_retr(-1, sd);
  8559. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8560. sd->fakename[0]='\0';
  8561. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8562. clif_displaymessage(sd->fd,"Returned to real name.");
  8563. return 0;
  8564. }
  8565. if (!message || !*message) {
  8566. clif_displaymessage(sd->fd,"You must enter a name.");
  8567. return 0;
  8568. }
  8569. if (sscanf(message, "%23[^\n]", name) < 1) {
  8570. return 0;
  8571. }
  8572. if(strlen(name) < 2) {
  8573. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8574. return 0;
  8575. }
  8576. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8577. clif_charnameack(0, &sd->bl);
  8578. clif_displaymessage(sd->fd,"Fake name enabled.");
  8579. return 0;
  8580. }
  8581. /*==========================================
  8582. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8583. * => Shows information about the map flags [map name]
  8584. * Also set flags
  8585. *------------------------------------------
  8586. */
  8587. int atcommand_mapflag(
  8588. const int fd, struct map_session_data* sd,
  8589. const char* command, const char* message)
  8590. {
  8591. // WIP
  8592. return 0;
  8593. }
  8594. /*===================================
  8595. * Remove some messages
  8596. *-----------------------------------
  8597. */
  8598. int atcommand_showexp(
  8599. const int fd, struct map_session_data* sd,
  8600. const char* command, const char* message)
  8601. {
  8602. if (sd->state.showexp) {
  8603. sd->state.showexp = 0;
  8604. clif_displaymessage(fd, "Gained exp will not be shown.");
  8605. return 0;
  8606. }
  8607. sd->state.showexp = 1;
  8608. clif_displaymessage(fd, "Gained exp is now shown");
  8609. return 0;
  8610. }
  8611. int atcommand_showzeny(
  8612. const int fd, struct map_session_data* sd,
  8613. const char* command, const char* message)
  8614. {
  8615. if (sd->state.showzeny) {
  8616. sd->state.showzeny = 0;
  8617. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8618. return 0;
  8619. }
  8620. sd->state.showzeny = 1;
  8621. clif_displaymessage(fd, "Gained zeny is now shown");
  8622. return 0;
  8623. }
  8624. int atcommand_showdelay(
  8625. const int fd, struct map_session_data* sd,
  8626. const char* command, const char* message)
  8627. {
  8628. if (sd->state.showdelay) {
  8629. sd->state.showdelay = 0;
  8630. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8631. return 0;
  8632. }
  8633. sd->state.showdelay = 1;
  8634. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8635. return 0;
  8636. }
  8637. /*==========================================
  8638. * Duel organizing functions [LuzZza]
  8639. *
  8640. * @duel [limit|nick] - create a duel
  8641. * @invite <nick> - invite player
  8642. * @accept - accept invitation
  8643. * @reject - reject invitation
  8644. * @leave - leave duel
  8645. *------------------------------------------
  8646. */
  8647. int atcommand_invite(
  8648. const int fd, struct map_session_data* sd,
  8649. const char* command, const char* message)
  8650. {
  8651. unsigned int did = sd->duel_group;
  8652. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8653. if(did <= 0) {
  8654. // "Duel: @invite without @duel."
  8655. clif_displaymessage(fd, msg_txt(350));
  8656. return 0;
  8657. }
  8658. if(duel_list[did].max_players_limit > 0 &&
  8659. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8660. // "Duel: Limit of players is reached."
  8661. clif_displaymessage(fd, msg_txt(351));
  8662. return 0;
  8663. }
  8664. if(target_sd == NULL) {
  8665. // "Duel: Player not found."
  8666. clif_displaymessage(fd, msg_txt(352));
  8667. return 0;
  8668. }
  8669. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8670. // "Duel: Player already in duel."
  8671. clif_displaymessage(fd, msg_txt(353));
  8672. return 0;
  8673. }
  8674. duel_invite(did, sd, target_sd);
  8675. // "Duel: Invitation has been sent."
  8676. clif_displaymessage(fd, msg_txt(354));
  8677. return 0;
  8678. }
  8679. int atcommand_duel(
  8680. const int fd, struct map_session_data* sd,
  8681. const char* command, const char* message)
  8682. {
  8683. char output[256];
  8684. unsigned int maxpl=0, newduel;
  8685. struct map_session_data *target_sd;
  8686. /* // Commnted because it can be disabled in at-comms conf.
  8687. if(!battle_config.duel_enable) {
  8688. clif_displaymessage(fd, "Duel: duel is disable.");
  8689. return 0;
  8690. }
  8691. */
  8692. if(sd->duel_group > 0) {
  8693. duel_showinfo(sd->duel_group, sd);
  8694. return 0;
  8695. }
  8696. if(sd->duel_invite > 0) {
  8697. // "Duel: @duel without @reject."
  8698. clif_displaymessage(fd, msg_txt(355));
  8699. return 0;
  8700. }
  8701. if(!duel_checktime(sd)) {
  8702. // "Duel: You can take part in duel only one time per %d minutes."
  8703. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8704. clif_displaymessage(fd, output);
  8705. return 0;
  8706. }
  8707. if(strlen(message) > 0) {
  8708. if(sscanf(message, "%d", &maxpl) >= 1) {
  8709. if(maxpl < 2 || maxpl > 65535) {
  8710. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8711. return 0;
  8712. }
  8713. duel_create(sd, maxpl);
  8714. } else {
  8715. target_sd = map_nick2sd((char *)message);
  8716. if(target_sd != NULL) {
  8717. if((newduel = duel_create(sd, 2)) != -1) {
  8718. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8719. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8720. return 0;
  8721. }
  8722. duel_invite(newduel, sd, target_sd);
  8723. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8724. }
  8725. } else {
  8726. // "Duel: Player not found."
  8727. clif_displaymessage(fd, msg_txt(352));
  8728. return 0;
  8729. }
  8730. }
  8731. } else
  8732. duel_create(sd, 0);
  8733. return 0;
  8734. }
  8735. int atcommand_leave(
  8736. const int fd, struct map_session_data* sd,
  8737. const char* command, const char* message)
  8738. {
  8739. if(sd->duel_group <= 0) {
  8740. // "Duel: @leave without @duel."
  8741. clif_displaymessage(fd, msg_txt(358));
  8742. return 0;
  8743. }
  8744. duel_leave(sd->duel_group, sd);
  8745. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8746. return 0;
  8747. }
  8748. int atcommand_accept(
  8749. const int fd, struct map_session_data* sd,
  8750. const char* command, const char* message)
  8751. {
  8752. char output[256];
  8753. if(!duel_checktime(sd)) {
  8754. // "Duel: You can take part in duel only one time per %d minutes."
  8755. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8756. clif_displaymessage(fd, output);
  8757. return 0;
  8758. }
  8759. if(sd->duel_invite <= 0) {
  8760. // "Duel: @accept without invititation."
  8761. clif_displaymessage(fd, msg_txt(360));
  8762. return 0;
  8763. }
  8764. duel_accept(sd->duel_invite, sd);
  8765. // "Duel: Invitation has been accepted."
  8766. clif_displaymessage(fd, msg_txt(361));
  8767. return 0;
  8768. }
  8769. int atcommand_reject(
  8770. const int fd, struct map_session_data* sd,
  8771. const char* command, const char* message)
  8772. {
  8773. if(sd->duel_invite <= 0) {
  8774. // "Duel: @reject without invititation."
  8775. clif_displaymessage(fd, msg_txt(362));
  8776. return 0;
  8777. }
  8778. duel_reject(sd->duel_invite, sd);
  8779. // "Duel: Invitation has been rejected."
  8780. clif_displaymessage(fd, msg_txt(363));
  8781. return 0;
  8782. }
  8783. /*===================================
  8784. * Away message (@away, @aw) [LuzZza]
  8785. *-----------------------------------
  8786. */
  8787. int atcommand_away(
  8788. const int fd, struct map_session_data* sd,
  8789. const char* command, const char* message)
  8790. {
  8791. if(strlen(message) > 0) {
  8792. if(strlen(message) > 128)
  8793. return -1;
  8794. strcpy(sd->away_message, message);
  8795. //"Away automessage has been activated."
  8796. clif_displaymessage(fd, msg_txt(546));
  8797. } else {
  8798. if(strlen(sd->away_message) > 0) {
  8799. sd->away_message[0] = 0;
  8800. //"Away automessage has been disabled."
  8801. clif_displaymessage(fd, msg_txt(547));
  8802. return 0;
  8803. }
  8804. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8805. clif_displaymessage(fd, msg_txt(548));
  8806. }
  8807. return 0;
  8808. }
  8809. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8810. int atcommand_clone(
  8811. const int fd, struct map_session_data* sd,
  8812. const char* command, const char* message)
  8813. {
  8814. int x=0,y=0,flag=0,master=0,i=0;
  8815. struct map_session_data *pl_sd=NULL;
  8816. if (!message || !*message) {
  8817. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8818. return 0;
  8819. }
  8820. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8821. clif_displaymessage(fd, msg_txt(3));
  8822. return 0;
  8823. }
  8824. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8825. clif_displaymessage(fd, msg_txt(126));
  8826. return 0;
  8827. }
  8828. if (strcmpi(command, "@clone") == 0)
  8829. flag = 1;
  8830. else if (strcmpi(command, "@slaveclone") == 0) {
  8831. flag = 2;
  8832. master = sd->bl.id;
  8833. if (battle_config.atc_slave_clone_limit
  8834. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8835. clif_displaymessage(fd, msg_txt(127));
  8836. return 0;
  8837. }
  8838. }
  8839. do {
  8840. x = sd->bl.x + (rand() % 10 - 5);
  8841. y = sd->bl.y + (rand() % 10 - 5);
  8842. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8843. if (i >= 10) {
  8844. x = sd->bl.x;
  8845. y = sd->bl.y;
  8846. }
  8847. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8848. clif_displaymessage(fd, msg_txt(128+flag*2));
  8849. return 0;
  8850. }
  8851. clif_displaymessage(fd, msg_txt(129+flag*2));
  8852. return 0;
  8853. }
  8854. /*===================================
  8855. * Main chat [LuzZza]
  8856. * Usage: @main <on|off|message>
  8857. *-----------------------------------
  8858. */
  8859. int atcommand_main(
  8860. const int fd, struct map_session_data* sd,
  8861. const char* command, const char* message)
  8862. {
  8863. if(strlen(message) > 0) {
  8864. if(strcmpi(message, "on") == 0) {
  8865. if(!sd->state.mainchat) {
  8866. sd->state.mainchat = 1;
  8867. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8868. } else {
  8869. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8870. }
  8871. } else if(strcmpi(message, "off") == 0) {
  8872. if(sd->state.mainchat) {
  8873. sd->state.mainchat = 0;
  8874. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8875. } else {
  8876. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8877. }
  8878. } else {
  8879. if(!sd->state.mainchat) {
  8880. sd->state.mainchat = 1;
  8881. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8882. }
  8883. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8884. clif_displaymessage(fd, msg_txt(387));
  8885. return -1;
  8886. }
  8887. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8888. // I use 0xFE000000 color for signalizing that this message is
  8889. // main chat message. 0xFE000000 is invalid color, same using
  8890. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8891. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8892. }
  8893. } else {
  8894. if(sd->state.mainchat)
  8895. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8896. clif_displaymessage(fd, msg_txt(384));
  8897. else
  8898. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8899. clif_displaymessage(fd, msg_txt(385));
  8900. }
  8901. return 0;
  8902. }
  8903. /*=====================================
  8904. * Autorejecting Invites/Deals [LuzZza]
  8905. * Usage: @noask
  8906. *-------------------------------------
  8907. */
  8908. int atcommand_noask(
  8909. const int fd, struct map_session_data* sd,
  8910. const char* command, const char* message)
  8911. {
  8912. if(sd->state.noask) {
  8913. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  8914. sd->state.noask = 0;
  8915. } else {
  8916. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  8917. sd->state.noask = 1;
  8918. }
  8919. return 0;
  8920. }
  8921. /*=====================================
  8922. * Send a @request message to all GMs of lowest_gm_level.
  8923. * Usage: @request <petition>
  8924. *-------------------------------------
  8925. */
  8926. int atcommand_request(
  8927. const int fd, struct map_session_data* sd,
  8928. const char* command, const char* message)
  8929. {
  8930. if (!message || !*message) {
  8931. clif_displaymessage(sd->fd,msg_txt(277));
  8932. return -1;
  8933. }
  8934. sprintf(atcmd_output, msg_txt(278), message);
  8935. intif_wis_message_to_gm(sd->status.name, lowest_gm_level, atcmd_output);
  8936. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  8937. clif_displaymessage(sd->fd,msg_txt(279));
  8938. return 0;
  8939. }
  8940. void do_init_atcommand() {
  8941. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8942. duel_count = 0;
  8943. memset(&duel_list[0], 0, sizeof(duel_list));
  8944. return;
  8945. }
  8946. void do_final_atcommand() {
  8947. users_db->destroy(users_db,NULL);
  8948. }