atcommand.c 309 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include "../common/socket.h"
  9. #include "../common/timer.h"
  10. #include "../common/nullpo.h"
  11. #include "../common/mmo.h"
  12. #include "../common/core.h"
  13. #include "../common/showmsg.h"
  14. #include "log.h"
  15. #include "clif.h"
  16. #include "chrif.h"
  17. #include "intif.h"
  18. #include "itemdb.h"
  19. #include "map.h"
  20. #include "pc.h"
  21. #include "status.h"
  22. #include "skill.h"
  23. #include "mob.h"
  24. #include "pet.h"
  25. #include "battle.h"
  26. #include "party.h"
  27. #include "guild.h"
  28. #include "atcommand.h"
  29. #include "script.h"
  30. #include "npc.h"
  31. #include "trade.h"
  32. #include "unit.h"
  33. #ifndef TXT_ONLY
  34. #include "mail.h"
  35. #endif
  36. static char command_symbol = '@'; // first char of the commands (by [Yor])
  37. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  38. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  39. ACMD_FUNC(broadcast);
  40. ACMD_FUNC(localbroadcast);
  41. ACMD_FUNC(rura);
  42. ACMD_FUNC(where);
  43. ACMD_FUNC(jumpto);
  44. ACMD_FUNC(jump);
  45. ACMD_FUNC(who);
  46. ACMD_FUNC(who2);
  47. ACMD_FUNC(who3);
  48. ACMD_FUNC(whomap);
  49. ACMD_FUNC(whomap2);
  50. ACMD_FUNC(whomap3);
  51. ACMD_FUNC(whogm); // by Yor
  52. ACMD_FUNC(whozeny); // [Valaris]
  53. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  54. ACMD_FUNC(save);
  55. ACMD_FUNC(load);
  56. ACMD_FUNC(speed);
  57. ACMD_FUNC(storage);
  58. ACMD_FUNC(guildstorage);
  59. ACMD_FUNC(option);
  60. ACMD_FUNC(hide);
  61. ACMD_FUNC(jobchange);
  62. ACMD_FUNC(die);
  63. ACMD_FUNC(kill);
  64. ACMD_FUNC(alive);
  65. ACMD_FUNC(kami);
  66. ACMD_FUNC(heal);
  67. ACMD_FUNC(item);
  68. ACMD_FUNC(item2);
  69. ACMD_FUNC(itemreset);
  70. ACMD_FUNC(itemcheck);
  71. ACMD_FUNC(baselevelup);
  72. ACMD_FUNC(joblevelup);
  73. ACMD_FUNC(help);
  74. ACMD_FUNC(help2);
  75. ACMD_FUNC(gm);
  76. ACMD_FUNC(pvpoff);
  77. ACMD_FUNC(pvpon);
  78. ACMD_FUNC(gvgoff);
  79. ACMD_FUNC(gvgon);
  80. ACMD_FUNC(model);
  81. ACMD_FUNC(go);
  82. ACMD_FUNC(monster);
  83. ACMD_FUNC(monstersmall);
  84. ACMD_FUNC(monsterbig);
  85. ACMD_FUNC(spawn);
  86. ACMD_FUNC(killmonster);
  87. ACMD_FUNC(killmonster2);
  88. ACMD_FUNC(refine);
  89. ACMD_FUNC(produce);
  90. ACMD_FUNC(memo);
  91. ACMD_FUNC(gat);
  92. ACMD_FUNC(packet);
  93. ACMD_FUNC(waterlevel);
  94. ACMD_FUNC(statuspoint);
  95. ACMD_FUNC(skillpoint);
  96. ACMD_FUNC(zeny);
  97. ACMD_FUNC(param);
  98. ACMD_FUNC(guildlevelup);
  99. ACMD_FUNC(makeegg);
  100. ACMD_FUNC(hatch);
  101. ACMD_FUNC(petfriendly);
  102. ACMD_FUNC(pethungry);
  103. ACMD_FUNC(petrename);
  104. ACMD_FUNC(recall);
  105. ACMD_FUNC(recallall);
  106. ACMD_FUNC(revive);
  107. ACMD_FUNC(night);
  108. ACMD_FUNC(day);
  109. ACMD_FUNC(doom);
  110. ACMD_FUNC(doommap);
  111. ACMD_FUNC(raise);
  112. ACMD_FUNC(raisemap);
  113. ACMD_FUNC(kick);
  114. ACMD_FUNC(kickall);
  115. ACMD_FUNC(allskill);
  116. ACMD_FUNC(questskill);
  117. ACMD_FUNC(lostskill);
  118. ACMD_FUNC(spiritball);
  119. ACMD_FUNC(party);
  120. ACMD_FUNC(guild);
  121. ACMD_FUNC(agitstart);
  122. ACMD_FUNC(agitend);
  123. ACMD_FUNC(reloaditemdb);
  124. ACMD_FUNC(reloadmobdb);
  125. ACMD_FUNC(reloadskilldb);
  126. ACMD_FUNC(reloadscript);
  127. ACMD_FUNC(reloadgmdb); // by Yor
  128. ACMD_FUNC(reloadatcommand);
  129. ACMD_FUNC(reloadbattleconf);
  130. ACMD_FUNC(reloadstatusdb);
  131. ACMD_FUNC(reloadpcdb);
  132. ACMD_FUNC(reloadmotd); // [Valaris]
  133. ACMD_FUNC(mapexit);
  134. ACMD_FUNC(idsearch);
  135. ACMD_FUNC(mapinfo);
  136. ACMD_FUNC(dye); //** by fritz
  137. ACMD_FUNC(hair_style); //** by fritz
  138. ACMD_FUNC(hair_color); //** by fritz
  139. ACMD_FUNC(stat_all); //** by fritz
  140. ACMD_FUNC(char_block); // by Yor
  141. ACMD_FUNC(char_ban); // by Yor
  142. ACMD_FUNC(char_unblock); // by Yor
  143. ACMD_FUNC(char_unban); // by Yor
  144. ACMD_FUNC(mount_peco); // by Valaris
  145. ACMD_FUNC(char_mount_peco); // by Yor
  146. ACMD_FUNC(guildspy); // [Syrus22]
  147. ACMD_FUNC(partyspy); // [Syrus22]
  148. ACMD_FUNC(repairall); // [Valaris]
  149. ACMD_FUNC(guildrecall); // by Yor
  150. ACMD_FUNC(partyrecall); // by Yor
  151. ACMD_FUNC(nuke); // [Valaris]
  152. ACMD_FUNC(shownpc);
  153. ACMD_FUNC(hidenpc);
  154. ACMD_FUNC(loadnpc);
  155. ACMD_FUNC(unloadnpc);
  156. ACMD_FUNC(servertime); // by Yor
  157. ACMD_FUNC(chardelitem); // by Yor
  158. ACMD_FUNC(jail); // by Yor
  159. ACMD_FUNC(unjail); // by Yor
  160. ACMD_FUNC(disguise); // [Valaris]
  161. ACMD_FUNC(undisguise); // by Yor
  162. ACMD_FUNC(chardisguise); // Kalaspuff
  163. ACMD_FUNC(charundisguise); // Kalaspuff
  164. ACMD_FUNC(email); // by Yor
  165. ACMD_FUNC(effect);//by Apple
  166. ACMD_FUNC(character_cart_list); // by Yor
  167. ACMD_FUNC(addwarp); // by MouseJstr
  168. ACMD_FUNC(follow); // by MouseJstr
  169. ACMD_FUNC(skillon); // by MouseJstr
  170. ACMD_FUNC(skilloff); // by MouseJstr
  171. ACMD_FUNC(killer); // by MouseJstr
  172. ACMD_FUNC(npcmove); // by MouseJstr
  173. ACMD_FUNC(killable); // by MouseJstr
  174. ACMD_FUNC(charkillable); // by MouseJstr
  175. ACMD_FUNC(dropall); // by MouseJstr
  176. ACMD_FUNC(chardropall); // by MouseJstr
  177. ACMD_FUNC(storeall); // by MouseJstr
  178. ACMD_FUNC(charstoreall); // by MouseJstr
  179. ACMD_FUNC(skillid); // by MouseJstr
  180. ACMD_FUNC(useskill); // by MouseJstr
  181. ACMD_FUNC(summon);
  182. ACMD_FUNC(rain);
  183. ACMD_FUNC(snow);
  184. ACMD_FUNC(sakura);
  185. ACMD_FUNC(clouds);
  186. ACMD_FUNC(clouds2); // [Valaris]
  187. ACMD_FUNC(fog);
  188. ACMD_FUNC(fireworks);
  189. ACMD_FUNC(leaves);
  190. ACMD_FUNC(adjgmlvl); // by MouseJstr
  191. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  192. ACMD_FUNC(trade); // by MouseJstr
  193. ACMD_FUNC(send); // by davidsiaw
  194. ACMD_FUNC(setbattleflag); // by MouseJstr
  195. ACMD_FUNC(unmute); // [Valaris]
  196. ACMD_FUNC(clearweather); // Dexity
  197. ACMD_FUNC(uptime); // by MC Cameri
  198. ACMD_FUNC(changesex); // by MC Cameri
  199. ACMD_FUNC(mute); // celest
  200. ACMD_FUNC(refresh); // by MC Cameri
  201. ACMD_FUNC(petid); // by MC Cameri
  202. ACMD_FUNC(identify); // by MC Cameri
  203. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  204. ACMD_FUNC(misceffect); // by MC Cameri
  205. ACMD_FUNC(mobsearch);
  206. ACMD_FUNC(cleanmap);
  207. ACMD_FUNC(npctalk);
  208. ACMD_FUNC(pettalk);
  209. ACMD_FUNC(users);
  210. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  211. #ifndef TXT_ONLY
  212. ACMD_FUNC(checkmail); // [Valaris]
  213. ACMD_FUNC(listmail); // [Valaris]
  214. ACMD_FUNC(listnewmail); // [Valaris]
  215. ACMD_FUNC(readmail); // [Valaris]
  216. ACMD_FUNC(sendmail); // [Valaris]
  217. ACMD_FUNC(sendprioritymail); // [Valaris]
  218. ACMD_FUNC(deletemail); // [Valaris]
  219. ACMD_FUNC(refreshonline); // [Valaris]
  220. #endif /* TXT_ONLY */
  221. ACMD_FUNC(skilltree); // by MouseJstr
  222. ACMD_FUNC(marry); // by MouseJstr
  223. ACMD_FUNC(divorce); // by MouseJstr
  224. ACMD_FUNC(grind); // by MouseJstr
  225. ACMD_FUNC(grind2); // by MouseJstr
  226. #ifdef DMALLOC
  227. ACMD_FUNC(dmstart); // by MouseJstr
  228. ACMD_FUNC(dmtick); // by MouseJstr
  229. #endif
  230. ACMD_FUNC(jumptoid); // by Dino9021
  231. ACMD_FUNC(jumptoid2); // by Dino9021
  232. ACMD_FUNC(recallid); // by Dino9021
  233. ACMD_FUNC(recallid2); // by Dino9021
  234. ACMD_FUNC(kickid); // by Dino9021
  235. ACMD_FUNC(kickid2); // by Dino9021
  236. ACMD_FUNC(reviveid); // by Dino9021
  237. ACMD_FUNC(reviveid2); // by Dino9021
  238. ACMD_FUNC(killid); // by Dino9021
  239. ACMD_FUNC(killid2); // by Dino9021
  240. ACMD_FUNC(charkillableid); // by Dino9021
  241. ACMD_FUNC(charkillableid2); // by Dino9021
  242. ACMD_FUNC(sound);
  243. ACMD_FUNC(undisguiseall);
  244. ACMD_FUNC(disguiseall);
  245. ACMD_FUNC(changelook);
  246. ACMD_FUNC(mobinfo); //by Lupus
  247. ACMD_FUNC(exp); // by Skotlex
  248. ACMD_FUNC(adopt); // by Veider
  249. ACMD_FUNC(version); // by Ancyker
  250. ACMD_FUNC(mutearea); // by MouseJstr
  251. ACMD_FUNC(shuffle); // by MouseJstr
  252. ACMD_FUNC(rates); // by MouseJstr
  253. ACMD_FUNC(iteminfo); // Lupus
  254. ACMD_FUNC(whodrops); //Skotlex
  255. ACMD_FUNC(mapflag); // Lupus
  256. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  257. ACMD_FUNC(monsterignore); // [Valaris]
  258. ACMD_FUNC(fakename); //[Valaris]
  259. ACMD_FUNC(size); //[Valaris]
  260. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  261. ACMD_FUNC(showzeny);
  262. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  263. ACMD_FUNC(autotrade);// durf
  264. ACMD_FUNC(changeleader);// [Skotlex]
  265. ACMD_FUNC(changegm);// durf
  266. // Duel [LuzZza]
  267. ACMD_FUNC(invite);
  268. ACMD_FUNC(duel);
  269. ACMD_FUNC(leave);
  270. ACMD_FUNC(accept);
  271. ACMD_FUNC(reject);
  272. ACMD_FUNC(away); // LuzZza
  273. ACMD_FUNC(main); // LuzZza
  274. ACMD_FUNC(clone); // [Valaris]
  275. ACMD_FUNC(tonpc); // LuzZza
  276. /*==========================================
  277. *AtCommandInfo atcommand_info[]構造体の定義
  278. *------------------------------------------
  279. */
  280. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  281. // to set default level, read atcommand_athena.conf first please.
  282. static AtCommandInfo atcommand_info[] = {
  283. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  284. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  285. { AtCommand_Where, "@where", 1, atcommand_where },
  286. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  287. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  288. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  289. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  290. { AtCommand_Who, "@who", 20, atcommand_who },
  291. { AtCommand_Who, "@whois", 20, atcommand_who },
  292. { AtCommand_Who, "@w", 20, atcommand_who },
  293. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  294. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  295. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  296. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  297. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  298. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  299. { AtCommand_Save, "@save", 40, atcommand_save },
  300. { AtCommand_Load, "@return", 40, atcommand_load },
  301. { AtCommand_Load, "@load", 40, atcommand_load },
  302. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  303. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  304. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  305. { AtCommand_Option, "@option", 40, atcommand_option },
  306. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  307. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  308. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  309. { AtCommand_Die, "@die", 1, atcommand_die },
  310. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  311. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  312. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  313. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  314. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  315. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  316. { AtCommand_Item, "@item", 60, atcommand_item },
  317. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  318. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  319. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  320. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  321. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  322. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  323. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  324. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  325. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  326. { AtCommand_H, "@h", 20, atcommand_help },
  327. { AtCommand_Help, "@help", 20, atcommand_help },
  328. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  329. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  330. { AtCommand_GM, "@gm", 100,atcommand_gm },
  331. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  332. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  333. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  334. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  335. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  336. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  337. { AtCommand_Model, "@model", 20, atcommand_model },
  338. { AtCommand_Go, "@go", 10, atcommand_go },
  339. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  340. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  341. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  342. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  343. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  344. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  345. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  346. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  347. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  348. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  349. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  350. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  351. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  352. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  353. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  354. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  355. { AtCommand_Strength, "@str", 60, atcommand_param },
  356. { AtCommand_Agility, "@agi", 60, atcommand_param },
  357. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  358. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  359. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  360. { AtCommand_Luck, "@luk", 60, atcommand_param },
  361. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  362. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  363. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  364. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  365. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  366. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  367. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  368. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  369. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  370. { AtCommand_Night, "@night", 80, atcommand_night },
  371. { AtCommand_Day, "@day", 80, atcommand_day },
  372. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  373. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  374. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  375. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  376. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  377. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  378. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  379. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  380. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  381. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  382. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  383. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  384. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  385. { AtCommand_Party, "@party", 1, atcommand_party },
  386. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  387. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  388. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  389. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  390. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  391. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  392. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  393. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  394. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  395. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  396. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  397. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  398. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  399. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  400. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  401. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  402. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  403. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  404. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  405. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  406. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  407. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  408. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  409. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  410. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  411. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  412. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  413. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  414. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  415. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  416. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  417. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  418. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  419. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  420. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  421. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  422. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  423. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  424. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  425. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  426. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  427. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  428. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  429. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  430. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  431. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  432. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  433. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  434. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  435. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  436. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  437. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  438. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  439. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  440. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  441. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  444. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  446. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  447. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  448. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  449. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  450. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  451. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  452. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  453. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  454. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  455. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  456. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  457. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  458. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  459. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  460. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  461. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  462. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  463. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  464. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  465. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  466. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  467. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  468. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  469. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  470. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  471. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  472. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  473. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  474. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  475. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  476. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  477. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  478. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  479. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  480. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  481. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  482. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  483. { AtCommand_Send, "@send", 60, atcommand_send },
  484. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  485. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  486. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  487. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  488. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  489. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  490. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  491. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  492. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  493. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  494. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  495. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  496. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  497. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  498. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  499. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  500. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  501. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  502. { AtCommand_Users, "@users", 40, atcommand_users },
  503. { AtCommand_ResetState, "/reset", 40, NULL },
  504. #ifndef TXT_ONLY // sql-only commands
  505. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  506. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  507. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  508. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  509. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  510. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  511. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  512. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  513. #endif /* TXT_ONLY */
  514. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  515. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  516. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  517. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  518. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  519. #ifdef DMALLOC
  520. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  521. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  522. #endif
  523. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  524. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  525. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  526. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  527. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  528. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  529. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  530. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  531. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  532. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  533. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  534. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  535. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  536. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  537. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  538. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  539. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  540. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  541. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  542. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  543. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  544. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  545. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  546. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  547. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  548. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  549. { AtCommand_Version, "@version", 1, atcommand_version },
  550. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  551. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  552. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  553. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  554. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  555. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  556. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  557. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  558. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  559. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  560. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  561. { AtCommand_Size, "@size", 20, atcommand_size },
  562. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  563. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  564. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  565. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  566. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  567. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  568. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  569. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  570. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  571. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  572. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  573. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  574. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  575. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  576. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  577. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  578. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  579. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  580. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  581. // add new commands before this line
  582. { AtCommand_Unknown, NULL, 1, NULL }
  583. };
  584. /*=========================================
  585. * Generic variables
  586. *-----------------------------------------
  587. */
  588. char atcmd_output[200];
  589. char atcmd_player_name[100];
  590. char atcmd_temp[100];
  591. /*==========================================
  592. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  593. *------------------------------------------
  594. */
  595. char *estr_lower(char *str)
  596. {
  597. int i;
  598. for (i=0; str[i]; i++)
  599. if ((str[i] >= 65) && (str[i] <= 90))
  600. str[i] += 32;
  601. return str;
  602. }
  603. // compare function for sorting high to lowest
  604. int hightolow_compare (const void * a, const void * b)
  605. {
  606. return ( *(int*)b - *(int*)a );
  607. }
  608. // compare function for sorting lowest to highest
  609. int lowtohigh_compare (const void * a, const void * b)
  610. {
  611. return ( *(int*)a - *(int*)b );
  612. }
  613. //-----------------------------------------------------------
  614. // Return the message string of the specified number by [Yor]
  615. //-----------------------------------------------------------
  616. char * msg_txt(int msg_number) {
  617. if (msg_number >= 0 && msg_number < MAX_MSG &&
  618. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  619. return msg_table[msg_number];
  620. return "??";
  621. }
  622. //-----------------------------------------------------------
  623. // Returns Players title (from msg_athena.conf) [Lupus]
  624. //-----------------------------------------------------------
  625. char * player_title_txt(int level) {
  626. if (level < battle_config.title_lvl1)
  627. return ""; //w/o any titles
  628. if (level >= battle_config.title_lvl8)
  629. sprintf(atcmd_temp, msg_table[332], level);
  630. else
  631. if (level >= battle_config.title_lvl7)
  632. sprintf(atcmd_temp, msg_table[331], level);
  633. else
  634. if (level >= battle_config.title_lvl6)
  635. sprintf(atcmd_temp, msg_table[330], level);
  636. else
  637. if (level >= battle_config.title_lvl5)
  638. sprintf(atcmd_temp, msg_table[329], level);
  639. else
  640. if (level >= battle_config.title_lvl4)
  641. sprintf(atcmd_temp, msg_table[328], level);
  642. else
  643. if (level >= battle_config.title_lvl3)
  644. sprintf(atcmd_temp, msg_table[327], level);
  645. else
  646. if (level >= battle_config.title_lvl2)
  647. sprintf(atcmd_temp, msg_table[326], level);
  648. else
  649. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  650. return atcmd_temp;
  651. }
  652. //------------------------------------------------------------
  653. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  654. //------------------------------------------------------------
  655. int e_mail_check(char *email) {
  656. char ch;
  657. char* last_arobas;
  658. // athena limits
  659. if (strlen(email) < 3 || strlen(email) > 39)
  660. return 0;
  661. // part of RFC limits (official reference of e-mail description)
  662. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  663. return 0;
  664. if (email[strlen(email)-1] == '.')
  665. return 0;
  666. last_arobas = strrchr(email, '@');
  667. if (strstr(last_arobas, "@.") != NULL ||
  668. strstr(last_arobas, "..") != NULL)
  669. return 0;
  670. for(ch = 1; ch < 32; ch++) {
  671. if (strchr(last_arobas, ch) != NULL) {
  672. return 0;
  673. break;
  674. }
  675. }
  676. if (strchr(last_arobas, ' ') != NULL ||
  677. strchr(last_arobas, ';') != NULL)
  678. return 0;
  679. // all correct
  680. return 1;
  681. }
  682. /*==========================================
  683. * get_atcommand_level @コマンドの必要レベルを取得
  684. *------------------------------------------
  685. */
  686. int get_atcommand_level(const AtCommandType type) {
  687. int i;
  688. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  689. if (atcommand_info[i].type == type)
  690. return atcommand_info[i].level;
  691. return 100; // 100: command can not be used
  692. }
  693. /*==========================================
  694. *is_atcommand @コマンドに存在するかどうか確認する
  695. *------------------------------------------
  696. */
  697. AtCommandType
  698. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  699. const char* str = message;
  700. int s_flag = 0;
  701. AtCommandInfo info;
  702. AtCommandType type;
  703. nullpo_retr(AtCommand_None, sd);
  704. if (!battle_config.allow_atcommand_when_mute &&
  705. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  706. return AtCommand_Unknown;
  707. }
  708. if (!message || !*message)
  709. return AtCommand_None;
  710. memset(&info, 0, sizeof(info));
  711. str += strlen(sd->status.name);
  712. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  713. if (*str == ':')
  714. s_flag = 1;
  715. str++;
  716. }
  717. if (!*str)
  718. return AtCommand_None;
  719. if (map[sd->bl.m].flag.nocommand &&
  720. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  721. { //Command not allowed on this map.
  722. sprintf(atcmd_output, msg_table[143]);
  723. clif_displaymessage(fd, atcmd_output);
  724. return AtCommand_None;
  725. }
  726. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  727. if (type != AtCommand_None) {
  728. char command[100];
  729. const char* p = str;
  730. memset(command, '\0', sizeof(command));
  731. memset(atcmd_output, '\0', sizeof(atcmd_output));
  732. while (*p && !isspace(*p))
  733. p++;
  734. if (p - str >= sizeof(command)) // too long
  735. return AtCommand_Unknown;
  736. strncpy(command, str, p - str);
  737. while (isspace(*p))
  738. p++;
  739. if (type == AtCommand_Unknown || info.proc == NULL) {
  740. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  741. clif_displaymessage(fd, atcmd_output);
  742. } else {
  743. if (info.proc(fd, sd, command, p) != 0) {
  744. // Command can not be executed
  745. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  746. clif_displaymessage(fd, atcmd_output);
  747. }
  748. }
  749. return info.type;
  750. }
  751. return AtCommand_None;
  752. }
  753. /*==========================================
  754. *
  755. *------------------------------------------
  756. */
  757. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  758. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  759. if (!info)
  760. return AtCommand_None;
  761. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  762. return AtCommand_None;
  763. if (!p || !*p) {
  764. ShowError("at command message is empty\n");
  765. return AtCommand_None;
  766. }
  767. if (*p == command_symbol) { // check first char.
  768. char command[101];
  769. int i = 0;
  770. memset(info, 0, sizeof(AtCommandInfo));
  771. sscanf(p, "%100s", command);
  772. command[sizeof(command)-1] = '\0';
  773. while (atcommand_info[i].type != AtCommand_Unknown) {
  774. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  775. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  776. break;
  777. }
  778. i++;
  779. }
  780. if (atcommand_info[i].type == AtCommand_Unknown) {
  781. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  782. if (level == 0)
  783. return AtCommand_None;
  784. else
  785. return AtCommand_Unknown;
  786. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  787. log_atcommand(sd, message);
  788. }
  789. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  790. } else {
  791. return AtCommand_None;
  792. }
  793. return info->type;
  794. }
  795. /*==========================================
  796. * Read Message Data
  797. *------------------------------------------
  798. */
  799. int msg_config_read(const char *cfgName) {
  800. int msg_number;
  801. char line[1024], w1[1024], w2[1024];
  802. FILE *fp;
  803. static int called = 1;
  804. if ((fp = fopen(cfgName, "r")) == NULL) {
  805. ShowError("Messages file not found: %s\n", cfgName);
  806. return 1;
  807. }
  808. if ((--called) == 0)
  809. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  810. while(fgets(line, sizeof(line)-1, fp)) {
  811. if (line[0] == '/' && line[1] == '/')
  812. continue;
  813. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  814. if (strcmpi(w1, "import") == 0) {
  815. msg_config_read(w2);
  816. } else {
  817. msg_number = atoi(w1);
  818. if (msg_number >= 0 && msg_number < MAX_MSG) {
  819. if (msg_table[msg_number] != NULL)
  820. aFree(msg_table[msg_number]);
  821. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  822. strcpy(msg_table[msg_number],w2);
  823. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  824. }
  825. }
  826. }
  827. }
  828. fclose(fp);
  829. return 0;
  830. }
  831. /*==========================================
  832. * Cleanup Message Data
  833. *------------------------------------------
  834. */
  835. void do_final_msg (void) {
  836. int i;
  837. for (i = 0; i < MAX_MSG; i++)
  838. aFree(msg_table[i]);
  839. return;
  840. }
  841. /*==========================================
  842. *
  843. *------------------------------------------
  844. */
  845. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  846. int i;
  847. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  848. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  849. return &atcommand_info[i];
  850. return NULL;
  851. }
  852. /*==========================================
  853. *
  854. *------------------------------------------
  855. */
  856. int atcommand_config_read(const char *cfgName) {
  857. char line[1024], w1[1024], w2[1024];
  858. AtCommandInfo* p;
  859. FILE* fp;
  860. if ((fp = fopen(cfgName, "r")) == NULL) {
  861. ShowError("At commands configuration file not found: %s\n", cfgName);
  862. return 1;
  863. }
  864. while (fgets(line, sizeof(line)-1, fp)) {
  865. if (line[0] == '/' && line[1] == '/')
  866. continue;
  867. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  868. continue;
  869. p = get_atcommandinfo_byname(w1);
  870. if (p != NULL) {
  871. p->level = atoi(w2);
  872. if (p->level > 100)
  873. p->level = 100;
  874. else if (p->level < 0)
  875. p->level = 0;
  876. }
  877. if (strcmpi(w1, "import") == 0)
  878. atcommand_config_read(w2);
  879. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  880. w2[0] != '/' && // symbol of standard ragnarok GM commands
  881. w2[0] != '%' && // symbol of party chat speaking
  882. w2[0] != '$' && // symbol of guild chat
  883. w2[0] != '#') // symbol of charcommand
  884. command_symbol = w2[0];
  885. }
  886. fclose(fp);
  887. return 0;
  888. }
  889. /*==========================================
  890. * Duel organizing functions [LuzZza]
  891. *------------------------------------------
  892. */
  893. void duel_msg_foreach_sameduel_wos(
  894. const unsigned int did, struct map_session_data* sd, char *output)
  895. {
  896. int i;
  897. struct map_session_data* msg_sd;
  898. for(i=0; i<fd_max; i++)
  899. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  900. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  901. clif_disp_onlyself(msg_sd, output, strlen(output));
  902. return;
  903. }
  904. void duel_savetime(struct map_session_data* sd) {
  905. time_t timer;
  906. struct tm *t;
  907. time(&timer);
  908. t = localtime(&timer);
  909. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  910. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  911. return;
  912. }
  913. int duel_checktime(struct map_session_data* sd) {
  914. int diff;
  915. time_t timer;
  916. struct tm *t;
  917. time(&timer);
  918. t = localtime(&timer);
  919. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  920. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  921. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  922. }
  923. int duel_showinfo(
  924. const unsigned int did, struct map_session_data* sd)
  925. {
  926. int i, p=0;
  927. char output[256];
  928. struct map_session_data* msg_sd;
  929. if(duel_list[did].max_players_limit > 0)
  930. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  931. did, duel_count,
  932. duel_list[did].members_count,
  933. duel_list[did].members_count + duel_list[did].invites_count,
  934. duel_list[did].max_players_limit);
  935. else
  936. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  937. did, duel_count,
  938. duel_list[did].members_count,
  939. duel_list[did].members_count + duel_list[did].invites_count);
  940. clif_disp_onlyself(sd, output, strlen(output));
  941. for(i=0; i<fd_max; i++)
  942. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  943. && msg_sd->state.auth && msg_sd->duel_group == did) {
  944. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  945. clif_disp_onlyself(sd, output, strlen(output));
  946. }
  947. return 0;
  948. }
  949. int duel_create(
  950. struct map_session_data* sd, const unsigned int maxpl)
  951. {
  952. int i=1;
  953. char output[256];
  954. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  955. if(i == MAX_DUEL) return 0;
  956. duel_count++;
  957. sd->duel_group = i;
  958. duel_list[i].members_count++;
  959. duel_list[i].invites_count = 0;
  960. duel_list[i].max_players_limit = maxpl;
  961. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  962. clif_disp_onlyself(sd, output, strlen(output));
  963. clif_set0199(sd->fd, 1);
  964. //clif_misceffect2(&sd->bl, 159);
  965. return i;
  966. }
  967. int duel_invite(
  968. const unsigned int did, struct map_session_data* sd,
  969. struct map_session_data* target_sd)
  970. {
  971. char output[256];
  972. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  973. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  974. duel_msg_foreach_sameduel_wos(did, sd, output);
  975. target_sd->duel_invite = did;
  976. duel_list[did].invites_count++;
  977. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  978. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  979. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  980. return 0;
  981. }
  982. int duel_leave(
  983. const unsigned int did, struct map_session_data* sd)
  984. {
  985. int i;
  986. char output[256];
  987. struct map_session_data* msg_sd;
  988. // " <- Player %s has left duel --"
  989. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  990. duel_msg_foreach_sameduel_wos(did, sd, output);
  991. duel_list[did].members_count--;
  992. if(duel_list[did].members_count == 0) {
  993. for (i=0; i<fd_max; i++)
  994. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  995. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  996. msg_sd->duel_invite = 0;
  997. }
  998. duel_count--;
  999. }
  1000. sd->duel_group = 0;
  1001. duel_savetime(sd);
  1002. clif_set0199(sd->fd, 0);
  1003. return 0;
  1004. }
  1005. int duel_accept(
  1006. const unsigned int did, struct map_session_data* sd)
  1007. {
  1008. char output[256];
  1009. // " -> Player %s has accepted duel --"
  1010. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1011. duel_msg_foreach_sameduel_wos(did, sd, output);
  1012. duel_list[did].members_count++;
  1013. sd->duel_group = sd->duel_invite;
  1014. duel_list[did].invites_count--;
  1015. sd->duel_invite = 0;
  1016. clif_set0199(sd->fd, 1);
  1017. //clif_misceffect2(&sd->bl, 159);
  1018. return 0;
  1019. }
  1020. int duel_reject(
  1021. const unsigned int did, struct map_session_data* sd)
  1022. {
  1023. char output[256];
  1024. // " -- Player %s has rejected duel --"
  1025. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1026. duel_msg_foreach_sameduel_wos(did, sd, output);
  1027. duel_list[did].invites_count--;
  1028. sd->duel_invite = 0;
  1029. return 0;
  1030. }
  1031. /*==========================================
  1032. // @ command processing functions
  1033. *------------------------------------------
  1034. */
  1035. /*==========================================
  1036. * @send (used for testing packet sends from the client)
  1037. *------------------------------------------
  1038. */
  1039. int atcommand_send(
  1040. const int fd, struct map_session_data* sd,
  1041. const char* command, const char* message)
  1042. {
  1043. int i,type=0;
  1044. int info[20];
  1045. 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) {
  1046. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1047. return -1;
  1048. }
  1049. if (type > 0 && type < MAX_PACKET_DB) {
  1050. switch (type)
  1051. {
  1052. case 0x209: {
  1053. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1054. WFIFOW(fd,0) = 0x209;
  1055. WFIFOW(fd,2) = 2;
  1056. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1057. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1058. break;
  1059. }
  1060. case 0x1b1:
  1061. case 0x1c2:
  1062. //case xxx:
  1063. // add others here
  1064. // break;
  1065. default: {
  1066. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1067. WFIFOW(fd,0) = type;
  1068. for(i=1;i<=sizeof(info);i++)
  1069. if(info[i])
  1070. WFIFOW(fd,i) = info[i];
  1071. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1072. break;
  1073. }
  1074. }
  1075. sprintf (atcmd_output, msg_table[258], type, type);
  1076. clif_displaymessage(fd, atcmd_output);
  1077. } else {
  1078. clif_displaymessage(fd, msg_table[259]);
  1079. }
  1080. return 0;
  1081. }
  1082. // @rura
  1083. /*==========================================
  1084. *
  1085. *------------------------------------------
  1086. */
  1087. int atcommand_rura(
  1088. const int fd, struct map_session_data* sd,
  1089. const char* command, const char* message)
  1090. {
  1091. char map_name[MAP_NAME_LENGTH];
  1092. unsigned short mapindex;
  1093. int x = 0, y = 0;
  1094. int m = -1;
  1095. nullpo_retr(-1, sd);
  1096. memset(map_name, '\0', sizeof(map_name));
  1097. if (!message || !*message ||
  1098. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1099. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1100. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1101. return -1;
  1102. }
  1103. if (x <= 0)
  1104. x = rand() % 399 + 1;
  1105. if (y <= 0)
  1106. y = rand() % 399 + 1;
  1107. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1108. strcat(map_name, ".gat");
  1109. mapindex = mapindex_name2id(map_name);
  1110. if (mapindex)
  1111. m = map_mapindex2mapid(mapindex);
  1112. if (!mapindex || m < 0) {
  1113. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1114. return -1;
  1115. }
  1116. if (x > 0 && x < 400 && y > 0 && y < 400) {
  1117. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1118. clif_displaymessage(fd, msg_table[247]);
  1119. return -1;
  1120. }
  1121. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1122. clif_displaymessage(fd, msg_table[248]);
  1123. return -1;
  1124. }
  1125. if (pc_setpos(sd, mapindex, x, y, 3) == 0)
  1126. clif_displaymessage(fd, msg_table[0]); // Warped.
  1127. else {
  1128. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1129. return -1;
  1130. }
  1131. } else {
  1132. clif_displaymessage(fd, msg_table[2]); // Coordinates out of range.
  1133. return -1;
  1134. }
  1135. return 0;
  1136. }
  1137. /*==========================================
  1138. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1139. *------------------------------------------
  1140. */
  1141. int atcommand_where(
  1142. const int fd, struct map_session_data* sd,
  1143. const char* command, const char* message)
  1144. {
  1145. struct map_session_data *pl_sd = NULL;
  1146. int GM_level, pl_GM_level;
  1147. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1148. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1149. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1150. return -1;
  1151. }
  1152. pl_sd = map_nick2sd(atcmd_player_name);
  1153. nullpo_retr(-1, sd);
  1154. if (pl_sd == NULL)
  1155. return -1;
  1156. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1157. return -1;
  1158. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1159. pl_GM_level = pc_isGM(pl_sd);
  1160. if (battle_config.hide_GM_session) {
  1161. if(!(GM_level >= pl_GM_level)) {
  1162. if (!(battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid)) {
  1163. return -1;
  1164. }
  1165. }
  1166. }
  1167. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1168. atcmd_player_name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1169. clif_displaymessage(fd, atcmd_output);
  1170. return 0;
  1171. }
  1172. /*==========================================
  1173. *
  1174. *------------------------------------------
  1175. */
  1176. int atcommand_jumpto(
  1177. const int fd, struct map_session_data* sd,
  1178. const char* command, const char* message)
  1179. {
  1180. struct map_session_data *pl_sd = NULL;
  1181. nullpo_retr(-1, sd);
  1182. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1183. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1184. return -1;
  1185. }
  1186. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1187. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1188. return -1;
  1189. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1190. return -1;
  1191. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1192. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1193. clif_displaymessage(fd, msg_table[247]);
  1194. return -1;
  1195. }
  1196. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1197. clif_displaymessage(fd, msg_table[248]);
  1198. return -1;
  1199. }
  1200. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1201. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1202. clif_displaymessage(fd, atcmd_output);
  1203. } else {
  1204. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1205. return -1;
  1206. }
  1207. return 0;
  1208. }
  1209. /*==========================================
  1210. *
  1211. *------------------------------------------
  1212. */
  1213. int atcommand_jump(
  1214. const int fd, struct map_session_data* sd,
  1215. const char* command, const char* message)
  1216. {
  1217. int x = 0, y = 0;
  1218. nullpo_retr(-1, sd);
  1219. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1220. sscanf(message, "%d %d", &x, &y);
  1221. if (x <= 0) //If coordinates are 'wrong', random jump.
  1222. x = -1;
  1223. if (y <= 0)
  1224. y = -1;
  1225. 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)) {
  1226. clif_displaymessage(fd, msg_table[248]);
  1227. return -1;
  1228. }
  1229. pc_setpos(sd, sd->mapindex, x, y, 3);
  1230. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1231. clif_displaymessage(fd, atcmd_output);
  1232. return 0;
  1233. }
  1234. /*==========================================
  1235. * @who3 = Player name, his location
  1236. *------------------------------------------
  1237. */
  1238. int atcommand_who3(
  1239. const int fd, struct map_session_data* sd,
  1240. const char* command, const char* message)
  1241. {
  1242. char temp0[100];
  1243. struct map_session_data *pl_sd, **pl_allsd;
  1244. int i, j, count, users;
  1245. int pl_GM_level, GM_level;
  1246. char match_text[100];
  1247. char player_name[NAME_LENGTH];
  1248. nullpo_retr(-1, sd);
  1249. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1250. memset(match_text, '\0', sizeof(match_text));
  1251. memset(player_name, '\0', sizeof(player_name));
  1252. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1253. strcpy(match_text, "");
  1254. for (j = 0; match_text[j]; j++)
  1255. match_text[j] = tolower(match_text[j]);
  1256. count = 0;
  1257. GM_level = pc_isGM(sd);
  1258. pl_allsd = map_getallusers(&users);
  1259. for (i = 0; i < users; i++) {
  1260. if ((pl_sd = pl_allsd[i])) {
  1261. pl_GM_level = pc_isGM(pl_sd);
  1262. 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
  1263. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1264. for (j = 0; player_name[j]; j++)
  1265. player_name[j] = tolower(player_name[j]);
  1266. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1267. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1268. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1269. } else {
  1270. atcmd_output[0]=0;
  1271. }
  1272. //Player name
  1273. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1274. strcat(atcmd_output,temp0);
  1275. //Player title, if exists
  1276. if (pl_GM_level > 0) {
  1277. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1278. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1279. strcat(atcmd_output,temp0);
  1280. }
  1281. //Players Location: map x y
  1282. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1283. strcat(atcmd_output,temp0);
  1284. clif_displaymessage(fd, atcmd_output);
  1285. count++;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. if (count == 0)
  1291. clif_displaymessage(fd, msg_table[28]); // No player found.
  1292. else if (count == 1)
  1293. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1294. else {
  1295. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1296. clif_displaymessage(fd, atcmd_output);
  1297. }
  1298. return 0;
  1299. }
  1300. /*==========================================
  1301. * Player name, BLevel, Job,
  1302. *------------------------------------------
  1303. */
  1304. int atcommand_who2(
  1305. const int fd, struct map_session_data* sd,
  1306. const char* command, const char* message)
  1307. {
  1308. char temp0[100];
  1309. struct map_session_data *pl_sd, **pl_allsd;
  1310. int i, j, count, users;
  1311. int pl_GM_level, GM_level;
  1312. char match_text[100];
  1313. char player_name[NAME_LENGTH];
  1314. nullpo_retr(-1, sd);
  1315. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1316. memset(match_text, '\0', sizeof(match_text));
  1317. memset(player_name, '\0', sizeof(player_name));
  1318. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1319. strcpy(match_text, "");
  1320. for (j = 0; match_text[j]; j++)
  1321. match_text[j] = tolower(match_text[j]);
  1322. count = 0;
  1323. GM_level = pc_isGM(sd);
  1324. pl_allsd = map_getallusers(&users);
  1325. for (i = 0; i < users; i++) {
  1326. if ((pl_sd = pl_allsd[i])) {
  1327. pl_GM_level = pc_isGM(pl_sd);
  1328. 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
  1329. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1330. for (j = 0; player_name[j]; j++)
  1331. player_name[j] = tolower(player_name[j]);
  1332. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1333. //Players Name
  1334. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1335. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1336. //Player title, if exists
  1337. if (pl_GM_level > 0) {
  1338. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1339. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1340. strcat(atcmd_output,temp0);
  1341. }
  1342. //Players Base Level / Job name
  1343. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1344. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1345. strcat(atcmd_output,temp0);
  1346. clif_displaymessage(fd, atcmd_output);
  1347. count++;
  1348. }
  1349. }
  1350. }
  1351. }
  1352. if (count == 0)
  1353. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1354. else if (count == 1)
  1355. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1356. else {
  1357. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1358. clif_displaymessage(fd, atcmd_output);
  1359. }
  1360. return 0;
  1361. }
  1362. /*==========================================
  1363. * Player name, Playrs Party / Guild name
  1364. *------------------------------------------
  1365. */
  1366. int atcommand_who(
  1367. const int fd, struct map_session_data* sd,
  1368. const char* command, const char* message)
  1369. {
  1370. char temp0[100];
  1371. struct map_session_data *pl_sd, **pl_allsd;
  1372. int i, j, count, users;
  1373. int pl_GM_level, GM_level;
  1374. char match_text[100];
  1375. char player_name[NAME_LENGTH];
  1376. struct guild *g;
  1377. struct party *p;
  1378. nullpo_retr(-1, sd);
  1379. memset(temp0, '\0', sizeof(temp0));
  1380. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1381. memset(match_text, '\0', sizeof(match_text));
  1382. memset(player_name, '\0', sizeof(player_name));
  1383. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1384. strcpy(match_text, "");
  1385. for (j = 0; match_text[j]; j++)
  1386. match_text[j] = tolower(match_text[j]);
  1387. count = 0;
  1388. GM_level = pc_isGM(sd);
  1389. pl_allsd = map_getallusers(&users);
  1390. for (i = 0; i < users; i++) {
  1391. if ((pl_sd = pl_allsd[i])) {
  1392. pl_GM_level = pc_isGM(pl_sd);
  1393. 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
  1394. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1395. for (j = 0; player_name[j]; j++)
  1396. player_name[j] = tolower(player_name[j]);
  1397. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1398. g = guild_search(pl_sd->status.guild_id);
  1399. p = party_search(pl_sd->status.party_id);
  1400. //Players Name
  1401. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1402. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1403. //Player title, if exists
  1404. if (pl_GM_level > 0) {
  1405. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1406. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1407. strcat(atcmd_output,temp0);
  1408. }
  1409. //Players Party if exists
  1410. if (p != NULL) {
  1411. //sprintf(temp0," | Party: '%s'", p->name);
  1412. sprintf(temp0, msg_txt(335), p->name);
  1413. strcat(atcmd_output,temp0);
  1414. }
  1415. //Players Guild if exists
  1416. if (g != NULL) {
  1417. //sprintf(temp0," | Guild: '%s'", g->name);
  1418. sprintf(temp0, msg_txt(336), g->name);
  1419. strcat(atcmd_output,temp0);
  1420. }
  1421. clif_displaymessage(fd, atcmd_output);
  1422. count++;
  1423. }
  1424. }
  1425. }
  1426. }
  1427. if (count == 0)
  1428. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1429. else if (count == 1)
  1430. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1431. else {
  1432. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1433. clif_displaymessage(fd, atcmd_output);
  1434. }
  1435. return 0;
  1436. }
  1437. /*==========================================
  1438. *
  1439. *------------------------------------------
  1440. */
  1441. int atcommand_whomap3(
  1442. const int fd, struct map_session_data* sd,
  1443. const char* command, const char* message)
  1444. {
  1445. struct map_session_data *pl_sd, **pl_allsd;
  1446. int i, count, users;
  1447. int pl_GM_level, GM_level;
  1448. int map_id;
  1449. char map_name[MAP_NAME_LENGTH];
  1450. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1451. memset(map_name, '\0', sizeof(map_name));
  1452. if (!message || !*message)
  1453. map_id = sd->bl.m;
  1454. else {
  1455. sscanf(message, "%15s", map_name);
  1456. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1457. strcat(map_name, ".gat");
  1458. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1459. map_id = sd->bl.m;
  1460. }
  1461. count = 0;
  1462. GM_level = pc_isGM(sd);
  1463. pl_allsd = map_getallusers(&users);
  1464. for (i = 0; i < users; i++) {
  1465. if ((pl_sd = pl_allsd[i])) {
  1466. pl_GM_level = pc_isGM(pl_sd);
  1467. 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
  1468. if (pl_sd->bl.m == map_id) {
  1469. if (pl_GM_level > 0)
  1470. 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);
  1471. else
  1472. 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);
  1473. clif_displaymessage(fd, atcmd_output);
  1474. count++;
  1475. }
  1476. }
  1477. }
  1478. }
  1479. if (count == 0)
  1480. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1481. else if (count == 1)
  1482. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1483. else {
  1484. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1485. }
  1486. clif_displaymessage(fd, atcmd_output);
  1487. return 0;
  1488. }
  1489. /*==========================================
  1490. *
  1491. *------------------------------------------
  1492. */
  1493. int atcommand_whomap2(
  1494. const int fd, struct map_session_data* sd,
  1495. const char* command, const char* message)
  1496. {
  1497. struct map_session_data *pl_sd, **pl_allsd;
  1498. int i, count, users;
  1499. int pl_GM_level, GM_level;
  1500. int map_id = 0;
  1501. char map_name[MAP_NAME_LENGTH];
  1502. nullpo_retr(-1, sd);
  1503. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1504. memset(map_name, '\0', sizeof(map_name));
  1505. if (!message || !*message)
  1506. map_id = sd->bl.m;
  1507. else {
  1508. sscanf(message, "%15s", map_name);
  1509. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1510. strcat(map_name, ".gat");
  1511. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1512. map_id = sd->bl.m;
  1513. }
  1514. count = 0;
  1515. GM_level = pc_isGM(sd);
  1516. pl_allsd = map_getallusers(&users);
  1517. for (i = 0; i < users; i++) {
  1518. if ((pl_sd = pl_allsd[i])) {
  1519. pl_GM_level = pc_isGM(pl_sd);
  1520. 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
  1521. if (pl_sd->bl.m == map_id) {
  1522. if (pl_GM_level > 0)
  1523. 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);
  1524. else
  1525. 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);
  1526. clif_displaymessage(fd, atcmd_output);
  1527. count++;
  1528. }
  1529. }
  1530. }
  1531. }
  1532. if (count == 0)
  1533. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1534. else if (count == 1)
  1535. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1536. else {
  1537. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1538. }
  1539. clif_displaymessage(fd, atcmd_output);
  1540. return 0;
  1541. }
  1542. /*==========================================
  1543. *
  1544. *------------------------------------------
  1545. */
  1546. int atcommand_whomap(
  1547. const int fd, struct map_session_data* sd,
  1548. const char* command, const char* message)
  1549. {
  1550. char temp0[100];
  1551. char temp1[100];
  1552. struct map_session_data *pl_sd, **pl_allsd;
  1553. int i, count, users;
  1554. int pl_GM_level, GM_level;
  1555. int map_id = 0;
  1556. char map_name[MAP_NAME_LENGTH];
  1557. struct guild *g;
  1558. struct party *p;
  1559. nullpo_retr(-1, sd);
  1560. memset(temp0, '\0', sizeof(temp0));
  1561. memset(temp1, '\0', sizeof(temp1));
  1562. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1563. memset(map_name, '\0', sizeof(map_name));
  1564. if (!message || !*message)
  1565. map_id = sd->bl.m;
  1566. else {
  1567. sscanf(message, "%15s", map_name);
  1568. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1569. strcat(map_name, ".gat");
  1570. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1571. map_id = sd->bl.m;
  1572. }
  1573. count = 0;
  1574. GM_level = pc_isGM(sd);
  1575. pl_allsd = map_getallusers(&users);
  1576. for (i = 0; i < users; i++) {
  1577. if ((pl_sd = pl_allsd[i])) {
  1578. pl_GM_level = pc_isGM(pl_sd);
  1579. 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
  1580. if (pl_sd->bl.m == map_id) {
  1581. g = guild_search(pl_sd->status.guild_id);
  1582. if (g == NULL)
  1583. sprintf(temp1, "None");
  1584. else
  1585. sprintf(temp1, "%s", g->name);
  1586. p = party_search(pl_sd->status.party_id);
  1587. if (p == NULL)
  1588. sprintf(temp0, "None");
  1589. else
  1590. sprintf(temp0, "%s", p->name);
  1591. if (pl_GM_level > 0)
  1592. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1593. else
  1594. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1595. clif_displaymessage(fd, atcmd_output);
  1596. count++;
  1597. }
  1598. }
  1599. }
  1600. }
  1601. if (count == 0)
  1602. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1603. else if (count == 1)
  1604. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1605. else {
  1606. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1607. }
  1608. clif_displaymessage(fd, atcmd_output);
  1609. return 0;
  1610. }
  1611. /*==========================================
  1612. *
  1613. *------------------------------------------
  1614. */
  1615. int atcommand_whogm(
  1616. const int fd, struct map_session_data* sd,
  1617. const char* command, const char* message)
  1618. {
  1619. char temp0[100];
  1620. char temp1[100];
  1621. struct map_session_data *pl_sd, **pl_allsd;
  1622. int i, j, count, users;
  1623. int pl_GM_level, GM_level;
  1624. char match_text[100];
  1625. char player_name[NAME_LENGTH];
  1626. struct guild *g;
  1627. struct party *p;
  1628. nullpo_retr(-1, sd);
  1629. memset(temp0, '\0', sizeof(temp0));
  1630. memset(temp1, '\0', sizeof(temp1));
  1631. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1632. memset(match_text, '\0', sizeof(match_text));
  1633. memset(player_name, '\0', sizeof(player_name));
  1634. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1635. strcpy(match_text, "");
  1636. for (j = 0; match_text[j]; j++)
  1637. match_text[j] = tolower(match_text[j]);
  1638. count = 0;
  1639. GM_level = pc_isGM(sd);
  1640. pl_allsd = map_getallusers(&users);
  1641. for (i = 0; i < users; i++) {
  1642. if ((pl_sd = pl_allsd[i])) {
  1643. pl_GM_level = pc_isGM(pl_sd);
  1644. if (pl_GM_level > 0) {
  1645. 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
  1646. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1647. for (j = 0; player_name[j]; j++)
  1648. player_name[j] = tolower(player_name[j]);
  1649. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1650. 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);
  1651. clif_displaymessage(fd, atcmd_output);
  1652. 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);
  1653. clif_displaymessage(fd, atcmd_output);
  1654. g = guild_search(pl_sd->status.guild_id);
  1655. if (g == NULL)
  1656. sprintf(temp1, "None");
  1657. else
  1658. sprintf(temp1, "%s", g->name);
  1659. p = party_search(pl_sd->status.party_id);
  1660. if (p == NULL)
  1661. sprintf(temp0, "None");
  1662. else
  1663. sprintf(temp0, "%s", p->name);
  1664. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1665. clif_displaymessage(fd, atcmd_output);
  1666. count++;
  1667. }
  1668. }
  1669. }
  1670. }
  1671. }
  1672. if (count == 0)
  1673. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1674. else if (count == 1)
  1675. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1676. else {
  1677. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1678. clif_displaymessage(fd, atcmd_output);
  1679. }
  1680. return 0;
  1681. }
  1682. int atcommand_whozeny(
  1683. const int fd, struct map_session_data* sd,
  1684. const char* command, const char* message)
  1685. {
  1686. struct map_session_data *pl_sd, **pl_allsd;
  1687. int i, j, count,c, users;
  1688. char match_text[100];
  1689. char player_name[NAME_LENGTH];
  1690. int *zeny;
  1691. int *counted;
  1692. nullpo_retr(-1, sd);
  1693. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1694. memset(match_text, '\0', sizeof(match_text));
  1695. memset(player_name, '\0', sizeof(player_name));
  1696. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1697. strcpy(match_text, "");
  1698. for (j = 0; match_text[j]; j++)
  1699. match_text[j] = tolower(match_text[j]);
  1700. count = 0;
  1701. pl_allsd = map_getallusers(&users);
  1702. if (users < 1)
  1703. {
  1704. clif_displaymessage(fd, msg_table[28]); // No player found.
  1705. return 0;
  1706. }
  1707. zeny = (int *)aCallocA(users, sizeof(int));
  1708. counted = (int *)aCallocA(users, sizeof(int));
  1709. for (i = 0; i < users; i++) {
  1710. if ((pl_sd = pl_allsd[i])) {
  1711. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1712. for (j = 0; player_name[j]; j++)
  1713. player_name[j] = tolower(player_name[j]);
  1714. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1715. zeny[count]=pl_sd->status.zeny;
  1716. counted[i]=0;
  1717. count++;
  1718. }
  1719. }
  1720. }
  1721. qsort(zeny, count, sizeof(int), hightolow_compare);
  1722. for (c = 0; c < count && c < 50; c++) {
  1723. if(!zeny[c])
  1724. continue;
  1725. for (i = 0; i < users; i++) {
  1726. if(!zeny[c])
  1727. continue;
  1728. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1729. if(pl_sd->status.zeny==zeny[c]) {
  1730. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1731. clif_displaymessage(fd, atcmd_output);
  1732. zeny[c]=0;
  1733. counted[i]=1;
  1734. }
  1735. }
  1736. }
  1737. }
  1738. if (count == 0)
  1739. clif_displaymessage(fd, msg_table[28]); // No player found.
  1740. else if (count == 1)
  1741. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1742. else {
  1743. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1744. clif_displaymessage(fd, atcmd_output);
  1745. }
  1746. aFree(zeny);
  1747. aFree(counted);
  1748. return 0;
  1749. }
  1750. // cause random emote on all online players [Valaris]
  1751. int atcommand_happyhappyjoyjoy(
  1752. const int fd, struct map_session_data* sd,
  1753. const char* command, const char* message)
  1754. {
  1755. struct map_session_data *pl_sd, **pl_allsd;
  1756. int i,e, users;
  1757. nullpo_retr(-1, sd);
  1758. pl_allsd = map_getallusers(&users);
  1759. for (i = 0; i < users; i++) {
  1760. if ((pl_sd = pl_allsd[i])) {
  1761. e=rand()%40;
  1762. if(e==34)
  1763. e = 0;
  1764. clif_emotion(&pl_sd->bl,e);
  1765. }
  1766. }
  1767. return 0;
  1768. }
  1769. /*==========================================
  1770. *
  1771. *------------------------------------------
  1772. */
  1773. int atcommand_save(
  1774. const int fd, struct map_session_data* sd,
  1775. const char* command, const char* message)
  1776. {
  1777. nullpo_retr(-1, sd);
  1778. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1779. if (sd->status.pet_id > 0 && sd->pd)
  1780. intif_save_petdata(sd->status.account_id, &sd->pet);
  1781. chrif_save(sd,0);
  1782. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1783. return 0;
  1784. }
  1785. /*==========================================
  1786. *
  1787. *------------------------------------------
  1788. */
  1789. int atcommand_load(
  1790. const int fd, struct map_session_data* sd,
  1791. const char* command, const char* message)
  1792. {
  1793. int m;
  1794. nullpo_retr(-1, sd);
  1795. m = map_mapindex2mapid(sd->status.save_point.map);
  1796. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1797. clif_displaymessage(fd, msg_table[249]);
  1798. return -1;
  1799. }
  1800. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1801. clif_displaymessage(fd, msg_table[248]);
  1802. return -1;
  1803. }
  1804. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1805. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1806. return 0;
  1807. }
  1808. /*==========================================
  1809. *
  1810. *------------------------------------------
  1811. */
  1812. int atcommand_speed(
  1813. const int fd, struct map_session_data* sd,
  1814. const char* command, const char* message)
  1815. {
  1816. int speed;
  1817. nullpo_retr(-1, sd);
  1818. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1819. if (!message || !*message) {
  1820. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1821. clif_displaymessage(fd, atcmd_output);
  1822. return -1;
  1823. }
  1824. speed = atoi(message);
  1825. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1826. sd->speed = speed;
  1827. //sd->walktimer = x;
  1828. //この文を追加 by れ�
  1829. clif_updatestatus(sd, SP_SPEED);
  1830. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1831. } else {
  1832. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1833. clif_displaymessage(fd, atcmd_output);
  1834. return -1;
  1835. }
  1836. return 0;
  1837. }
  1838. /*==========================================
  1839. *
  1840. *------------------------------------------
  1841. */
  1842. int atcommand_storage(
  1843. const int fd, struct map_session_data* sd,
  1844. const char* command, const char* message)
  1845. {
  1846. struct storage *stor; //changes from Freya/Yor
  1847. nullpo_retr(-1, sd);
  1848. if (sd->state.storage_flag) {
  1849. clif_displaymessage(fd, msg_table[250]);
  1850. return -1;
  1851. }
  1852. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1853. clif_displaymessage(fd, msg_table[250]);
  1854. return -1;
  1855. }
  1856. storage_storageopen(sd);
  1857. return 0;
  1858. }
  1859. /*==========================================
  1860. *
  1861. *------------------------------------------
  1862. */
  1863. int atcommand_guildstorage(
  1864. const int fd, struct map_session_data* sd,
  1865. const char* command, const char* message)
  1866. {
  1867. struct storage *stor; //changes from Freya/Yor
  1868. nullpo_retr(-1, sd);
  1869. if (sd->status.guild_id > 0) {
  1870. if (sd->state.storage_flag) {
  1871. clif_displaymessage(fd, msg_table[251]);
  1872. return -1;
  1873. }
  1874. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1875. clif_displaymessage(fd, msg_table[251]);
  1876. return -1;
  1877. }
  1878. storage_guild_storageopen(sd);
  1879. } else {
  1880. clif_displaymessage(fd, msg_table[252]);
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------
  1888. */
  1889. int atcommand_option(
  1890. const int fd, struct map_session_data* sd,
  1891. const char* command, const char* message)
  1892. {
  1893. int param1 = 0, param2 = 0, param3 = 0;
  1894. nullpo_retr(-1, sd);
  1895. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1896. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1897. return -1;
  1898. }
  1899. sd->sc.opt1 = param1;
  1900. sd->sc.opt2 = param2;
  1901. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1902. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1903. clif_cart_itemlist(sd);
  1904. clif_cart_equiplist(sd);
  1905. clif_updatestatus(sd, SP_CARTINFO);
  1906. }
  1907. pc_setoption(sd, param3);
  1908. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1909. return 0;
  1910. }
  1911. /*==========================================
  1912. *
  1913. *------------------------------------------
  1914. */
  1915. int atcommand_hide(
  1916. const int fd, struct map_session_data* sd,
  1917. const char* command, const char* message)
  1918. {
  1919. nullpo_retr(-1, sd);
  1920. if (sd->sc.option & OPTION_INVISIBLE) {
  1921. sd->sc.option &= ~OPTION_INVISIBLE;
  1922. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1923. } else {
  1924. sd->sc.option |= OPTION_INVISIBLE;
  1925. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1926. }
  1927. clif_changeoption(&sd->bl);
  1928. return 0;
  1929. }
  1930. /*==========================================
  1931. * 転職する upperを指定すると転生や養子にもなれる
  1932. *------------------------------------------
  1933. */
  1934. int atcommand_jobchange(
  1935. const int fd, struct map_session_data* sd,
  1936. const char* command, const char* message)
  1937. {
  1938. int job = 0, upper = 0;
  1939. nullpo_retr(-1, sd);
  1940. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1941. int i, found = 0;
  1942. const struct { char name[16]; int id; } jobs[] = {
  1943. { "novice", 0 },
  1944. { "swordsman", 1 },
  1945. { "mage", 2 },
  1946. { "archer", 3 },
  1947. { "acolyte", 4 },
  1948. { "merchant", 5 },
  1949. { "thief", 6 },
  1950. { "knight", 7 },
  1951. { "priest", 8 },
  1952. { "priestess", 8 },
  1953. { "wizard", 9 },
  1954. { "blacksmith", 10 },
  1955. { "hunter", 11 },
  1956. { "assassin", 12 },
  1957. { "crusader", 14 },
  1958. { "monk", 15 },
  1959. { "sage", 16 },
  1960. { "rogue", 17 },
  1961. { "alchemist", 18 },
  1962. { "bard", 19 },
  1963. { "dancer", 20 },
  1964. { "super novice", 23 },
  1965. { "supernovice", 23 },
  1966. { "gunslinger", 24 },
  1967. { "gunner", 24 },
  1968. { "ninja", 25 },
  1969. { "high novice", 4001 },
  1970. { "swordsman high", 4002 },
  1971. { "mage high", 4003 },
  1972. { "archer high", 4004 },
  1973. { "acolyte high", 4005 },
  1974. { "merchant high", 4006 },
  1975. { "thief high", 4007 },
  1976. { "lord knight", 4008 },
  1977. { "high priest", 4009 },
  1978. { "high priestess", 4009 },
  1979. { "high wizard", 4010 },
  1980. { "whitesmith", 4011 },
  1981. { "sniper", 4012 },
  1982. { "assassin cross", 4013 },
  1983. { "paladin", 4015 },
  1984. { "champion", 4016 },
  1985. { "professor", 4017 },
  1986. { "stalker", 4018 },
  1987. { "creator", 4019 },
  1988. { "clown", 4020 },
  1989. { "gypsy", 4021 },
  1990. { "baby novice", 4023 },
  1991. { "baby swordsman", 4024 },
  1992. { "baby mage", 4025 },
  1993. { "baby archer", 4026 },
  1994. { "baby acolyte", 4027 },
  1995. { "baby merchant", 4028 },
  1996. { "baby thief", 4029 },
  1997. { "baby knight", 4030 },
  1998. { "baby priest", 4031 },
  1999. { "baby priestess", 4031 },
  2000. { "baby wizard", 4032 },
  2001. { "baby blacksmith",4033 },
  2002. { "baby hunter", 4034 },
  2003. { "baby assassin", 4035 },
  2004. { "baby crusader", 4037 },
  2005. { "baby monk", 4038 },
  2006. { "baby sage", 4039 },
  2007. { "baby rogue", 4040 },
  2008. { "baby alchemist", 4041 },
  2009. { "baby bard", 4042 },
  2010. { "baby dancer", 4043 },
  2011. { "super baby", 4045 },
  2012. { "taekwon", 4046 },
  2013. { "taekwon boy", 4046 },
  2014. { "taekwon girl", 4046 },
  2015. { "star gladiator", 4047 },
  2016. { "soul linker", 4049 },
  2017. };
  2018. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2019. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2020. job = jobs[i].id;
  2021. upper = 0;
  2022. found = 1;
  2023. break;
  2024. }
  2025. }
  2026. if (!found) {
  2027. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2028. return -1;
  2029. }
  2030. }
  2031. if (job == 37 ||job == 45)
  2032. return 0;
  2033. if ((job >= 0 && job < MAX_PC_CLASS))
  2034. {
  2035. int j;
  2036. for (j=0; j < MAX_INVENTORY; j++) {
  2037. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2038. pc_unequipitem(sd, j, 3);
  2039. }
  2040. if (pc_jobchange(sd, job, upper) == 0)
  2041. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2042. else {
  2043. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2044. return -1;
  2045. }
  2046. } else {
  2047. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2048. return -1;
  2049. }
  2050. return 0;
  2051. }
  2052. /*==========================================
  2053. *
  2054. *------------------------------------------
  2055. */
  2056. int atcommand_die(
  2057. const int fd, struct map_session_data* sd,
  2058. const char* command, const char* message)
  2059. {
  2060. nullpo_retr(-1, sd);
  2061. clif_specialeffect(&sd->bl,450,1);
  2062. pc_damage(NULL, sd, sd->status.hp);
  2063. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2064. return 0;
  2065. }
  2066. /*==========================================
  2067. *
  2068. *------------------------------------------
  2069. */
  2070. int atcommand_kill(
  2071. const int fd, struct map_session_data* sd,
  2072. const char* command, const char* message)
  2073. {
  2074. struct map_session_data *pl_sd;
  2075. nullpo_retr(-1, sd);
  2076. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2077. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2078. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2079. return -1;
  2080. }
  2081. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2082. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2083. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2084. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2085. } else {
  2086. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2087. return -1;
  2088. }
  2089. } else {
  2090. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. *
  2097. *------------------------------------------
  2098. */
  2099. int atcommand_alive(
  2100. const int fd, struct map_session_data* sd,
  2101. const char* command, const char* message)
  2102. {
  2103. nullpo_retr(-1, sd);
  2104. if (pc_isdead(sd)) {
  2105. sd->status.hp = sd->status.max_hp;
  2106. sd->status.sp = sd->status.max_sp;
  2107. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2108. pc_setstand(sd);
  2109. if (battle_config.pc_invincible_time > 0)
  2110. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2111. clif_updatestatus(sd, SP_HP);
  2112. clif_updatestatus(sd, SP_SP);
  2113. clif_resurrection(&sd->bl, 1);
  2114. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2115. return 0;
  2116. }
  2117. return -1;
  2118. }
  2119. /*==========================================
  2120. * +kamic [LuzZza]
  2121. *------------------------------------------
  2122. */
  2123. int atcommand_kami(
  2124. const int fd, struct map_session_data* sd,
  2125. const char* command, const char* message)
  2126. {
  2127. unsigned long color=0;
  2128. nullpo_retr(-1, sd);
  2129. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2130. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2131. if (!message || !*message) {
  2132. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2133. return -1;
  2134. }
  2135. sscanf(message, "%199[^\n]", atcmd_output);
  2136. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2137. } else {
  2138. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2139. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2140. return -1;
  2141. }
  2142. if(color < 0 || color > 0xFFFFFF) {
  2143. clif_displaymessage(fd, "Invalid color.");
  2144. return -1;
  2145. }
  2146. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2147. }
  2148. return 0;
  2149. }
  2150. /*==========================================
  2151. *
  2152. *------------------------------------------
  2153. */
  2154. int atcommand_heal(
  2155. const int fd, struct map_session_data* sd,
  2156. const char* command, const char* message)
  2157. {
  2158. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2159. nullpo_retr(-1, sd);
  2160. sscanf(message, "%d %d", &hp, &sp);
  2161. if (hp == 0 && sp == 0) {
  2162. hp = sd->status.max_hp - sd->status.hp;
  2163. sp = sd->status.max_sp - sd->status.sp;
  2164. } else {
  2165. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2166. hp = sd->status.max_hp - sd->status.hp;
  2167. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2168. hp = 1 - sd->status.hp;
  2169. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2170. sp = sd->status.max_sp - sd->status.sp;
  2171. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2172. sp = 1 - sd->status.sp;
  2173. }
  2174. if (hp > 0) // display like heal
  2175. clif_heal(fd, SP_HP, hp);
  2176. else if (hp < 0) // display like damage
  2177. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2178. if (sp > 0) // no display when we lost SP
  2179. clif_heal(fd, SP_SP, sp);
  2180. if (hp != 0 || sp != 0) {
  2181. pc_heal(sd, hp, sp);
  2182. if (hp >= 0 && sp >= 0)
  2183. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2184. else
  2185. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2186. } else {
  2187. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2188. return -1;
  2189. }
  2190. return 0;
  2191. }
  2192. /*==========================================
  2193. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2194. *------------------------------------------
  2195. */
  2196. int atcommand_item(
  2197. const int fd, struct map_session_data* sd,
  2198. const char* command, const char* message)
  2199. {
  2200. char item_name[100];
  2201. int number = 0, item_id, flag;
  2202. struct item item_tmp;
  2203. struct item_data *item_data;
  2204. int get_count, i, pet_id;
  2205. nullpo_retr(-1, sd);
  2206. memset(item_name, '\0', sizeof(item_name));
  2207. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2208. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2209. return -1;
  2210. }
  2211. if (number <= 0)
  2212. number = 1;
  2213. item_id = 0;
  2214. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2215. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2216. item_id = item_data->nameid;
  2217. if (item_id >= 500) {
  2218. get_count = number;
  2219. // check pet egg
  2220. pet_id = search_petDB_index(item_id, PET_EGG);
  2221. if (item_data->type == 4 || item_data->type == 5 ||
  2222. item_data->type == 7 || item_data->type == 8) {
  2223. get_count = 1;
  2224. }
  2225. for (i = 0; i < number; i += get_count) {
  2226. // if pet egg
  2227. if (pet_id >= 0) {
  2228. sd->catch_target_class = pet_db[pet_id].class_;
  2229. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2230. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2231. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2232. 100, 0, 1, pet_db[pet_id].jname);
  2233. // if not pet egg
  2234. } else {
  2235. memset(&item_tmp, 0, sizeof(item_tmp));
  2236. item_tmp.nameid = item_id;
  2237. item_tmp.identify = 1;
  2238. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2239. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2240. }
  2241. }
  2242. //Logs (A)dmins items [Lupus]
  2243. if(log_config.pick > 0 ) {
  2244. log_pick(sd, "A", 0, item_id, number, NULL);
  2245. }
  2246. //Logs
  2247. clif_displaymessage(fd, msg_table[18]); // Item created.
  2248. } else {
  2249. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2250. return -1;
  2251. }
  2252. return 0;
  2253. }
  2254. /*==========================================
  2255. *
  2256. *------------------------------------------
  2257. */
  2258. int atcommand_item2(
  2259. const int fd, struct map_session_data* sd,
  2260. const char* command, const char* message)
  2261. {
  2262. struct item item_tmp;
  2263. struct item_data *item_data;
  2264. char item_name[100];
  2265. int item_id, number = 0;
  2266. int identify = 0, refine = 0, attr = 0;
  2267. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2268. int flag;
  2269. int loop, get_count, i;
  2270. nullpo_retr(-1, sd);
  2271. memset(item_name, '\0', sizeof(item_name));
  2272. 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) {
  2273. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2274. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2275. return -1;
  2276. }
  2277. if (number <= 0)
  2278. number = 1;
  2279. item_id = 0;
  2280. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2281. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2282. item_id = item_data->nameid;
  2283. if (item_id > 500) {
  2284. loop = 1;
  2285. get_count = number;
  2286. if (item_data->type == 4 || item_data->type == 5 ||
  2287. item_data->type == 7 || item_data->type == 8) {
  2288. loop = number;
  2289. get_count = 1;
  2290. if (item_data->type == 7) {
  2291. identify = 1;
  2292. refine = 0;
  2293. }
  2294. if (item_data->type == 8)
  2295. refine = 0;
  2296. if (refine > 10)
  2297. refine = 10;
  2298. } else {
  2299. identify = 1;
  2300. refine = attr = 0;
  2301. }
  2302. for (i = 0; i < loop; i++) {
  2303. memset(&item_tmp, 0, sizeof(item_tmp));
  2304. item_tmp.nameid = item_id;
  2305. item_tmp.identify = identify;
  2306. item_tmp.refine = refine;
  2307. item_tmp.attribute = attr;
  2308. item_tmp.card[0] = c1;
  2309. item_tmp.card[1] = c2;
  2310. item_tmp.card[2] = c3;
  2311. item_tmp.card[3] = c4;
  2312. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2313. clif_additem(sd, 0, 0, flag);
  2314. }
  2315. //Logs (A)dmins items [Lupus]
  2316. if(log_config.pick > 0 ) {
  2317. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2318. }
  2319. //Logs
  2320. clif_displaymessage(fd, msg_table[18]); // Item created.
  2321. } else {
  2322. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2323. return -1;
  2324. }
  2325. return 0;
  2326. }
  2327. /*==========================================
  2328. *
  2329. *------------------------------------------
  2330. */
  2331. int atcommand_itemreset(
  2332. const int fd, struct map_session_data* sd,
  2333. const char* command, const char* message)
  2334. {
  2335. int i;
  2336. nullpo_retr(-1, sd);
  2337. for (i = 0; i < MAX_INVENTORY; i++) {
  2338. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2339. //Logs (A)dmins items [Lupus]
  2340. if(log_config.pick > 0 ) {
  2341. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2342. }
  2343. //Logs
  2344. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2345. }
  2346. }
  2347. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2348. return 0;
  2349. }
  2350. /*==========================================
  2351. *
  2352. *------------------------------------------
  2353. */
  2354. int atcommand_itemcheck(
  2355. const int fd, struct map_session_data* sd,
  2356. const char* command, const char* message)
  2357. {
  2358. nullpo_retr(-1, sd);
  2359. pc_checkitem(sd);
  2360. return 0;
  2361. }
  2362. /*==========================================
  2363. * Atcommand @lvlup
  2364. *------------------------------------------
  2365. */
  2366. int atcommand_baselevelup(
  2367. const int fd, struct map_session_data* sd,
  2368. const char* command, const char* message)
  2369. {
  2370. int level=0, i=0;
  2371. nullpo_retr(-1, sd);
  2372. level = atoi(message);
  2373. if (!message || !*message || !level) {
  2374. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2375. return -1;
  2376. }
  2377. if (level > 0) {
  2378. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2379. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2380. return -1;
  2381. } /* End Addition */
  2382. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2383. level = pc_maxbaselv(sd) - sd->status.base_level;
  2384. for (i = 1; i <= level; i++)
  2385. sd->status.status_point += (sd->status.base_level + i + 14) / 5;
  2386. sd->status.base_level += (unsigned int)level;
  2387. clif_updatestatus(sd, SP_BASELEVEL);
  2388. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2389. clif_updatestatus(sd, SP_STATUSPOINT);
  2390. status_calc_pc(sd, 0);
  2391. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2392. clif_misceffect(&sd->bl, 0);
  2393. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2394. } else {
  2395. if (sd->status.base_level == 1) {
  2396. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2397. return -1;
  2398. }
  2399. level*=-1;
  2400. if ((unsigned int)level >= sd->status.base_level)
  2401. level = sd->status.base_level-1;
  2402. if (sd->status.status_point > 0) {
  2403. for (i = 0; i > -level; i--)
  2404. sd->status.status_point -= (sd->status.base_level + i + 14) / 5;
  2405. if (sd->status.status_point < 0)
  2406. sd->status.status_point = 0;
  2407. clif_updatestatus(sd, SP_STATUSPOINT);
  2408. } /* to add: remove status points from stats */
  2409. sd->status.base_level -= (unsigned int)level;
  2410. clif_updatestatus(sd, SP_BASELEVEL);
  2411. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2412. status_calc_pc(sd, 0);
  2413. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2414. }
  2415. return 0;
  2416. }
  2417. /*==========================================
  2418. *
  2419. *------------------------------------------
  2420. */
  2421. int atcommand_joblevelup(
  2422. const int fd, struct map_session_data* sd,
  2423. const char* command, const char* message)
  2424. {
  2425. int level=0;
  2426. nullpo_retr(-1, sd);
  2427. level = atoi(message);
  2428. if (!message || !*message || !level) {
  2429. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2430. return -1;
  2431. }
  2432. if (level > 0) {
  2433. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2434. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2435. return -1;
  2436. }
  2437. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2438. level = pc_maxjoblv(sd) - sd->status.job_level;
  2439. sd->status.job_level += (unsigned int)level;
  2440. clif_updatestatus(sd, SP_JOBLEVEL);
  2441. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2442. sd->status.skill_point += level;
  2443. clif_updatestatus(sd, SP_SKILLPOINT);
  2444. status_calc_pc(sd, 0);
  2445. clif_misceffect(&sd->bl, 1);
  2446. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2447. } else {
  2448. if (sd->status.job_level == 1) {
  2449. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2450. return -1;
  2451. }
  2452. level *=-1;
  2453. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2454. level = sd->status.job_level-1;
  2455. sd->status.job_level -= (unsigned int)level;
  2456. clif_updatestatus(sd, SP_JOBLEVEL);
  2457. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2458. if (sd->status.skill_point < level)
  2459. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2460. sd->status.skill_point -= level;
  2461. if (sd->status.skill_point < 0)
  2462. sd->status.skill_point = 0;
  2463. clif_updatestatus(sd, SP_SKILLPOINT);
  2464. status_calc_pc(sd, 0);
  2465. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2466. }
  2467. return 0;
  2468. }
  2469. /*==========================================
  2470. * @help
  2471. *------------------------------------------
  2472. */
  2473. int atcommand_help(
  2474. const int fd, struct map_session_data* sd,
  2475. const char* command, const char* message)
  2476. {
  2477. char buf[2048], w1[2048], w2[2048];
  2478. int i, gm_level;
  2479. FILE* fp;
  2480. nullpo_retr(-1, sd);
  2481. memset(buf, '\0', sizeof(buf));
  2482. if ((fp = fopen(help_txt, "r")) != NULL) {
  2483. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2484. gm_level = pc_isGM(sd);
  2485. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2486. if (buf[0] == '/' && buf[1] == '/')
  2487. continue;
  2488. for (i = 0; buf[i] != '\0'; i++) {
  2489. if (buf[i] == '\r' || buf[i] == '\n') {
  2490. buf[i] = '\0';
  2491. break;
  2492. }
  2493. }
  2494. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2495. clif_displaymessage(fd, buf);
  2496. else if (gm_level >= atoi(w1))
  2497. clif_displaymessage(fd, w2);
  2498. }
  2499. fclose(fp);
  2500. } else {
  2501. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2502. return -1;
  2503. }
  2504. return 0;
  2505. }
  2506. /*==========================================
  2507. * @help2 - Char commands [Kayla]
  2508. *------------------------------------------
  2509. */
  2510. int atcommand_help2(
  2511. const int fd, struct map_session_data* sd,
  2512. const char* command, const char* message)
  2513. {
  2514. char buf[2048], w1[2048], w2[2048];
  2515. int i, gm_level;
  2516. FILE* fp;
  2517. nullpo_retr(-1, sd);
  2518. memset(buf, '\0', sizeof(buf));
  2519. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2520. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2521. gm_level = pc_isGM(sd);
  2522. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2523. if (buf[0] == '/' && buf[1] == '/')
  2524. continue;
  2525. for (i = 0; buf[i] != '\0'; i++) {
  2526. if (buf[i] == '\r' || buf[i] == '\n') {
  2527. buf[i] = '\0';
  2528. break;
  2529. }
  2530. }
  2531. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2532. clif_displaymessage(fd, buf);
  2533. else if (gm_level >= atoi(w1))
  2534. clif_displaymessage(fd, w2);
  2535. }
  2536. fclose(fp);
  2537. } else {
  2538. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2539. return -1;
  2540. }
  2541. return 0;
  2542. }
  2543. /*==========================================
  2544. * @gm
  2545. *------------------------------------------
  2546. */
  2547. int atcommand_gm(
  2548. const int fd, struct map_session_data* sd,
  2549. const char* command, const char* message)
  2550. {
  2551. char password[100];
  2552. nullpo_retr(-1, sd);
  2553. memset(password, '\0', sizeof(password));
  2554. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2555. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2556. return -1;
  2557. }
  2558. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2559. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2560. return -1;
  2561. } else
  2562. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2563. return 0;
  2564. }
  2565. /*==========================================
  2566. *
  2567. *------------------------------------------
  2568. */
  2569. int atcommand_pvpoff(
  2570. const int fd, struct map_session_data* sd,
  2571. const char* command, const char* message)
  2572. {
  2573. struct map_session_data *pl_sd, **pl_allsd;
  2574. int i, users;
  2575. nullpo_retr(-1, sd);
  2576. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2577. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2578. return -1;
  2579. }
  2580. if (map[sd->bl.m].flag.pvp) {
  2581. map[sd->bl.m].flag.pvp = 0;
  2582. clif_send0199(sd->bl.m, 0);
  2583. pl_allsd = map_getallusers(&users);
  2584. for (i = 0; i < users; i++) { //人数分ループ
  2585. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2586. clif_pvpset(pl_sd, 0, 0, 2);
  2587. if (pl_sd->pvp_timer != -1) {
  2588. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2589. pl_sd->pvp_timer = -1;
  2590. }
  2591. }
  2592. }
  2593. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2594. } else {
  2595. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2596. return -1;
  2597. }
  2598. return 0;
  2599. }
  2600. /*==========================================
  2601. *
  2602. *------------------------------------------
  2603. */
  2604. int atcommand_pvpon(
  2605. const int fd, struct map_session_data* sd,
  2606. const char* command, const char* message)
  2607. {
  2608. struct map_session_data *pl_sd, **pl_allsd;
  2609. int i, users;
  2610. nullpo_retr(-1, sd);
  2611. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2612. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2613. return -1;
  2614. }
  2615. if (!map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.nopvp) {
  2616. map[sd->bl.m].flag.pvp = 1;
  2617. clif_send0199(sd->bl.m, 1);
  2618. pl_allsd = map_getallusers(&users);
  2619. for (i = 0; i < users; i++) {
  2620. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2621. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2622. pl_sd->pvp_rank = 0;
  2623. pl_sd->pvp_lastusers = 0;
  2624. pl_sd->pvp_point = 5;
  2625. pl_sd->pvp_won = 0;
  2626. pl_sd->pvp_lost = 0;
  2627. }
  2628. }
  2629. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2630. } else {
  2631. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2632. return -1;
  2633. }
  2634. return 0;
  2635. }
  2636. /*==========================================
  2637. *
  2638. *------------------------------------------
  2639. */
  2640. int atcommand_gvgoff(
  2641. const int fd, struct map_session_data* sd,
  2642. const char* command, const char* message)
  2643. {
  2644. nullpo_retr(-1, sd);
  2645. if (map[sd->bl.m].flag.gvg) {
  2646. map[sd->bl.m].flag.gvg = 0;
  2647. clif_send0199(sd->bl.m, 0);
  2648. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2649. } else {
  2650. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2651. return -1;
  2652. }
  2653. return 0;
  2654. }
  2655. /*==========================================
  2656. *
  2657. *------------------------------------------
  2658. */
  2659. int atcommand_gvgon(
  2660. const int fd, struct map_session_data* sd,
  2661. const char* command, const char* message)
  2662. {
  2663. nullpo_retr(-1, sd);
  2664. if (!map[sd->bl.m].flag.gvg) {
  2665. map[sd->bl.m].flag.gvg = 1;
  2666. clif_send0199(sd->bl.m, 3);
  2667. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2668. } else {
  2669. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2670. return -1;
  2671. }
  2672. return 0;
  2673. }
  2674. /*==========================================
  2675. *
  2676. *------------------------------------------
  2677. */
  2678. int atcommand_model(
  2679. const int fd, struct map_session_data* sd,
  2680. const char* command, const char* message)
  2681. {
  2682. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2683. nullpo_retr(-1, sd);
  2684. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2685. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2686. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2687. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2688. clif_displaymessage(fd, atcmd_output);
  2689. return -1;
  2690. }
  2691. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2692. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2693. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2694. /* Removed because this check is TOO strange. [Skotlex]
  2695. //秒フ色変更
  2696. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2697. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2698. //秒フ色未実装職の判定
  2699. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2700. return -1;
  2701. } else {
  2702. */
  2703. pc_changelook(sd, LOOK_HAIR, hair_style);
  2704. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2705. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2706. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2707. // }
  2708. } else {
  2709. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2710. return -1;
  2711. }
  2712. return 0;
  2713. }
  2714. /*==========================================
  2715. * @dye && @ccolor
  2716. *------------------------------------------
  2717. */
  2718. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2719. {
  2720. int cloth_color = 0;
  2721. nullpo_retr(-1, sd);
  2722. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2723. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2724. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2725. clif_displaymessage(fd, atcmd_output);
  2726. return -1;
  2727. }
  2728. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2729. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2730. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2731. } else {
  2732. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2733. return -1;
  2734. }
  2735. return 0;
  2736. }
  2737. /*==========================================
  2738. * @hairstyle && @hstyle
  2739. *------------------------------------------
  2740. */
  2741. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2742. {
  2743. int hair_style = 0;
  2744. nullpo_retr(-1, sd);
  2745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2746. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2747. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2748. clif_displaymessage(fd, atcmd_output);
  2749. return -1;
  2750. }
  2751. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2752. /* Removed because this check is TOO strange. [Skotlex]
  2753. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2754. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2755. return -1;
  2756. } else {
  2757. */
  2758. pc_changelook(sd, LOOK_HAIR, hair_style);
  2759. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2760. // }
  2761. } else {
  2762. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2763. return -1;
  2764. }
  2765. return 0;
  2766. }
  2767. /*==========================================
  2768. * @charhairstyle by [MouseJstr]
  2769. *------------------------------------------
  2770. */
  2771. int
  2772. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2773. const char* command, const char* message)
  2774. {
  2775. nullpo_retr(-1, sd);
  2776. return 0;
  2777. }
  2778. /*==========================================
  2779. * @haircolor && @hcolor
  2780. *------------------------------------------
  2781. */
  2782. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2783. {
  2784. int hair_color = 0;
  2785. nullpo_retr(-1, sd);
  2786. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2787. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2788. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2789. clif_displaymessage(fd, atcmd_output);
  2790. return -1;
  2791. }
  2792. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2793. /* Removed for being such a strange check. [Skotlex]
  2794. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2795. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2796. return -1;
  2797. } else {
  2798. */
  2799. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2800. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2801. // }
  2802. } else {
  2803. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2804. return -1;
  2805. }
  2806. return 0;
  2807. }
  2808. /*==========================================
  2809. * @go [city_number or city_name] - Updated by Harbin
  2810. *------------------------------------------
  2811. */
  2812. int atcommand_go(
  2813. const int fd, struct map_session_data* sd,
  2814. const char* command, const char* message)
  2815. {
  2816. int i;
  2817. int town;
  2818. char map_name[MAP_NAME_LENGTH];
  2819. int m;
  2820. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2821. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2822. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2823. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2824. { MAP_PAYON, 162, 233 }, // 3=Payon
  2825. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2826. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2827. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2828. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2829. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2830. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2831. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2832. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2833. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2834. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2835. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2836. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2837. { MAP_JAIL, 23, 61 }, // 16=Prison
  2838. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2839. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2840. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2841. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2842. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2843. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2844. };
  2845. nullpo_retr(-1, sd);
  2846. if(map[sd->bl.m].flag.nogo) {
  2847. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2848. return 0;
  2849. }
  2850. memset(map_name, '\0', sizeof(map_name));
  2851. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2852. // get the number
  2853. town = atoi(message);
  2854. // if no value, display all value
  2855. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2856. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2857. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2858. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2859. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2860. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2861. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2862. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2863. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2864. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2865. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2866. return -1;
  2867. } else {
  2868. // get possible name of the city and add .gat if not in the name
  2869. map_name[MAP_NAME_LENGTH-1] = '\0';
  2870. for (i = 0; map_name[i]; i++)
  2871. map_name[i] = tolower(map_name[i]);
  2872. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2873. strcat(map_name, ".gat");
  2874. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2875. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2876. town = 0;
  2877. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2878. town = 1;
  2879. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2880. town = 2;
  2881. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2882. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2883. town = 3;
  2884. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2885. town = 4;
  2886. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2887. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2888. town = 5;
  2889. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2890. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2891. town = 6;
  2892. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2893. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2894. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2895. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2896. town = 7;
  2897. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2898. town = 8;
  2899. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2900. town = 9;
  2901. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2902. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2903. town = 10;
  2904. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2905. town = 11;
  2906. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2907. town = 12;
  2908. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2909. town = 13;
  2910. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2911. town = 14;
  2912. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2913. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2914. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2915. town = 15;
  2916. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2917. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2918. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2919. town = 16;
  2920. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2921. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2922. town = 17;
  2923. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2924. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2925. town = 18;
  2926. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2927. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2928. town = 19;
  2929. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2930. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2931. town = 20;
  2932. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2933. town = 21;
  2934. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2935. town = 22;
  2936. }
  2937. if (town >= -3 && town <= -1) {
  2938. if (sd->status.memo_point[-town-1].map) {
  2939. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2940. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2941. clif_displaymessage(fd, msg_table[247]);
  2942. return -1;
  2943. }
  2944. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2945. clif_displaymessage(fd, msg_table[248]);
  2946. return -1;
  2947. }
  2948. 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) {
  2949. clif_displaymessage(fd, msg_table[0]); // Warped.
  2950. } else {
  2951. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2952. return -1;
  2953. }
  2954. } else {
  2955. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2956. clif_displaymessage(fd, atcmd_output);
  2957. return -1;
  2958. }
  2959. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2960. m = map_mapname2mapid((char *)data[town].map);
  2961. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2962. clif_displaymessage(fd, msg_table[247]);
  2963. return -1;
  2964. }
  2965. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2966. clif_displaymessage(fd, msg_table[248]);
  2967. return -1;
  2968. }
  2969. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2970. clif_displaymessage(fd, msg_table[0]); // Warped.
  2971. } else {
  2972. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2973. return -1;
  2974. }
  2975. } else { // if you arrive here, you have an error in town variable when reading of names
  2976. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2977. return -1;
  2978. }
  2979. }
  2980. return 0;
  2981. }
  2982. /*==========================================
  2983. *
  2984. *------------------------------------------
  2985. */
  2986. int atcommand_monster(
  2987. const int fd, struct map_session_data* sd,
  2988. const char* command, const char* message)
  2989. {
  2990. char name[NAME_LENGTH];
  2991. char monster[NAME_LENGTH];
  2992. int mob_id;
  2993. int number = 0;
  2994. int x = 0, y = 0;
  2995. int count;
  2996. int i, j, k;
  2997. int mx, my, range;
  2998. nullpo_retr(-1, sd);
  2999. memset(name, '\0', sizeof(name));
  3000. memset(monster, '\0', sizeof(monster));
  3001. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3002. if (!message || !*message) {
  3003. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3004. return -1;
  3005. }
  3006. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) > 1 ||
  3007. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) > 1) {
  3008. //All data can be left as it is.
  3009. } else if ((count=sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y)) > 1) {
  3010. //Here, it is possible name was not given and we are using monster for it.
  3011. if (count < 3) //Blank mob's name.
  3012. name[0] = '\0';
  3013. } else if (sscanf(message, "%23s %23s %d %d %d", name, monster, &number, &x, &y) > 1) {
  3014. //All data can be left as it is.
  3015. } else if (sscanf(message, "%23s", monster) > 0) {
  3016. //As before, name may be already filled.
  3017. name[0] = '\0';
  3018. } else {
  3019. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3020. return -1;
  3021. }
  3022. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3023. mob_id = mobdb_checkid(atoi(monster));
  3024. if (mob_id == 0) {
  3025. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3026. return -1;
  3027. }
  3028. if (mob_id == MOBID_EMPERIUM) {
  3029. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3030. return -1;
  3031. }
  3032. if (number <= 0)
  3033. number = 1;
  3034. if (strlen(name) < 1)
  3035. strcpy(name, "--ja--");
  3036. // 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
  3037. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3038. number = battle_config.atc_spawn_quantity_limit;
  3039. if (battle_config.etc_log)
  3040. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, x, y);
  3041. count = 0;
  3042. range = (int)sqrt(number) / 2;
  3043. range = range * 2 + 5; // calculation of an odd number (+ 4 area around)
  3044. for (i = 0; i < number; i++) {
  3045. j = 0;
  3046. k = 0;
  3047. while(j++ < 8 && k == 0) { // try 8 times to spawn the monster (needed for close area)
  3048. if (x <= 0)
  3049. mx = sd->bl.x + (rand() % range - (range / 2));
  3050. else
  3051. mx = x;
  3052. if (y <= 0)
  3053. my = sd->bl.y + (rand() % range - (range / 2));
  3054. else
  3055. my = y;
  3056. k = mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "");
  3057. }
  3058. count += (k != 0) ? 1 : 0;
  3059. }
  3060. if (count != 0)
  3061. if (number == count)
  3062. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3063. else {
  3064. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3065. clif_displaymessage(fd, atcmd_output);
  3066. }
  3067. else {
  3068. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3069. return -1;
  3070. }
  3071. return 0;
  3072. }
  3073. // small monster spawning [Valaris]
  3074. int atcommand_monstersmall(
  3075. const int fd, struct map_session_data* sd,
  3076. const char* command, const char* message) {
  3077. char name[NAME_LENGTH] = "";
  3078. char monster[NAME_LENGTH] = "";
  3079. int mob_id = 0;
  3080. int number = 0;
  3081. int x = 0;
  3082. int y = 0;
  3083. int count;
  3084. int i;
  3085. nullpo_retr(-1, sd);
  3086. if (!message || !*message) {
  3087. clif_displaymessage(fd, "Give a monster name/id please.");
  3088. return -1;
  3089. }
  3090. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3091. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3092. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3093. clif_displaymessage(fd, "Give a monster name/id please.");
  3094. return -1;
  3095. }
  3096. // If monster identifier/name argument is a name
  3097. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3098. mob_id = atoi(monster);
  3099. if (mob_id == 0) {
  3100. clif_displaymessage(fd, msg_table[40]);
  3101. return -1;
  3102. }
  3103. if (mob_id == MOBID_EMPERIUM) {
  3104. clif_displaymessage(fd, msg_table[83]);
  3105. return -1;
  3106. }
  3107. if (mobdb_checkid(mob_id) == 0) {
  3108. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3109. return -1;
  3110. }
  3111. if (number <= 0)
  3112. number = 1;
  3113. if (strlen(name) < 1)
  3114. strcpy(name, "--ja--");
  3115. // 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
  3116. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3117. number = battle_config.atc_spawn_quantity_limit;
  3118. count = 0;
  3119. for (i = 0; i < number; i++) {
  3120. int mx, my;
  3121. if (x <= 0)
  3122. mx = sd->bl.x + (rand() % 11 - 5);
  3123. else
  3124. mx = x;
  3125. if (y <= 0)
  3126. my = sd->bl.y + (rand() % 11 - 5);
  3127. else
  3128. my = y;
  3129. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3130. }
  3131. if (count != 0)
  3132. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3133. else
  3134. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3135. return 0;
  3136. }
  3137. // big monster spawning [Valaris]
  3138. int atcommand_monsterbig(
  3139. const int fd, struct map_session_data* sd,
  3140. const char* command, const char* message) {
  3141. char name[NAME_LENGTH] = "";
  3142. char monster[NAME_LENGTH] = "";
  3143. int mob_id = 0;
  3144. int number = 0;
  3145. int x = 0;
  3146. int y = 0;
  3147. int count;
  3148. int i;
  3149. nullpo_retr(-1, sd);
  3150. if (!message || !*message) {
  3151. clif_displaymessage(fd, "Give a monster name/id please.");
  3152. return -1;
  3153. }
  3154. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3155. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3156. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3157. clif_displaymessage(fd, "Give a monster name/id please.");
  3158. return -1;
  3159. }
  3160. // If monster identifier/name argument is a name
  3161. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3162. mob_id = atoi(monster);
  3163. if (mob_id == 0) {
  3164. clif_displaymessage(fd, msg_table[40]);
  3165. return -1;
  3166. }
  3167. if (mob_id == MOBID_EMPERIUM) {
  3168. clif_displaymessage(fd, msg_table[83]);
  3169. return -1;
  3170. }
  3171. if (mobdb_checkid(mob_id) == 0) {
  3172. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3173. return -1;
  3174. }
  3175. if (number <= 0)
  3176. number = 1;
  3177. if (strlen(name) < 1)
  3178. strcpy(name, "--ja--");
  3179. // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive
  3180. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3181. number = battle_config.atc_spawn_quantity_limit;
  3182. count = 0;
  3183. for (i = 0; i < number; i++) {
  3184. int mx, my;
  3185. if (x <= 0)
  3186. mx = sd->bl.x + (rand() % 11 - 5);
  3187. else
  3188. mx = x;
  3189. if (y <= 0)
  3190. my = sd->bl.y + (rand() % 11 - 5);
  3191. else
  3192. my = y;
  3193. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id+2*MAX_MOB_DB, 1, "") != 0) ? 1 : 0;
  3194. }
  3195. if (count != 0)
  3196. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3197. else
  3198. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3199. return 0;
  3200. }
  3201. /*==========================================
  3202. *
  3203. *------------------------------------------
  3204. */
  3205. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3206. struct mob_data *md;
  3207. int flag;
  3208. nullpo_retr(0, ap);
  3209. nullpo_retr(0, md=(struct mob_data *)bl);
  3210. flag = va_arg(ap, int);
  3211. if (md->guardian_data)
  3212. return 0; //Do not touch WoE mobs!
  3213. if (flag)
  3214. mob_damage(NULL, md, md->hp, 2);
  3215. else
  3216. unit_remove_map(&md->bl,1);
  3217. return 1;
  3218. }
  3219. void atcommand_killmonster_sub(
  3220. const int fd, struct map_session_data* sd, const char* message,
  3221. const int drop)
  3222. {
  3223. int map_id;
  3224. char map_name[MAP_NAME_LENGTH];
  3225. if (!sd) return;
  3226. memset(map_name, '\0', sizeof(map_name));
  3227. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3228. map_id = sd->bl.m;
  3229. else {
  3230. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3231. strcat(map_name, ".gat");
  3232. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3233. map_id = sd->bl.m;
  3234. }
  3235. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3236. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3237. return;
  3238. }
  3239. /*==========================================
  3240. *
  3241. *------------------------------------------
  3242. */
  3243. int atcommand_killmonster(
  3244. const int fd, struct map_session_data* sd,
  3245. const char* command, const char* message)
  3246. {
  3247. if (!sd) return 0;
  3248. atcommand_killmonster_sub(fd, sd, message, 1);
  3249. return 0;
  3250. }
  3251. /*==========================================
  3252. *
  3253. *------------------------------------------
  3254. */
  3255. int atcommand_killmonster2(
  3256. const int fd, struct map_session_data* sd,
  3257. const char* command, const char* message)
  3258. {
  3259. if (!sd) return 0;
  3260. atcommand_killmonster_sub(fd, sd, message, 0);
  3261. return 0;
  3262. }
  3263. /*==========================================
  3264. *
  3265. *------------------------------------------
  3266. */
  3267. int atcommand_refine(
  3268. const int fd, struct map_session_data* sd,
  3269. const char* command, const char* message)
  3270. {
  3271. int i, position = 0, refine = 0, current_position, final_refine;
  3272. int count;
  3273. nullpo_retr(-1, sd);
  3274. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3275. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3276. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3277. return -1;
  3278. }
  3279. if (refine < -10)
  3280. refine = -10;
  3281. else if (refine > 10)
  3282. refine = 10;
  3283. else if (refine == 0)
  3284. refine = 1;
  3285. count = 0;
  3286. for (i = 0; i < MAX_INVENTORY; i++) {
  3287. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3288. (sd->status.inventory[i].equip & position ||
  3289. (sd->status.inventory[i].equip && !position))) {
  3290. final_refine = sd->status.inventory[i].refine + refine;
  3291. if (final_refine > 10)
  3292. final_refine = 10;
  3293. else if (final_refine < 0)
  3294. final_refine = 0;
  3295. if (sd->status.inventory[i].refine != final_refine) {
  3296. sd->status.inventory[i].refine = final_refine;
  3297. current_position = sd->status.inventory[i].equip;
  3298. pc_unequipitem(sd, i, 3);
  3299. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3300. clif_delitem(sd, i, 1);
  3301. clif_additem(sd, i, 1, 0);
  3302. pc_equipitem(sd, i, current_position);
  3303. clif_misceffect((struct block_list*)&sd->bl, 3);
  3304. count++;
  3305. }
  3306. }
  3307. }
  3308. if (count == 0)
  3309. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3310. else if (count == 1)
  3311. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3312. else {
  3313. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3314. clif_displaymessage(fd, atcmd_output);
  3315. }
  3316. return 0;
  3317. }
  3318. /*==========================================
  3319. *
  3320. *------------------------------------------
  3321. */
  3322. int atcommand_produce(
  3323. const int fd, struct map_session_data* sd,
  3324. const char* command, const char* message)
  3325. {
  3326. char item_name[100];
  3327. int item_id, attribute = 0, star = 0;
  3328. int flag = 0;
  3329. struct item_data *item_data;
  3330. struct item tmp_item;
  3331. nullpo_retr(-1, sd);
  3332. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3333. memset(item_name, '\0', sizeof(item_name));
  3334. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3335. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3336. return -1;
  3337. }
  3338. item_id = 0;
  3339. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3340. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3341. item_id = item_data->nameid;
  3342. if (itemdb_exists(item_id) &&
  3343. (item_id <= 500 || item_id > 1099) &&
  3344. (item_id < 4001 || item_id > 4148) &&
  3345. (item_id < 7001 || item_id > 10019) &&
  3346. itemdb_isequip(item_id)) {
  3347. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3348. attribute = ATTRIBUTE_NORMAL;
  3349. if (star < MIN_STAR || star > MAX_STAR)
  3350. star = 0;
  3351. memset(&tmp_item, 0, sizeof tmp_item);
  3352. tmp_item.nameid = item_id;
  3353. tmp_item.amount = 1;
  3354. tmp_item.identify = 1;
  3355. tmp_item.card[0] = 0x00ff;
  3356. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3357. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3358. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3359. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3360. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3361. //Logs (A)dmins items [Lupus]
  3362. if(log_config.pick > 0 ) {
  3363. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3364. }
  3365. //Logs
  3366. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3367. clif_additem(sd, 0, 0, flag);
  3368. } else {
  3369. if (battle_config.error_log)
  3370. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3371. if (item_id != 0 && itemdb_exists(item_id))
  3372. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3373. else
  3374. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3375. clif_displaymessage(fd, atcmd_output);
  3376. return -1;
  3377. }
  3378. return 0;
  3379. }
  3380. /*==========================================
  3381. * Sub-function to display actual memo points
  3382. *------------------------------------------
  3383. */
  3384. void atcommand_memo_sub(struct map_session_data* sd) {
  3385. int i;
  3386. if (!sd) return;
  3387. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3388. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3389. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3390. if (sd->status.memo_point[i].map)
  3391. 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);
  3392. else
  3393. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3394. clif_displaymessage(sd->fd, atcmd_output);
  3395. }
  3396. return;
  3397. }
  3398. /*==========================================
  3399. *
  3400. *------------------------------------------
  3401. */
  3402. int atcommand_memo(
  3403. const int fd, struct map_session_data* sd,
  3404. const char* command, const char* message)
  3405. {
  3406. int position = 0;
  3407. nullpo_retr(-1, sd);
  3408. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3409. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3410. atcommand_memo_sub(sd);
  3411. else {
  3412. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3413. 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)) {
  3414. clif_displaymessage(fd, msg_table[253]);
  3415. return -1;
  3416. }
  3417. if (sd->status.memo_point[position].map) {
  3418. 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).
  3419. clif_displaymessage(fd, atcmd_output);
  3420. }
  3421. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3422. sd->status.memo_point[position].x = sd->bl.x;
  3423. sd->status.memo_point[position].y = sd->bl.y;
  3424. clif_skill_memo(sd, 0);
  3425. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3426. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3427. atcommand_memo_sub(sd);
  3428. } else {
  3429. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3430. clif_displaymessage(fd, atcmd_output);
  3431. atcommand_memo_sub(sd);
  3432. return -1;
  3433. }
  3434. }
  3435. return 0;
  3436. }
  3437. /*==========================================
  3438. *
  3439. *------------------------------------------
  3440. */
  3441. int atcommand_gat(
  3442. const int fd, struct map_session_data* sd,
  3443. const char* command, const char* message)
  3444. {
  3445. int y;
  3446. nullpo_retr(-1, sd);
  3447. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3448. for (y = 2; y >= -2; y--) {
  3449. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3450. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3451. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3452. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3453. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  3454. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  3455. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  3456. clif_displaymessage(fd, atcmd_output);
  3457. }
  3458. return 0;
  3459. }
  3460. /*==========================================
  3461. *
  3462. *------------------------------------------
  3463. */
  3464. int atcommand_packet(
  3465. const int fd, struct map_session_data* sd,
  3466. const char* command, const char* message)
  3467. {
  3468. static int packet_mode = 0;
  3469. int i, x = 0, y = 0;
  3470. nullpo_retr(-1, sd);
  3471. if (strstr(command, "packetmode")) {
  3472. packet_mode = atoi(message);
  3473. clif_displaymessage(fd, "Packet mode changed.");
  3474. return 0;
  3475. }
  3476. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3477. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3478. return -1;
  3479. }
  3480. if (i == 1) y = 1;
  3481. switch (packet_mode)
  3482. {
  3483. case 0:
  3484. clif_status_change(&sd->bl, x, y);
  3485. break;
  3486. case 1:
  3487. sd->status.skill[sd->cloneskill_id].id=0;
  3488. sd->status.skill[sd->cloneskill_id].lv=0;
  3489. sd->status.skill[sd->cloneskill_id].flag=0;
  3490. sd->cloneskill_id = x;
  3491. sd->status.skill[x].id = x;
  3492. sd->status.skill[x].lv = skill_get_max(x);
  3493. sd->status.skill[x].flag = 13;//cloneskill flag
  3494. clif_skillinfoblock(sd);
  3495. break;
  3496. case 2:
  3497. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3498. case 3:
  3499. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3500. default:
  3501. break;
  3502. //added later
  3503. }
  3504. return 0;
  3505. }
  3506. /*==========================================
  3507. * @waterlevel [Skotlex]
  3508. *------------------------------------------
  3509. */
  3510. int atcommand_waterlevel(
  3511. const int fd, struct map_session_data* sd,
  3512. const char* command, const char* message)
  3513. {
  3514. int newlevel;
  3515. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3516. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3517. clif_displaymessage(fd, atcmd_output);
  3518. return 0;
  3519. }
  3520. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3521. if (newlevel > 0)
  3522. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3523. else
  3524. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3525. clif_displaymessage(fd, atcmd_output);
  3526. } else {
  3527. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3528. clif_displaymessage(fd, atcmd_output);
  3529. }
  3530. return 0;
  3531. }
  3532. /*==========================================
  3533. * @stpoint (Rewritten by [Yor])
  3534. *------------------------------------------
  3535. */
  3536. int atcommand_statuspoint(
  3537. const int fd, struct map_session_data* sd,
  3538. const char* command, const char* message)
  3539. {
  3540. int point, new_status_point;
  3541. if (!message || !*message || (point = atoi(message)) == 0) {
  3542. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3543. return -1;
  3544. }
  3545. new_status_point = (int)sd->status.status_point + point;
  3546. if (point > 0 && (point > 0x7FFF || new_status_point > 0x7FFF)) // fix positiv overflow
  3547. new_status_point = 0x7FFF;
  3548. else if (point < 0 && (point < -0x7FFF || new_status_point < 0)) // fix negativ overflow
  3549. new_status_point = 0;
  3550. if (new_status_point != (int)sd->status.status_point) {
  3551. sd->status.status_point = (short)new_status_point;
  3552. clif_updatestatus(sd, SP_STATUSPOINT);
  3553. clif_displaymessage(fd, msg_table[174]); // Number of status points changed!
  3554. } else {
  3555. if (point < 0)
  3556. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3557. else
  3558. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3559. return -1;
  3560. }
  3561. return 0;
  3562. }
  3563. /*==========================================
  3564. * @skpoint (Rewritten by [Yor])
  3565. *------------------------------------------
  3566. */
  3567. int atcommand_skillpoint(
  3568. const int fd, struct map_session_data* sd,
  3569. const char* command, const char* message)
  3570. {
  3571. int point, new_skill_point;
  3572. nullpo_retr(-1, sd);
  3573. if (!message || !*message || (point = atoi(message)) == 0) {
  3574. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  3575. return -1;
  3576. }
  3577. new_skill_point = (int)sd->status.skill_point + point;
  3578. if (point > 0 && (point > 0x7FFF || new_skill_point > 0x7FFF)) // fix positiv overflow
  3579. new_skill_point = 0x7FFF;
  3580. else if (point < 0 && (point < -0x7FFF || new_skill_point < 0)) // fix negativ overflow
  3581. new_skill_point = 0;
  3582. if (new_skill_point != (int)sd->status.skill_point) {
  3583. sd->status.skill_point = (short)new_skill_point;
  3584. clif_updatestatus(sd, SP_SKILLPOINT);
  3585. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3586. } else {
  3587. if (point < 0)
  3588. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3589. else
  3590. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3591. return -1;
  3592. }
  3593. return 0;
  3594. }
  3595. /*==========================================
  3596. * @zeny (Rewritten by [Yor])
  3597. *------------------------------------------
  3598. */
  3599. int atcommand_zeny(
  3600. const int fd, struct map_session_data* sd,
  3601. const char* command, const char* message)
  3602. {
  3603. int zeny, new_zeny;
  3604. nullpo_retr(-1, sd);
  3605. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3606. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3607. return -1;
  3608. }
  3609. new_zeny = sd->status.zeny + zeny;
  3610. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3611. new_zeny = MAX_ZENY;
  3612. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3613. new_zeny = 0;
  3614. if (new_zeny != sd->status.zeny) {
  3615. sd->status.zeny = new_zeny;
  3616. clif_updatestatus(sd, SP_ZENY);
  3617. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3618. } else {
  3619. if (zeny < 0)
  3620. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3621. else
  3622. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3623. return -1;
  3624. }
  3625. return 0;
  3626. }
  3627. /*==========================================
  3628. *
  3629. *------------------------------------------
  3630. */
  3631. int atcommand_param(
  3632. const int fd, struct map_session_data* sd,
  3633. const char* command, const char* message)
  3634. {
  3635. int i, index, value = 0, new_value;
  3636. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3637. short* status[] = {
  3638. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3639. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3640. };
  3641. nullpo_retr(-1, sd);
  3642. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3643. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3644. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3645. clif_displaymessage(fd, atcmd_output);
  3646. return -1;
  3647. }
  3648. index = -1;
  3649. for (i = 0; param[i] != NULL; i++) {
  3650. if (strcmpi(command, param[i]) == 0) {
  3651. index = i;
  3652. break;
  3653. }
  3654. }
  3655. if (index < 0 || index > MAX_STATUS_TYPE) { // normaly impossible...
  3656. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3657. clif_displaymessage(fd, atcmd_output);
  3658. return -1;
  3659. }
  3660. new_value = (int)*status[index] + value;
  3661. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3662. new_value = pc_maxparameter(sd);
  3663. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negativ overflow
  3664. new_value = 1;
  3665. if (new_value != (int)*status[index]) {
  3666. *status[index] = new_value;
  3667. clif_updatestatus(sd, SP_STR + index);
  3668. clif_updatestatus(sd, SP_USTR + index);
  3669. status_calc_pc(sd, 0);
  3670. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3671. } else {
  3672. if (value < 0)
  3673. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3674. else
  3675. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3676. return -1;
  3677. }
  3678. return 0;
  3679. }
  3680. /*==========================================
  3681. *
  3682. *------------------------------------------
  3683. */
  3684. //** Stat all by fritz (rewritten by [Yor])
  3685. int atcommand_stat_all(
  3686. const int fd, struct map_session_data* sd,
  3687. const char* command, const char* message)
  3688. {
  3689. int index, count, value = 0, new_value;
  3690. short* status[] = {
  3691. &sd->status.str, &sd->status.agi, &sd->status.vit,
  3692. &sd->status.int_, &sd->status.dex, &sd->status.luk
  3693. };
  3694. nullpo_retr(-1, sd);
  3695. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3696. value = pc_maxparameter(sd);
  3697. count = 0;
  3698. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3699. new_value = (int)*status[index] + value;
  3700. if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
  3701. new_value = pc_maxparameter(sd);
  3702. else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negative overflow
  3703. new_value = 1;
  3704. if (new_value != (int)*status[index]) {
  3705. *status[index] = new_value;
  3706. clif_updatestatus(sd, SP_STR + index);
  3707. clif_updatestatus(sd, SP_USTR + index);
  3708. status_calc_pc(sd, 0);
  3709. count++;
  3710. }
  3711. }
  3712. if (count > 0) // if at least 1 stat modified
  3713. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3714. else {
  3715. if (value < 0)
  3716. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3717. else
  3718. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3719. return -1;
  3720. }
  3721. return 0;
  3722. }
  3723. /*==========================================
  3724. *
  3725. *------------------------------------------
  3726. */
  3727. int atcommand_guildlevelup(
  3728. const int fd, struct map_session_data* sd,
  3729. const char* command, const char* message)
  3730. {
  3731. int level = 0;
  3732. short added_level;
  3733. struct guild *guild_info;
  3734. nullpo_retr(-1, sd);
  3735. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3736. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3737. return -1;
  3738. }
  3739. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3740. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3741. return -1;
  3742. }
  3743. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3744. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3745. return -1;
  3746. }
  3747. added_level = (short)level;
  3748. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3749. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3750. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3751. added_level = 1 - guild_info->guild_lv;
  3752. if (added_level != 0) {
  3753. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3754. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3755. } else {
  3756. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3757. return -1;
  3758. }
  3759. return 0;
  3760. }
  3761. /*==========================================
  3762. *
  3763. *------------------------------------------
  3764. */
  3765. int atcommand_makeegg(
  3766. const int fd, struct map_session_data* sd,
  3767. const char* command, const char* message)
  3768. {
  3769. struct item_data *item_data;
  3770. int id, pet_id;
  3771. nullpo_retr(-1, sd);
  3772. if (!message || !*message) {
  3773. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3774. return -1;
  3775. }
  3776. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3777. id = item_data->nameid;
  3778. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3779. id = atoi(message);
  3780. pet_id = search_petDB_index(id, PET_CLASS);
  3781. if (pet_id < 0)
  3782. pet_id = search_petDB_index(id, PET_EGG);
  3783. if (pet_id >= 0) {
  3784. sd->catch_target_class = pet_db[pet_id].class_;
  3785. intif_create_pet(
  3786. sd->status.account_id, sd->status.char_id,
  3787. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3788. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3789. 100, 0, 1, pet_db[pet_id].jname);
  3790. } else {
  3791. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3792. return -1;
  3793. }
  3794. return 0;
  3795. }
  3796. /*==========================================
  3797. *
  3798. *------------------------------------------
  3799. */
  3800. int atcommand_hatch(
  3801. const int fd, struct map_session_data* sd,
  3802. const char* command, const char* message)
  3803. {
  3804. nullpo_retr(-1, sd);
  3805. if (sd->status.pet_id <= 0)
  3806. clif_sendegg(sd);
  3807. else {
  3808. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3809. return -1;
  3810. }
  3811. return 0;
  3812. }
  3813. /*==========================================
  3814. *
  3815. *------------------------------------------
  3816. */
  3817. int atcommand_petfriendly(
  3818. const int fd, struct map_session_data* sd,
  3819. const char* command, const char* message)
  3820. {
  3821. int friendly;
  3822. int t;
  3823. nullpo_retr(-1, sd);
  3824. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3825. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3826. return -1;
  3827. }
  3828. if (sd->status.pet_id > 0 && sd->pd) {
  3829. if (friendly >= 0 && friendly <= 1000) {
  3830. if (friendly != sd->pet.intimate) {
  3831. t = sd->pet.intimate;
  3832. sd->pet.intimate = friendly;
  3833. clif_send_petstatus(sd);
  3834. if (battle_config.pet_status_support) {
  3835. if ((sd->pet.intimate > 0 && t <= 0) ||
  3836. (sd->pet.intimate <= 0 && t > 0)) {
  3837. if (sd->bl.prev != NULL)
  3838. status_calc_pc(sd, 0);
  3839. else
  3840. status_calc_pc(sd, 2);
  3841. }
  3842. }
  3843. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3844. } else {
  3845. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3846. return -1;
  3847. }
  3848. } else {
  3849. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3850. return -1;
  3851. }
  3852. } else {
  3853. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3854. return -1;
  3855. }
  3856. return 0;
  3857. }
  3858. /*==========================================
  3859. *
  3860. *------------------------------------------
  3861. */
  3862. int atcommand_pethungry(
  3863. const int fd, struct map_session_data* sd,
  3864. const char* command, const char* message)
  3865. {
  3866. int hungry;
  3867. nullpo_retr(-1, sd);
  3868. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3869. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3870. return -1;
  3871. }
  3872. if (sd->status.pet_id > 0 && sd->pd) {
  3873. if (hungry >= 0 && hungry <= 100) {
  3874. if (hungry != sd->pet.hungry) {
  3875. sd->pet.hungry = hungry;
  3876. clif_send_petstatus(sd);
  3877. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3878. } else {
  3879. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3880. return -1;
  3881. }
  3882. } else {
  3883. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3884. return -1;
  3885. }
  3886. } else {
  3887. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3888. return -1;
  3889. }
  3890. return 0;
  3891. }
  3892. /*==========================================
  3893. *
  3894. *------------------------------------------
  3895. */
  3896. int atcommand_petrename(
  3897. const int fd, struct map_session_data* sd,
  3898. const char* command, const char* message)
  3899. {
  3900. nullpo_retr(-1, sd);
  3901. if (sd->status.pet_id > 0 && sd->pd) {
  3902. if (sd->pet.rename_flag != 0) {
  3903. sd->pet.rename_flag = 0;
  3904. intif_save_petdata(sd->status.account_id, &sd->pet);
  3905. clif_send_petstatus(sd);
  3906. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3907. } else {
  3908. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3909. return -1;
  3910. }
  3911. } else {
  3912. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3913. return -1;
  3914. }
  3915. return 0;
  3916. }
  3917. /*==========================================
  3918. *
  3919. *------------------------------------------
  3920. */
  3921. int
  3922. atcommand_recall(
  3923. const int fd, struct map_session_data* sd,
  3924. const char* command, const char* message)
  3925. {
  3926. struct map_session_data *pl_sd = NULL;
  3927. nullpo_retr(-1, sd);
  3928. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3929. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3930. return -1;
  3931. }
  3932. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3933. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3934. return -1;
  3935. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3936. return -1;
  3937. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3938. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3939. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3940. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3941. return -1;
  3942. }
  3943. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3944. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3945. return -1;
  3946. }
  3947. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3948. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3949. clif_displaymessage(fd, atcmd_output);
  3950. } else {
  3951. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3952. return -1;
  3953. }
  3954. } else {
  3955. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3956. return -1;
  3957. }
  3958. return 0;
  3959. }
  3960. /*==========================================
  3961. *
  3962. *------------------------------------------
  3963. */
  3964. int atcommand_revive(
  3965. const int fd, struct map_session_data* sd,
  3966. const char* command, const char* message)
  3967. {
  3968. struct map_session_data *pl_sd;
  3969. nullpo_retr(-1, sd);
  3970. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3971. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3972. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3973. return -1;
  3974. }
  3975. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3976. if (pc_isdead(pl_sd)) {
  3977. pl_sd->status.hp = pl_sd->status.max_hp;
  3978. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3979. pc_setstand(pl_sd);
  3980. if (battle_config.pc_invincible_time > 0)
  3981. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3982. clif_updatestatus(pl_sd, SP_HP);
  3983. clif_updatestatus(pl_sd, SP_SP);
  3984. clif_resurrection(&pl_sd->bl, 1);
  3985. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3986. return 0;
  3987. }
  3988. return -1;
  3989. } else {
  3990. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3991. return -1;
  3992. }
  3993. return 0;
  3994. }
  3995. /*==========================================
  3996. * charblock command (usage: charblock <player_name>)
  3997. * This command do a definitiv ban on a player
  3998. *------------------------------------------
  3999. */
  4000. int atcommand_char_block(
  4001. const int fd, struct map_session_data* sd,
  4002. const char* command, const char* message)
  4003. {
  4004. nullpo_retr(-1, sd);
  4005. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4006. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4007. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4008. return -1;
  4009. }
  4010. // check player name
  4011. if (strlen(atcmd_player_name) < 4) {
  4012. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4013. return -1;
  4014. } else if (strlen(atcmd_player_name) > 23) {
  4015. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4016. return -1;
  4017. } else {
  4018. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4019. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4020. }
  4021. return 0;
  4022. }
  4023. /*==========================================
  4024. * charban command (usage: charban <time> <player_name>)
  4025. * This command do a limited ban on a player
  4026. * Time is done as follows:
  4027. * Adjustment value (-1, 1, +1, etc...)
  4028. * Modified element:
  4029. * a or y: year
  4030. * m: month
  4031. * j or d: day
  4032. * h: hour
  4033. * mn: minute
  4034. * s: second
  4035. * <example> @ban +1m-2mn1s-6y test_player
  4036. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4037. *------------------------------------------
  4038. */
  4039. int atcommand_char_ban(
  4040. const int fd, struct map_session_data* sd,
  4041. const char* command, const char* message)
  4042. {
  4043. char * modif_p;
  4044. int year, month, day, hour, minute, second, value;
  4045. nullpo_retr(-1, sd);
  4046. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4047. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4048. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4049. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4050. return -1;
  4051. }
  4052. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4053. modif_p = atcmd_output;
  4054. year = month = day = hour = minute = second = 0;
  4055. while (modif_p[0] != '\0') {
  4056. value = atoi(modif_p);
  4057. if (value == 0)
  4058. modif_p++;
  4059. else {
  4060. if (modif_p[0] == '-' || modif_p[0] == '+')
  4061. modif_p++;
  4062. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4063. modif_p++;
  4064. if (modif_p[0] == 's') {
  4065. second = value;
  4066. modif_p++;
  4067. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4068. minute = value;
  4069. modif_p = modif_p + 2;
  4070. } else if (modif_p[0] == 'h') {
  4071. hour = value;
  4072. modif_p++;
  4073. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4074. day = value;
  4075. modif_p++;
  4076. } else if (modif_p[0] == 'm') {
  4077. month = value;
  4078. modif_p++;
  4079. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4080. year = value;
  4081. modif_p++;
  4082. } else if (modif_p[0] != '\0') {
  4083. modif_p++;
  4084. }
  4085. }
  4086. }
  4087. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4088. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4089. return -1;
  4090. }
  4091. // check player name
  4092. if (strlen(atcmd_player_name) < 4) {
  4093. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4094. return -1;
  4095. } else if (strlen(atcmd_player_name) > 23) {
  4096. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4097. return -1;
  4098. } else {
  4099. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4100. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4101. }
  4102. return 0;
  4103. }
  4104. /*==========================================
  4105. * charunblock command (usage: charunblock <player_name>)
  4106. *------------------------------------------
  4107. */
  4108. int atcommand_char_unblock(
  4109. const int fd, struct map_session_data* sd,
  4110. const char* command, const char* message)
  4111. {
  4112. nullpo_retr(-1, sd);
  4113. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4114. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4115. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4116. return -1;
  4117. }
  4118. // check player name
  4119. if (strlen(atcmd_player_name) < 4) {
  4120. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4121. return -1;
  4122. } else if (strlen(atcmd_player_name) > 23) {
  4123. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4124. return -1;
  4125. } else {
  4126. // send answer to login server via char-server
  4127. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4128. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4129. }
  4130. return 0;
  4131. }
  4132. /*==========================================
  4133. * charunban command (usage: charunban <player_name>)
  4134. *------------------------------------------
  4135. */
  4136. int atcommand_char_unban(
  4137. const int fd, struct map_session_data* sd,
  4138. const char* command, const char* message)
  4139. {
  4140. nullpo_retr(-1, sd);
  4141. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4142. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4143. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4144. return -1;
  4145. }
  4146. // check player name
  4147. if (strlen(atcmd_player_name) < 4) {
  4148. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4149. return -1;
  4150. } else if (strlen(atcmd_player_name) > 23) {
  4151. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4152. return -1;
  4153. } else {
  4154. // send answer to login server via char-server
  4155. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4156. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4157. }
  4158. return 0;
  4159. }
  4160. /*==========================================
  4161. *
  4162. *------------------------------------------
  4163. */
  4164. int atcommand_night(
  4165. const int fd, struct map_session_data* sd,
  4166. const char* command, const char* message)
  4167. {
  4168. nullpo_retr(-1, sd);
  4169. if (night_flag != 1) {
  4170. map_night_timer(night_timer_tid, 0, 0, 1);
  4171. } else {
  4172. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4173. return -1;
  4174. }
  4175. return 0;
  4176. }
  4177. /*==========================================
  4178. *
  4179. *------------------------------------------
  4180. */
  4181. int atcommand_day(
  4182. const int fd, struct map_session_data* sd,
  4183. const char* command, const char* message)
  4184. {
  4185. nullpo_retr(-1, sd);
  4186. if (night_flag != 0) {
  4187. map_day_timer(day_timer_tid, 0, 0, 1);
  4188. } else {
  4189. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4190. return -1;
  4191. }
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. *
  4196. *------------------------------------------
  4197. */
  4198. int atcommand_doom(
  4199. const int fd, struct map_session_data* sd,
  4200. const char* command, const char* message)
  4201. {
  4202. struct map_session_data *pl_sd, **pl_allsd;
  4203. int i, users;
  4204. nullpo_retr(-1, sd);
  4205. clif_specialeffect(&sd->bl,450,2);
  4206. pl_allsd = map_getallusers(&users);
  4207. for(i = 0; i < users; i++) {
  4208. 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
  4209. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4210. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4211. }
  4212. }
  4213. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4214. return 0;
  4215. }
  4216. /*==========================================
  4217. *
  4218. *------------------------------------------
  4219. */
  4220. int atcommand_doommap(
  4221. const int fd, struct map_session_data* sd,
  4222. const char* command, const char* message)
  4223. {
  4224. struct map_session_data *pl_sd, **pl_allsd;
  4225. int i, users;
  4226. nullpo_retr(-1, sd);
  4227. clif_specialeffect(&sd->bl,450,3);
  4228. pl_allsd = map_getallusers(&users);
  4229. for (i = 0; i < users; i++) {
  4230. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4231. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4232. {
  4233. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4234. // clif_specialeffect(&pl_sd->bl,450,1);
  4235. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4236. }
  4237. }
  4238. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4239. return 0;
  4240. }
  4241. /*==========================================
  4242. *
  4243. *------------------------------------------
  4244. */
  4245. static void atcommand_raise_sub(struct map_session_data* sd)
  4246. {
  4247. if (sd && sd->state.auth && pc_isdead(sd)) {
  4248. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4249. sd->status.hp = sd->status.max_hp;
  4250. sd->status.sp = sd->status.max_sp;
  4251. pc_setstand(sd);
  4252. clif_updatestatus(sd, SP_HP);
  4253. clif_updatestatus(sd, SP_SP);
  4254. clif_resurrection(&sd->bl, 1);
  4255. if (battle_config.pc_invincible_time > 0)
  4256. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4257. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4258. }
  4259. }
  4260. /*==========================================
  4261. *
  4262. *------------------------------------------
  4263. */
  4264. int atcommand_raise(
  4265. const int fd, struct map_session_data* sd,
  4266. const char* command, const char* message)
  4267. {
  4268. int i, users;
  4269. struct map_session_data **all_sd;
  4270. nullpo_retr(-1, sd);
  4271. all_sd = map_getallusers(&users);
  4272. for (i = 0; i < users; i++) {
  4273. atcommand_raise_sub(all_sd[i]);
  4274. }
  4275. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4276. return 0;
  4277. }
  4278. /*==========================================
  4279. *
  4280. *------------------------------------------
  4281. */
  4282. int atcommand_raisemap(
  4283. const int fd, struct map_session_data* sd,
  4284. const char* command, const char* message)
  4285. {
  4286. struct map_session_data **pl_allsd;
  4287. int i, users;
  4288. nullpo_retr(-1, sd);
  4289. pl_allsd = map_getallusers(&users);
  4290. for (i = 0; i < users; i++) {
  4291. if (sd->bl.m == pl_allsd[i]->bl.m)
  4292. atcommand_raise_sub(pl_allsd[i]);
  4293. }
  4294. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4295. return 0;
  4296. }
  4297. /*==========================================
  4298. *
  4299. *------------------------------------------
  4300. */
  4301. int atcommand_kick(
  4302. const int fd, struct map_session_data* sd,
  4303. const char* command, const char* message)
  4304. {
  4305. struct map_session_data *pl_sd;
  4306. nullpo_retr(-1, sd);
  4307. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4308. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4309. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4310. return -1;
  4311. }
  4312. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4313. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4314. clif_GM_kick(sd, pl_sd, 1);
  4315. else {
  4316. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4317. return -1;
  4318. }
  4319. } else {
  4320. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4321. return -1;
  4322. }
  4323. return 0;
  4324. }
  4325. /*==========================================
  4326. *
  4327. *------------------------------------------
  4328. */
  4329. int atcommand_kickall(
  4330. const int fd, struct map_session_data* sd,
  4331. const char* command, const char* message)
  4332. {
  4333. struct map_session_data *pl_sd, **pl_allsd;
  4334. int i, users;
  4335. nullpo_retr(-1, sd);
  4336. pl_allsd = map_getallusers(&users);
  4337. for (i = 0; i < users; i++) {
  4338. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4339. if (sd->status.account_id != pl_sd->status.account_id)
  4340. clif_GM_kick(sd, pl_sd, 0);
  4341. }
  4342. }
  4343. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4344. return 0;
  4345. }
  4346. /*==========================================
  4347. *
  4348. *------------------------------------------
  4349. */
  4350. int atcommand_allskill(
  4351. const int fd, struct map_session_data* sd,
  4352. const char* command, const char* message)
  4353. {
  4354. nullpo_retr(-1, sd);
  4355. pc_allskillup(sd); // all skills
  4356. sd->status.skill_point = 0; // 0 skill points
  4357. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4358. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4359. return 0;
  4360. }
  4361. /*==========================================
  4362. *
  4363. *------------------------------------------
  4364. */
  4365. int atcommand_questskill(
  4366. const int fd, struct map_session_data* sd,
  4367. const char* command, const char* message)
  4368. {
  4369. int skill_id;
  4370. nullpo_retr(-1, sd);
  4371. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4372. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4373. return -1;
  4374. }
  4375. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4376. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4377. if (pc_checkskill(sd, skill_id) == 0) {
  4378. pc_skill(sd, skill_id, 1, 0);
  4379. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4380. } else {
  4381. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4382. return -1;
  4383. }
  4384. } else {
  4385. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4386. return -1;
  4387. }
  4388. } else {
  4389. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4390. return -1;
  4391. }
  4392. return 0;
  4393. }
  4394. /*==========================================
  4395. *
  4396. *------------------------------------------
  4397. */
  4398. int atcommand_lostskill(
  4399. const int fd, struct map_session_data* sd,
  4400. const char* command, const char* message)
  4401. {
  4402. int skill_id;
  4403. nullpo_retr(-1, sd);
  4404. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4405. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4406. return -1;
  4407. }
  4408. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4409. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4410. if (pc_checkskill(sd, skill_id) > 0) {
  4411. sd->status.skill[skill_id].lv = 0;
  4412. sd->status.skill[skill_id].flag = 0;
  4413. clif_skillinfoblock(sd);
  4414. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4415. } else {
  4416. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4417. return -1;
  4418. }
  4419. } else {
  4420. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4421. return -1;
  4422. }
  4423. } else {
  4424. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4425. return -1;
  4426. }
  4427. return 0;
  4428. }
  4429. /*==========================================
  4430. *
  4431. *------------------------------------------
  4432. */
  4433. int atcommand_spiritball(
  4434. const int fd, struct map_session_data* sd,
  4435. const char* command, const char* message)
  4436. {
  4437. int number;
  4438. nullpo_retr(-1, sd);
  4439. if (!message || !*message || (number = atoi(message)) < 0) {
  4440. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4441. return -1;
  4442. }
  4443. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4444. if (number > 500)
  4445. number = 500;
  4446. if (number >= 0 && number <= 0x7FFF) {
  4447. if (sd->spiritball != number || number > 499) {
  4448. if (sd->spiritball > 0)
  4449. pc_delspiritball(sd, sd->spiritball, 1);
  4450. sd->spiritball = number;
  4451. clif_spiritball(sd);
  4452. // no message, player can look the difference
  4453. if (number > 1000)
  4454. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4455. } else {
  4456. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4457. return -1;
  4458. }
  4459. } else {
  4460. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4461. return -1;
  4462. }
  4463. return 0;
  4464. }
  4465. /*==========================================
  4466. *
  4467. *------------------------------------------
  4468. */
  4469. int atcommand_party(
  4470. const int fd, struct map_session_data* sd,
  4471. const char* command, const char* message)
  4472. {
  4473. char party[NAME_LENGTH];
  4474. nullpo_retr(-1, sd);
  4475. memset(party, '\0', sizeof(party));
  4476. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4477. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4478. return -1;
  4479. }
  4480. party_create(sd, party, 0, 0);
  4481. return 0;
  4482. }
  4483. /*==========================================
  4484. *
  4485. *------------------------------------------
  4486. */
  4487. int atcommand_guild(
  4488. const int fd, struct map_session_data* sd,
  4489. const char* command, const char* message)
  4490. {
  4491. char guild[NAME_LENGTH];
  4492. int prev;
  4493. nullpo_retr(-1, sd);
  4494. memset(guild, '\0', sizeof(guild));
  4495. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4496. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4497. return -1;
  4498. }
  4499. prev = battle_config.guild_emperium_check;
  4500. battle_config.guild_emperium_check = 0;
  4501. guild_create(sd, guild);
  4502. battle_config.guild_emperium_check = prev;
  4503. return 0;
  4504. }
  4505. /*==========================================
  4506. *
  4507. *------------------------------------------
  4508. */
  4509. int atcommand_agitstart(
  4510. const int fd, struct map_session_data* sd,
  4511. const char* command, const char* message)
  4512. {
  4513. nullpo_retr(-1, sd);
  4514. if (agit_flag == 1) {
  4515. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4516. return -1;
  4517. }
  4518. agit_flag = 1;
  4519. guild_agit_start();
  4520. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4521. return 0;
  4522. }
  4523. /*==========================================
  4524. *
  4525. *------------------------------------------
  4526. */
  4527. int atcommand_agitend(
  4528. const int fd, struct map_session_data* sd,
  4529. const char* command, const char* message)
  4530. {
  4531. nullpo_retr(-1, sd);
  4532. if (agit_flag == 0) {
  4533. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4534. return -1;
  4535. }
  4536. agit_flag = 0;
  4537. guild_agit_end();
  4538. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4539. return 0;
  4540. }
  4541. /*==========================================
  4542. * @mapexitでマップサーバーを終了させる
  4543. *------------------------------------------
  4544. */
  4545. int atcommand_mapexit(
  4546. const int fd, struct map_session_data* sd,
  4547. const char* command, const char* message)
  4548. {
  4549. struct map_session_data *pl_sd, **pl_allsd;
  4550. int i, users;
  4551. nullpo_retr(-1, sd);
  4552. pl_allsd = map_getallusers(&users);
  4553. for (i = 0; i < users; i++) {
  4554. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4555. clif_GM_kick(sd, pl_sd, 0);
  4556. }
  4557. clif_GM_kick(sd, sd, 0);
  4558. flush_fifos();
  4559. runflag = 0;
  4560. return 0;
  4561. }
  4562. /*==========================================
  4563. * idsearch <part_of_name>: revrited by [Yor]
  4564. *------------------------------------------
  4565. */
  4566. int atcommand_idsearch(
  4567. const int fd, struct map_session_data* sd,
  4568. const char* command, const char* message)
  4569. {
  4570. char item_name[100];
  4571. unsigned int i, match;
  4572. struct item_data *item_array[MAX_SEARCH];
  4573. nullpo_retr(-1, sd);
  4574. memset(item_name, '\0', sizeof(item_name));
  4575. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4576. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4577. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4578. return -1;
  4579. }
  4580. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4581. clif_displaymessage(fd, atcmd_output);
  4582. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4583. if (match > MAX_SEARCH) {
  4584. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
  4585. clif_displaymessage(fd, atcmd_output);
  4586. match = MAX_SEARCH;
  4587. }
  4588. for(i = 0; i < match; i++) {
  4589. sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4590. clif_displaymessage(fd, atcmd_output);
  4591. }
  4592. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4593. clif_displaymessage(fd, atcmd_output);
  4594. return 0;
  4595. }
  4596. /*==========================================
  4597. * Recall All Characters Online To Your Location
  4598. *------------------------------------------
  4599. */
  4600. int atcommand_recallall(
  4601. const int fd, struct map_session_data* sd,
  4602. const char* command, const char* message)
  4603. {
  4604. struct map_session_data *pl_sd, **pl_allsd;
  4605. int i;
  4606. int count, users;
  4607. nullpo_retr(-1, sd);
  4608. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4609. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4610. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4611. return -1;
  4612. }
  4613. count = 0;
  4614. pl_allsd = map_getallusers(&users);
  4615. for (i = 0; i < users; i++) {
  4616. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4617. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4618. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4619. count++;
  4620. else {
  4621. if (pc_isdead(pl_sd)) { //Wake them up
  4622. pc_setstand(pl_sd);
  4623. pc_setrestartvalue(pl_sd,1);
  4624. }
  4625. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4626. }
  4627. }
  4628. }
  4629. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4630. if (count) {
  4631. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4632. clif_displaymessage(fd, atcmd_output);
  4633. }
  4634. return 0;
  4635. }
  4636. /*==========================================
  4637. * Recall online characters of a guild to your location
  4638. *------------------------------------------
  4639. */
  4640. int atcommand_guildrecall(
  4641. const int fd, struct map_session_data* sd,
  4642. const char* command, const char* message)
  4643. {
  4644. struct map_session_data *pl_sd, **pl_allsd;
  4645. int i, users, count;
  4646. char guild_name[NAME_LENGTH];
  4647. struct guild *g;
  4648. nullpo_retr(-1, sd);
  4649. memset(guild_name, '\0', sizeof(guild_name));
  4650. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4651. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4652. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4653. return -1;
  4654. }
  4655. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4656. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4657. return -1;
  4658. }
  4659. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4660. (g = guild_search(atoi(message))) != NULL) {
  4661. count = 0;
  4662. pl_allsd = map_getallusers(&users);
  4663. for (i = 0; i < users; i++) {
  4664. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4665. pl_sd->status.guild_id == g->guild_id) {
  4666. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4667. continue; //Skip GMs greater than you.
  4668. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4669. count++;
  4670. else
  4671. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4672. }
  4673. }
  4674. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4675. clif_displaymessage(fd, atcmd_output);
  4676. if (count) {
  4677. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4678. clif_displaymessage(fd, atcmd_output);
  4679. }
  4680. } else {
  4681. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4682. return -1;
  4683. }
  4684. return 0;
  4685. }
  4686. /*==========================================
  4687. * Recall online characters of a party to your location
  4688. *------------------------------------------
  4689. */
  4690. int atcommand_partyrecall(
  4691. const int fd, struct map_session_data* sd,
  4692. const char* command, const char* message)
  4693. {
  4694. int i;
  4695. struct map_session_data *pl_sd, **pl_allsd;
  4696. char party_name[NAME_LENGTH];
  4697. struct party *p;
  4698. int count, users;
  4699. nullpo_retr(-1, sd);
  4700. memset(party_name, '\0', sizeof(party_name));
  4701. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4702. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4703. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4704. return -1;
  4705. }
  4706. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4707. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4708. return -1;
  4709. }
  4710. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4711. (p = party_search(atoi(message))) != NULL) {
  4712. count = 0;
  4713. pl_allsd = map_getallusers(&users);
  4714. for (i = 0; i < users; i++) {
  4715. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4716. pl_sd->status.party_id == p->party_id) {
  4717. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4718. continue; //Skip GMs greater than you.
  4719. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4720. count++;
  4721. else
  4722. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4723. }
  4724. }
  4725. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4726. clif_displaymessage(fd, atcmd_output);
  4727. if (count) {
  4728. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4729. clif_displaymessage(fd, atcmd_output);
  4730. }
  4731. } else {
  4732. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4733. return -1;
  4734. }
  4735. return 0;
  4736. }
  4737. /*==========================================
  4738. *
  4739. *------------------------------------------
  4740. */
  4741. int atcommand_reloaditemdb(
  4742. const int fd, struct map_session_data* sd,
  4743. const char* command, const char* message)
  4744. {
  4745. nullpo_retr(-1, sd);
  4746. itemdb_reload();
  4747. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4748. return 0;
  4749. }
  4750. /*==========================================
  4751. *
  4752. *------------------------------------------
  4753. */
  4754. int atcommand_reloadmobdb(
  4755. const int fd, struct map_session_data* sd,
  4756. const char* command, const char* message)
  4757. {
  4758. nullpo_retr(-1, sd);
  4759. mob_reload();
  4760. do_final_pet();
  4761. read_petdb();
  4762. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4763. return 0;
  4764. }
  4765. /*==========================================
  4766. *
  4767. *------------------------------------------
  4768. */
  4769. int atcommand_reloadskilldb(
  4770. const int fd, struct map_session_data* sd,
  4771. const char* command, const char* message)
  4772. {
  4773. nullpo_retr(-1, sd);
  4774. skill_reload();
  4775. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4776. return 0;
  4777. }
  4778. /*==========================================
  4779. * @reloadatcommand
  4780. * atcommand_athena.conf のリロード
  4781. *------------------------------------------
  4782. */
  4783. int
  4784. atcommand_reloadatcommand(
  4785. const int fd, struct map_session_data* sd,
  4786. const char* command, const char* message)
  4787. {
  4788. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4789. clif_displaymessage(fd, msg_table[254]);
  4790. return 0;
  4791. }
  4792. /*==========================================
  4793. * @reloadbattleconf
  4794. * battle_athena.conf のリロード
  4795. *------------------------------------------
  4796. */
  4797. int
  4798. atcommand_reloadbattleconf(
  4799. const int fd, struct map_session_data* sd,
  4800. const char* command, const char* message)
  4801. {
  4802. battle_config_read(BATTLE_CONF_FILENAME);
  4803. mob_reload(); //Needed as well so rate changes take effect.
  4804. clif_displaymessage(fd, msg_table[255]);
  4805. return 0;
  4806. }
  4807. /*==========================================
  4808. * @reloadstatusdb
  4809. * job_db1.txt job_db2.txt job_db2-2.txt
  4810. * refine_db.txt size_fix.txt
  4811. * のリロード
  4812. *------------------------------------------
  4813. */
  4814. int
  4815. atcommand_reloadstatusdb(
  4816. const int fd, struct map_session_data* sd,
  4817. const char* command, const char* message)
  4818. {
  4819. status_readdb();
  4820. clif_displaymessage(fd, msg_table[256]);
  4821. return 0;
  4822. }
  4823. /*==========================================
  4824. * @reloadpcdb
  4825. * exp.txt skill_tree.txt attr_fix.txt
  4826. * のリロード
  4827. *------------------------------------------
  4828. */
  4829. int
  4830. atcommand_reloadpcdb(
  4831. const int fd, struct map_session_data* sd,
  4832. const char* command, const char* message)
  4833. {
  4834. pc_readdb();
  4835. clif_displaymessage(fd, msg_table[257]);
  4836. return 0;
  4837. }
  4838. /*==========================================
  4839. * @reloadmotd [Valaris]
  4840. * Reloads motd.txt
  4841. *------------------------------------------
  4842. */
  4843. int
  4844. atcommand_reloadmotd(
  4845. const int fd, struct map_session_data* sd,
  4846. const char* command, const char* message)
  4847. {
  4848. pc_read_motd();
  4849. clif_displaymessage(fd, msg_table[268]);
  4850. return 0;
  4851. }
  4852. /*==========================================
  4853. *
  4854. *------------------------------------------
  4855. */
  4856. int atcommand_reloadscript(
  4857. const int fd, struct map_session_data* sd,
  4858. const char* command, const char* message)
  4859. {
  4860. nullpo_retr(-1, sd);
  4861. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4862. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4863. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4864. flush_fifos();
  4865. //do_init_npc();
  4866. script_reload();
  4867. npc_reload();
  4868. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4869. return 0;
  4870. }
  4871. /*==========================================
  4872. *
  4873. *------------------------------------------
  4874. */
  4875. int atcommand_reloadgmdb( // by [Yor]
  4876. const int fd, struct map_session_data* sd,
  4877. const char* command, const char* message)
  4878. {
  4879. nullpo_retr(-1, sd);
  4880. chrif_reloadGMdb();
  4881. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4882. return 0;
  4883. }
  4884. /*==========================================
  4885. * @mapinfo <map name> [0-3] by MC_Cameri
  4886. * => Shows information about the map [map name]
  4887. * 0 = no additional information
  4888. * 1 = Show users in that map and their location
  4889. * 2 = Shows NPCs in that map
  4890. * 3 = Shows the shops/chats in that map (not implemented)
  4891. *------------------------------------------
  4892. */
  4893. int atcommand_mapinfo(
  4894. const int fd, struct map_session_data* sd,
  4895. const char* command, const char* message)
  4896. {
  4897. struct map_session_data *pl_sd, **pl_allsd;
  4898. struct npc_data *nd = NULL;
  4899. struct chat_data *cd = NULL;
  4900. char direction[12];
  4901. int m_id, i, chat_num, users, list = 0;
  4902. unsigned short m_index;
  4903. nullpo_retr(-1, sd);
  4904. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4905. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4906. memset(direction, '\0', sizeof(direction));
  4907. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4908. if (list < 0 || list > 3) {
  4909. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4910. return -1;
  4911. }
  4912. if (atcmd_player_name[0] == '\0') {
  4913. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4914. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4915. m_id = map_mapindex2mapid(sd->mapindex);
  4916. } else {
  4917. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4918. strcat(atcmd_player_name, ".gat");
  4919. m_id = map_mapname2mapid(atcmd_player_name);
  4920. }
  4921. if (m_id < 0) {
  4922. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4923. return -1;
  4924. }
  4925. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4926. clif_displaymessage(fd, "------ Map Info ------");
  4927. chat_num = 0;
  4928. pl_allsd = map_getallusers(&users);
  4929. for (i = 0; i < users; i++) {
  4930. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4931. chat_num++;
  4932. }
  4933. }
  4934. 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);
  4935. clif_displaymessage(fd, atcmd_output);
  4936. if (map[m_id].flag.alias)
  4937. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4938. clif_displaymessage(fd, "------ Map Flags ------");
  4939. strcpy(atcmd_output,"PvP Flags: ");
  4940. if (map[m_id].flag.pvp)
  4941. strcat(atcmd_output, "Pvp ON | ");
  4942. if (map[m_id].flag.nopvp)
  4943. strcat(atcmd_output, "NoPvp | ");
  4944. if (map[m_id].flag.pvp_noguild)
  4945. strcat(atcmd_output, "NoGuild | ");
  4946. if (map[m_id].flag.pvp_noparty)
  4947. strcat(atcmd_output, "NoParty | ");
  4948. if (map[m_id].flag.pvp_nightmaredrop)
  4949. strcat(atcmd_output, "NightmareDrop | ");
  4950. if (map[m_id].flag.pvp_nocalcrank)
  4951. strcat(atcmd_output, "NoCalcRank | ");
  4952. clif_displaymessage(fd, atcmd_output);
  4953. strcpy(atcmd_output,"GvG Flags: ");
  4954. if (map[m_id].flag.gvg)
  4955. strcat(atcmd_output, "GvG ON | ");
  4956. if (map[m_id].flag.gvg_dungeon)
  4957. strcat(atcmd_output, "GvG Dungeon | ");
  4958. if (map[m_id].flag.gvg_castle)
  4959. strcat(atcmd_output, "GvG Castle | ");
  4960. if (map[m_id].flag.gvg_noparty)
  4961. strcat(atcmd_output, "NoParty | ");
  4962. clif_displaymessage(fd, atcmd_output);
  4963. strcpy(atcmd_output,"Teleport Flags: ");
  4964. if (map[m_id].flag.noteleport)
  4965. strcat(atcmd_output, "NoTeleport | ");
  4966. if (map[m_id].flag.monster_noteleport)
  4967. strcat(atcmd_output, "Monster NoTeleport | ");
  4968. if (map[m_id].flag.nowarp)
  4969. strcat(atcmd_output, "NoWarp | ");
  4970. if (map[m_id].flag.nowarpto)
  4971. strcat(atcmd_output, "NoWarpTo | ");
  4972. if (map[m_id].flag.noreturn)
  4973. strcat(atcmd_output, "NoReturn | ");
  4974. if (map[m_id].flag.nogo)
  4975. strcat(atcmd_output, "NoGo | ");
  4976. if (map[m_id].flag.nomemo)
  4977. strcat(atcmd_output, "NoMemo | ");
  4978. clif_displaymessage(fd, atcmd_output);
  4979. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4980. clif_displaymessage(fd, atcmd_output);
  4981. if (map[m_id].flag.nosave) {
  4982. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4983. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4984. else
  4985. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4986. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4987. clif_displaymessage(fd, atcmd_output);
  4988. }
  4989. strcpy(atcmd_output,"Weather Flags: ");
  4990. if (map[m_id].flag.snow)
  4991. strcat(atcmd_output, "Snow | ");
  4992. if (map[m_id].flag.fog)
  4993. strcat(atcmd_output, "Fog | ");
  4994. if (map[m_id].flag.sakura)
  4995. strcat(atcmd_output, "Sakura | ");
  4996. if (map[m_id].flag.clouds)
  4997. strcat(atcmd_output, "Clouds | ");
  4998. if (map[m_id].flag.clouds2)
  4999. strcat(atcmd_output, "Clouds2 | ");
  5000. if (map[m_id].flag.fireworks)
  5001. strcat(atcmd_output, "Fireworks | ");
  5002. if (map[m_id].flag.leaves)
  5003. strcat(atcmd_output, "Leaves | ");
  5004. if (map[m_id].flag.rain)
  5005. strcat(atcmd_output, "Rain | ");
  5006. if (map[m_id].flag.indoors)
  5007. strcat(atcmd_output, "Indoors | ");
  5008. if (map[m_id].flag.nightenabled)
  5009. strcat(atcmd_output, "Displays Night | ");
  5010. clif_displaymessage(fd, atcmd_output);
  5011. strcpy(atcmd_output,"Other Flags: ");
  5012. if (map[m_id].flag.nobranch)
  5013. strcat(atcmd_output, "NoBranch | ");
  5014. if (map[m_id].flag.notrade)
  5015. strcat(atcmd_output, "NoTrade | ");
  5016. if (map[m_id].flag.nodrop)
  5017. strcat(atcmd_output, "NoDrop | ");
  5018. if (map[m_id].flag.noskill)
  5019. strcat(atcmd_output, "NoSkill | ");
  5020. if (map[m_id].flag.noicewall)
  5021. strcat(atcmd_output, "NoIcewall | ");
  5022. if (map[m_id].flag.nocommand)
  5023. strcat(atcmd_output, "NoCommand | ");
  5024. clif_displaymessage(fd, atcmd_output);
  5025. strcpy(atcmd_output,"Other Flags: ");
  5026. if (map[m_id].flag.nobaseexp)
  5027. strcat(atcmd_output, "NoBaseEXP | ");
  5028. if (map[m_id].flag.nojobexp)
  5029. strcat(atcmd_output, "NoJobEXP | ");
  5030. if (map[m_id].flag.nomobloot)
  5031. strcat(atcmd_output, "NoMobLoot | ");
  5032. if (map[m_id].flag.nomvploot)
  5033. strcat(atcmd_output, "NoMVPLoot | ");
  5034. clif_displaymessage(fd, atcmd_output);
  5035. switch (list) {
  5036. case 0:
  5037. // Do nothing. It's list 0, no additional display.
  5038. break;
  5039. case 1:
  5040. clif_displaymessage(fd, "----- Players in Map -----");
  5041. for (i = 0; i < users; i++) {
  5042. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5043. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5044. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5045. clif_displaymessage(fd, atcmd_output);
  5046. }
  5047. }
  5048. break;
  5049. case 2:
  5050. clif_displaymessage(fd, "----- NPCs in Map -----");
  5051. for (i = 0; i < map[m_id].npc_num;) {
  5052. nd = map[m_id].npc[i];
  5053. switch(nd->ud.dir) {
  5054. case 0: strcpy(direction, "North"); break;
  5055. case 1: strcpy(direction, "North West"); break;
  5056. case 2: strcpy(direction, "West"); break;
  5057. case 3: strcpy(direction, "South West"); break;
  5058. case 4: strcpy(direction, "South"); break;
  5059. case 5: strcpy(direction, "South East"); break;
  5060. case 6: strcpy(direction, "East"); break;
  5061. case 7: strcpy(direction, "North East"); break;
  5062. case 9: strcpy(direction, "North"); break;
  5063. default: strcpy(direction, "Unknown"); break;
  5064. }
  5065. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5066. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5067. clif_displaymessage(fd, atcmd_output);
  5068. }
  5069. break;
  5070. case 3:
  5071. clif_displaymessage(fd, "----- Chats in Map -----");
  5072. for (i = 0; i < users; i++) {
  5073. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5074. pl_sd->mapindex == m_index &&
  5075. cd->usersd[0] == pl_sd) {
  5076. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5077. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5078. clif_displaymessage(fd, atcmd_output);
  5079. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5080. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5081. clif_displaymessage(fd, atcmd_output);
  5082. }
  5083. }
  5084. break;
  5085. default: // normally impossible to arrive here
  5086. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5087. return -1;
  5088. break;
  5089. }
  5090. return 0;
  5091. }
  5092. /*==========================================
  5093. *
  5094. *------------------------------------------
  5095. */
  5096. int atcommand_mount_peco(
  5097. const int fd, struct map_session_data* sd,
  5098. const char* command, const char* message)
  5099. {
  5100. nullpo_retr(-1, sd);
  5101. if (!pc_isriding(sd)) { // if actually no peco
  5102. if (pc_checkskill(sd, KN_RIDING)) {
  5103. pc_setoption(sd, sd->sc.option | 0x0020);
  5104. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5105. } else {
  5106. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5107. return -1;
  5108. }
  5109. } else { //Dismount
  5110. pc_setoption(sd, sd->sc.option & ~0x0020);
  5111. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5112. }
  5113. return 0;
  5114. }
  5115. /*==========================================
  5116. *
  5117. *------------------------------------------
  5118. */
  5119. int atcommand_char_mount_peco(
  5120. const int fd, struct map_session_data* sd,
  5121. const char* command, const char* message)
  5122. {
  5123. struct map_session_data *pl_sd;
  5124. nullpo_retr(-1, sd);
  5125. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5126. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5127. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5128. return -1;
  5129. }
  5130. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5131. if (!pc_isriding(pl_sd)) { // if actually no peco
  5132. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5133. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5134. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5135. } else {
  5136. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5137. return -1;
  5138. }
  5139. } else { //Dismount
  5140. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5141. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5142. }
  5143. } else {
  5144. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5145. return -1;
  5146. }
  5147. return 0;
  5148. }
  5149. /*==========================================
  5150. *Spy Commands by Syrus22
  5151. *------------------------------------------
  5152. */
  5153. int atcommand_guildspy(
  5154. const int fd, struct map_session_data* sd,
  5155. const char* command, const char* message)
  5156. {
  5157. char guild_name[NAME_LENGTH];
  5158. struct guild *g;
  5159. nullpo_retr(-1, sd);
  5160. memset(guild_name, '\0', sizeof(guild_name));
  5161. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5162. if (!enable_spy)
  5163. {
  5164. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5165. return -1;
  5166. }
  5167. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5168. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5169. return -1;
  5170. }
  5171. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5172. (g = guild_search(atoi(message))) != NULL) {
  5173. if (sd->guildspy == g->guild_id) {
  5174. sd->guildspy = 0;
  5175. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5176. clif_displaymessage(fd, atcmd_output);
  5177. } else {
  5178. sd->guildspy = g->guild_id;
  5179. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5180. clif_displaymessage(fd, atcmd_output);
  5181. }
  5182. } else {
  5183. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5184. return -1;
  5185. }
  5186. return 0;
  5187. }
  5188. /*==========================================
  5189. *
  5190. *------------------------------------------
  5191. */
  5192. int atcommand_partyspy(
  5193. const int fd, struct map_session_data* sd,
  5194. const char* command, const char* message)
  5195. {
  5196. char party_name[NAME_LENGTH];
  5197. struct party *p;
  5198. nullpo_retr(-1, sd);
  5199. memset(party_name, '\0', sizeof(party_name));
  5200. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5201. if (!enable_spy)
  5202. {
  5203. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5204. return -1;
  5205. }
  5206. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5207. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5208. return -1;
  5209. }
  5210. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5211. (p = party_search(atoi(message))) != NULL) {
  5212. if (sd->partyspy == p->party_id) {
  5213. sd->partyspy = 0;
  5214. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5215. clif_displaymessage(fd, atcmd_output);
  5216. } else {
  5217. sd->partyspy = p->party_id;
  5218. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5219. clif_displaymessage(fd, atcmd_output);
  5220. }
  5221. } else {
  5222. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5223. return -1;
  5224. }
  5225. return 0;
  5226. }
  5227. /*==========================================
  5228. * @repairall [Valaris]
  5229. *------------------------------------------
  5230. */
  5231. int atcommand_repairall(
  5232. const int fd, struct map_session_data* sd,
  5233. const char* command, const char* message)
  5234. {
  5235. int count, i;
  5236. nullpo_retr(-1, sd);
  5237. count = 0;
  5238. for (i = 0; i < MAX_INVENTORY; i++) {
  5239. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5240. sd->status.inventory[i].attribute = 0;
  5241. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5242. count++;
  5243. }
  5244. }
  5245. if (count > 0) {
  5246. clif_misceffect(&sd->bl, 3);
  5247. clif_equiplist(sd);
  5248. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5249. } else {
  5250. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5251. return -1;
  5252. }
  5253. return 0;
  5254. }
  5255. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5256. int atcommand_nuke(
  5257. const int fd, struct map_session_data* sd,
  5258. const char* command, const char* message)
  5259. {
  5260. struct map_session_data *pl_sd;
  5261. nullpo_retr(-1, sd);
  5262. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5263. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5264. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5265. return -1;
  5266. }
  5267. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5268. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5269. skill_castend_damage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5270. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5271. } else {
  5272. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5273. return -1;
  5274. }
  5275. } else {
  5276. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5277. return -1;
  5278. }
  5279. return 0;
  5280. }
  5281. /*==========================================
  5282. * @tonpc
  5283. *------------------------------------------
  5284. */
  5285. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5286. const char* command, const char* message)
  5287. {
  5288. char npcname[NAME_LENGTH];
  5289. struct npc_data *nd;
  5290. nullpo_retr(-1, sd);
  5291. memset(npcname, 0, sizeof(npcname));
  5292. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5293. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5294. return -1;
  5295. }
  5296. if ((nd = npc_name2id(npcname)) != NULL) {
  5297. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5298. clif_displaymessage(fd, msg_table[0]); // Warped.
  5299. else
  5300. return -1;
  5301. } else {
  5302. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5303. return -1;
  5304. }
  5305. return 0;
  5306. }
  5307. /*==========================================
  5308. *
  5309. *------------------------------------------
  5310. */
  5311. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5312. const char* command, const char* message)
  5313. {
  5314. char NPCname[NAME_LENGTH];
  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: @enablenpc <NPC_name>).");
  5319. return -1;
  5320. }
  5321. if (npc_name2id(NPCname) != NULL) {
  5322. npc_enable(NPCname, 1);
  5323. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5324. } else {
  5325. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5326. return -1;
  5327. }
  5328. return 0;
  5329. }
  5330. /*==========================================
  5331. *
  5332. *------------------------------------------
  5333. */
  5334. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5335. const char* command, const char* message)
  5336. {
  5337. char NPCname[NAME_LENGTH];
  5338. nullpo_retr(-1, sd);
  5339. memset(NPCname, '\0', sizeof(NPCname));
  5340. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5341. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5342. return -1;
  5343. }
  5344. if (npc_name2id(NPCname) != NULL) {
  5345. npc_enable(NPCname, 0);
  5346. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5347. } else {
  5348. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5349. return -1;
  5350. }
  5351. return 0;
  5352. }
  5353. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5354. const char* command, const char* message)
  5355. {
  5356. FILE *fp;
  5357. if (!message || !*message) {
  5358. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5359. return -1;
  5360. }
  5361. // check if script file exists
  5362. if ((fp = fopen(message, "r")) == NULL) {
  5363. clif_displaymessage(fd, msg_table[261]);
  5364. return -1;
  5365. }
  5366. fclose(fp);
  5367. // add to list of script sources and run it
  5368. npc_addsrcfile((char *)message);
  5369. npc_parsesrcfile((char *)message);
  5370. clif_displaymessage(fd, msg_table[262]);
  5371. return 0;
  5372. }
  5373. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5374. const char* command, const char* message)
  5375. {
  5376. struct npc_data *nd;
  5377. char NPCname[NAME_LENGTH];
  5378. nullpo_retr(-1, sd);
  5379. memset(NPCname, '\0', sizeof(NPCname));
  5380. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5381. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5382. return -1;
  5383. }
  5384. if ((nd = npc_name2id(NPCname)) != NULL) {
  5385. npc_unload(nd);
  5386. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5387. } else {
  5388. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5389. return -1;
  5390. }
  5391. return 0;
  5392. }
  5393. /*==========================================
  5394. * time in txt for time command (by [Yor])
  5395. *------------------------------------------
  5396. */
  5397. char * txt_time(unsigned int duration) {
  5398. int days, hours, minutes, seconds;
  5399. char temp[256];
  5400. static char temp1[256];
  5401. memset(temp, '\0', sizeof(temp));
  5402. memset(temp1, '\0', sizeof(temp1));
  5403. if (duration < 0)
  5404. duration = 0;
  5405. days = duration / (60 * 60 * 24);
  5406. duration = duration - (60 * 60 * 24 * days);
  5407. hours = duration / (60 * 60);
  5408. duration = duration - (60 * 60 * hours);
  5409. minutes = duration / 60;
  5410. seconds = duration - (60 * minutes);
  5411. if (days < 2)
  5412. sprintf(temp, msg_table[219], days); // %d day
  5413. else
  5414. sprintf(temp, msg_table[220], days); // %d days
  5415. if (hours < 2)
  5416. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5417. else
  5418. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5419. if (minutes < 2)
  5420. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5421. else
  5422. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5423. if (seconds < 2)
  5424. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5425. else
  5426. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5427. return temp1;
  5428. }
  5429. /*==========================================
  5430. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5431. * Calculation management of GM modification (@day/@night GM commands) is done
  5432. *------------------------------------------
  5433. */
  5434. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5435. const char* command, const char* message)
  5436. {
  5437. struct TimerData * timer_data;
  5438. struct TimerData * timer_data2;
  5439. time_t time_server; // variable for number of seconds (used with time() function)
  5440. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5441. char temp[256];
  5442. nullpo_retr(-1, sd);
  5443. memset(temp, '\0', sizeof(temp));
  5444. time(&time_server); // get time in seconds since 1/1/1970
  5445. datetime = localtime(&time_server); // convert seconds in structure
  5446. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5447. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5448. clif_displaymessage(fd, temp);
  5449. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5450. if (night_flag == 0)
  5451. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5452. else
  5453. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5454. } else if (battle_config.night_duration == 0)
  5455. if (night_flag == 1) { // we start with night
  5456. timer_data = get_timer(day_timer_tid);
  5457. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5458. clif_displaymessage(fd, temp);
  5459. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5460. } else
  5461. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5462. else if (battle_config.day_duration == 0)
  5463. if (night_flag == 0) { // we start with day
  5464. timer_data = get_timer(night_timer_tid);
  5465. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5466. clif_displaymessage(fd, temp);
  5467. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5468. } else
  5469. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5470. else {
  5471. if (night_flag == 0) {
  5472. timer_data = get_timer(night_timer_tid);
  5473. timer_data2 = get_timer(day_timer_tid);
  5474. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5475. clif_displaymessage(fd, temp);
  5476. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5477. 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.
  5478. else
  5479. 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.
  5480. clif_displaymessage(fd, temp);
  5481. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5482. clif_displaymessage(fd, temp);
  5483. } else {
  5484. timer_data = get_timer(day_timer_tid);
  5485. timer_data2 = get_timer(night_timer_tid);
  5486. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5487. clif_displaymessage(fd, temp);
  5488. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5489. 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.
  5490. else
  5491. 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.
  5492. clif_displaymessage(fd, temp);
  5493. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5494. clif_displaymessage(fd, temp);
  5495. }
  5496. }
  5497. return 0;
  5498. }
  5499. /*==========================================
  5500. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5501. * removes <quantity> item from a character
  5502. * item can be equiped or not.
  5503. * Inspired from a old command created by RoVeRT
  5504. *------------------------------------------
  5505. */
  5506. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5507. const char* command, const char* message)
  5508. {
  5509. struct map_session_data *pl_sd;
  5510. char item_name[100];
  5511. int i, number = 0, item_id, item_position, count;
  5512. struct item_data *item_data;
  5513. nullpo_retr(-1, sd);
  5514. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5515. memset(item_name, '\0', sizeof(item_name));
  5516. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5517. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5518. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5519. return -1;
  5520. }
  5521. item_id = 0;
  5522. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5523. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5524. item_id = item_data->nameid;
  5525. if (item_id > 500) {
  5526. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5527. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5528. item_position = pc_search_inventory(pl_sd, item_id);
  5529. if (item_position >= 0) {
  5530. count = 0;
  5531. for(i = 0; i < number && item_position >= 0; i++) {
  5532. //Logs (A)dmins items [Lupus]
  5533. if(log_config.pick > 0 ) {
  5534. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5535. }
  5536. //Logs
  5537. pc_delitem(pl_sd, item_position, 1, 0);
  5538. count++;
  5539. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5540. }
  5541. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5542. clif_displaymessage(pl_sd->fd, atcmd_output);
  5543. if (number == count)
  5544. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5545. else
  5546. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5547. clif_displaymessage(fd, atcmd_output);
  5548. } else {
  5549. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5550. return -1;
  5551. }
  5552. } else {
  5553. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5554. return -1;
  5555. }
  5556. } else {
  5557. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5558. return -1;
  5559. }
  5560. } else {
  5561. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5562. return -1;
  5563. }
  5564. return 0;
  5565. }
  5566. /*==========================================
  5567. * @jail <char_name> by [Yor]
  5568. * Special warp! No check with nowarp and nowarpto flag
  5569. *------------------------------------------
  5570. */
  5571. int atcommand_jail(
  5572. const int fd, struct map_session_data* sd,
  5573. const char* command, const char* message)
  5574. {
  5575. struct map_session_data *pl_sd;
  5576. int x, y;
  5577. unsigned short m_index;
  5578. nullpo_retr(-1, sd);
  5579. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5580. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5581. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5582. return -1;
  5583. }
  5584. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5585. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5586. switch(rand() % 2) {
  5587. case 0:
  5588. x = 24;
  5589. y = 75;
  5590. break;
  5591. default:
  5592. x = 49;
  5593. y = 75;
  5594. break;
  5595. }
  5596. m_index = mapindex_name2id(MAP_JAIL);
  5597. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5598. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5599. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5600. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5601. } else {
  5602. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5603. return -1;
  5604. }
  5605. } else {
  5606. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5607. return -1;
  5608. }
  5609. } else {
  5610. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5611. return -1;
  5612. }
  5613. return 0;
  5614. }
  5615. /*==========================================
  5616. * @unjail/@discharge <char_name> by [Yor]
  5617. * Special warp! No check with nowarp and nowarpto flag
  5618. *------------------------------------------
  5619. */
  5620. int atcommand_unjail(
  5621. const int fd, struct map_session_data* sd,
  5622. const char* command, const char* message)
  5623. {
  5624. struct map_session_data *pl_sd;
  5625. unsigned short m_index;
  5626. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5627. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5628. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5629. return -1;
  5630. }
  5631. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5632. m_index = mapindex_name2id(MAP_PRONTERA);
  5633. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5634. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5635. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5636. return -1;
  5637. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5638. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5639. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5640. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5641. } else {
  5642. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5643. return -1;
  5644. }
  5645. } else {
  5646. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5647. return -1;
  5648. }
  5649. } else {
  5650. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5651. return -1;
  5652. }
  5653. return 0;
  5654. }
  5655. /*==========================================
  5656. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5657. *------------------------------------------
  5658. */
  5659. int atcommand_disguise(
  5660. const int fd, struct map_session_data* sd,
  5661. const char* command, const char* message)
  5662. {
  5663. int id = 0;
  5664. nullpo_retr(-1, sd);
  5665. if (!message || !*message) {
  5666. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5667. return -1;
  5668. }
  5669. if ((id = atoi(message)) > 0)
  5670. { //Acquired an ID
  5671. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5672. id = 0; //Invalid id for either mobs or npcs.
  5673. } else { //Acquired a Name
  5674. if ((id = mobdb_searchname(message)) == 0)
  5675. {
  5676. struct npc_data* nd = npc_name2id(message);
  5677. if (nd != NULL)
  5678. id = nd->n;
  5679. }
  5680. }
  5681. if (id == 0)
  5682. { // Monster/NPC name/id hasn't been found.
  5683. clif_displaymessage(fd, msg_table[123]);
  5684. return -1;
  5685. }
  5686. /* The previous way....
  5687. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5688. mob_id = atoi(message);
  5689. if ((mob_id >= 46 && mob_id <= 125) || (mob_id >= 700 && mob_id <= 718) || // NPC
  5690. (mob_id >= 721 && mob_id <= 755) || (mob_id >= 757 && mob_id <= 811) || // NPC
  5691. (mob_id >= 813 && mob_id <= 858) || // NPC
  5692. (mob_id > 1000 && mob_id < 1582)) { // monsters
  5693. */
  5694. pc_stop_walking(sd,0);
  5695. clif_clearchar(&sd->bl, 0);
  5696. sd->disguise = id;
  5697. sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5698. clif_changeoption(&sd->bl);
  5699. clif_spawnpc(sd);
  5700. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5701. return 0;
  5702. }
  5703. /*==========================================
  5704. * DisguiseAll
  5705. *------------------------------------------
  5706. */
  5707. int atcommand_disguiseall(
  5708. const int fd, struct map_session_data* sd,
  5709. const char* command, const char* message)
  5710. {
  5711. int mob_id=0, i=0, users;
  5712. struct map_session_data *pl_sd, **pl_allsd;
  5713. nullpo_retr(-1, sd);
  5714. if (!message || !*message) {
  5715. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5716. return -1;
  5717. }
  5718. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5719. mob_id = atoi(message);
  5720. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5721. pl_allsd = map_getallusers(&users);
  5722. for(i=0; i < users; i++) {
  5723. if((pl_sd = pl_allsd[i])) {
  5724. pc_stop_walking(pl_sd,0);
  5725. clif_clearchar(&pl_sd->bl, 0);
  5726. pl_sd->disguise = mob_id;
  5727. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5728. clif_changeoption(&pl_sd->bl);
  5729. clif_spawnpc(pl_sd);
  5730. }
  5731. }
  5732. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5733. } else {
  5734. return -1;
  5735. }
  5736. return 0;
  5737. }
  5738. /*==========================================
  5739. * @undisguise by [Yor]
  5740. *------------------------------------------
  5741. */
  5742. int atcommand_undisguise(
  5743. const int fd, struct map_session_data* sd,
  5744. const char* command, const char* message)
  5745. {
  5746. nullpo_retr(-1, sd);
  5747. if (sd->disguise) {
  5748. pc_stop_walking(sd,0);
  5749. clif_clearchar(&sd->bl, 0);
  5750. sd->disguise = 0;
  5751. clif_changeoption(&sd->bl);
  5752. clif_spawnpc(sd);
  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_stop_walking(pl_sd,0);
  5775. clif_clearchar(&pl_sd->bl, 0);
  5776. pl_sd->disguise = 0;
  5777. clif_changeoption(&pl_sd->bl);
  5778. clif_spawnpc(pl_sd);
  5779. }
  5780. }
  5781. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5782. return 0;
  5783. }
  5784. /*==========================================
  5785. * @exp by [Skotlex]
  5786. *------------------------------------------
  5787. */
  5788. int atcommand_exp(
  5789. const int fd, struct map_session_data* sd,
  5790. const char* command, const char* message)
  5791. {
  5792. char output[200];
  5793. double nextb, nextj;
  5794. nullpo_retr(-1, sd);
  5795. memset(output, '\0', sizeof(output));
  5796. nextb = pc_nextbaseexp(sd);
  5797. if (nextb)
  5798. nextb = sd->status.base_exp*100.0/nextb;
  5799. nextj = pc_nextjobexp(sd);
  5800. if (nextj)
  5801. nextj = sd->status.job_exp*100.0/nextj;
  5802. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5803. clif_displaymessage(fd, output);
  5804. return 0;
  5805. }
  5806. /*==========================================
  5807. * @broadcast by [Valaris]
  5808. *------------------------------------------
  5809. */
  5810. int atcommand_broadcast(
  5811. const int fd, struct map_session_data* sd,
  5812. const char* command, const char* message)
  5813. {
  5814. nullpo_retr(-1, sd);
  5815. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5816. if (!message || !*message) {
  5817. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5818. return -1;
  5819. }
  5820. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5821. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5822. return 0;
  5823. }
  5824. /*==========================================
  5825. * @localbroadcast by [Valaris]
  5826. *------------------------------------------
  5827. */
  5828. int atcommand_localbroadcast(
  5829. const int fd, struct map_session_data* sd,
  5830. const char* command, const char* message)
  5831. {
  5832. nullpo_retr(-1, sd);
  5833. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5834. if (!message || !*message) {
  5835. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  5836. return -1;
  5837. }
  5838. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5839. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5840. return 0;
  5841. }
  5842. /*==========================================
  5843. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5844. *------------------------------------------
  5845. */
  5846. int atcommand_chardisguise(
  5847. const int fd, struct map_session_data* sd,
  5848. const char* command, const char* message)
  5849. {
  5850. int mob_id;
  5851. char mob_name[NAME_LENGTH];
  5852. struct map_session_data* pl_sd;
  5853. nullpo_retr(-1, sd);
  5854. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5855. memset(mob_name, '\0', sizeof(mob_name));
  5856. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5857. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5858. return -1;
  5859. }
  5860. if ((mob_id = atoi(mob_name)) > 0)
  5861. { //Acquired an ID
  5862. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5863. mob_id = 0; //Invalid id for either mobs or npcs.
  5864. } else { //Acquired a Name
  5865. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5866. {
  5867. struct npc_data* nd = npc_name2id(mob_name);
  5868. if (nd != NULL)
  5869. mob_id = nd->n;
  5870. }
  5871. }
  5872. if (mob_id == 0)
  5873. {
  5874. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5875. return -1;
  5876. }
  5877. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5878. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5879. pc_stop_walking(pl_sd,0);
  5880. clif_clearchar(&pl_sd->bl, 0);
  5881. pl_sd->disguise = mob_id;
  5882. pl_sd->state.disguised = 1; // set to override items with disguise script [Valaris]
  5883. clif_changeoption(&pl_sd->bl);
  5884. clif_spawnpc(pl_sd);
  5885. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5886. } else {
  5887. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5888. return -1;
  5889. }
  5890. } else {
  5891. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5892. return -1;
  5893. }
  5894. return 0;
  5895. }
  5896. /*==========================================
  5897. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5898. *------------------------------------------
  5899. */
  5900. int atcommand_charundisguise(
  5901. const int fd, struct map_session_data* sd,
  5902. const char* command, const char* message)
  5903. {
  5904. struct map_session_data* pl_sd;
  5905. nullpo_retr(-1, sd);
  5906. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5907. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5908. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5909. return -1;
  5910. }
  5911. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5912. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5913. if (pl_sd->disguise) {
  5914. pc_stop_walking(pl_sd,0);
  5915. clif_clearchar(&pl_sd->bl, 0);
  5916. pl_sd->disguise = 0;
  5917. clif_changeoption(&pl_sd->bl);
  5918. clif_spawnpc(pl_sd);
  5919. clif_displaymessage(fd, msg_table[141]); // Character's undisguise applied.
  5920. } else {
  5921. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5922. return -1;
  5923. }
  5924. } else {
  5925. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5926. return -1;
  5927. }
  5928. } else {
  5929. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5930. return -1;
  5931. }
  5932. return 0;
  5933. }
  5934. /*==========================================
  5935. * @email <actual@email> <new@email> by [Yor]
  5936. *------------------------------------------
  5937. */
  5938. int atcommand_email(
  5939. const int fd, struct map_session_data* sd,
  5940. const char* command, const char* message)
  5941. {
  5942. char actual_email[100];
  5943. char new_email[100];
  5944. nullpo_retr(-1, sd);
  5945. memset(actual_email, '\0', sizeof(actual_email));
  5946. memset(new_email, '\0', sizeof(new_email));
  5947. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5948. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5949. return -1;
  5950. }
  5951. if (e_mail_check(actual_email) == 0) {
  5952. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5953. return -1;
  5954. } else if (e_mail_check(new_email) == 0) {
  5955. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5956. return -1;
  5957. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5958. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5959. return -1;
  5960. } else if (strcmpi(actual_email, new_email) == 0) {
  5961. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5962. return -1;
  5963. } else {
  5964. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5965. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5966. }
  5967. return 0;
  5968. }
  5969. /*==========================================
  5970. *@effect
  5971. *------------------------------------------
  5972. */
  5973. int atcommand_effect(
  5974. const int fd, struct map_session_data* sd,
  5975. const char* command, const char* message)
  5976. {
  5977. struct map_session_data *pl_sd, **pl_allsd;
  5978. int type = 0, flag = 0, i, users;
  5979. nullpo_retr(-1, sd);
  5980. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5981. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5982. return -1;
  5983. }
  5984. if(flag <=0){
  5985. clif_specialeffect(&sd->bl, type, flag);
  5986. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5987. }
  5988. else{
  5989. pl_allsd = map_getallusers(&users);
  5990. for (i = 0; i < users; i++) {
  5991. if ((pl_sd = pl_allsd[i])) {
  5992. clif_specialeffect(&pl_sd->bl, type, flag);
  5993. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5994. }
  5995. }
  5996. }
  5997. return 0;
  5998. }
  5999. /*==========================================
  6000. * @charcartlist <character>: Displays the items list of a player's cart.
  6001. *------------------------------------------
  6002. */
  6003. int
  6004. atcommand_character_cart_list(
  6005. const int fd, struct map_session_data* sd,
  6006. const char* command, const char* message)
  6007. {
  6008. char outputtmp[200];
  6009. struct map_session_data *pl_sd;
  6010. struct item_data *item_data, *item_temp;
  6011. int i, j, count, counter, counter2;
  6012. nullpo_retr(-1, sd);
  6013. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6014. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6015. memset(outputtmp, '\0', sizeof(outputtmp));
  6016. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6017. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  6018. return -1;
  6019. }
  6020. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  6021. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  6022. counter = 0;
  6023. count = 0;
  6024. for (i = 0; i < MAX_CART; i++) {
  6025. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  6026. counter = counter + pl_sd->status.cart[i].amount;
  6027. count++;
  6028. if (count == 1) {
  6029. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6030. clif_displaymessage(fd, atcmd_output);
  6031. }
  6032. if (pl_sd->status.cart[i].refine)
  6033. 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);
  6034. else
  6035. 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);
  6036. clif_displaymessage(fd, atcmd_output);
  6037. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6038. counter2 = 0;
  6039. for (j = 0; j < item_data->slot; j++) {
  6040. if (pl_sd->status.cart[i].card[j]) {
  6041. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6042. if (atcmd_output[0] == '\0')
  6043. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6044. else
  6045. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6046. strcat(atcmd_output, outputtmp);
  6047. }
  6048. }
  6049. }
  6050. if (atcmd_output[0] != '\0') {
  6051. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6052. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6053. clif_displaymessage(fd, atcmd_output);
  6054. }
  6055. }
  6056. }
  6057. if (count == 0)
  6058. clif_displaymessage(fd, "No item found in the cart of this player.");
  6059. else {
  6060. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6061. clif_displaymessage(fd, atcmd_output);
  6062. }
  6063. } else {
  6064. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6065. return -1;
  6066. }
  6067. } else {
  6068. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6069. return -1;
  6070. }
  6071. return 0;
  6072. }
  6073. /*==========================================
  6074. * @killer by MouseJstr
  6075. * enable killing players even when not in pvp
  6076. *------------------------------------------
  6077. */
  6078. int
  6079. atcommand_killer(
  6080. const int fd, struct map_session_data* sd,
  6081. const char* command, const char* message)
  6082. {
  6083. nullpo_retr(-1, sd);
  6084. sd->special_state.killer = !sd->special_state.killer;
  6085. if(sd->special_state.killer)
  6086. clif_displaymessage(fd, msg_table[241]);
  6087. else
  6088. clif_displaymessage(fd, msg_table[242]);
  6089. return 0;
  6090. }
  6091. /*==========================================
  6092. * @killable by MouseJstr
  6093. * enable other people killing you
  6094. *------------------------------------------
  6095. */
  6096. int
  6097. atcommand_killable(
  6098. const int fd, struct map_session_data* sd,
  6099. const char* command, const char* message)
  6100. {
  6101. nullpo_retr(-1, sd);
  6102. sd->special_state.killable = !sd->special_state.killable;
  6103. if(sd->special_state.killable)
  6104. clif_displaymessage(fd, msg_table[242]);
  6105. else
  6106. clif_displaymessage(fd, msg_table[241]);
  6107. return 0;
  6108. }
  6109. /*==========================================
  6110. * @charkillable by MouseJstr
  6111. * enable another player to be killed
  6112. *------------------------------------------
  6113. */
  6114. int
  6115. atcommand_charkillable(
  6116. const int fd, struct map_session_data* sd,
  6117. const char* command, const char* message)
  6118. {
  6119. struct map_session_data *pl_sd = NULL;
  6120. nullpo_retr(-1, sd);
  6121. if (!message || !*message)
  6122. return -1;
  6123. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6124. return -1;
  6125. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6126. if(pl_sd->special_state.killable)
  6127. clif_displaymessage(fd, "The player is now killable");
  6128. else
  6129. clif_displaymessage(fd, "The player is no longer killable");
  6130. return 0;
  6131. }
  6132. /*==========================================
  6133. * @skillon by MouseJstr
  6134. * turn skills on for the map
  6135. *------------------------------------------
  6136. */
  6137. int
  6138. atcommand_skillon(
  6139. const int fd, struct map_session_data* sd,
  6140. const char* command, const char* message)
  6141. {
  6142. nullpo_retr(-1, sd);
  6143. map[sd->bl.m].flag.noskill = 0;
  6144. clif_displaymessage(fd, msg_table[244]);
  6145. return 0;
  6146. }
  6147. /*==========================================
  6148. * @skilloff by MouseJstr
  6149. * Turn skills off on the map
  6150. *------------------------------------------
  6151. */
  6152. int
  6153. atcommand_skilloff(
  6154. const int fd, struct map_session_data* sd,
  6155. const char* command, const char* message)
  6156. {
  6157. nullpo_retr(-1, sd);
  6158. map[sd->bl.m].flag.noskill = 1;
  6159. clif_displaymessage(fd, msg_table[243]);
  6160. return 0;
  6161. }
  6162. /*==========================================
  6163. * @npcmove by MouseJstr
  6164. *
  6165. * move a npc
  6166. *------------------------------------------
  6167. */
  6168. int
  6169. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6170. const char* command, const char* message)
  6171. {
  6172. int x = 0, y = 0;
  6173. struct npc_data *nd = 0;
  6174. nullpo_retr(-1, sd);
  6175. if (!message || !*message)
  6176. return -1;
  6177. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6178. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6179. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6180. return -1;
  6181. }
  6182. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6183. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6184. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6185. return -1;
  6186. npc_enable(atcmd_player_name, 0);
  6187. nd->bl.x = x;
  6188. nd->bl.y = y;
  6189. npc_enable(atcmd_player_name, 1);
  6190. return 0;
  6191. }
  6192. /*==========================================
  6193. * @addwarp by MouseJstr
  6194. *
  6195. * Create a new static warp point.
  6196. *------------------------------------------
  6197. */
  6198. int
  6199. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6200. const char* command, const char* message)
  6201. {
  6202. char w1[64], w3[64], w4[64];
  6203. int x,y,ret;
  6204. nullpo_retr(-1, sd);
  6205. if (!message || !*message)
  6206. return -1;
  6207. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6208. return -1;
  6209. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6210. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6211. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6212. ret = npc_parse_warp(w1, "warp", w3, w4);
  6213. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6214. clif_displaymessage(fd, atcmd_output);
  6215. return ret;
  6216. }
  6217. /*==========================================
  6218. * @follow by [MouseJstr]
  6219. *
  6220. * Follow a player .. staying no more then 5 spaces away
  6221. *------------------------------------------
  6222. */
  6223. int
  6224. atcommand_follow(const int fd, struct map_session_data* sd,
  6225. const char* command, const char* message)
  6226. {
  6227. struct map_session_data *pl_sd = NULL;
  6228. nullpo_retr(-1, sd);
  6229. if (!message || !*message) {
  6230. if (sd->followtarget == -1)
  6231. return -1;
  6232. pc_stop_following (sd);
  6233. clif_displaymessage(fd, "Stop following");
  6234. return 0;
  6235. }
  6236. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6237. if (sd->followtarget == pl_sd->bl.id)
  6238. pc_stop_following (sd);
  6239. else
  6240. pc_follow(sd, pl_sd->bl.id);
  6241. return 0;
  6242. }
  6243. return 1;
  6244. }
  6245. /*==========================================
  6246. * @dropall by [MouseJstr]
  6247. *
  6248. * Drop all your possession on the ground
  6249. *------------------------------------------
  6250. */
  6251. int
  6252. atcommand_dropall(const int fd, struct map_session_data* sd,
  6253. const char* command, const char* message)
  6254. {
  6255. int i;
  6256. nullpo_retr(-1, sd);
  6257. for (i = 0; i < MAX_INVENTORY; i++) {
  6258. if (sd->status.inventory[i].amount) {
  6259. if(sd->status.inventory[i].equip != 0)
  6260. pc_unequipitem(sd, i, 3);
  6261. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6262. }
  6263. }
  6264. return 0;
  6265. }
  6266. /*==========================================
  6267. * @chardropall by [MouseJstr]
  6268. *
  6269. * Throw all the characters possessions on the ground. Normally
  6270. * done in response to them being disrespectful of a GM
  6271. *------------------------------------------
  6272. */
  6273. int
  6274. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6275. const char* command, const char* message)
  6276. {
  6277. int i;
  6278. struct map_session_data *pl_sd = NULL;
  6279. nullpo_retr(-1, sd);
  6280. if (!message || !*message)
  6281. return -1;
  6282. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6283. return -1;
  6284. for (i = 0; i < MAX_INVENTORY; i++) {
  6285. if (pl_sd->status.inventory[i].amount) {
  6286. if(pl_sd->status.inventory[i].equip != 0)
  6287. pc_unequipitem(pl_sd, i, 3);
  6288. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6289. }
  6290. }
  6291. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6292. clif_displaymessage(fd, "It is done");
  6293. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6294. return 0;
  6295. }
  6296. /*==========================================
  6297. * @storeall by [MouseJstr]
  6298. *
  6299. * Put everything into storage to simplify your inventory to make
  6300. * debugging easie
  6301. *------------------------------------------
  6302. */
  6303. int
  6304. atcommand_storeall(const int fd, struct map_session_data* sd,
  6305. const char* command, const char* message)
  6306. {
  6307. int i;
  6308. nullpo_retr(-1, sd);
  6309. if (storage_storageopen(sd) == 1) {
  6310. clif_displaymessage(fd, "run this command again..");
  6311. return 0;
  6312. }
  6313. for (i = 0; i < MAX_INVENTORY; i++) {
  6314. if (sd->status.inventory[i].amount) {
  6315. if(sd->status.inventory[i].equip != 0)
  6316. pc_unequipitem(sd, i, 3);
  6317. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6318. }
  6319. }
  6320. storage_storageclose(sd);
  6321. clif_displaymessage(fd, "It is done");
  6322. return 0;
  6323. }
  6324. /*==========================================
  6325. * @charstoreall by [MouseJstr]
  6326. *
  6327. * A way to screw with players who piss you off
  6328. *------------------------------------------
  6329. */
  6330. int
  6331. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6332. const char* command, const char* message)
  6333. {
  6334. int i;
  6335. struct map_session_data *pl_sd = NULL;
  6336. nullpo_retr(-1, sd);
  6337. if (!message || !*message)
  6338. return -1;
  6339. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6340. return -1;
  6341. if (storage_storageopen(pl_sd) == 1) {
  6342. clif_displaymessage(fd, "Had to open the characters storage window...");
  6343. clif_displaymessage(fd, "run this command again..");
  6344. return 0;
  6345. }
  6346. for (i = 0; i < MAX_INVENTORY; i++) {
  6347. if (pl_sd->status.inventory[i].amount) {
  6348. if(pl_sd->status.inventory[i].equip != 0)
  6349. pc_unequipitem(pl_sd, i, 3);
  6350. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6351. }
  6352. }
  6353. storage_storageclose(pl_sd);
  6354. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6355. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6356. clif_displaymessage(pl_sd->fd, " -- the management");
  6357. clif_displaymessage(fd, "It is done");
  6358. return 0;
  6359. }
  6360. /*==========================================
  6361. * @skillid by [MouseJstr]
  6362. *
  6363. * lookup a skill by name
  6364. *------------------------------------------
  6365. */
  6366. int
  6367. atcommand_skillid(const int fd, struct map_session_data* sd,
  6368. const char* command, const char* message)
  6369. {
  6370. int skillen, idx;
  6371. nullpo_retr(-1, sd);
  6372. if (!message || !*message)
  6373. return -1;
  6374. skillen = strlen(message);
  6375. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6376. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6377. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6378. {
  6379. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6380. clif_displaymessage(fd, atcmd_output);
  6381. }
  6382. }
  6383. return 0;
  6384. }
  6385. /*==========================================
  6386. * @useskill by [MouseJstr]
  6387. *
  6388. * A way of using skills without having to find them in the skills menu
  6389. *------------------------------------------
  6390. */
  6391. int
  6392. atcommand_useskill(const int fd, struct map_session_data* sd,
  6393. const char* command, const char* message)
  6394. {
  6395. struct map_session_data *pl_sd = NULL;
  6396. int skillnum;
  6397. int skilllv;
  6398. char target[255];
  6399. nullpo_retr(-1, sd);
  6400. if (!message || !*message)
  6401. return -1;
  6402. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6403. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6404. return -1;
  6405. }
  6406. if((pl_sd=map_nick2sd(target)) == NULL) {
  6407. return -1;
  6408. }
  6409. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6410. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6411. else
  6412. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, skilllv);
  6413. return 0;
  6414. }
  6415. /*==========================================
  6416. * @skilltree by [MouseJstr]
  6417. *
  6418. * prints the skill tree for a player required to get to a skill
  6419. *------------------------------------------
  6420. */
  6421. int
  6422. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6423. const char* command, const char* message)
  6424. {
  6425. struct map_session_data *pl_sd = NULL;
  6426. int skillnum, skillidx = -1;
  6427. int meets = 1, j, c=0;
  6428. char target[NAME_LENGTH], *tbl;
  6429. struct skill_tree_entry *ent;
  6430. nullpo_retr(-1, sd);
  6431. if (!message || !*message)
  6432. return -1;
  6433. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6434. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6435. return -1;
  6436. }
  6437. if((pl_sd=map_nick2sd(target)) == NULL)
  6438. return -1;
  6439. c = pc_calc_skilltree_normalize_job(pl_sd);
  6440. tbl = job_name(c);
  6441. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6442. tbl, pc_checkskill(pl_sd, 1));
  6443. clif_displaymessage(fd, atcmd_output);
  6444. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6445. if (skill_tree[c][j].id == skillnum) {
  6446. skillidx = j;
  6447. break;
  6448. }
  6449. }
  6450. if (skillidx == -1) {
  6451. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6452. clif_displaymessage(fd, atcmd_output);
  6453. return 0;
  6454. }
  6455. ent = &skill_tree[c][skillidx];
  6456. for(j=0;j<5;j++)
  6457. if( ent->need[j].id &&
  6458. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6459. {
  6460. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6461. sprintf(atcmd_output, "player requires level %d of skill %s",
  6462. ent->need[j].lv, desc);
  6463. clif_displaymessage(fd, atcmd_output);
  6464. meets = 0;
  6465. }
  6466. if (meets == 1) {
  6467. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6468. clif_displaymessage(fd, atcmd_output);
  6469. }
  6470. return 0;
  6471. }
  6472. // Hand a ring with partners name on it to this char
  6473. void getring (struct map_session_data *sd)
  6474. {
  6475. int flag,item_id = 0;
  6476. struct item item_tmp;
  6477. if(sd->status.sex==0)
  6478. item_id = 2635;
  6479. else
  6480. item_id = 2634;
  6481. memset(&item_tmp,0,sizeof(item_tmp));
  6482. item_tmp.nameid=item_id;
  6483. item_tmp.identify=1;
  6484. item_tmp.card[0]=255;
  6485. item_tmp.card[2]=sd->status.partner_id;
  6486. item_tmp.card[3]=sd->status.partner_id >> 16;
  6487. //Logs (A)dmins items [Lupus]
  6488. if(log_config.pick > 0 ) {
  6489. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6490. }
  6491. //Logs
  6492. if((flag = pc_additem(sd,&item_tmp,1))) {
  6493. clif_additem(sd,0,0,flag);
  6494. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6495. }
  6496. }
  6497. /*==========================================
  6498. * @marry by [MouseJstr], fixed by Lupus
  6499. *
  6500. * Marry two players
  6501. *------------------------------------------
  6502. */
  6503. int
  6504. atcommand_marry(const int fd, struct map_session_data* sd,
  6505. const char* command, const char* message)
  6506. {
  6507. struct map_session_data *pl_sd1 = NULL;
  6508. struct map_session_data *pl_sd2 = NULL;
  6509. char player1[128], player2[128]; //Length used for return error msgs
  6510. nullpo_retr(-1, sd);
  6511. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6512. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6513. return -1;
  6514. }
  6515. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6516. sprintf(player2, "Cannot find player '%s' online", player1);
  6517. clif_displaymessage(fd, player2);
  6518. return -1;
  6519. }
  6520. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6521. sprintf(player1, "Cannot find player '%s' online", player2);
  6522. clif_displaymessage(fd, player1);
  6523. return -1;
  6524. }
  6525. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6526. clif_displaymessage(fd, "They are married.. wish them well");
  6527. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6528. // Auto-give named rings (Aru)
  6529. getring (pl_sd1);
  6530. getring (pl_sd2);
  6531. return 0;
  6532. }
  6533. return -1;
  6534. }
  6535. /*==========================================
  6536. * @divorce by [MouseJstr], fixed by [Lupus]
  6537. *
  6538. * divorce two players
  6539. *------------------------------------------
  6540. */
  6541. int
  6542. atcommand_divorce(const int fd, struct map_session_data* sd,
  6543. const char* command, const char* message)
  6544. {
  6545. struct map_session_data *pl_sd = NULL;
  6546. nullpo_retr(-1, sd);
  6547. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6548. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6549. return -1;
  6550. }
  6551. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6552. if (pc_divorce(pl_sd) != 0) {
  6553. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6554. clif_displaymessage(fd, atcmd_output);
  6555. return -1;
  6556. } else {
  6557. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6558. clif_displaymessage(fd, atcmd_output);
  6559. return 0;
  6560. }
  6561. }
  6562. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6563. clif_displaymessage(fd, atcmd_output);
  6564. return -1;
  6565. }
  6566. #ifdef DMALLOC
  6567. unsigned long dmark_;
  6568. int
  6569. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6570. const char* command, const char* message)
  6571. {
  6572. dmark_ = dmalloc_mark();
  6573. clif_displaymessage(fd, "debug mark set");
  6574. return 0;
  6575. }
  6576. int
  6577. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6578. const char* command, const char* message)
  6579. {
  6580. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6581. dmark_ = dmalloc_mark();
  6582. clif_displaymessage(fd, "malloc changes logged");
  6583. return 0;
  6584. }
  6585. #endif
  6586. /*==========================================
  6587. * @grind by [MouseJstr]
  6588. *------------------------------------------
  6589. */
  6590. int
  6591. atcommand_grind(const int fd, struct map_session_data* sd,
  6592. const char* command, const char* message)
  6593. {
  6594. struct map_session_data *pl_sd = NULL;
  6595. int skillnum;
  6596. int inf;
  6597. char target[NAME_LENGTH];
  6598. nullpo_retr(-1, sd);
  6599. if (!message || !*message)
  6600. return -1;
  6601. if(sscanf(message, "%23s", target) != 1) {
  6602. clif_displaymessage(fd, "Usage: @grind <target>");
  6603. return -1;
  6604. }
  6605. if((pl_sd=map_nick2sd(target)) == NULL)
  6606. return -1;
  6607. for (skillnum = 1; skillnum < 500; skillnum++) {
  6608. sd->status.sp = sd->status.max_sp;
  6609. atcommand_alive(fd, sd, command, message);
  6610. inf = skill_get_inf(skillnum);
  6611. if (inf & INF_GROUND_SKILL)
  6612. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6613. else if (!(inf & INF_SUPPORT_SKILL))
  6614. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6615. }
  6616. return 0;
  6617. }
  6618. /*==========================================
  6619. * @grind2 by [MouseJstr]
  6620. *------------------------------------------
  6621. */
  6622. int
  6623. atcommand_grind2(const int fd, struct map_session_data* sd,
  6624. const char* command, const char* message)
  6625. {
  6626. int i, x, y, id;
  6627. for (i = 1000; i <2000; i++) {
  6628. x = sd->bl.x + (rand() % 10 - 5);
  6629. y = sd->bl.y + (rand() % 10 - 5);
  6630. id = mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6631. }
  6632. return 0;
  6633. }
  6634. /*==========================================
  6635. * @changelook by [Celest]
  6636. *------------------------------------------
  6637. */
  6638. int
  6639. atcommand_changelook(const int fd, struct map_session_data* sd,
  6640. const char* command, const char* message)
  6641. {
  6642. int i, j = 0, k = 0;
  6643. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6644. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6645. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6646. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6647. return -1;
  6648. } else if (i == 2) {
  6649. if (j < 1) j = 1;
  6650. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6651. j = pos[j - 1];
  6652. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6653. k = j; // swap
  6654. j = LOOK_HEAD_TOP;
  6655. }
  6656. clif_changelook(&sd->bl,j,k);
  6657. return 0;
  6658. }
  6659. /*==========================================
  6660. *Turns on/off Autotrade for a specific player
  6661. *------------------------------------------
  6662. *by durf (changed by Lupus)
  6663. */
  6664. int
  6665. atcommand_autotrade(
  6666. const int fd, struct map_session_data* sd,
  6667. const char* command, const char* message)
  6668. {
  6669. nullpo_retr(-1, sd);
  6670. if (sd->vender_id) //check if player's vending
  6671. {
  6672. sd->state.autotrade = 1;
  6673. clif_authfail_fd(fd, 15);
  6674. }
  6675. else
  6676. {
  6677. //"You should be vending to use @Autotrade."
  6678. clif_displaymessage(fd, msg_txt(549));
  6679. }
  6680. return 0;
  6681. }
  6682. /*==========================================
  6683. * Changes Master of your Guild to a specified guild member
  6684. *------------------------------------------
  6685. *by durf (changed by Lupus)
  6686. */
  6687. int
  6688. atcommand_changegm(
  6689. const int fd, struct map_session_data* sd,
  6690. const char* command, const char* message)
  6691. {
  6692. struct guild *g;
  6693. struct map_session_data *pl_sd;
  6694. nullpo_retr(-1, sd);
  6695. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6696. {
  6697. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6698. return -1;
  6699. }
  6700. if (strlen(message)==0)
  6701. {
  6702. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6703. return -1;
  6704. }
  6705. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6706. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6707. return -1;
  6708. }
  6709. guild_gm_change(sd->status.guild_id, pl_sd);
  6710. return 0;
  6711. }
  6712. /*==========================================
  6713. *Changes the leader of a party.
  6714. *------------------------------------------
  6715. *by Skotlex
  6716. */
  6717. int
  6718. atcommand_changeleader(
  6719. const int fd, struct map_session_data* sd,
  6720. const char* command, const char* message)
  6721. {
  6722. struct party *p;
  6723. struct map_session_data *pl_sd;
  6724. int mi, pl_mi;
  6725. nullpo_retr(-1, sd);
  6726. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6727. {
  6728. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6729. return -1;
  6730. }
  6731. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6732. if (mi == MAX_PARTY)
  6733. return -1; //Shouldn't happen
  6734. if (!p->member[mi].leader)
  6735. {
  6736. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6737. return -1;
  6738. }
  6739. if (strlen(message)==0)
  6740. {
  6741. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6742. return -1;
  6743. }
  6744. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6745. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6746. return -1;
  6747. }
  6748. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6749. if (pl_mi == MAX_PARTY)
  6750. return -1; //Shouldn't happen
  6751. //Change leadership.
  6752. p->member[mi].leader = 0;
  6753. if (p->member[mi].sd->fd)
  6754. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6755. p->member[pl_mi].leader = 1;
  6756. if (p->member[pl_mi].sd->fd)
  6757. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6758. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6759. //Update info.
  6760. clif_party_main_info(p,-1);
  6761. clif_party_info(p,-1);
  6762. return 0;
  6763. }
  6764. /*==========================================
  6765. *Turns on/off AutoLoot for a specific player
  6766. *------------------------------------------
  6767. *by Upa-Kun
  6768. */
  6769. int
  6770. atcommand_autoloot(
  6771. const int fd, struct map_session_data* sd,
  6772. const char* command, const char* message)
  6773. {
  6774. int rate;
  6775. double drate;
  6776. nullpo_retr(-1, sd);
  6777. if (!message || !*message) {
  6778. if (sd->state.autoloot)
  6779. rate = 0;
  6780. else
  6781. rate = 10000;
  6782. } else {
  6783. drate = atof(message);
  6784. rate = (int)(drate*100);
  6785. }
  6786. if (rate > 10000) rate = 10000;
  6787. else if (rate < 0) rate = 0;
  6788. sd->state.autoloot = rate;
  6789. if (sd->state.autoloot) {
  6790. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6791. clif_displaymessage(fd, atcmd_output);
  6792. }else
  6793. clif_displaymessage(fd, "Autoloot is now off.");
  6794. return 0;
  6795. }
  6796. /*==========================================
  6797. * It is made to rain.
  6798. *------------------------------------------
  6799. */
  6800. int
  6801. atcommand_rain(
  6802. const int fd, struct map_session_data* sd,
  6803. const char* command, const char* message)
  6804. {
  6805. nullpo_retr(-1, sd);
  6806. if (map[sd->bl.m].flag.rain) {
  6807. map[sd->bl.m].flag.rain=0;
  6808. clif_weather(sd->bl.m);
  6809. clif_displaymessage(fd, "The rain has stopped.");
  6810. } else {
  6811. map[sd->bl.m].flag.rain=1;
  6812. clif_weather(sd->bl.m);
  6813. clif_displaymessage(fd, "It is made to rain.");
  6814. }
  6815. return 0;
  6816. }
  6817. /*==========================================
  6818. * It is made to snow.
  6819. *------------------------------------------
  6820. */
  6821. int
  6822. atcommand_snow(
  6823. const int fd, struct map_session_data* sd,
  6824. const char* command, const char* message)
  6825. {
  6826. nullpo_retr(-1, sd);
  6827. if (map[sd->bl.m].flag.snow) {
  6828. map[sd->bl.m].flag.snow=0;
  6829. clif_weather(sd->bl.m);
  6830. clif_displaymessage(fd, "Snow has stopped falling.");
  6831. } else {
  6832. map[sd->bl.m].flag.snow=1;
  6833. clif_weather(sd->bl.m);
  6834. clif_displaymessage(fd, "It is made to snow.");
  6835. }
  6836. return 0;
  6837. }
  6838. /*==========================================
  6839. * Cherry tree snowstorm is made to fall. (Sakura)
  6840. *------------------------------------------
  6841. */
  6842. int
  6843. atcommand_sakura(
  6844. const int fd, struct map_session_data* sd,
  6845. const char* command, const char* message)
  6846. {
  6847. nullpo_retr(-1, sd);
  6848. if (map[sd->bl.m].flag.sakura) {
  6849. map[sd->bl.m].flag.sakura=0;
  6850. clif_weather(sd->bl.m);
  6851. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6852. } else {
  6853. map[sd->bl.m].flag.sakura=1;
  6854. clif_weather(sd->bl.m);
  6855. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6856. }
  6857. return 0;
  6858. }
  6859. /*==========================================
  6860. * Clouds appear.
  6861. *------------------------------------------
  6862. */
  6863. int
  6864. atcommand_clouds(
  6865. const int fd, struct map_session_data* sd,
  6866. const char* command, const char* message)
  6867. {
  6868. nullpo_retr(-1, sd);
  6869. if (map[sd->bl.m].flag.clouds) {
  6870. map[sd->bl.m].flag.clouds=0;
  6871. clif_weather(sd->bl.m);
  6872. clif_displaymessage(fd, "The clouds has disappear.");
  6873. } else {
  6874. map[sd->bl.m].flag.clouds=1;
  6875. clif_weather(sd->bl.m);
  6876. clif_displaymessage(fd, "Clouds appear.");
  6877. }
  6878. return 0;
  6879. }
  6880. /*==========================================
  6881. * Different type of clouds using effect 516
  6882. *------------------------------------------
  6883. */
  6884. int
  6885. atcommand_clouds2(
  6886. const int fd, struct map_session_data* sd,
  6887. const char* command, const char* message)
  6888. {
  6889. nullpo_retr(-1, sd);
  6890. if (map[sd->bl.m].flag.clouds2) {
  6891. map[sd->bl.m].flag.clouds2=0;
  6892. clif_weather(sd->bl.m);
  6893. clif_displaymessage(fd, "The alternative clouds disappear.");
  6894. } else {
  6895. map[sd->bl.m].flag.clouds2=1;
  6896. clif_weather(sd->bl.m);
  6897. clif_displaymessage(fd, "Alternative clouds appear.");
  6898. }
  6899. return 0;
  6900. }
  6901. /*==========================================
  6902. * Fog hangs over.
  6903. *------------------------------------------
  6904. */
  6905. int
  6906. atcommand_fog(
  6907. const int fd, struct map_session_data* sd,
  6908. const char* command, const char* message)
  6909. {
  6910. nullpo_retr(-1, sd);
  6911. if (map[sd->bl.m].flag.fog) {
  6912. map[sd->bl.m].flag.fog=0;
  6913. clif_weather(sd->bl.m);
  6914. clif_displaymessage(fd, "The fog has gone.");
  6915. } else {
  6916. map[sd->bl.m].flag.fog=1;
  6917. clif_weather(sd->bl.m);
  6918. clif_displaymessage(fd, "Fog hangs over.");
  6919. }
  6920. return 0;
  6921. }
  6922. /*==========================================
  6923. * Fallen leaves fall.
  6924. *------------------------------------------
  6925. */
  6926. int
  6927. atcommand_leaves(
  6928. const int fd, struct map_session_data* sd,
  6929. const char* command, const char* message)
  6930. {
  6931. nullpo_retr(-1, sd);
  6932. if (map[sd->bl.m].flag.leaves) {
  6933. map[sd->bl.m].flag.leaves=0;
  6934. clif_weather(sd->bl.m);
  6935. clif_displaymessage(fd, "Leaves no longer fall.");
  6936. } else {
  6937. map[sd->bl.m].flag.leaves=1;
  6938. clif_weather(sd->bl.m);
  6939. clif_displaymessage(fd, "Fallen leaves fall.");
  6940. }
  6941. return 0;
  6942. }
  6943. /*==========================================
  6944. * Fireworks appear.
  6945. *------------------------------------------
  6946. */
  6947. int
  6948. atcommand_fireworks(
  6949. const int fd, struct map_session_data* sd,
  6950. const char* command, const char* message)
  6951. {
  6952. nullpo_retr(-1, sd);
  6953. if (map[sd->bl.m].flag.fireworks) {
  6954. map[sd->bl.m].flag.fireworks=0;
  6955. clif_weather(sd->bl.m);
  6956. clif_displaymessage(fd, "Fireworks are ended.");
  6957. } else {
  6958. map[sd->bl.m].flag.fireworks=1;
  6959. clif_weather(sd->bl.m);
  6960. clif_displaymessage(fd, "Fireworks are launched.");
  6961. }
  6962. return 0;
  6963. }
  6964. /*==========================================
  6965. * Clearing Weather Effects by Dexity
  6966. *------------------------------------------
  6967. */
  6968. int
  6969. atcommand_clearweather(
  6970. const int fd, struct map_session_data* sd,
  6971. const char* command, const char* message)
  6972. {
  6973. nullpo_retr(-1, sd);
  6974. map[sd->bl.m].flag.rain=0;
  6975. map[sd->bl.m].flag.snow=0;
  6976. map[sd->bl.m].flag.sakura=0;
  6977. map[sd->bl.m].flag.clouds=0;
  6978. map[sd->bl.m].flag.clouds2=0;
  6979. map[sd->bl.m].flag.fog=0;
  6980. map[sd->bl.m].flag.fireworks=0;
  6981. map[sd->bl.m].flag.leaves=0;
  6982. clif_weather(sd->bl.m);
  6983. return 0;
  6984. }
  6985. /*===============================================================
  6986. * Sound Command - plays a sound for everyone! [Codemaster]
  6987. *---------------------------------------------------------------
  6988. */
  6989. int
  6990. atcommand_sound(
  6991. const int fd, struct map_session_data *sd,
  6992. const char *command, const char *message)
  6993. {
  6994. char sound_file[100];
  6995. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6996. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6997. return -1;
  6998. }
  6999. memset(sound_file, '\0', sizeof(sound_file));
  7000. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  7001. return -1;
  7002. if(strstr(sound_file, ".wav") == NULL)
  7003. strcat(sound_file, ".wav");
  7004. clif_soundeffectall(&sd->bl, sound_file,0);
  7005. return 0;
  7006. }
  7007. /*==========================================
  7008. * MOB Search
  7009. *------------------------------------------
  7010. */
  7011. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  7012. {
  7013. int mob_id,fd;
  7014. static int number=0;
  7015. struct mob_data *md;
  7016. nullpo_retr(0, bl);
  7017. if(!ap){
  7018. number=0;
  7019. return 0;
  7020. }
  7021. mob_id = va_arg(ap,int);
  7022. fd = va_arg(ap,int);
  7023. md = (struct mob_data *)bl;
  7024. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7025. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7026. ++number,bl->x, bl->y,md->name);
  7027. clif_displaymessage(fd, atcmd_output);
  7028. }
  7029. return 0;
  7030. }
  7031. int atcommand_mobsearch(
  7032. const int fd, struct map_session_data* sd,
  7033. const char* command, const char* message)
  7034. {
  7035. char mob_name[100];
  7036. int mob_id,map_id = 0;
  7037. nullpo_retr(-1, sd);
  7038. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7039. return -1;
  7040. if ((mob_id = atoi(mob_name)) == 0)
  7041. mob_id = mobdb_searchname(mob_name);
  7042. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7043. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7044. clif_displaymessage(fd, atcmd_output);
  7045. return 0;
  7046. }
  7047. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7048. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7049. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7050. map_id = sd->bl.m;
  7051. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7052. mob_name, mapindex_id2name(sd->mapindex));
  7053. clif_displaymessage(fd, atcmd_output);
  7054. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7055. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7056. return 0;
  7057. }
  7058. /*==========================================
  7059. * ドロップアイテムの掃除
  7060. *------------------------------------------
  7061. */
  7062. /*==========================================
  7063. * cleanmap
  7064. *------------------------------------------
  7065. */
  7066. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7067. {
  7068. nullpo_retr(0, bl);
  7069. map_clearflooritem(bl->id);
  7070. return 0;
  7071. }
  7072. int
  7073. atcommand_cleanmap(
  7074. const int fd, struct map_session_data* sd,
  7075. const char* command, const char* message)
  7076. {
  7077. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7078. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7079. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7080. BL_ITEM);
  7081. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7082. return 0;
  7083. }
  7084. /*==========================================
  7085. * NPC/PETに話させる
  7086. *------------------------------------------
  7087. */
  7088. int
  7089. atcommand_npctalk(
  7090. const int fd, struct map_session_data* sd,
  7091. const char* command, const char* message)
  7092. {
  7093. char name[NAME_LENGTH],mes[100],temp[100];
  7094. struct npc_data *nd;
  7095. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7096. return -1;
  7097. if (!(nd = npc_name2id(name)))
  7098. return -1;
  7099. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7100. clif_message(&nd->bl, temp);
  7101. return 0;
  7102. }
  7103. int
  7104. atcommand_pettalk(
  7105. const int fd, struct map_session_data* sd,
  7106. const char* command, const char* message)
  7107. {
  7108. char mes[100],temp[100];
  7109. struct pet_data *pd;
  7110. nullpo_retr(-1, sd);
  7111. if(!sd->status.pet_id || !(pd=sd->pd))
  7112. return -1;
  7113. if (sscanf(message, "%99[^\n]", mes) < 1)
  7114. return -1;
  7115. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7116. clif_message(&pd->bl, temp);
  7117. return 0;
  7118. }
  7119. /*==========================================
  7120. * @users
  7121. * サーバー内の人数マップを表示させる
  7122. * 手抜きのため汚くなっているのは仕様です。
  7123. *------------------------------------------
  7124. */
  7125. static struct dbt *users_db = NULL;
  7126. static int users_all;
  7127. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7128. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7129. users_all++;
  7130. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7131. return 0;
  7132. }
  7133. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7134. char buf[256];
  7135. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7136. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7137. clif_displaymessage(sd->fd,buf);
  7138. return 0;
  7139. }
  7140. int
  7141. atcommand_users(
  7142. const int fd, struct map_session_data* sd,
  7143. const char* command, const char* message)
  7144. {
  7145. char buf[256];
  7146. users_all = 0;
  7147. users_db->clear(users_db, NULL);
  7148. clif_foreachclient(atcommand_users_sub1);
  7149. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7150. sprintf(buf,"all : %d",users_all);
  7151. clif_displaymessage(fd,buf);
  7152. return 0;
  7153. }
  7154. /*==========================================
  7155. *
  7156. *------------------------------------------
  7157. */
  7158. int
  7159. atcommand_summon(
  7160. const int fd, struct map_session_data* sd,
  7161. const char* command, const char* message)
  7162. {
  7163. char name[NAME_LENGTH];
  7164. int mob_id = 0;
  7165. int x = 0;
  7166. int y = 0;
  7167. int id = 0;
  7168. int duration = 0;
  7169. struct mob_data *md;
  7170. unsigned int tick=gettick();
  7171. nullpo_retr(-1, sd);
  7172. if (!message || !*message)
  7173. return -1;
  7174. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7175. return -1;
  7176. if (duration < 1)
  7177. duration =1;
  7178. else if (duration > 60)
  7179. duration =60;
  7180. if ((mob_id = atoi(name)) == 0)
  7181. mob_id = mobdb_searchname(name);
  7182. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7183. return -1;
  7184. x = sd->bl.x + (rand() % 10 - 5);
  7185. y = sd->bl.y + (rand() % 10 - 5);
  7186. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7187. if((md=(struct mob_data *)map_id2bl(id))){
  7188. md->master_id=sd->bl.id;
  7189. md->special_state.ai=1;
  7190. md->mode=md->db->mode|MD_AGGRESSIVE;
  7191. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7192. clif_misceffect2(&md->bl,344);
  7193. }
  7194. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7195. return 0;
  7196. }
  7197. /*==========================================
  7198. * @adjcmdlvl by [MouseJstr]
  7199. *
  7200. * Temp adjust the GM level required to use a GM command
  7201. *
  7202. * Used during beta testing to allow players to use GM commands
  7203. * for short periods of time
  7204. *------------------------------------------
  7205. */
  7206. int
  7207. atcommand_adjcmdlvl(
  7208. const int fd, struct map_session_data* sd,
  7209. const char* command, const char* message)
  7210. {
  7211. int i, newlev;
  7212. char cmd[100];
  7213. nullpo_retr(-1, sd);
  7214. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7215. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7216. return -1;
  7217. }
  7218. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7219. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7220. atcommand_info[i].level = newlev;
  7221. clif_displaymessage(fd, "@command level changed.");
  7222. return 0;
  7223. }
  7224. clif_displaymessage(fd, "@command not found.");
  7225. return -1;
  7226. }
  7227. /*==========================================
  7228. * @adjgmlvl by [MouseJstr]
  7229. *
  7230. * Create a temp GM
  7231. *
  7232. * Used during beta testing to allow players to use GM commands
  7233. * for short periods of time
  7234. *------------------------------------------
  7235. */
  7236. int
  7237. atcommand_adjgmlvl(
  7238. const int fd, struct map_session_data* sd,
  7239. const char* command, const char* message)
  7240. {
  7241. int newlev;
  7242. char user[NAME_LENGTH];
  7243. struct map_session_data *pl_sd;
  7244. nullpo_retr(-1, sd);
  7245. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7246. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7247. return -1;
  7248. }
  7249. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7250. return -1;
  7251. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7252. return 0;
  7253. }
  7254. /*==========================================
  7255. * @trade by [MouseJstr]
  7256. *
  7257. * Open a trade window with a remote player
  7258. *
  7259. * If I have to jump to a remote player one more time, I am
  7260. * gonna scream!
  7261. *------------------------------------------
  7262. */
  7263. int
  7264. atcommand_trade(
  7265. const int fd, struct map_session_data* sd,
  7266. const char* command, const char* message)
  7267. {
  7268. struct map_session_data *pl_sd = NULL;
  7269. nullpo_retr(-1, sd);
  7270. if (!message || !*message)
  7271. return -1;
  7272. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7273. trade_traderequest(sd, pl_sd->bl.id);
  7274. return 0;
  7275. }
  7276. return -1;
  7277. }
  7278. /*==========================================
  7279. * @setbattleflag by [MouseJstr]
  7280. *
  7281. * set a battle_config flag without having to reboot
  7282. */
  7283. int
  7284. atcommand_setbattleflag(
  7285. const int fd, struct map_session_data* sd,
  7286. const char* command, const char* message)
  7287. {
  7288. char flag[128], value[128];
  7289. nullpo_retr(-1, sd);
  7290. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7291. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7292. return -1;
  7293. }
  7294. if (battle_set_value(flag, value) == 0)
  7295. clif_displaymessage(fd, "unknown battle_config flag");
  7296. else
  7297. clif_displaymessage(fd, "battle_config set as requested");
  7298. return 0;
  7299. }
  7300. /*===========================
  7301. * @unmute [Valaris]
  7302. *===========================
  7303. */
  7304. int atcommand_unmute(
  7305. const int fd, struct map_session_data* sd,
  7306. const char* command, const char* message)
  7307. {
  7308. struct map_session_data *pl_sd = NULL;
  7309. nullpo_retr(-1, sd);
  7310. if(!battle_config.muting_players) {
  7311. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7312. return 0;
  7313. }
  7314. if (!message || !*message)
  7315. return -1;
  7316. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7317. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7318. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7319. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7320. clif_displaymessage(sd->fd,"Player unmuted");
  7321. }
  7322. else
  7323. clif_displaymessage(sd->fd,"Player is not muted");
  7324. }
  7325. return 0;
  7326. }
  7327. /*==========================================
  7328. * @uptime by MC Cameri
  7329. *------------------------------------------
  7330. */
  7331. int
  7332. atcommand_uptime(
  7333. const int fd, struct map_session_data* sd,
  7334. const char* command, const char* message)
  7335. {
  7336. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7337. minute = 60, days = 0, hours = 0, minutes = 0;
  7338. nullpo_retr(-1, sd);
  7339. seconds = get_uptime();
  7340. days = seconds/day;
  7341. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7342. hours = seconds/hour;
  7343. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7344. minutes = seconds/minute;
  7345. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7346. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7347. clif_displaymessage(fd, atcmd_output);
  7348. return 0;
  7349. }
  7350. /*==========================================
  7351. * @changesex <sex>
  7352. * => Changes one's sex. Argument sex can be
  7353. * 0 or 1, m or f, male or female.
  7354. *------------------------------------------
  7355. */
  7356. int
  7357. atcommand_changesex(
  7358. const int fd, struct map_session_data* sd,
  7359. const char* command, const char* message)
  7360. {
  7361. nullpo_retr(-1, sd);
  7362. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7363. return 0;
  7364. }
  7365. /*================================================
  7366. * @mute - Mutes a player for a set amount of time
  7367. *------------------------------------------------
  7368. */
  7369. int atcommand_mute(
  7370. const int fd, struct map_session_data* sd,
  7371. const char* command, const char* message)
  7372. {
  7373. struct map_session_data *pl_sd = NULL;
  7374. int manner;
  7375. nullpo_retr(-1, sd);
  7376. if(!battle_config.muting_players) {
  7377. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7378. return 0;
  7379. }
  7380. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7381. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7382. return -1;
  7383. }
  7384. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7385. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7386. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7387. return -1;
  7388. }
  7389. clif_GM_silence(sd, pl_sd, 0);
  7390. pl_sd->status.manner -= manner;
  7391. if(pl_sd->status.manner < 0)
  7392. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7393. }
  7394. else {
  7395. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7396. return -1;
  7397. }
  7398. return 0;
  7399. }
  7400. /*==========================================
  7401. * @refresh (like @jumpto <<yourself>>)
  7402. *------------------------------------------
  7403. */
  7404. int atcommand_refresh(
  7405. const int fd, struct map_session_data* sd,
  7406. const char* command, const char* message)
  7407. {
  7408. nullpo_retr(-1, sd);
  7409. clif_refresh(sd);
  7410. return 0;
  7411. }
  7412. /*==========================================
  7413. * @petid <part of pet name>
  7414. * => Displays a list of matching pets.
  7415. *------------------------------------------
  7416. */
  7417. int
  7418. atcommand_petid(const int fd, struct map_session_data* sd,
  7419. const char* command, const char* message)
  7420. {
  7421. char searchtext[100];
  7422. char temp0[100];
  7423. char temp1[100];
  7424. int cnt = 0, i = 0;
  7425. nullpo_retr(-1, sd);
  7426. if (!message || !*message)
  7427. return -1;
  7428. if (sscanf(message, "%99s", searchtext) < 1)
  7429. return -1;
  7430. estr_lower(searchtext);
  7431. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7432. clif_displaymessage(fd,temp0);
  7433. while (i < MAX_PET_DB) {
  7434. strcpy(temp1,pet_db[i].name);
  7435. strcpy(temp1, estr_lower(temp1));
  7436. strcpy(temp0,pet_db[i].jname);
  7437. strcpy(temp0, estr_lower(temp1));
  7438. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7439. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7440. pet_db[i].jname);
  7441. if (cnt >= 100) { // Only if there are custom pets
  7442. clif_displaymessage(fd, "Be more specific, can't send more than"
  7443. " 100 results.");
  7444. } else {
  7445. clif_displaymessage(fd, temp0);
  7446. }
  7447. cnt++;
  7448. }
  7449. i++;
  7450. }
  7451. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7452. clif_displaymessage(fd, temp0);
  7453. return 0;
  7454. }
  7455. /*==========================================
  7456. * @identify
  7457. * => GM's magnifier.
  7458. *------------------------------------------
  7459. */
  7460. int
  7461. atcommand_identify(
  7462. const int fd, struct map_session_data* sd,
  7463. const char* command, const char* message)
  7464. {
  7465. int i,num;
  7466. nullpo_retr(-1, sd);
  7467. for(i=num=0;i<MAX_INVENTORY;i++){
  7468. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7469. num++;
  7470. }
  7471. }
  7472. if (num > 0) {
  7473. clif_item_identify_list(sd);
  7474. } else {
  7475. clif_displaymessage(fd,"There are no items to appraise.");
  7476. }
  7477. return 0;
  7478. }
  7479. /*==========================================
  7480. * @gmotd (Global MOTD)
  7481. * by davidsiaw :P
  7482. *------------------------------------------
  7483. */
  7484. int
  7485. atcommand_gmotd(
  7486. const int fd, struct map_session_data* sd,
  7487. const char* command, const char* message)
  7488. {
  7489. char buf[256];
  7490. FILE *fp;
  7491. nullpo_retr(-1, sd);
  7492. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7493. while (fgets(buf, 250, fp) != NULL){
  7494. int i;
  7495. for( i=0; buf[i]; i++){
  7496. if( buf[i]=='\r' || buf[i]=='\n'){
  7497. buf[i]=0;
  7498. break;
  7499. }
  7500. }
  7501. intif_GMmessage(buf,strlen(buf)+1,8);
  7502. }
  7503. fclose(fp);
  7504. }
  7505. return 0;
  7506. }
  7507. int atcommand_misceffect(
  7508. const int fd, struct map_session_data* sd,
  7509. const char* command, const char* message)
  7510. {
  7511. int effect = 0;
  7512. nullpo_retr(-1, sd);
  7513. if (!message || !*message)
  7514. return -1;
  7515. if (sscanf(message, "%d", &effect) < 1)
  7516. return -1;
  7517. clif_misceffect(&sd->bl,effect);
  7518. return 0;
  7519. }
  7520. int charid2sessionid(int charid)
  7521. {
  7522. struct map_session_data *pl_sd = NULL;
  7523. pl_sd = map_charid2sd(charid);
  7524. if (pl_sd) return pl_sd->fd;
  7525. return 0;
  7526. }
  7527. int accountid2sessionid(int accountid)
  7528. {
  7529. struct map_session_data *pl_sd = NULL;
  7530. pl_sd = map_id2sd(accountid);
  7531. if (pl_sd) return pl_sd->fd;
  7532. return 0;
  7533. }
  7534. /*==========================================
  7535. * Jump to a player by PID number
  7536. * Original by Dino9021
  7537. * Added in by nsstrunks
  7538. *------------------------------------------
  7539. */
  7540. int atcommand_jumptoid(
  7541. const int fd, struct map_session_data* sd,
  7542. const char* command, const char* message)
  7543. {
  7544. int cid=0;
  7545. int session_id=0;
  7546. struct map_session_data *pl_sd;
  7547. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7548. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7549. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7550. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7551. return -1;
  7552. }
  7553. cid=atoi(message);
  7554. if ((session_id=charid2sessionid(cid))!=0)
  7555. {
  7556. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7557. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7558. clif_displaymessage(fd, msg_table[247]);
  7559. return -1;
  7560. }
  7561. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7562. clif_displaymessage(fd, msg_table[248]);
  7563. return -1;
  7564. }
  7565. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7566. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7567. clif_displaymessage(fd, atcmd_output);
  7568. } else {
  7569. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7570. return -1;
  7571. }
  7572. }
  7573. else
  7574. {
  7575. clif_displaymessage(fd,msg_table[3]);
  7576. }
  7577. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7578. return 0;
  7579. }
  7580. /*==========================================
  7581. * Jump to a player by PID number
  7582. * Original by Dino9021
  7583. * Added in by nsstrunks
  7584. *------------------------------------------
  7585. */
  7586. int atcommand_jumptoid2(
  7587. const int fd, struct map_session_data* sd,
  7588. const char* command, const char* message)
  7589. {
  7590. int aid=0;
  7591. int session_id=0;
  7592. struct map_session_data *pl_sd;
  7593. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7594. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7595. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7596. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7597. return -1;
  7598. }
  7599. aid=atoi(message);
  7600. if ((session_id=accountid2sessionid(aid))!=0)
  7601. {
  7602. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7603. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7604. clif_displaymessage(fd, msg_table[247]);
  7605. return -1;
  7606. }
  7607. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7608. clif_displaymessage(fd, msg_table[248]);
  7609. return -1;
  7610. }
  7611. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7612. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7613. clif_displaymessage(fd, atcmd_output);
  7614. } else {
  7615. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7616. return -1;
  7617. }
  7618. }
  7619. else
  7620. {
  7621. clif_displaymessage(fd,msg_table[3]);
  7622. }
  7623. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7624. return 0;
  7625. }
  7626. /*==========================================
  7627. * Recall a player by PID number
  7628. * Original by Dino9021
  7629. * Added in by nsstrunks
  7630. *------------------------------------------
  7631. */
  7632. int atcommand_recallid(
  7633. const int fd, struct map_session_data* sd,
  7634. const char* command, const char* message)
  7635. {
  7636. int cid=0;
  7637. int session_id=0;
  7638. struct map_session_data *pl_sd;
  7639. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7641. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7642. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7643. return -1;
  7644. }
  7645. cid=atoi(message);
  7646. if ((session_id=charid2sessionid(cid))!=0)
  7647. {
  7648. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7649. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7650. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7651. clif_displaymessage(fd, msg_table[247]);
  7652. return -1;
  7653. }
  7654. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7655. clif_displaymessage(fd, msg_table[248]);
  7656. return -1;
  7657. }
  7658. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7659. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7660. clif_displaymessage(fd, atcmd_output);
  7661. } else {
  7662. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7663. return -1;
  7664. }
  7665. } else {
  7666. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7667. return -1;
  7668. }
  7669. }
  7670. else
  7671. {
  7672. clif_displaymessage(fd,msg_table[3]);
  7673. }
  7674. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7675. return 0;
  7676. }
  7677. /*==========================================
  7678. * Recall a player by PID number
  7679. * Original by Dino9021
  7680. * Added in by nsstrunks
  7681. *------------------------------------------
  7682. */
  7683. int atcommand_recallid2(
  7684. const int fd, struct map_session_data* sd,
  7685. const char* command, const char* message)
  7686. {
  7687. int aid=0;
  7688. int session_id=0;
  7689. struct map_session_data *pl_sd;
  7690. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7691. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7692. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7693. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7694. return -1;
  7695. }
  7696. aid=atoi(message);
  7697. if ((session_id=accountid2sessionid(aid))!=0)
  7698. {
  7699. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7700. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7701. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7702. clif_displaymessage(fd, msg_table[247]);
  7703. return -1;
  7704. }
  7705. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7706. clif_displaymessage(fd, msg_table[248]);
  7707. return -1;
  7708. }
  7709. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7710. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7711. clif_displaymessage(fd, atcmd_output);
  7712. } else {
  7713. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7714. return -1;
  7715. }
  7716. } else {
  7717. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7718. return -1;
  7719. }
  7720. }
  7721. else
  7722. {
  7723. clif_displaymessage(fd,msg_table[3]);
  7724. }
  7725. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7726. return 0;
  7727. }
  7728. /*==========================================
  7729. * Kick a player by PID number
  7730. * Original by Dino9021
  7731. * Added in by nsstrunks
  7732. *------------------------------------------
  7733. */
  7734. int atcommand_kickid(
  7735. const int fd, struct map_session_data* sd,
  7736. const char* command, const char* message)
  7737. {
  7738. struct map_session_data *pl_sd;
  7739. int cid=0;
  7740. int session_id=0;
  7741. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7742. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7743. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7744. return -1;
  7745. }
  7746. cid=atoi(message);
  7747. if ((session_id=charid2sessionid(cid))!=0)
  7748. {
  7749. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7750. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7751. clif_GM_kick(sd, pl_sd, 1);
  7752. else {
  7753. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7754. return -1;
  7755. }
  7756. } else {
  7757. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7758. return -1;
  7759. }
  7760. }
  7761. else
  7762. {
  7763. clif_displaymessage(fd,msg_table[3]);
  7764. }
  7765. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7766. return 0;
  7767. }
  7768. /*==========================================
  7769. * Kick a player by PID number
  7770. * Original by Dino9021
  7771. * Added in by nsstrunks
  7772. *------------------------------------------
  7773. */
  7774. int atcommand_kickid2(
  7775. const int fd, struct map_session_data* sd,
  7776. const char* command, const char* message)
  7777. {
  7778. struct map_session_data *pl_sd;
  7779. int aid=0;
  7780. int session_id=0;
  7781. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7782. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7783. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7784. return -1;
  7785. }
  7786. aid=atoi(message);
  7787. if ((session_id=accountid2sessionid(aid))!=0)
  7788. {
  7789. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7790. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7791. clif_GM_kick(sd, pl_sd, 1);
  7792. else {
  7793. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7794. return -1;
  7795. }
  7796. } else {
  7797. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7798. return -1;
  7799. }
  7800. }
  7801. else
  7802. {
  7803. clif_displaymessage(fd,msg_table[3]);
  7804. }
  7805. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7806. return 0;
  7807. }
  7808. /*==========================================
  7809. * Revive a player by PID number
  7810. * Original by Dino9021
  7811. * Added in by nsstrunks
  7812. *------------------------------------------
  7813. */
  7814. int atcommand_reviveid(
  7815. const int fd, struct map_session_data* sd,
  7816. const char* command, const char* message)
  7817. {
  7818. int cid=0;
  7819. int session_id=0;
  7820. struct map_session_data *pl_sd;
  7821. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7822. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7823. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7824. return -1;
  7825. }
  7826. cid=atoi(message);
  7827. if ((session_id=charid2sessionid(cid))!=0)
  7828. {
  7829. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7830. pl_sd->status.hp = pl_sd->status.max_hp;
  7831. pc_setstand(pl_sd);
  7832. if (battle_config.pc_invincible_time > 0)
  7833. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7834. clif_updatestatus(pl_sd, SP_HP);
  7835. clif_updatestatus(pl_sd, SP_SP);
  7836. clif_resurrection(&pl_sd->bl, 1);
  7837. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7838. } else {
  7839. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7840. return -1;
  7841. }
  7842. }
  7843. else
  7844. {
  7845. clif_displaymessage(fd,msg_table[3]);
  7846. }
  7847. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7848. return 0;
  7849. }
  7850. /*==========================================
  7851. * Revive a player by PID number
  7852. * Original by Dino9021
  7853. * Added in by nsstrunks
  7854. *------------------------------------------
  7855. */
  7856. int atcommand_reviveid2(
  7857. const int fd, struct map_session_data* sd,
  7858. const char* command, const char* message)
  7859. {
  7860. int aid=0;
  7861. int session_id=0;
  7862. struct map_session_data *pl_sd;
  7863. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7864. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7865. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7866. return -1;
  7867. }
  7868. aid=atoi(message);
  7869. if ((session_id=accountid2sessionid(aid))!=0)
  7870. {
  7871. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7872. pl_sd->status.hp = pl_sd->status.max_hp;
  7873. pc_setstand(pl_sd);
  7874. if (battle_config.pc_invincible_time > 0)
  7875. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7876. clif_updatestatus(pl_sd, SP_HP);
  7877. clif_updatestatus(pl_sd, SP_SP);
  7878. clif_resurrection(&pl_sd->bl, 1);
  7879. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7880. } else {
  7881. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7882. return -1;
  7883. }
  7884. }
  7885. else
  7886. {
  7887. clif_displaymessage(fd,msg_table[3]);
  7888. }
  7889. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7890. return 0;
  7891. }
  7892. /*==========================================
  7893. * Kill a player by PID number
  7894. * Original by Dino9021
  7895. * Added in by nsstrunks
  7896. *------------------------------------------
  7897. */
  7898. int atcommand_killid(
  7899. const int fd, struct map_session_data* sd,
  7900. const char* command, const char* message)
  7901. {
  7902. int cid=0;
  7903. int session_id=0;
  7904. struct map_session_data *pl_sd;
  7905. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7906. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7907. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7908. return -1;
  7909. }
  7910. cid=atoi(message);
  7911. if ((session_id=charid2sessionid(cid))!=0)
  7912. {
  7913. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7914. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7915. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7916. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7917. } else {
  7918. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7919. return -1;
  7920. }
  7921. } else {
  7922. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7923. return -1;
  7924. }
  7925. }
  7926. else
  7927. {
  7928. clif_displaymessage(fd,msg_table[3]);
  7929. }
  7930. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7931. return 0;
  7932. }
  7933. /*==========================================
  7934. * Kill a player by PID number
  7935. * Original by Dino9021
  7936. * Added in by nsstrunks
  7937. *------------------------------------------
  7938. */
  7939. int atcommand_killid2(
  7940. const int fd, struct map_session_data* sd,
  7941. const char* command, const char* message)
  7942. {
  7943. int aid=0;
  7944. int session_id=0;
  7945. struct map_session_data *pl_sd;
  7946. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7947. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7948. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7949. return -1;
  7950. }
  7951. aid=atoi(message);
  7952. if ((session_id=accountid2sessionid(aid))!=0)
  7953. {
  7954. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7955. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7956. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7957. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7958. } else {
  7959. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7960. return -1;
  7961. }
  7962. } else {
  7963. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7964. return -1;
  7965. }
  7966. }
  7967. else
  7968. {
  7969. clif_displaymessage(fd,msg_table[3]);
  7970. }
  7971. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7972. return 0;
  7973. }
  7974. /*==========================================
  7975. * Make a player killable, by PID
  7976. * Original by Dino9021
  7977. * Added in by nsstrunks
  7978. *------------------------------------------
  7979. */
  7980. int
  7981. atcommand_charkillableid(
  7982. const int fd, struct map_session_data* sd,
  7983. const char* command, const char* message)
  7984. {
  7985. struct map_session_data *pl_sd = NULL;
  7986. int cid=0;
  7987. int session_id=0;
  7988. if (!message || (cid = atoi(message)) == 0 || !*message)
  7989. return -1;
  7990. cid=atoi(message);
  7991. if ((session_id=charid2sessionid(cid))!=0)
  7992. {
  7993. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7994. return -1;
  7995. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7996. if(pl_sd->special_state.killable)
  7997. clif_displaymessage(fd, "The player is now killable");
  7998. else
  7999. clif_displaymessage(fd, "The player is no longer killable");
  8000. }
  8001. else
  8002. {
  8003. clif_displaymessage(fd,msg_table[3]);
  8004. }
  8005. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  8006. return 0;
  8007. }
  8008. /*==========================================
  8009. * Make a player killable, by PID
  8010. * Original by Dino9021
  8011. * Added in by nsstrunks
  8012. *------------------------------------------
  8013. */
  8014. int
  8015. atcommand_charkillableid2(
  8016. const int fd, struct map_session_data* sd,
  8017. const char* command, const char* message)
  8018. {
  8019. struct map_session_data *pl_sd = NULL;
  8020. int aid=0;
  8021. int session_id=0;
  8022. if (!message || (aid = atoi(message)) == 0 || !*message)
  8023. return -1;
  8024. aid=atoi(message);
  8025. if ((session_id=accountid2sessionid(aid))!=0)
  8026. {
  8027. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8028. return -1;
  8029. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8030. if(pl_sd->special_state.killable)
  8031. clif_displaymessage(fd, "The player is now killable");
  8032. else
  8033. clif_displaymessage(fd, "The player is no longer killable");
  8034. }
  8035. else
  8036. {
  8037. clif_displaymessage(fd,msg_table[3]);
  8038. }
  8039. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8040. return 0;
  8041. }
  8042. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8043. /*==========================================
  8044. * Mail System commands by [Valaris]
  8045. *------------------------------------------
  8046. */
  8047. int atcommand_listmail(
  8048. const int fd, struct map_session_data* sd,
  8049. const char* command, const char* message)
  8050. {
  8051. if(!mail_server_enable)
  8052. return 0;
  8053. nullpo_retr(-1, sd);
  8054. if(strlen(command)==12)
  8055. mail_check(sd,3);
  8056. else if(strlen(command)==9)
  8057. mail_check(sd,2);
  8058. else
  8059. mail_check(sd,1);
  8060. return 0;
  8061. }
  8062. int atcommand_readmail(
  8063. const int fd, struct map_session_data* sd,
  8064. const char* command, const char* message)
  8065. {
  8066. int index;
  8067. if(!mail_server_enable)
  8068. return 0;
  8069. nullpo_retr(-1, sd);
  8070. if (!message || !*message) {
  8071. clif_displaymessage(sd->fd,"You must specify a message number.");
  8072. return 0;
  8073. }
  8074. index = atoi(message);
  8075. if (index < 1) {
  8076. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8077. return 0;
  8078. }
  8079. if(strlen(command)==11)
  8080. mail_delete(sd,index);
  8081. else
  8082. mail_read(sd,index);
  8083. return 0;
  8084. }
  8085. int atcommand_sendmail(
  8086. const int fd, struct map_session_data* sd,
  8087. const char* command, const char* message)
  8088. {
  8089. char name[NAME_LENGTH],text[80];
  8090. if(!mail_server_enable)
  8091. return 0;
  8092. nullpo_retr(-1, sd);
  8093. if (!message || !*message) {
  8094. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8095. return 0;
  8096. }
  8097. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8098. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8099. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8100. return 0;
  8101. }
  8102. if(strlen(command)==17)
  8103. mail_send(sd,name,text,1);
  8104. else
  8105. mail_send(sd,name,text,0);
  8106. return 0;
  8107. }
  8108. /*==========================================
  8109. * Refresh online command for SQL [Valaris]
  8110. * Will refresh and check online column of
  8111. * players and set correctly.
  8112. *------------------------------------------
  8113. */
  8114. int atcommand_refreshonline(
  8115. const int fd, struct map_session_data* sd,
  8116. const char* command, const char* message)
  8117. {
  8118. send_users_tochar(-1, gettick(), 0, 0);
  8119. return 0;
  8120. }
  8121. #endif /* end sql only */
  8122. /*==========================================
  8123. * Show Monster DB Info v 1.0
  8124. * originally by [Lupus] eAthena
  8125. *------------------------------------------
  8126. */
  8127. int atcommand_mobinfo(
  8128. const int fd, struct map_session_data* sd,
  8129. const char* command, const char* message)
  8130. {
  8131. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8132. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8133. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8134. char atcmd_output2[200];
  8135. struct item_data *item_data;
  8136. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8137. int mob_id, count;
  8138. int i, j, k;
  8139. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8140. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8141. if (!message || !*message) {
  8142. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8143. return -1;
  8144. }
  8145. // If monster identifier/name argument is a name
  8146. if ((mob_id = mobdb_checkid(atoi(message))))
  8147. {
  8148. mob_array[0] = mob_db(mob_id);
  8149. count = 1;
  8150. } else
  8151. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8152. if (!count) {
  8153. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8154. return -1;
  8155. }
  8156. if (count > MAX_SEARCH) {
  8157. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8158. clif_displaymessage(fd, atcmd_output);
  8159. count = MAX_SEARCH;
  8160. }
  8161. for (k = 0; k < count; k++) {
  8162. mob = mob_array[k];
  8163. // stats
  8164. if (mob->mexp)
  8165. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8166. else
  8167. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8168. clif_displaymessage(fd, atcmd_output);
  8169. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%d Job EXP:%d", mob->lv, mob->max_hp, mob->max_sp, mob->base_exp, mob->job_exp);
  8170. clif_displaymessage(fd, atcmd_output);
  8171. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d", mob->def, mob->mdef, mob->str, mob->agi, mob->vit, mob->int_, mob->dex, mob->luk);
  8172. clif_displaymessage(fd, atcmd_output);
  8173. if (mob->element < 20) {
  8174. //Element - None, Level 0
  8175. i = 0;
  8176. j = 0;
  8177. } else {
  8178. i = mob->element % 20 + 1;
  8179. j = mob->element / 20;
  8180. }
  8181. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)", mob->atk1, mob->atk2, mob->range, mob->range2 , mob->range3, msize[mob->size], mrace[mob->race], melement[i], j);
  8182. clif_displaymessage(fd, atcmd_output);
  8183. // drops
  8184. clif_displaymessage(fd, " Drops:");
  8185. strcpy(atcmd_output, " ");
  8186. j = 0;
  8187. for (i = 0; i < 10; i++) {
  8188. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8189. continue;
  8190. if (mob->dropitem[i].p > 0) {
  8191. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8192. strcat(atcmd_output, atcmd_output2);
  8193. if (++j % 3 == 0) {
  8194. clif_displaymessage(fd, atcmd_output);
  8195. strcpy(atcmd_output, " ");
  8196. }
  8197. }
  8198. }
  8199. if (j == 0)
  8200. clif_displaymessage(fd, "This monster has no drops.");
  8201. else if (j % 3 != 0)
  8202. clif_displaymessage(fd, atcmd_output);
  8203. // mvp
  8204. if (mob->mexp) {
  8205. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8206. clif_displaymessage(fd, atcmd_output);
  8207. strcpy(atcmd_output, " MVP Items:");
  8208. j = 0;
  8209. for (i = 0; i < 3; i++) {
  8210. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8211. continue;
  8212. if (mob->mvpitem[i].p > 0) {
  8213. j++;
  8214. if (j == 1)
  8215. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8216. else
  8217. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8218. strcat(atcmd_output, atcmd_output2);
  8219. }
  8220. }
  8221. if (j == 0)
  8222. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8223. else
  8224. clif_displaymessage(fd, atcmd_output);
  8225. }
  8226. }
  8227. return 0;
  8228. }
  8229. /*==========================================
  8230. * Show Items DB Info v 1.0
  8231. * originally by [Lupus] eAthena
  8232. *------------------------------------------
  8233. */
  8234. int atcommand_iteminfo(
  8235. const int fd, struct map_session_data* sd,
  8236. const char* command, const char* message)
  8237. {
  8238. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8239. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8240. struct item_data *item_data, *item_array[MAX_SEARCH];
  8241. int i, item_id=0, count = 1;
  8242. if (!message || !*message) {
  8243. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8244. return -1;
  8245. }
  8246. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8247. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8248. if (!count) {
  8249. clif_displaymessage(fd, "Item not found.");
  8250. return -1;
  8251. }
  8252. if (count > MAX_SEARCH) {
  8253. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8254. clif_displaymessage(fd, atcmd_output);
  8255. count = MAX_SEARCH;
  8256. }
  8257. for (i = 0; i < MAX_SEARCH; i++) {
  8258. item_data = item_array[i];
  8259. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8260. item_data->name,item_data->jname,item_data->slot,item_id,
  8261. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8262. (item_data->script==NULL)? "None" : "With script"
  8263. );
  8264. clif_displaymessage(fd, atcmd_output);
  8265. sprintf(atcmd_output, "NPC Buy:%dz%s, Sell:%dz%s | Weight: %d ", 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 );
  8266. clif_displaymessage(fd, atcmd_output);
  8267. if (item_data->maxchance == 10000)
  8268. strcpy(atcmd_output, " - Available in the shops only");
  8269. else if (item_data->maxchance)
  8270. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8271. else
  8272. strcpy(atcmd_output, " - Monsters don't drop this item");
  8273. clif_displaymessage(fd, atcmd_output);
  8274. return 0;
  8275. }
  8276. clif_displaymessage(fd, "Item not found.");
  8277. return -1;
  8278. }
  8279. /*==========================================
  8280. * Show who drops the item.
  8281. *------------------------------------------
  8282. */
  8283. int atcommand_whodrops(
  8284. const int fd, struct map_session_data* sd,
  8285. const char* command, const char* message)
  8286. {
  8287. struct item_data *item_data, *item_array[MAX_SEARCH];
  8288. int i,j, count = 1;
  8289. if (!message || !*message) {
  8290. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8291. return -1;
  8292. }
  8293. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8294. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8295. if (!count) {
  8296. clif_displaymessage(fd, "Item not found.");
  8297. return -1;
  8298. }
  8299. if (count > MAX_SEARCH) {
  8300. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8301. clif_displaymessage(fd, atcmd_output);
  8302. count = MAX_SEARCH;
  8303. }
  8304. for (i = 0; i < count; i++) {
  8305. item_data = item_array[i];
  8306. sprintf(atcmd_output, "Item: '%s'[%d]",
  8307. item_data->jname,item_data->slot);
  8308. clif_displaymessage(fd, atcmd_output);
  8309. if (item_data->mob[0].chance == 0) {
  8310. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8311. clif_displaymessage(fd, atcmd_output);
  8312. } else {
  8313. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8314. clif_displaymessage(fd, atcmd_output);
  8315. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8316. {
  8317. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8318. clif_displaymessage(fd, atcmd_output);
  8319. }
  8320. }
  8321. }
  8322. return 0;
  8323. }
  8324. /*==========================================
  8325. * @adopt by [Veider]
  8326. *
  8327. * adopt a novice
  8328. *------------------------------------------
  8329. */
  8330. int
  8331. atcommand_adopt(const int fd, struct map_session_data* sd,
  8332. const char* command, const char* message)
  8333. {
  8334. struct map_session_data *pl_sd1 = NULL;
  8335. struct map_session_data *pl_sd2 = NULL;
  8336. struct map_session_data *pl_sd3 = NULL;
  8337. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8338. nullpo_retr(-1, sd);
  8339. if (!message || !*message)
  8340. return -1;
  8341. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8342. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8343. return -1;
  8344. }
  8345. if (battle_config.etc_log)
  8346. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8347. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8348. sprintf(player2, "Cannot find player %s online", player1);
  8349. clif_displaymessage(fd, player2);
  8350. return -1;
  8351. }
  8352. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8353. sprintf(player1, "Cannot find player %s online", player2);
  8354. clif_displaymessage(fd, player1);
  8355. return -1;
  8356. }
  8357. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8358. sprintf(player1, "Cannot find player %s online", player3);
  8359. clif_displaymessage(fd, player1);
  8360. return -1;
  8361. }
  8362. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8363. clif_displaymessage(fd, "They are too young to be parents!");
  8364. return -1;
  8365. }
  8366. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8367. clif_displaymessage(fd, "They are family.. wish them luck");
  8368. return 0;
  8369. }
  8370. else
  8371. return -1;
  8372. }
  8373. int atcommand_version(
  8374. const int fd, struct map_session_data* sd,
  8375. const char* command, const char* message)
  8376. {
  8377. const char * revision;
  8378. if ((revision = get_svn_revision()) != 0) {
  8379. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8380. clif_displaymessage(fd,atcmd_output);
  8381. } else
  8382. clif_displaymessage(fd,"Cannot determine SVN revision");
  8383. return 0;
  8384. }
  8385. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8386. {
  8387. int time, id;
  8388. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8389. if (pl_sd == NULL)
  8390. return 0;
  8391. id = va_arg(ap, int);
  8392. time = va_arg(ap, int);
  8393. if (id != bl->id && !pc_isGM(pl_sd)) {
  8394. pl_sd->status.manner -= time;
  8395. if (pl_sd->status.manner < 0)
  8396. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8397. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8398. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8399. }
  8400. return 0;
  8401. }
  8402. /*==========================================
  8403. * @mutearea by MouseJstr
  8404. *------------------------------------------
  8405. */
  8406. int atcommand_mutearea(
  8407. const int fd, struct map_session_data* sd,
  8408. const char* command, const char* message)
  8409. {
  8410. int time;
  8411. nullpo_retr(0, sd);
  8412. if(!battle_config.muting_players) {
  8413. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8414. return 0;
  8415. }
  8416. time = atoi(message);
  8417. if (!time)
  8418. time = 15; // 15 minutes default
  8419. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8420. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8421. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8422. return 0;
  8423. }
  8424. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8425. {
  8426. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8427. if (bl == NULL)
  8428. return 0;
  8429. if (!pc_isGM(pl_sd))
  8430. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8431. return 0;
  8432. }
  8433. /*==========================================
  8434. * @shuffle by MouseJstr
  8435. *------------------------------------------
  8436. */
  8437. int atcommand_shuffle(
  8438. const int fd, struct map_session_data* sd,
  8439. const char* command, const char* message)
  8440. {
  8441. nullpo_retr(0, sd);
  8442. if (strcmp(message, "area")== 0) {
  8443. map_foreachinarea(atcommand_shuffle_sub,sd->bl.m,
  8444. sd->bl.x-AREA_SIZE,sd->bl.y-AREA_SIZE,
  8445. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC);
  8446. } else if (strcmp(message, "map")== 0) {
  8447. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8448. } else if (strcmp(message, "world") == 0) {
  8449. struct map_session_data **pl_allsd;
  8450. int i, users;
  8451. pl_allsd = map_getallusers(&users);
  8452. for (i = 0; i < users; i++)
  8453. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8454. } else
  8455. clif_displaymessage(fd, "options are area, map, or world");
  8456. return 0;
  8457. }
  8458. int atcommand_rates(
  8459. const int fd, struct map_session_data* sd,
  8460. const char* command, const char* message)
  8461. {
  8462. char buf[255];
  8463. nullpo_retr(0, sd);
  8464. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8465. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8466. clif_displaymessage(fd, buf);
  8467. return 0;
  8468. }
  8469. /*==========================================
  8470. * @me by lordalfa
  8471. * => Displays the OUTPUT string on top of
  8472. * the Visible players Heads.
  8473. *------------------------------------------
  8474. */
  8475. int atcommand_me(
  8476. const int fd, struct map_session_data* sd,
  8477. const char* command, const char* message)
  8478. {
  8479. char tempmes[200];
  8480. nullpo_retr(-1, sd);
  8481. memset(tempmes, '\0', sizeof(tempmes));
  8482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8483. if (!message || !*message) {
  8484. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8485. return -1;
  8486. }
  8487. sscanf(message, "%199[^\n]", tempmes);
  8488. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8489. clif_disp_overhead(sd, atcmd_output);
  8490. return 0;
  8491. }
  8492. /*==========================================
  8493. * @size
  8494. * => Resize your character sprite. [Valaris]
  8495. *------------------------------------------
  8496. */
  8497. int atcommand_size(
  8498. const int fd, struct map_session_data* sd,
  8499. const char* command, const char* message)
  8500. {
  8501. int size=0;
  8502. nullpo_retr(-1, sd);
  8503. if (!message || !*message)
  8504. return -1;
  8505. if (sscanf(message,"%d", &size) < 1)
  8506. return -1;
  8507. if(sd->state.size) {
  8508. sd->state.size=0;
  8509. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8510. }
  8511. if(size==1) {
  8512. sd->state.size=1;
  8513. clif_specialeffect(&sd->bl,420,0);
  8514. } else if(size==2) {
  8515. sd->state.size=2;
  8516. clif_specialeffect(&sd->bl,422,0);
  8517. }
  8518. return 0;
  8519. }
  8520. /*==========================================
  8521. * @monsterignore
  8522. * => Makes monsters ignore you. [Valaris]
  8523. *------------------------------------------
  8524. */
  8525. int atcommand_monsterignore(
  8526. const int fd, struct map_session_data* sd,
  8527. const char* command, const char* message)
  8528. {
  8529. nullpo_retr(-1, sd);
  8530. if (!sd->state.monster_ignore) {
  8531. sd->state.monster_ignore = 1;
  8532. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8533. } else {
  8534. sd->state.monster_ignore = 0;
  8535. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8536. }
  8537. return 0;
  8538. }
  8539. /*==========================================
  8540. * @fakename
  8541. * => Gives your character a fake name. [Valaris]
  8542. *------------------------------------------
  8543. */
  8544. int atcommand_fakename(
  8545. const int fd, struct map_session_data* sd,
  8546. const char* command, const char* message)
  8547. {
  8548. char name[NAME_LENGTH];
  8549. nullpo_retr(-1, sd);
  8550. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8551. sd->fakename[0]='\0';
  8552. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8553. clif_displaymessage(sd->fd,"Returned to real name.");
  8554. return 0;
  8555. }
  8556. if (!message || !*message) {
  8557. clif_displaymessage(sd->fd,"You must enter a name.");
  8558. return 0;
  8559. }
  8560. if (sscanf(message, "%23[^\n]", name) < 1) {
  8561. return 0;
  8562. }
  8563. if(strlen(name) < 2) {
  8564. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8565. return 0;
  8566. }
  8567. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8568. clif_charnameack(0, &sd->bl);
  8569. clif_displaymessage(sd->fd,"Fake name enabled.");
  8570. return 0;
  8571. }
  8572. /*==========================================
  8573. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8574. * => Shows information about the map flags [map name]
  8575. * Also set flags
  8576. *------------------------------------------
  8577. */
  8578. int atcommand_mapflag(
  8579. const int fd, struct map_session_data* sd,
  8580. const char* command, const char* message)
  8581. {
  8582. // WIP
  8583. return 0;
  8584. }
  8585. /*===================================
  8586. * Remove some messages
  8587. *-----------------------------------
  8588. */
  8589. int atcommand_showexp(
  8590. const int fd, struct map_session_data* sd,
  8591. const char* command, const char* message)
  8592. {
  8593. if (sd->state.showexp) {
  8594. sd->state.showexp = 0;
  8595. clif_displaymessage(fd, "Gained exp will not be shown.");
  8596. return 0;
  8597. }
  8598. sd->state.showexp = 1;
  8599. clif_displaymessage(fd, "Gained exp is now shown");
  8600. return 0;
  8601. }
  8602. int atcommand_showzeny(
  8603. const int fd, struct map_session_data* sd,
  8604. const char* command, const char* message)
  8605. {
  8606. if (sd->state.showzeny) {
  8607. sd->state.showzeny = 0;
  8608. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8609. return 0;
  8610. }
  8611. sd->state.showzeny = 1;
  8612. clif_displaymessage(fd, "Gained zeny is now shown");
  8613. return 0;
  8614. }
  8615. int atcommand_showdelay(
  8616. const int fd, struct map_session_data* sd,
  8617. const char* command, const char* message)
  8618. {
  8619. if (sd->state.showdelay) {
  8620. sd->state.showdelay = 0;
  8621. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8622. return 0;
  8623. }
  8624. sd->state.showdelay = 1;
  8625. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8626. return 0;
  8627. }
  8628. /*==========================================
  8629. * Duel organizing functions [LuzZza]
  8630. *
  8631. * @duel [limit|nick] - create a duel
  8632. * @invite <nick> - invite player
  8633. * @accept - accept invitation
  8634. * @reject - reject invitation
  8635. * @leave - leave duel
  8636. *------------------------------------------
  8637. */
  8638. int atcommand_invite(
  8639. const int fd, struct map_session_data* sd,
  8640. const char* command, const char* message)
  8641. {
  8642. unsigned int did = sd->duel_group;
  8643. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8644. if(did <= 0) {
  8645. // "Duel: @invite without @duel."
  8646. clif_displaymessage(fd, msg_txt(350));
  8647. return 0;
  8648. }
  8649. if(duel_list[did].max_players_limit > 0 &&
  8650. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8651. // "Duel: Limit of players is reached."
  8652. clif_displaymessage(fd, msg_txt(351));
  8653. return 0;
  8654. }
  8655. if(target_sd == NULL) {
  8656. // "Duel: Player not found."
  8657. clif_displaymessage(fd, msg_txt(352));
  8658. return 0;
  8659. }
  8660. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8661. // "Duel: Player already in duel."
  8662. clif_displaymessage(fd, msg_txt(353));
  8663. return 0;
  8664. }
  8665. duel_invite(did, sd, target_sd);
  8666. // "Duel: Invitation has been sent."
  8667. clif_displaymessage(fd, msg_txt(354));
  8668. return 0;
  8669. }
  8670. int atcommand_duel(
  8671. const int fd, struct map_session_data* sd,
  8672. const char* command, const char* message)
  8673. {
  8674. char output[256];
  8675. unsigned int maxpl=0, newduel;
  8676. struct map_session_data *target_sd;
  8677. /* // Commnted because it can be disabled in at-comms conf.
  8678. if(!battle_config.duel_enable) {
  8679. clif_displaymessage(fd, "Duel: duel is disable.");
  8680. return 0;
  8681. }
  8682. */
  8683. if(sd->duel_group > 0) {
  8684. duel_showinfo(sd->duel_group, sd);
  8685. return 0;
  8686. }
  8687. if(sd->duel_invite > 0) {
  8688. // "Duel: @duel without @reject."
  8689. clif_displaymessage(fd, msg_txt(355));
  8690. return 0;
  8691. }
  8692. if(!duel_checktime(sd)) {
  8693. // "Duel: You can take part in duel only one time per %d minutes."
  8694. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8695. clif_displaymessage(fd, output);
  8696. return 0;
  8697. }
  8698. if(strlen(message) > 0) {
  8699. if(sscanf(message, "%d", &maxpl) >= 1) {
  8700. if(maxpl < 2 || maxpl > 65535) {
  8701. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8702. return 0;
  8703. }
  8704. duel_create(sd, maxpl);
  8705. } else {
  8706. target_sd = map_nick2sd((char *)message);
  8707. if(target_sd != NULL) {
  8708. if((newduel = duel_create(sd, 2)) != -1) {
  8709. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8710. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8711. return 0;
  8712. }
  8713. duel_invite(newduel, sd, target_sd);
  8714. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8715. }
  8716. } else {
  8717. // "Duel: Player not found."
  8718. clif_displaymessage(fd, msg_txt(352));
  8719. return 0;
  8720. }
  8721. }
  8722. } else
  8723. duel_create(sd, 0);
  8724. return 0;
  8725. }
  8726. int atcommand_leave(
  8727. const int fd, struct map_session_data* sd,
  8728. const char* command, const char* message)
  8729. {
  8730. if(sd->duel_group <= 0) {
  8731. // "Duel: @leave without @duel."
  8732. clif_displaymessage(fd, msg_txt(358));
  8733. return 0;
  8734. }
  8735. duel_leave(sd->duel_group, sd);
  8736. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8737. return 0;
  8738. }
  8739. int atcommand_accept(
  8740. const int fd, struct map_session_data* sd,
  8741. const char* command, const char* message)
  8742. {
  8743. char output[256];
  8744. if(!duel_checktime(sd)) {
  8745. // "Duel: You can take part in duel only one time per %d minutes."
  8746. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8747. clif_displaymessage(fd, output);
  8748. return 0;
  8749. }
  8750. if(sd->duel_invite <= 0) {
  8751. // "Duel: @accept without invititation."
  8752. clif_displaymessage(fd, msg_txt(360));
  8753. return 0;
  8754. }
  8755. duel_accept(sd->duel_invite, sd);
  8756. // "Duel: Invitation has been accepted."
  8757. clif_displaymessage(fd, msg_txt(361));
  8758. return 0;
  8759. }
  8760. int atcommand_reject(
  8761. const int fd, struct map_session_data* sd,
  8762. const char* command, const char* message)
  8763. {
  8764. if(sd->duel_invite <= 0) {
  8765. // "Duel: @reject without invititation."
  8766. clif_displaymessage(fd, msg_txt(362));
  8767. return 0;
  8768. }
  8769. duel_reject(sd->duel_invite, sd);
  8770. // "Duel: Invitation has been rejected."
  8771. clif_displaymessage(fd, msg_txt(363));
  8772. return 0;
  8773. }
  8774. /*===================================
  8775. * Away message (@away, @aw) [LuzZza]
  8776. *-----------------------------------
  8777. */
  8778. int atcommand_away(
  8779. const int fd, struct map_session_data* sd,
  8780. const char* command, const char* message)
  8781. {
  8782. if(strlen(message) > 0) {
  8783. if(strlen(message) > 128)
  8784. return -1;
  8785. strcpy(sd->away_message, message);
  8786. //"Away automessage has been activated."
  8787. clif_displaymessage(fd, msg_txt(546));
  8788. } else {
  8789. if(strlen(sd->away_message) > 0) {
  8790. sd->away_message[0] = 0;
  8791. //"Away automessage has been disabled."
  8792. clif_displaymessage(fd, msg_txt(547));
  8793. return 0;
  8794. }
  8795. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8796. clif_displaymessage(fd, msg_txt(548));
  8797. }
  8798. return 0;
  8799. }
  8800. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8801. int atcommand_clone(
  8802. const int fd, struct map_session_data* sd,
  8803. const char* command, const char* message)
  8804. {
  8805. int x=0,y=0,flag=0,master=0,i=0;
  8806. struct map_session_data *pl_sd=NULL;
  8807. if (!message || !*message) {
  8808. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8809. return 0;
  8810. }
  8811. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8812. clif_displaymessage(fd, msg_txt(3));
  8813. return 0;
  8814. }
  8815. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8816. clif_displaymessage(fd, msg_txt(126));
  8817. return 0;
  8818. }
  8819. if (strcmpi(command, "@clone") == 0)
  8820. flag = 1;
  8821. else if (strcmpi(command, "@slaveclone") == 0) {
  8822. flag = 2;
  8823. master = sd->bl.id;
  8824. if (battle_config.atc_slave_clone_limit
  8825. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8826. clif_displaymessage(fd, "");
  8827. return 0;
  8828. }
  8829. }
  8830. do {
  8831. x = sd->bl.x + (rand() % 10 - 5);
  8832. y = sd->bl.y + (rand() % 10 - 5);
  8833. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8834. if (i >= 10) {
  8835. x = sd->bl.x;
  8836. y = sd->bl.y;
  8837. }
  8838. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8839. clif_displaymessage(fd, msg_txt(128+flag*2));
  8840. return 0;
  8841. }
  8842. clif_displaymessage(fd, msg_txt(129+flag*2));
  8843. return 0;
  8844. }
  8845. /*===================================
  8846. * Main chat [LuzZza]
  8847. * Usage: @main <on|off|message>
  8848. *-----------------------------------
  8849. */
  8850. int atcommand_main(
  8851. const int fd, struct map_session_data* sd,
  8852. const char* command, const char* message)
  8853. {
  8854. if(strlen(message) > 0) {
  8855. if(strlen(message) > 128)
  8856. return -1;
  8857. if(strcmpi(message, "on") == 0) {
  8858. if(!sd->state.mainchat) {
  8859. sd->state.mainchat = 1;
  8860. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8861. } else {
  8862. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8863. }
  8864. } else if(strcmpi(message, "off") == 0) {
  8865. if(sd->state.mainchat) {
  8866. sd->state.mainchat = 0;
  8867. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8868. } else {
  8869. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8870. }
  8871. } else {
  8872. if(!sd->state.mainchat) {
  8873. sd->state.mainchat = 1;
  8874. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8875. }
  8876. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8877. clif_displaymessage(fd, msg_txt(387));
  8878. return -1;
  8879. }
  8880. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8881. // I use 0xFE000000 color for signalizing that this message is
  8882. // main chat message. 0xFE000000 is invalid color, same using
  8883. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8884. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8885. }
  8886. } else {
  8887. if(sd->state.mainchat)
  8888. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8889. clif_displaymessage(fd, msg_txt(384));
  8890. else
  8891. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8892. clif_displaymessage(fd, msg_txt(385));
  8893. }
  8894. return 0;
  8895. }
  8896. void do_init_atcommand() {
  8897. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8898. duel_count = 0;
  8899. memset(&duel_list[0], 0, sizeof(duel_list));
  8900. return;
  8901. }
  8902. void do_final_atcommand() {
  8903. users_db->destroy(users_db,NULL);
  8904. }