atcommand.c 308 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <math.h>
  8. #include <limits.h>
  9. #include "../common/socket.h"
  10. #include "../common/timer.h"
  11. #include "../common/nullpo.h"
  12. #include "../common/mmo.h"
  13. #include "../common/core.h"
  14. #include "../common/showmsg.h"
  15. #include "log.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "intif.h"
  19. #include "itemdb.h"
  20. #include "map.h"
  21. #include "pc.h"
  22. #include "status.h"
  23. #include "skill.h"
  24. #include "mob.h"
  25. #include "pet.h"
  26. #include "battle.h"
  27. #include "party.h"
  28. #include "guild.h"
  29. #include "atcommand.h"
  30. #include "script.h"
  31. #include "npc.h"
  32. #include "trade.h"
  33. #include "unit.h"
  34. #ifndef TXT_ONLY
  35. #include "mail.h"
  36. #endif
  37. static char command_symbol = '@'; // first char of the commands (by [Yor])
  38. char *msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  39. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  40. ACMD_FUNC(broadcast);
  41. ACMD_FUNC(localbroadcast);
  42. ACMD_FUNC(rura);
  43. ACMD_FUNC(where);
  44. ACMD_FUNC(jumpto);
  45. ACMD_FUNC(jump);
  46. ACMD_FUNC(who);
  47. ACMD_FUNC(who2);
  48. ACMD_FUNC(who3);
  49. ACMD_FUNC(whomap);
  50. ACMD_FUNC(whomap2);
  51. ACMD_FUNC(whomap3);
  52. ACMD_FUNC(whogm); // by Yor
  53. ACMD_FUNC(whozeny); // [Valaris]
  54. ACMD_FUNC(happyhappyjoyjoy); // [Valaris]
  55. ACMD_FUNC(save);
  56. ACMD_FUNC(load);
  57. ACMD_FUNC(speed);
  58. ACMD_FUNC(storage);
  59. ACMD_FUNC(guildstorage);
  60. ACMD_FUNC(option);
  61. ACMD_FUNC(hide);
  62. ACMD_FUNC(jobchange);
  63. ACMD_FUNC(die);
  64. ACMD_FUNC(kill);
  65. ACMD_FUNC(alive);
  66. ACMD_FUNC(kami);
  67. ACMD_FUNC(heal);
  68. ACMD_FUNC(item);
  69. ACMD_FUNC(item2);
  70. ACMD_FUNC(itemreset);
  71. ACMD_FUNC(itemcheck);
  72. ACMD_FUNC(baselevelup);
  73. ACMD_FUNC(joblevelup);
  74. ACMD_FUNC(help);
  75. ACMD_FUNC(help2);
  76. ACMD_FUNC(gm);
  77. ACMD_FUNC(pvpoff);
  78. ACMD_FUNC(pvpon);
  79. ACMD_FUNC(gvgoff);
  80. ACMD_FUNC(gvgon);
  81. ACMD_FUNC(model);
  82. ACMD_FUNC(go);
  83. ACMD_FUNC(monster);
  84. ACMD_FUNC(monstersmall);
  85. ACMD_FUNC(monsterbig);
  86. ACMD_FUNC(spawn);
  87. ACMD_FUNC(killmonster);
  88. ACMD_FUNC(killmonster2);
  89. ACMD_FUNC(refine);
  90. ACMD_FUNC(produce);
  91. ACMD_FUNC(memo);
  92. ACMD_FUNC(gat);
  93. ACMD_FUNC(packet);
  94. ACMD_FUNC(waterlevel);
  95. ACMD_FUNC(statuspoint);
  96. ACMD_FUNC(skillpoint);
  97. ACMD_FUNC(zeny);
  98. ACMD_FUNC(param);
  99. ACMD_FUNC(guildlevelup);
  100. ACMD_FUNC(makeegg);
  101. ACMD_FUNC(hatch);
  102. ACMD_FUNC(petfriendly);
  103. ACMD_FUNC(pethungry);
  104. ACMD_FUNC(petrename);
  105. ACMD_FUNC(recall);
  106. ACMD_FUNC(recallall);
  107. ACMD_FUNC(revive);
  108. ACMD_FUNC(night);
  109. ACMD_FUNC(day);
  110. ACMD_FUNC(doom);
  111. ACMD_FUNC(doommap);
  112. ACMD_FUNC(raise);
  113. ACMD_FUNC(raisemap);
  114. ACMD_FUNC(kick);
  115. ACMD_FUNC(kickall);
  116. ACMD_FUNC(allskill);
  117. ACMD_FUNC(questskill);
  118. ACMD_FUNC(lostskill);
  119. ACMD_FUNC(spiritball);
  120. ACMD_FUNC(party);
  121. ACMD_FUNC(guild);
  122. ACMD_FUNC(agitstart);
  123. ACMD_FUNC(agitend);
  124. ACMD_FUNC(reloaditemdb);
  125. ACMD_FUNC(reloadmobdb);
  126. ACMD_FUNC(reloadskilldb);
  127. ACMD_FUNC(reloadscript);
  128. ACMD_FUNC(reloadgmdb); // by Yor
  129. ACMD_FUNC(reloadatcommand);
  130. ACMD_FUNC(reloadbattleconf);
  131. ACMD_FUNC(reloadstatusdb);
  132. ACMD_FUNC(reloadpcdb);
  133. ACMD_FUNC(reloadmotd); // [Valaris]
  134. ACMD_FUNC(mapexit);
  135. ACMD_FUNC(idsearch);
  136. ACMD_FUNC(mapinfo);
  137. ACMD_FUNC(dye); //** by fritz
  138. ACMD_FUNC(hair_style); //** by fritz
  139. ACMD_FUNC(hair_color); //** by fritz
  140. ACMD_FUNC(stat_all); //** by fritz
  141. ACMD_FUNC(char_block); // by Yor
  142. ACMD_FUNC(char_ban); // by Yor
  143. ACMD_FUNC(char_unblock); // by Yor
  144. ACMD_FUNC(char_unban); // by Yor
  145. ACMD_FUNC(mount_peco); // by Valaris
  146. ACMD_FUNC(char_mount_peco); // by Yor
  147. ACMD_FUNC(guildspy); // [Syrus22]
  148. ACMD_FUNC(partyspy); // [Syrus22]
  149. ACMD_FUNC(repairall); // [Valaris]
  150. ACMD_FUNC(guildrecall); // by Yor
  151. ACMD_FUNC(partyrecall); // by Yor
  152. ACMD_FUNC(nuke); // [Valaris]
  153. ACMD_FUNC(shownpc);
  154. ACMD_FUNC(hidenpc);
  155. ACMD_FUNC(loadnpc);
  156. ACMD_FUNC(unloadnpc);
  157. ACMD_FUNC(servertime); // by Yor
  158. ACMD_FUNC(chardelitem); // by Yor
  159. ACMD_FUNC(jail); // by Yor
  160. ACMD_FUNC(unjail); // by Yor
  161. ACMD_FUNC(disguise); // [Valaris]
  162. ACMD_FUNC(undisguise); // by Yor
  163. ACMD_FUNC(chardisguise); // Kalaspuff
  164. ACMD_FUNC(charundisguise); // Kalaspuff
  165. ACMD_FUNC(email); // by Yor
  166. ACMD_FUNC(effect);//by Apple
  167. ACMD_FUNC(character_cart_list); // by Yor
  168. ACMD_FUNC(addwarp); // by MouseJstr
  169. ACMD_FUNC(follow); // by MouseJstr
  170. ACMD_FUNC(skillon); // by MouseJstr
  171. ACMD_FUNC(skilloff); // by MouseJstr
  172. ACMD_FUNC(killer); // by MouseJstr
  173. ACMD_FUNC(npcmove); // by MouseJstr
  174. ACMD_FUNC(killable); // by MouseJstr
  175. ACMD_FUNC(charkillable); // by MouseJstr
  176. ACMD_FUNC(dropall); // by MouseJstr
  177. ACMD_FUNC(chardropall); // by MouseJstr
  178. ACMD_FUNC(storeall); // by MouseJstr
  179. ACMD_FUNC(charstoreall); // by MouseJstr
  180. ACMD_FUNC(skillid); // by MouseJstr
  181. ACMD_FUNC(useskill); // by MouseJstr
  182. ACMD_FUNC(summon);
  183. ACMD_FUNC(rain);
  184. ACMD_FUNC(snow);
  185. ACMD_FUNC(sakura);
  186. ACMD_FUNC(clouds);
  187. ACMD_FUNC(clouds2); // [Valaris]
  188. ACMD_FUNC(fog);
  189. ACMD_FUNC(fireworks);
  190. ACMD_FUNC(leaves);
  191. ACMD_FUNC(adjgmlvl); // by MouseJstr
  192. ACMD_FUNC(adjcmdlvl); // by MouseJstr
  193. ACMD_FUNC(trade); // by MouseJstr
  194. ACMD_FUNC(send); // by davidsiaw
  195. ACMD_FUNC(setbattleflag); // by MouseJstr
  196. ACMD_FUNC(unmute); // [Valaris]
  197. ACMD_FUNC(clearweather); // Dexity
  198. ACMD_FUNC(uptime); // by MC Cameri
  199. ACMD_FUNC(changesex); // by MC Cameri
  200. ACMD_FUNC(mute); // celest
  201. ACMD_FUNC(refresh); // by MC Cameri
  202. ACMD_FUNC(petid); // by MC Cameri
  203. ACMD_FUNC(identify); // by MC Cameri
  204. ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
  205. ACMD_FUNC(misceffect); // by MC Cameri
  206. ACMD_FUNC(mobsearch);
  207. ACMD_FUNC(cleanmap);
  208. ACMD_FUNC(npctalk);
  209. ACMD_FUNC(pettalk);
  210. ACMD_FUNC(users);
  211. ACMD_FUNC(autoloot); // Improved version imported from Freya.
  212. #ifndef TXT_ONLY
  213. ACMD_FUNC(checkmail); // [Valaris]
  214. ACMD_FUNC(listmail); // [Valaris]
  215. ACMD_FUNC(listnewmail); // [Valaris]
  216. ACMD_FUNC(readmail); // [Valaris]
  217. ACMD_FUNC(sendmail); // [Valaris]
  218. ACMD_FUNC(sendprioritymail); // [Valaris]
  219. ACMD_FUNC(deletemail); // [Valaris]
  220. ACMD_FUNC(refreshonline); // [Valaris]
  221. #endif /* TXT_ONLY */
  222. ACMD_FUNC(skilltree); // by MouseJstr
  223. ACMD_FUNC(marry); // by MouseJstr
  224. ACMD_FUNC(divorce); // by MouseJstr
  225. ACMD_FUNC(grind); // by MouseJstr
  226. ACMD_FUNC(grind2); // by MouseJstr
  227. #ifdef DMALLOC
  228. ACMD_FUNC(dmstart); // by MouseJstr
  229. ACMD_FUNC(dmtick); // by MouseJstr
  230. #endif
  231. ACMD_FUNC(jumptoid); // by Dino9021
  232. ACMD_FUNC(jumptoid2); // by Dino9021
  233. ACMD_FUNC(recallid); // by Dino9021
  234. ACMD_FUNC(recallid2); // by Dino9021
  235. ACMD_FUNC(kickid); // by Dino9021
  236. ACMD_FUNC(kickid2); // by Dino9021
  237. ACMD_FUNC(reviveid); // by Dino9021
  238. ACMD_FUNC(reviveid2); // by Dino9021
  239. ACMD_FUNC(killid); // by Dino9021
  240. ACMD_FUNC(killid2); // by Dino9021
  241. ACMD_FUNC(charkillableid); // by Dino9021
  242. ACMD_FUNC(charkillableid2); // by Dino9021
  243. ACMD_FUNC(sound);
  244. ACMD_FUNC(undisguiseall);
  245. ACMD_FUNC(disguiseall);
  246. ACMD_FUNC(changelook);
  247. ACMD_FUNC(mobinfo); //by Lupus
  248. ACMD_FUNC(exp); // by Skotlex
  249. ACMD_FUNC(adopt); // by Veider
  250. ACMD_FUNC(version); // by Ancyker
  251. ACMD_FUNC(mutearea); // by MouseJstr
  252. ACMD_FUNC(shuffle); // by MouseJstr
  253. ACMD_FUNC(rates); // by MouseJstr
  254. ACMD_FUNC(iteminfo); // Lupus
  255. ACMD_FUNC(whodrops); //Skotlex
  256. ACMD_FUNC(mapflag); // Lupus
  257. ACMD_FUNC(me); //added by massdriller, code by lordalfa
  258. ACMD_FUNC(monsterignore); // [Valaris]
  259. ACMD_FUNC(fakename); //[Valaris]
  260. ACMD_FUNC(size); //[Valaris]
  261. ACMD_FUNC(showexp); //moved from charcommand [Kevin]
  262. ACMD_FUNC(showzeny);
  263. ACMD_FUNC(showdelay); //moved from charcommand [Kevin]
  264. ACMD_FUNC(autotrade);// durf
  265. ACMD_FUNC(changeleader);// [Skotlex]
  266. ACMD_FUNC(changegm);// durf
  267. // Duel [LuzZza]
  268. ACMD_FUNC(invite);
  269. ACMD_FUNC(duel);
  270. ACMD_FUNC(leave);
  271. ACMD_FUNC(accept);
  272. ACMD_FUNC(reject);
  273. ACMD_FUNC(away); // LuzZza
  274. ACMD_FUNC(main); // LuzZza
  275. ACMD_FUNC(clone); // [Valaris]
  276. ACMD_FUNC(tonpc); // LuzZza
  277. /*==========================================
  278. *AtCommandInfo atcommand_info[]構造体の定義
  279. *------------------------------------------
  280. */
  281. // First char of commands is configured in atcommand_athena.conf. Leave @ in this list for default value.
  282. // to set default level, read atcommand_athena.conf first please.
  283. static AtCommandInfo atcommand_info[] = {
  284. { AtCommand_Rura, "@rura", 40, atcommand_rura },
  285. { AtCommand_Warp, "@warp", 40, atcommand_rura },
  286. { AtCommand_Where, "@where", 1, atcommand_where },
  287. { AtCommand_JumpTo, "@jumpto", 20, atcommand_jumpto }, // + /shift
  288. { AtCommand_JumpTo, "@warpto", 20, atcommand_jumpto },
  289. { AtCommand_JumpTo, "@goto", 20, atcommand_jumpto },
  290. { AtCommand_Jump, "@jump", 40, atcommand_jump },
  291. { AtCommand_Who, "@who", 20, atcommand_who },
  292. { AtCommand_Who, "@whois", 20, atcommand_who },
  293. { AtCommand_Who, "@w", 20, atcommand_who },
  294. { AtCommand_Who2, "@who2", 20, atcommand_who2 },
  295. { AtCommand_Who3, "@who3", 20, atcommand_who3 },
  296. { AtCommand_WhoMap, "@whomap", 20, atcommand_whomap },
  297. { AtCommand_WhoMap2, "@whomap2", 20, atcommand_whomap2 },
  298. { AtCommand_WhoMap3, "@whomap3", 20, atcommand_whomap3 },
  299. { AtCommand_WhoGM, "@whogm", 20, atcommand_whogm }, // by Yor
  300. { AtCommand_Save, "@save", 40, atcommand_save },
  301. { AtCommand_Load, "@return", 40, atcommand_load },
  302. { AtCommand_Load, "@load", 40, atcommand_load },
  303. { AtCommand_Speed, "@speed", 40, atcommand_speed },
  304. { AtCommand_Storage, "@storage", 1, atcommand_storage },
  305. { AtCommand_GuildStorage, "@gstorage", 50, atcommand_guildstorage },
  306. { AtCommand_Option, "@option", 40, atcommand_option },
  307. { AtCommand_Hide, "@hide", 40, atcommand_hide }, // + /hide
  308. { AtCommand_JobChange, "@jobchange", 40, atcommand_jobchange },
  309. { AtCommand_JobChange, "@job", 40, atcommand_jobchange },
  310. { AtCommand_Die, "@die", 1, atcommand_die },
  311. { AtCommand_Kill, "@kill", 60, atcommand_kill },
  312. { AtCommand_Alive, "@alive", 60, atcommand_alive },
  313. { AtCommand_Kami, "@kami", 40, atcommand_kami },
  314. { AtCommand_KamiB, "@kamib", 40, atcommand_kami },
  315. { AtCommand_KamiC, "@kamic", 40, atcommand_kami }, //[LuzZza]
  316. { AtCommand_Heal, "@heal", 40, atcommand_heal },
  317. { AtCommand_Item, "@item", 60, atcommand_item },
  318. { AtCommand_Item2, "@item2", 60, atcommand_item2 },
  319. { AtCommand_ItemReset, "@itemreset", 40, atcommand_itemreset },
  320. { AtCommand_ItemCheck, "@itemcheck", 60, atcommand_itemcheck },
  321. { AtCommand_BaseLevelUp, "@lvup", 60, atcommand_baselevelup },
  322. { AtCommand_BaseLevelUp, "@blevel", 60, atcommand_baselevelup },
  323. { AtCommand_BaseLevelUp, "@baselvlup", 60, atcommand_baselevelup },
  324. { AtCommand_JobLevelUp, "@jlevel", 60, atcommand_joblevelup },
  325. { AtCommand_JobLevelUp, "@joblvup", 60, atcommand_joblevelup },
  326. { AtCommand_JobLevelUp, "@joblvlup", 60, atcommand_joblevelup },
  327. { AtCommand_H, "@h", 20, atcommand_help },
  328. { AtCommand_Help, "@help", 20, atcommand_help },
  329. { AtCommand_H2, "@h2", 20, atcommand_help2 },
  330. { AtCommand_Help2, "@help2", 20, atcommand_help2 },
  331. { AtCommand_GM, "@gm", 100,atcommand_gm },
  332. { AtCommand_PvPOff, "@pvpoff", 40, atcommand_pvpoff },
  333. { AtCommand_PvPOn, "@pvpon", 40, atcommand_pvpon },
  334. { AtCommand_GvGOff, "@gvgoff", 40, atcommand_gvgoff },
  335. { AtCommand_GvGOff, "@gpvpoff", 40, atcommand_gvgoff },
  336. { AtCommand_GvGOn, "@gvgon", 40, atcommand_gvgon },
  337. { AtCommand_GvGOn, "@gpvpon", 40, atcommand_gvgon },
  338. { AtCommand_Model, "@model", 20, atcommand_model },
  339. { AtCommand_Go, "@go", 10, atcommand_go },
  340. { AtCommand_Spawn, "@monster", 50, atcommand_monster },
  341. { AtCommand_Spawn, "@spawn", 50, atcommand_monster },
  342. { AtCommand_MonsterSmall, "@monstersmall", 50, atcommand_monstersmall },
  343. { AtCommand_MonsterBig, "@monsterbig", 50, atcommand_monsterbig },
  344. { AtCommand_KillMonster, "@killmonster", 60, atcommand_killmonster },
  345. { AtCommand_KillMonster2, "@killmonster2", 40, atcommand_killmonster2 },
  346. { AtCommand_Refine, "@refine", 60, atcommand_refine },
  347. { AtCommand_Produce, "@produce", 60, atcommand_produce },
  348. { AtCommand_Memo, "@memo", 40, atcommand_memo },
  349. { AtCommand_GAT, "@gat", 99, atcommand_gat }, // debug function
  350. { AtCommand_Packet, "@packet", 99, atcommand_packet }, // debug function
  351. { AtCommand_Packet, "@packetmode", 99, atcommand_packet }, // debug function
  352. { AtCommand_WaterLevel, "@waterlevel", 99, atcommand_waterlevel }, // debug function
  353. { AtCommand_StatusPoint, "@stpoint", 60, atcommand_statuspoint },
  354. { AtCommand_SkillPoint, "@skpoint", 60, atcommand_skillpoint },
  355. { AtCommand_Zeny, "@zeny", 60, atcommand_zeny },
  356. { AtCommand_Strength, "@str", 60, atcommand_param },
  357. { AtCommand_Agility, "@agi", 60, atcommand_param },
  358. { AtCommand_Vitality, "@vit", 60, atcommand_param },
  359. { AtCommand_Intelligence, "@int", 60, atcommand_param },
  360. { AtCommand_Dexterity, "@dex", 60, atcommand_param },
  361. { AtCommand_Luck, "@luk", 60, atcommand_param },
  362. { AtCommand_GuildLevelUp, "@guildlvup", 60, atcommand_guildlevelup },
  363. { AtCommand_GuildLevelUp, "@guildlvlup", 60, atcommand_guildlevelup },
  364. { AtCommand_MakeEgg, "@makeegg", 60, atcommand_makeegg },
  365. { AtCommand_Hatch, "@hatch", 60, atcommand_hatch },
  366. { AtCommand_PetFriendly, "@petfriendly", 40, atcommand_petfriendly },
  367. { AtCommand_PetHungry, "@pethungry", 40, atcommand_pethungry },
  368. { AtCommand_PetRename, "@petrename", 1, atcommand_petrename },
  369. { AtCommand_Recall, "@recall", 60, atcommand_recall }, // + /recall
  370. { AtCommand_Revive, "@revive", 60, atcommand_revive },
  371. { AtCommand_Night, "@night", 80, atcommand_night },
  372. { AtCommand_Day, "@day", 80, atcommand_day },
  373. { AtCommand_Doom, "@doom", 80, atcommand_doom },
  374. { AtCommand_DoomMap, "@doommap", 80, atcommand_doommap },
  375. { AtCommand_Raise, "@raise", 80, atcommand_raise },
  376. { AtCommand_RaiseMap, "@raisemap", 80, atcommand_raisemap },
  377. { AtCommand_Kick, "@kick", 20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  378. { AtCommand_KickAll, "@kickall", 99, atcommand_kickall },
  379. { AtCommand_AllSkill, "@allskill", 60, atcommand_allskill },
  380. { AtCommand_AllSkill, "@allskills", 60, atcommand_allskill },
  381. { AtCommand_AllSkill, "@skillall", 60, atcommand_allskill },
  382. { AtCommand_AllSkill, "@skillsall", 60, atcommand_allskill },
  383. { AtCommand_QuestSkill, "@questskill", 40, atcommand_questskill },
  384. { AtCommand_LostSkill, "@lostskill", 40, atcommand_lostskill },
  385. { AtCommand_SpiritBall, "@spiritball", 40, atcommand_spiritball },
  386. { AtCommand_Party, "@party", 1, atcommand_party },
  387. { AtCommand_Guild, "@guild", 50, atcommand_guild },
  388. { AtCommand_AgitStart, "@agitstart", 60, atcommand_agitstart },
  389. { AtCommand_AgitEnd, "@agitend", 60, atcommand_agitend },
  390. { AtCommand_MapExit, "@mapexit", 99, atcommand_mapexit },
  391. { AtCommand_IDSearch, "@idsearch", 60, atcommand_idsearch },
  392. { AtCommand_MapMove, "@mapmove", 40, atcommand_rura }, // /mm command
  393. { AtCommand_Broadcast, "@broadcast", 40, atcommand_broadcast }, // /b and /nb command
  394. { AtCommand_LocalBroadcast, "@localbroadcast", 40, atcommand_localbroadcast }, // /lb and /nlb command
  395. { AtCommand_RecallAll, "@recallall", 80, atcommand_recallall },
  396. { AtCommand_ReloadItemDB, "@reloaditemdb", 99, atcommand_reloaditemdb }, // admin command
  397. { AtCommand_ReloadMobDB, "@reloadmobdb", 99, atcommand_reloadmobdb }, // admin command
  398. { AtCommand_ReloadSkillDB, "@reloadskilldb", 99, atcommand_reloadskilldb }, // admin command
  399. { AtCommand_ReloadScript, "@reloadscript", 99, atcommand_reloadscript }, // admin command
  400. { AtCommand_ReloadGMDB, "@reloadgmdb", 99, atcommand_reloadgmdb }, // admin command
  401. { AtCommand_ReloadAtcommand, "@reloadatcommand", 99, atcommand_reloadatcommand },
  402. { AtCommand_ReloadBattleConf, "@reloadbattleconf", 99, atcommand_reloadbattleconf },
  403. { AtCommand_ReloadStatusDB, "@reloadstatusdb", 99, atcommand_reloadstatusdb },
  404. { AtCommand_ReloadPcDB, "@reloadpcdb", 99, atcommand_reloadpcdb },
  405. { AtCommand_ReloadMOTD, "@reloadmotd", 99, atcommand_reloadmotd }, // [Valaris]
  406. { AtCommand_MapInfo, "@mapinfo", 99, atcommand_mapinfo },
  407. { AtCommand_Dye, "@dye", 40, atcommand_dye }, // by fritz
  408. { AtCommand_Dye, "@ccolor", 40, atcommand_dye }, // by fritz
  409. { AtCommand_Hstyle, "@hairstyle", 40, atcommand_hair_style }, // by fritz
  410. { AtCommand_Hstyle, "@hstyle", 40, atcommand_hair_style }, // by fritz
  411. { AtCommand_Hcolor, "@haircolor", 40, atcommand_hair_color }, // by fritz
  412. { AtCommand_Hcolor, "@hcolor", 40, atcommand_hair_color }, // by fritz
  413. { AtCommand_StatAll, "@statall", 60, atcommand_stat_all }, // by fritz
  414. { AtCommand_StatAll, "@statsall", 60, atcommand_stat_all },
  415. { AtCommand_StatAll, "@allstats", 60, atcommand_stat_all }, // by fritz
  416. { AtCommand_StatAll, "@allstat", 60, atcommand_stat_all }, // by fritz
  417. { AtCommand_CharBlock, "@block", 60, atcommand_char_block }, // by Yor
  418. { AtCommand_CharBlock, "@charblock", 60, atcommand_char_block }, // by Yor
  419. { AtCommand_CharBan, "@ban", 60, atcommand_char_ban }, // by Yor
  420. { AtCommand_CharBan, "@banish", 60, atcommand_char_ban }, // by Yor
  421. { AtCommand_CharBan, "@charban", 60, atcommand_char_ban }, // by Yor
  422. { AtCommand_CharBan, "@charbanish", 60, atcommand_char_ban }, // by Yor
  423. { AtCommand_CharUnBlock, "@unblock", 60, atcommand_char_unblock }, // by Yor
  424. { AtCommand_CharUnBlock, "@charunblock", 60, atcommand_char_unblock }, // by Yor
  425. { AtCommand_CharUnBan, "@unban", 60, atcommand_char_unban }, // by Yor
  426. { AtCommand_CharUnBan, "@unbanish", 60, atcommand_char_unban }, // by Yor
  427. { AtCommand_CharUnBan, "@charunban", 60, atcommand_char_unban }, // by Yor
  428. { AtCommand_CharUnBan, "@charunbanish", 60, atcommand_char_unban }, // by Yor
  429. { AtCommand_MountPeco, "@mountpeco", 20, atcommand_mount_peco }, // by Valaris
  430. { AtCommand_CharMountPeco, "@charmountpeco", 50, atcommand_char_mount_peco }, // by Yor
  431. { AtCommand_GuildSpy, "@guildspy", 60, atcommand_guildspy }, // [Syrus22]
  432. { AtCommand_PartySpy, "@partyspy", 60, atcommand_partyspy }, // [Syrus22]
  433. { AtCommand_RepairAll, "@repairall", 60, atcommand_repairall }, // [Valaris]
  434. { AtCommand_GuildRecall, "@guildrecall", 60, atcommand_guildrecall }, // by Yor
  435. { AtCommand_PartyRecall, "@partyrecall", 60, atcommand_partyrecall }, // by Yor
  436. { AtCommand_Nuke, "@nuke", 60, atcommand_nuke }, // [Valaris]
  437. { AtCommand_Shownpc, "@shownpc", 80, atcommand_shownpc }, // []
  438. { AtCommand_Hidenpc, "@hidenpc", 80, atcommand_hidenpc }, // []
  439. { AtCommand_Loadnpc, "@loadnpc", 80, atcommand_loadnpc }, // []
  440. { AtCommand_Unloadnpc, "@unloadnpc", 80, atcommand_unloadnpc }, // []
  441. { AtCommand_ServerTime, "@time", 1, atcommand_servertime }, // by Yor
  442. { AtCommand_ServerTime, "@date", 1, atcommand_servertime }, // by Yor
  443. { AtCommand_ServerTime, "@server_date", 1, atcommand_servertime }, // by Yor
  444. { AtCommand_ServerTime, "@serverdate", 1, atcommand_servertime }, // by Yor
  445. { AtCommand_ServerTime, "@server_time", 1, atcommand_servertime }, // by Yor
  446. { AtCommand_ServerTime, "@servertime", 1, atcommand_servertime }, // by Yor
  447. { AtCommand_CharDelItem, "@chardelitem", 60, atcommand_chardelitem }, // by Yor
  448. { AtCommand_Jail, "@jail", 60, atcommand_jail }, // by Yor
  449. { AtCommand_UnJail, "@unjail", 60, atcommand_unjail }, // by Yor
  450. { AtCommand_UnJail, "@discharge", 60, atcommand_unjail }, // by Yor
  451. { AtCommand_Disguise, "@disguise", 20, atcommand_disguise }, // [Valaris]
  452. { AtCommand_UnDisguise, "@undisguise", 20, atcommand_undisguise }, // by Yor
  453. { AtCommand_CharDisguise, "@chardisguise", 60, atcommand_chardisguise }, // Kalaspuff
  454. { AtCommand_CharUnDisguise, "@charundisguise", 60, atcommand_charundisguise }, // Kalaspuff
  455. { AtCommand_EMail, "@email", 1, atcommand_email }, // by Yor
  456. { AtCommand_Effect, "@effect", 40, atcommand_effect }, // by Apple
  457. { AtCommand_Char_Cart_List, "@charcartlist", 40, atcommand_character_cart_list }, // by Yor
  458. { AtCommand_Follow, "@follow", 20, atcommand_follow }, // by MouseJstr
  459. { AtCommand_AddWarp, "@addwarp", 60, atcommand_addwarp }, // by MouseJstr
  460. { AtCommand_SkillOn, "@skillon", 80, atcommand_skillon }, // by MouseJstr
  461. { AtCommand_SkillOff, "@skilloff", 80, atcommand_skilloff }, // by MouseJstr
  462. { AtCommand_Killer, "@killer", 60, atcommand_killer }, // by MouseJstr
  463. { AtCommand_NpcMove, "@npcmove", 20, atcommand_npcmove }, // by MouseJstr
  464. { AtCommand_Killable, "@killable", 40, atcommand_killable }, // by MouseJstr
  465. { AtCommand_CharKillable, "@charkillable", 40, atcommand_charkillable }, // by MouseJstr
  466. { AtCommand_Dropall, "@dropall", 40, atcommand_dropall }, // MouseJstr
  467. { AtCommand_Chardropall, "@chardropall", 40, atcommand_chardropall }, // MouseJstr
  468. { AtCommand_Storeall, "@storeall", 40, atcommand_storeall }, // MouseJstr
  469. { AtCommand_Charstoreall, "@charstoreall", 40, atcommand_charstoreall }, // MouseJstr
  470. { AtCommand_Skillid, "@skillid", 40, atcommand_skillid }, // MouseJstr
  471. { AtCommand_Useskill, "@useskill", 40, atcommand_useskill }, // MouseJstr
  472. { AtCommand_Rain, "@rain", 99, atcommand_rain },
  473. { AtCommand_Snow, "@snow", 99, atcommand_snow },
  474. { AtCommand_Sakura, "@sakura", 99, atcommand_sakura },
  475. { AtCommand_Clouds, "@clouds", 99, atcommand_clouds },
  476. { AtCommand_Clouds2, "@clouds2", 99, atcommand_clouds2 },
  477. { AtCommand_Fog, "@fog", 99, atcommand_fog },
  478. { AtCommand_Fireworks, "@fireworks", 99, atcommand_fireworks },
  479. { AtCommand_Leaves, "@leaves", 99, atcommand_leaves },
  480. { AtCommand_Summon, "@summon", 60, atcommand_summon },
  481. { AtCommand_AdjGmLvl, "@adjgmlvl", 99, atcommand_adjgmlvl },
  482. { AtCommand_AdjCmdLvl, "@adjcmdlvl", 99, atcommand_adjcmdlvl },
  483. { AtCommand_Trade, "@trade", 60, atcommand_trade },
  484. { AtCommand_Send, "@send", 60, atcommand_send },
  485. { AtCommand_SetBattleFlag, "@setbattleflag", 99, atcommand_setbattleflag },
  486. { AtCommand_UnMute, "@unmute", 60, atcommand_unmute }, // [Valaris]
  487. { AtCommand_Clearweather, "@clearweather", 99, atcommand_clearweather }, // Dexity
  488. { AtCommand_UpTime, "@uptime", 1, atcommand_uptime }, // by MC Cameri
  489. // { AtCommand_ChangeSex, "@changesex", 1, atcommand_changesex }, // by MC Cameri <- do we still need this? [Foruken]
  490. { AtCommand_Mute, "@mute", 99, atcommand_mute }, // [celest]
  491. { AtCommand_Mute, "@red", 99, atcommand_mute }, // [celest]
  492. { AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
  493. { AtCommand_HappyHappyJoyJoy, "@happyhappyjoyjoy", 40, atcommand_happyhappyjoyjoy }, // [Valaris]
  494. { AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
  495. { AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
  496. { AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
  497. { AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
  498. { AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
  499. { AtCommand_MobSearch, "@mobsearch", 10, atcommand_mobsearch },
  500. { AtCommand_CleanMap, "@cleanmap", 40, atcommand_cleanmap },
  501. { AtCommand_NpcTalk, "@npctalk", 20, atcommand_npctalk },
  502. { AtCommand_PetTalk, "@pettalk", 10, atcommand_pettalk },
  503. { AtCommand_Users, "@users", 40, atcommand_users },
  504. { AtCommand_ResetState, "/reset", 40, NULL },
  505. #ifndef TXT_ONLY // sql-only commands
  506. { AtCommand_CheckMail, "@checkmail", 1, atcommand_listmail }, // [Valaris]
  507. { AtCommand_ListMail, "@listmail", 1, atcommand_listmail }, // [Valaris]
  508. { AtCommand_ListNewMail, "@listnewmail", 1, atcommand_listmail }, // [Valaris]
  509. { AtCommand_ReadMail, "@readmail", 1, atcommand_readmail }, // [Valaris]
  510. { AtCommand_DeleteMail, "@deletemail", 1, atcommand_readmail }, // [Valaris]
  511. { AtCommand_SendMail, "@sendmail", 1, atcommand_sendmail }, // [Valaris]
  512. { AtCommand_SendPriorityMail, "@sendprioritymail", 80, atcommand_sendmail }, // [Valaris]
  513. { AtCommand_RefreshOnline, "@refreshonline", 99, atcommand_refreshonline }, // [Valaris]
  514. #endif /* TXT_ONLY */
  515. { AtCommand_SkillTree, "@skilltree", 40, atcommand_skilltree }, // [MouseJstr]
  516. { AtCommand_Marry, "@marry", 40, atcommand_marry }, // [MouseJstr]
  517. { AtCommand_Divorce, "@divorce", 40, atcommand_divorce }, // [MouseJstr]
  518. { AtCommand_Grind, "@grind", 99, atcommand_grind }, // [MouseJstr]
  519. { AtCommand_Grind2, "@grind2", 99, atcommand_grind2 }, // [MouseJstr]
  520. #ifdef DMALLOC
  521. { AtCommand_DMStart, "@dmstart", 99, atcommand_dmstart }, // [MouseJstr]
  522. { AtCommand_DMTick, "@dmtick", 99, atcommand_dmtick }, // [MouseJstr]
  523. #endif
  524. { AtCommand_JumpToId, "@jumptoid", 20, atcommand_jumptoid }, // [Dino9021]
  525. { AtCommand_JumpToId, "@warptoid", 20, atcommand_jumptoid }, // [Dino9021]
  526. { AtCommand_JumpToId, "@gotoid", 20, atcommand_jumptoid }, // [Dino9021]
  527. { AtCommand_JumpToId2, "@jumptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  528. { AtCommand_JumpToId2, "@warptoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  529. { AtCommand_JumpToId2, "@gotoid2", 20, atcommand_jumptoid2 }, // [Dino9021]
  530. { AtCommand_RecallId, "@recallid", 60, atcommand_recallid }, // [Dino9021]
  531. { AtCommand_RecallId2, "@recallid2", 60, atcommand_recallid2 }, // [Dino9021]
  532. { AtCommand_KickId, "@kickid", 99, atcommand_kickid }, // [Dino9021]
  533. { AtCommand_KickId2, "@kickid2", 99, atcommand_kickid2 }, // [Dino9021]
  534. { AtCommand_ReviveId, "@reviveid", 60, atcommand_reviveid }, // [Dino9021]
  535. { AtCommand_ReviveId2, "@reviveid2", 60, atcommand_reviveid2 }, // [Dino9021]
  536. { AtCommand_KillId, "@killid", 60, atcommand_killid }, // [Dino9021]
  537. { AtCommand_KillId2, "@killid2", 60, atcommand_killid2 }, // [Dino9021]
  538. { AtCommand_CharKillableId, "@charkillableid", 40, atcommand_charkillableid }, // [Dino9021]
  539. { AtCommand_CharKillableId2, "@charkillableid2", 40, atcommand_charkillableid2 }, // [Dino9021]
  540. { AtCommand_Sound, "@sound", 40, atcommand_sound },
  541. { AtCommand_UndisguiseAll, "@undisguiseall", 99, atcommand_undisguiseall },
  542. { AtCommand_DisguiseAll, "@disguiseall", 99, atcommand_disguiseall },
  543. { AtCommand_ChangeLook, "@changelook", 99, atcommand_changelook },
  544. { AtCommand_AutoLoot, "@autoloot", 10, atcommand_autoloot }, // Upa-Kun
  545. { AtCommand_MobInfo, "@mobinfo", 1, atcommand_mobinfo }, // [Lupus]
  546. { AtCommand_MobInfo, "@monsterinfo", 1, atcommand_mobinfo }, // [Lupus]
  547. { AtCommand_MobInfo, "@mi", 1, atcommand_mobinfo }, // [Lupus]
  548. { AtCommand_Exp, "@exp", 0, atcommand_exp }, // [Skotlex]
  549. { AtCommand_Adopt, "@adopt", 40, atcommand_adopt }, // [Veider]
  550. { AtCommand_Version, "@version", 1, atcommand_version },
  551. { AtCommand_MuteArea, "@mutearea", 99, atcommand_mutearea }, // MouseJstr
  552. { AtCommand_MuteArea, "@stfu", 99, atcommand_mutearea }, // MouseJstr
  553. { AtCommand_Shuffle, "@shuffle", 40, atcommand_shuffle }, // MouseJstr
  554. { AtCommand_Rates, "@rates", 1, atcommand_rates }, // MouseJstr
  555. { AtCommand_ItemInfo, "@iteminfo", 1, atcommand_iteminfo }, // [Lupus]
  556. { AtCommand_ItemInfo, "@ii", 1, atcommand_iteminfo }, // [Lupus]
  557. { AtCommand_WhoDrops, "@whodrops", 1, atcommand_whodrops }, // [Skotlex]
  558. { AtCommand_MapFlag, "@mapflag", 99, atcommand_mapflag }, // [Lupus]
  559. { AtCommand_Me, "@me", 20, atcommand_me }, //added by massdriller, code by lordalfa
  560. { AtCommand_MonsterIgnore, "@monsterignore", 99, atcommand_monsterignore }, // [Valaris]
  561. { AtCommand_FakeName, "@fakename", 20, atcommand_fakename }, // [Valaris]
  562. { AtCommand_Size, "@size", 20, atcommand_size },
  563. { AtCommand_ShowExp, "@showexp", 10, atcommand_showexp},
  564. { AtCommand_ShowZeny, "@showzeny", 10, atcommand_showzeny},
  565. { AtCommand_ShowDelay, "@showdelay", 1, atcommand_showdelay},
  566. { AtCommand_AutoTrade, "@autotrade", 10, atcommand_autotrade }, // durf
  567. { AtCommand_AutoTrade, "@at", 10, atcommand_autotrade },
  568. { AtCommand_ChangeGM, "@changegm", 10, atcommand_changegm }, // durf
  569. { AtCommand_ChangeLeader, "@changeleader", 10, atcommand_changeleader }, // durf
  570. { AtCommand_Invite, "@invite", 1, atcommand_invite }, // By LuzZza
  571. { AtCommand_Duel, "@duel", 1, atcommand_duel }, // By LuzZza
  572. { AtCommand_Leave, "@leave", 1, atcommand_leave }, // By LuzZza
  573. { AtCommand_Accept, "@accept", 1, atcommand_accept }, // By LuzZza
  574. { AtCommand_Reject, "@reject", 1, atcommand_reject }, // By LuzZza
  575. { AtCommand_Away, "@away", 1, atcommand_away }, // [LuzZza]
  576. { AtCommand_Away, "@aw", 1, atcommand_away }, // [LuzZza]
  577. { AtCommand_Main, "@main", 1, atcommand_main }, // [LuzZza]
  578. { AtCommand_Clone, "@clone", 50, atcommand_clone },
  579. { AtCommand_Clone, "@slaveclone", 50, atcommand_clone },
  580. { AtCommand_Clone, "@evilclone", 50, atcommand_clone }, // [Valaris]
  581. { AtCommand_ToNPC, "@tonpc", 40, atcommand_tonpc }, // LuzZza
  582. // add new commands before this line
  583. { AtCommand_Unknown, NULL, 1, NULL }
  584. };
  585. /*=========================================
  586. * Generic variables
  587. *-----------------------------------------
  588. */
  589. char atcmd_output[200];
  590. char atcmd_player_name[100];
  591. char atcmd_temp[100];
  592. /*==========================================
  593. * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator)
  594. *------------------------------------------
  595. */
  596. char *estr_lower(char *str)
  597. {
  598. int i;
  599. for (i=0; str[i]; i++)
  600. if ((str[i] >= 65) && (str[i] <= 90))
  601. str[i] += 32;
  602. return str;
  603. }
  604. // compare function for sorting high to lowest
  605. int hightolow_compare (const void * a, const void * b)
  606. {
  607. return ( *(int*)b - *(int*)a );
  608. }
  609. // compare function for sorting lowest to highest
  610. int lowtohigh_compare (const void * a, const void * b)
  611. {
  612. return ( *(int*)a - *(int*)b );
  613. }
  614. //-----------------------------------------------------------
  615. // Return the message string of the specified number by [Yor]
  616. //-----------------------------------------------------------
  617. char * msg_txt(int msg_number) {
  618. if (msg_number >= 0 && msg_number < MAX_MSG &&
  619. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  620. return msg_table[msg_number];
  621. return "??";
  622. }
  623. //-----------------------------------------------------------
  624. // Returns Players title (from msg_athena.conf) [Lupus]
  625. //-----------------------------------------------------------
  626. char * player_title_txt(int level) {
  627. if (level < battle_config.title_lvl1)
  628. return ""; //w/o any titles
  629. if (level >= battle_config.title_lvl8)
  630. sprintf(atcmd_temp, msg_table[332], level);
  631. else
  632. if (level >= battle_config.title_lvl7)
  633. sprintf(atcmd_temp, msg_table[331], level);
  634. else
  635. if (level >= battle_config.title_lvl6)
  636. sprintf(atcmd_temp, msg_table[330], level);
  637. else
  638. if (level >= battle_config.title_lvl5)
  639. sprintf(atcmd_temp, msg_table[329], level);
  640. else
  641. if (level >= battle_config.title_lvl4)
  642. sprintf(atcmd_temp, msg_table[328], level);
  643. else
  644. if (level >= battle_config.title_lvl3)
  645. sprintf(atcmd_temp, msg_table[327], level);
  646. else
  647. if (level >= battle_config.title_lvl2)
  648. sprintf(atcmd_temp, msg_table[326], level);
  649. else
  650. sprintf(atcmd_temp, msg_table[325], level); //lvl1
  651. return atcmd_temp;
  652. }
  653. //------------------------------------------------------------
  654. // E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
  655. //------------------------------------------------------------
  656. int e_mail_check(char *email) {
  657. char ch;
  658. char* last_arobas;
  659. // athena limits
  660. if (strlen(email) < 3 || strlen(email) > 39)
  661. return 0;
  662. // part of RFC limits (official reference of e-mail description)
  663. if (strchr(email, '@') == NULL || email[strlen(email)-1] == '@')
  664. return 0;
  665. if (email[strlen(email)-1] == '.')
  666. return 0;
  667. last_arobas = strrchr(email, '@');
  668. if (strstr(last_arobas, "@.") != NULL ||
  669. strstr(last_arobas, "..") != NULL)
  670. return 0;
  671. for(ch = 1; ch < 32; ch++) {
  672. if (strchr(last_arobas, ch) != NULL) {
  673. return 0;
  674. break;
  675. }
  676. }
  677. if (strchr(last_arobas, ' ') != NULL ||
  678. strchr(last_arobas, ';') != NULL)
  679. return 0;
  680. // all correct
  681. return 1;
  682. }
  683. /*==========================================
  684. * get_atcommand_level @コマンドの必要レベルを取得
  685. *------------------------------------------
  686. */
  687. int get_atcommand_level(const AtCommandType type) {
  688. int i;
  689. for (i = 0; atcommand_info[i].type != AtCommand_None; i++)
  690. if (atcommand_info[i].type == type)
  691. return atcommand_info[i].level;
  692. return 100; // 100: command can not be used
  693. }
  694. /*==========================================
  695. *is_atcommand @コマンドに存在するかどうか確認する
  696. *------------------------------------------
  697. */
  698. AtCommandType
  699. is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
  700. const char* str = message;
  701. int s_flag = 0;
  702. AtCommandInfo info;
  703. AtCommandType type;
  704. nullpo_retr(AtCommand_None, sd);
  705. if (!battle_config.allow_atcommand_when_mute &&
  706. sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1) {
  707. return AtCommand_Unknown;
  708. }
  709. if (!message || !*message)
  710. return AtCommand_None;
  711. memset(&info, 0, sizeof(info));
  712. str += strlen(sd->status.name);
  713. while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
  714. if (*str == ':')
  715. s_flag = 1;
  716. str++;
  717. }
  718. if (!*str)
  719. return AtCommand_None;
  720. if (map[sd->bl.m].flag.nocommand &&
  721. (gmlvl > 0? gmlvl:pc_isGM(sd)) < battle_config.gm_skilluncond)
  722. { //Command not allowed on this map.
  723. sprintf(atcmd_output, msg_table[143]);
  724. clif_displaymessage(fd, atcmd_output);
  725. return AtCommand_None;
  726. }
  727. type = atcommand(sd, gmlvl > 0 ? gmlvl : pc_isGM(sd), str, &info);
  728. if (type != AtCommand_None) {
  729. char command[100];
  730. const char* p = str;
  731. memset(command, '\0', sizeof(command));
  732. memset(atcmd_output, '\0', sizeof(atcmd_output));
  733. while (*p && !isspace(*p))
  734. p++;
  735. if (p - str >= sizeof(command)) // too long
  736. return AtCommand_Unknown;
  737. strncpy(command, str, p - str);
  738. while (isspace(*p))
  739. p++;
  740. if (type == AtCommand_Unknown || info.proc == NULL) {
  741. sprintf(atcmd_output, msg_table[153], command); // %s is Unknown Command.
  742. clif_displaymessage(fd, atcmd_output);
  743. } else {
  744. if (info.proc(fd, sd, command, p) != 0) {
  745. // Command can not be executed
  746. sprintf(atcmd_output, msg_table[154], command); // %s failed.
  747. clif_displaymessage(fd, atcmd_output);
  748. }
  749. }
  750. return info.type;
  751. }
  752. return AtCommand_None;
  753. }
  754. /*==========================================
  755. *
  756. *------------------------------------------
  757. */
  758. AtCommandType atcommand(struct map_session_data* sd, const int level, const char* message, struct AtCommandInfo* info) {
  759. char* p = (char *)message; // it's 'char' and not 'const char' to have possibility to modify the first character if necessary
  760. if (!info)
  761. return AtCommand_None;
  762. if (battle_config.atc_gmonly != 0 && !level) // level = pc_isGM(sd)
  763. return AtCommand_None;
  764. if (!p || !*p) {
  765. ShowError("at command message is empty\n");
  766. return AtCommand_None;
  767. }
  768. if (*p == command_symbol) { // check first char.
  769. char command[101];
  770. int i = 0;
  771. memset(info, 0, sizeof(AtCommandInfo));
  772. sscanf(p, "%100s", command);
  773. command[sizeof(command)-1] = '\0';
  774. while (atcommand_info[i].type != AtCommand_Unknown) {
  775. if (strcmpi(command+1, atcommand_info[i].command+1) == 0 && level >= atcommand_info[i].level) {
  776. p[0] = atcommand_info[i].command[0]; // set correct first symbol for after.
  777. break;
  778. }
  779. i++;
  780. }
  781. if (atcommand_info[i].type == AtCommand_Unknown) {
  782. // doesn't return Unknown if player is normal player (display the text, not display: unknown command)
  783. if (level == 0)
  784. return AtCommand_None;
  785. else
  786. return AtCommand_Unknown;
  787. } else if((log_config.gm) && (atcommand_info[i].level >= log_config.gm)) {
  788. log_atcommand(sd, message);
  789. }
  790. memcpy(info, &atcommand_info[i], sizeof atcommand_info[i]);
  791. } else {
  792. return AtCommand_None;
  793. }
  794. return info->type;
  795. }
  796. /*==========================================
  797. * Read Message Data
  798. *------------------------------------------
  799. */
  800. int msg_config_read(const char *cfgName) {
  801. int msg_number;
  802. char line[1024], w1[1024], w2[1024];
  803. FILE *fp;
  804. static int called = 1;
  805. if ((fp = fopen(cfgName, "r")) == NULL) {
  806. ShowError("Messages file not found: %s\n", cfgName);
  807. return 1;
  808. }
  809. if ((--called) == 0)
  810. memset(&msg_table[0], 0, sizeof(msg_table[0]) * MAX_MSG);
  811. while(fgets(line, sizeof(line)-1, fp)) {
  812. if (line[0] == '/' && line[1] == '/')
  813. continue;
  814. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) {
  815. if (strcmpi(w1, "import") == 0) {
  816. msg_config_read(w2);
  817. } else {
  818. msg_number = atoi(w1);
  819. if (msg_number >= 0 && msg_number < MAX_MSG) {
  820. if (msg_table[msg_number] != NULL)
  821. aFree(msg_table[msg_number]);
  822. msg_table[msg_number] = (char *)aCalloc(strlen(w2) + 1, sizeof (char));
  823. strcpy(msg_table[msg_number],w2);
  824. // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
  825. }
  826. }
  827. }
  828. }
  829. fclose(fp);
  830. return 0;
  831. }
  832. /*==========================================
  833. * Cleanup Message Data
  834. *------------------------------------------
  835. */
  836. void do_final_msg (void) {
  837. int i;
  838. for (i = 0; i < MAX_MSG; i++)
  839. aFree(msg_table[i]);
  840. return;
  841. }
  842. /*==========================================
  843. *
  844. *------------------------------------------
  845. */
  846. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  847. int i;
  848. for (i = 0; atcommand_info[i].type != AtCommand_Unknown; i++)
  849. if (strcmpi(atcommand_info[i].command + 1, name) == 0)
  850. return &atcommand_info[i];
  851. return NULL;
  852. }
  853. /*==========================================
  854. *
  855. *------------------------------------------
  856. */
  857. int atcommand_config_read(const char *cfgName) {
  858. char line[1024], w1[1024], w2[1024];
  859. AtCommandInfo* p;
  860. FILE* fp;
  861. if ((fp = fopen(cfgName, "r")) == NULL) {
  862. ShowError("At commands configuration file not found: %s\n", cfgName);
  863. return 1;
  864. }
  865. while (fgets(line, sizeof(line)-1, fp)) {
  866. if (line[0] == '/' && line[1] == '/')
  867. continue;
  868. if (sscanf(line, "%1023[^:]:%1023s", w1, w2) != 2)
  869. continue;
  870. p = get_atcommandinfo_byname(w1);
  871. if (p != NULL) {
  872. p->level = atoi(w2);
  873. if (p->level > 100)
  874. p->level = 100;
  875. else if (p->level < 0)
  876. p->level = 0;
  877. }
  878. if (strcmpi(w1, "import") == 0)
  879. atcommand_config_read(w2);
  880. else if (strcmpi(w1, "command_symbol") == 0 && w2[0] > 31 &&
  881. w2[0] != '/' && // symbol of standard ragnarok GM commands
  882. w2[0] != '%' && // symbol of party chat speaking
  883. w2[0] != '$' && // symbol of guild chat
  884. w2[0] != '#') // symbol of charcommand
  885. command_symbol = w2[0];
  886. }
  887. fclose(fp);
  888. return 0;
  889. }
  890. /*==========================================
  891. * Duel organizing functions [LuzZza]
  892. *------------------------------------------
  893. */
  894. void duel_msg_foreach_sameduel_wos(
  895. const unsigned int did, struct map_session_data* sd, char *output)
  896. {
  897. int i;
  898. struct map_session_data* msg_sd;
  899. for(i=0; i<fd_max; i++)
  900. if(session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  901. && msg_sd->state.auth && msg_sd->duel_group == did && msg_sd != sd)
  902. clif_disp_onlyself(msg_sd, output, strlen(output));
  903. return;
  904. }
  905. void duel_savetime(struct map_session_data* sd) {
  906. time_t timer;
  907. struct tm *t;
  908. time(&timer);
  909. t = localtime(&timer);
  910. pc_setglobalreg(sd, "PC_LAST_DUEL_TIME",
  911. t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
  912. return;
  913. }
  914. int duel_checktime(struct map_session_data* sd) {
  915. int diff;
  916. time_t timer;
  917. struct tm *t;
  918. time(&timer);
  919. t = localtime(&timer);
  920. diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min -
  921. pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
  922. return !(diff >= 0 && diff < battle_config.duel_time_interval);
  923. }
  924. int duel_showinfo(
  925. const unsigned int did, struct map_session_data* sd)
  926. {
  927. int i, p=0;
  928. char output[256];
  929. struct map_session_data* msg_sd;
  930. if(duel_list[did].max_players_limit > 0)
  931. sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
  932. did, duel_count,
  933. duel_list[did].members_count,
  934. duel_list[did].members_count + duel_list[did].invites_count,
  935. duel_list[did].max_players_limit);
  936. else
  937. sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
  938. did, duel_count,
  939. duel_list[did].members_count,
  940. duel_list[did].members_count + duel_list[did].invites_count);
  941. clif_disp_onlyself(sd, output, strlen(output));
  942. for(i=0; i<fd_max; i++)
  943. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  944. && msg_sd->state.auth && msg_sd->duel_group == did) {
  945. sprintf(output, " %d. %s", ++p, (unsigned char *) msg_sd->status.name);
  946. clif_disp_onlyself(sd, output, strlen(output));
  947. }
  948. return 0;
  949. }
  950. int duel_create(
  951. struct map_session_data* sd, const unsigned int maxpl)
  952. {
  953. int i=1;
  954. char output[256];
  955. while(duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
  956. if(i == MAX_DUEL) return 0;
  957. duel_count++;
  958. sd->duel_group = i;
  959. duel_list[i].members_count++;
  960. duel_list[i].invites_count = 0;
  961. duel_list[i].max_players_limit = maxpl;
  962. strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
  963. clif_disp_onlyself(sd, output, strlen(output));
  964. clif_set0199(sd->fd, 1);
  965. //clif_misceffect2(&sd->bl, 159);
  966. return i;
  967. }
  968. int duel_invite(
  969. const unsigned int did, struct map_session_data* sd,
  970. struct map_session_data* target_sd)
  971. {
  972. char output[256];
  973. sprintf(output, msg_txt(373), // " -- Player %s invites %s to duel --"
  974. (unsigned char *)sd->status.name, (unsigned char *)target_sd->status.name);
  975. duel_msg_foreach_sameduel_wos(did, sd, output);
  976. target_sd->duel_invite = did;
  977. duel_list[did].invites_count++;
  978. // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
  979. sprintf(output, msg_txt(374), (unsigned char *)sd->status.name);
  980. clif_GMmessage((struct block_list *)target_sd, output, strlen(output)+1, 3);
  981. return 0;
  982. }
  983. int duel_leave(
  984. const unsigned int did, struct map_session_data* sd)
  985. {
  986. int i;
  987. char output[256];
  988. struct map_session_data* msg_sd;
  989. // " <- Player %s has left duel --"
  990. sprintf(output, msg_txt(375), (unsigned char *)sd->status.name);
  991. duel_msg_foreach_sameduel_wos(did, sd, output);
  992. duel_list[did].members_count--;
  993. if(duel_list[did].members_count == 0) {
  994. for (i=0; i<fd_max; i++)
  995. if (session[i] && (msg_sd = (struct map_session_data *) session[i]->session_data)
  996. && msg_sd->state.auth && msg_sd->duel_invite == did && msg_sd != sd) {
  997. msg_sd->duel_invite = 0;
  998. }
  999. duel_count--;
  1000. }
  1001. sd->duel_group = 0;
  1002. duel_savetime(sd);
  1003. clif_set0199(sd->fd, 0);
  1004. return 0;
  1005. }
  1006. int duel_accept(
  1007. const unsigned int did, struct map_session_data* sd)
  1008. {
  1009. char output[256];
  1010. // " -> Player %s has accepted duel --"
  1011. sprintf(output, msg_txt(376), (unsigned char *)sd->status.name);
  1012. duel_msg_foreach_sameduel_wos(did, sd, output);
  1013. duel_list[did].members_count++;
  1014. sd->duel_group = sd->duel_invite;
  1015. duel_list[did].invites_count--;
  1016. sd->duel_invite = 0;
  1017. clif_set0199(sd->fd, 1);
  1018. //clif_misceffect2(&sd->bl, 159);
  1019. return 0;
  1020. }
  1021. int duel_reject(
  1022. const unsigned int did, struct map_session_data* sd)
  1023. {
  1024. char output[256];
  1025. // " -- Player %s has rejected duel --"
  1026. sprintf(output, msg_txt(377), (unsigned char *)sd->status.name);
  1027. duel_msg_foreach_sameduel_wos(did, sd, output);
  1028. duel_list[did].invites_count--;
  1029. sd->duel_invite = 0;
  1030. return 0;
  1031. }
  1032. /*==========================================
  1033. // @ command processing functions
  1034. *------------------------------------------
  1035. */
  1036. /*==========================================
  1037. * @send (used for testing packet sends from the client)
  1038. *------------------------------------------
  1039. */
  1040. int atcommand_send(
  1041. const int fd, struct map_session_data* sd,
  1042. const char* command, const char* message)
  1043. {
  1044. int i,type=0;
  1045. int info[20];
  1046. 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) {
  1047. clif_displaymessage(fd, "Please enter a packet number, and - if required - up to 20 additional values.");
  1048. return -1;
  1049. }
  1050. if (type > 0 && type < MAX_PACKET_DB) {
  1051. switch (type)
  1052. {
  1053. case 0x209: {
  1054. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1055. WFIFOW(fd,0) = 0x209;
  1056. WFIFOW(fd,2) = 2;
  1057. memcpy(WFIFOP(fd, 12), sd->status.name, NAME_LENGTH);
  1058. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1059. break;
  1060. }
  1061. case 0x1b1:
  1062. case 0x1c2:
  1063. //case xxx:
  1064. // add others here
  1065. // break;
  1066. default: {
  1067. WFIFOHEAD(fd, packet_db[sd->packet_ver][type].len);
  1068. WFIFOW(fd,0) = type;
  1069. for(i=1;i<=sizeof(info);i++)
  1070. if(info[i])
  1071. WFIFOW(fd,i) = info[i];
  1072. WFIFOSET(fd, packet_db[sd->packet_ver][type].len);
  1073. break;
  1074. }
  1075. }
  1076. sprintf (atcmd_output, msg_table[258], type, type);
  1077. clif_displaymessage(fd, atcmd_output);
  1078. } else {
  1079. clif_displaymessage(fd, msg_table[259]);
  1080. }
  1081. return 0;
  1082. }
  1083. // @rura
  1084. /*==========================================
  1085. *
  1086. *------------------------------------------
  1087. */
  1088. int atcommand_rura(
  1089. const int fd, struct map_session_data* sd,
  1090. const char* command, const char* message)
  1091. {
  1092. char map_name[MAP_NAME_LENGTH];
  1093. unsigned short mapindex;
  1094. int x = 0, y = 0;
  1095. int m = -1;
  1096. nullpo_retr(-1, sd);
  1097. memset(map_name, '\0', sizeof(map_name));
  1098. if (!message || !*message ||
  1099. (sscanf(message, "%15s %d %d", map_name, &x, &y) < 3 &&
  1100. sscanf(message, "%15[^,],%d,%d", map_name, &x, &y) < 1)) {
  1101. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  1102. return -1;
  1103. }
  1104. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1105. strcat(map_name, ".gat");
  1106. mapindex = mapindex_name2id(map_name);
  1107. if (mapindex)
  1108. m = map_mapindex2mapid(mapindex);
  1109. if (!mapindex || m < 0) {
  1110. clif_displaymessage(fd, msg_table[1]); // Map not found.
  1111. return -1;
  1112. }
  1113. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS)) {
  1114. clif_displaymessage(fd, msg_table[2]);
  1115. x = y = 0; //Invalid cell, use random spot.
  1116. }
  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. return 0;
  1132. }
  1133. /*==========================================
  1134. * Displays where a character is. Corrected version by Silent. [Skotlex]
  1135. *------------------------------------------
  1136. */
  1137. int atcommand_where(
  1138. const int fd, struct map_session_data* sd,
  1139. const char* command, const char* message)
  1140. {
  1141. struct map_session_data *pl_sd = NULL;
  1142. int GM_level, pl_GM_level;
  1143. nullpo_retr(-1, sd);
  1144. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1145. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  1146. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  1147. return -1;
  1148. }
  1149. pl_sd = map_nick2sd(atcmd_player_name);
  1150. if (pl_sd == NULL)
  1151. return -1;
  1152. if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0)
  1153. return -1;
  1154. GM_level = pc_isGM(sd);//also hide gms depending on settings in battle_athena.conf, show if they are aid [Kevin]
  1155. pl_GM_level = pc_isGM(pl_sd);
  1156. if (battle_config.hide_GM_session) {
  1157. if(GM_level < pl_GM_level) {
  1158. if (!(battle_config.who_display_aid && GM_level >= battle_config.who_display_aid)) {
  1159. return -1;
  1160. }
  1161. }
  1162. }
  1163. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d",
  1164. pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1165. clif_displaymessage(fd, atcmd_output);
  1166. return 0;
  1167. }
  1168. /*==========================================
  1169. *
  1170. *------------------------------------------
  1171. */
  1172. int atcommand_jumpto(
  1173. const int fd, struct map_session_data* sd,
  1174. const char* command, const char* message)
  1175. {
  1176. struct map_session_data *pl_sd = NULL;
  1177. nullpo_retr(-1, sd);
  1178. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  1179. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <char name>).");
  1180. return -1;
  1181. }
  1182. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  1183. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  1184. return -1;
  1185. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0) //Yourself mate? Tsk tsk tsk.
  1186. return -1;
  1187. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  1188. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1189. clif_displaymessage(fd, msg_table[247]);
  1190. return -1;
  1191. }
  1192. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1193. clif_displaymessage(fd, msg_table[248]);
  1194. return -1;
  1195. }
  1196. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  1197. sprintf(atcmd_output, msg_table[4], atcmd_player_name); // Jump to %s
  1198. clif_displaymessage(fd, atcmd_output);
  1199. } else {
  1200. clif_displaymessage(fd, msg_table[3]); // Character not found.
  1201. return -1;
  1202. }
  1203. return 0;
  1204. }
  1205. /*==========================================
  1206. *
  1207. *------------------------------------------
  1208. */
  1209. int atcommand_jump(
  1210. const int fd, struct map_session_data* sd,
  1211. const char* command, const char* message)
  1212. {
  1213. int x = 0, y = 0;
  1214. nullpo_retr(-1, sd);
  1215. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1216. sscanf(message, "%d %d", &x, &y);
  1217. if (x <= 0) //If coordinates are 'wrong', random jump.
  1218. x = -1;
  1219. if (y <= 0)
  1220. y = -1;
  1221. 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)) {
  1222. clif_displaymessage(fd, msg_table[248]);
  1223. return -1;
  1224. }
  1225. pc_setpos(sd, sd->mapindex, x, y, 3);
  1226. sprintf(atcmd_output, msg_table[5], sd->bl.x, sd->bl.y); // Jump to %d %d
  1227. clif_displaymessage(fd, atcmd_output);
  1228. return 0;
  1229. }
  1230. /*==========================================
  1231. * @who3 = Player name, his location
  1232. *------------------------------------------
  1233. */
  1234. int atcommand_who3(
  1235. const int fd, struct map_session_data* sd,
  1236. const char* command, const char* message)
  1237. {
  1238. char temp0[100];
  1239. struct map_session_data *pl_sd, **pl_allsd;
  1240. int i, j, count, users;
  1241. int pl_GM_level, GM_level;
  1242. char match_text[100];
  1243. char player_name[NAME_LENGTH];
  1244. nullpo_retr(-1, sd);
  1245. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1246. memset(match_text, '\0', sizeof(match_text));
  1247. memset(player_name, '\0', sizeof(player_name));
  1248. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1249. strcpy(match_text, "");
  1250. for (j = 0; match_text[j]; j++)
  1251. match_text[j] = tolower(match_text[j]);
  1252. count = 0;
  1253. GM_level = pc_isGM(sd);
  1254. pl_allsd = map_getallusers(&users);
  1255. for (i = 0; i < users; i++) {
  1256. if ((pl_sd = pl_allsd[i])) {
  1257. pl_GM_level = pc_isGM(pl_sd);
  1258. 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
  1259. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1260. for (j = 0; player_name[j]; j++)
  1261. player_name[j] = tolower(player_name[j]);
  1262. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1263. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  1264. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  1265. } else {
  1266. atcmd_output[0]=0;
  1267. }
  1268. //Player name
  1269. sprintf(temp0, msg_txt(333), pl_sd->status.name);
  1270. strcat(atcmd_output,temp0);
  1271. //Player title, if exists
  1272. if (pl_GM_level > 0) {
  1273. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1274. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1275. strcat(atcmd_output,temp0);
  1276. }
  1277. //Players Location: map x y
  1278. sprintf(temp0, msg_txt(338), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  1279. strcat(atcmd_output,temp0);
  1280. clif_displaymessage(fd, atcmd_output);
  1281. count++;
  1282. }
  1283. }
  1284. }
  1285. }
  1286. if (count == 0)
  1287. clif_displaymessage(fd, msg_table[28]); // No player found.
  1288. else if (count == 1)
  1289. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1290. else {
  1291. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1292. clif_displaymessage(fd, atcmd_output);
  1293. }
  1294. return 0;
  1295. }
  1296. /*==========================================
  1297. * Player name, BLevel, Job,
  1298. *------------------------------------------
  1299. */
  1300. int atcommand_who2(
  1301. const int fd, struct map_session_data* sd,
  1302. const char* command, const char* message)
  1303. {
  1304. char temp0[100];
  1305. struct map_session_data *pl_sd, **pl_allsd;
  1306. int i, j, count, users;
  1307. int pl_GM_level, GM_level;
  1308. char match_text[100];
  1309. char player_name[NAME_LENGTH];
  1310. nullpo_retr(-1, sd);
  1311. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1312. memset(match_text, '\0', sizeof(match_text));
  1313. memset(player_name, '\0', sizeof(player_name));
  1314. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1315. strcpy(match_text, "");
  1316. for (j = 0; match_text[j]; j++)
  1317. match_text[j] = tolower(match_text[j]);
  1318. count = 0;
  1319. GM_level = pc_isGM(sd);
  1320. pl_allsd = map_getallusers(&users);
  1321. for (i = 0; i < users; i++) {
  1322. if ((pl_sd = pl_allsd[i])) {
  1323. pl_GM_level = pc_isGM(pl_sd);
  1324. 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
  1325. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1326. for (j = 0; player_name[j]; j++)
  1327. player_name[j] = tolower(player_name[j]);
  1328. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1329. //Players Name
  1330. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1331. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1332. //Player title, if exists
  1333. if (pl_GM_level > 0) {
  1334. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1335. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1336. strcat(atcmd_output,temp0);
  1337. }
  1338. //Players Base Level / Job name
  1339. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1340. sprintf(temp0, msg_txt(337), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  1341. strcat(atcmd_output,temp0);
  1342. clif_displaymessage(fd, atcmd_output);
  1343. count++;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. if (count == 0)
  1349. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1350. else if (count == 1)
  1351. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1352. else {
  1353. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1354. clif_displaymessage(fd, atcmd_output);
  1355. }
  1356. return 0;
  1357. }
  1358. /*==========================================
  1359. * Player name, Playrs Party / Guild name
  1360. *------------------------------------------
  1361. */
  1362. int atcommand_who(
  1363. const int fd, struct map_session_data* sd,
  1364. const char* command, const char* message)
  1365. {
  1366. char temp0[100];
  1367. struct map_session_data *pl_sd, **pl_allsd;
  1368. int i, j, count, users;
  1369. int pl_GM_level, GM_level;
  1370. char match_text[100];
  1371. char player_name[NAME_LENGTH];
  1372. struct guild *g;
  1373. struct party *p;
  1374. nullpo_retr(-1, sd);
  1375. memset(temp0, '\0', sizeof(temp0));
  1376. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1377. memset(match_text, '\0', sizeof(match_text));
  1378. memset(player_name, '\0', sizeof(player_name));
  1379. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1380. strcpy(match_text, "");
  1381. for (j = 0; match_text[j]; j++)
  1382. match_text[j] = tolower(match_text[j]);
  1383. count = 0;
  1384. GM_level = pc_isGM(sd);
  1385. pl_allsd = map_getallusers(&users);
  1386. for (i = 0; i < users; i++) {
  1387. if ((pl_sd = pl_allsd[i])) {
  1388. pl_GM_level = pc_isGM(pl_sd);
  1389. 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
  1390. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1391. for (j = 0; player_name[j]; j++)
  1392. player_name[j] = tolower(player_name[j]);
  1393. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1394. g = guild_search(pl_sd->status.guild_id);
  1395. p = party_search(pl_sd->status.party_id);
  1396. //Players Name
  1397. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  1398. sprintf(atcmd_output, msg_txt(333), pl_sd->status.name);
  1399. //Player title, if exists
  1400. if (pl_GM_level > 0) {
  1401. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  1402. sprintf(temp0, msg_txt(334), player_title_txt(pl_GM_level) );
  1403. strcat(atcmd_output,temp0);
  1404. }
  1405. //Players Party if exists
  1406. if (p != NULL) {
  1407. //sprintf(temp0," | Party: '%s'", p->name);
  1408. sprintf(temp0, msg_txt(335), p->name);
  1409. strcat(atcmd_output,temp0);
  1410. }
  1411. //Players Guild if exists
  1412. if (g != NULL) {
  1413. //sprintf(temp0," | Guild: '%s'", g->name);
  1414. sprintf(temp0, msg_txt(336), g->name);
  1415. strcat(atcmd_output,temp0);
  1416. }
  1417. clif_displaymessage(fd, atcmd_output);
  1418. count++;
  1419. }
  1420. }
  1421. }
  1422. }
  1423. if (count == 0)
  1424. clif_displaymessage(fd, msg_txt(28)); // No player found.
  1425. else if (count == 1)
  1426. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  1427. else {
  1428. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  1429. clif_displaymessage(fd, atcmd_output);
  1430. }
  1431. return 0;
  1432. }
  1433. /*==========================================
  1434. *
  1435. *------------------------------------------
  1436. */
  1437. int atcommand_whomap3(
  1438. const int fd, struct map_session_data* sd,
  1439. const char* command, const char* message)
  1440. {
  1441. struct map_session_data *pl_sd, **pl_allsd;
  1442. int i, count, users;
  1443. int pl_GM_level, GM_level;
  1444. int map_id;
  1445. char map_name[MAP_NAME_LENGTH];
  1446. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1447. memset(map_name, '\0', sizeof(map_name));
  1448. if (!message || !*message)
  1449. map_id = sd->bl.m;
  1450. else {
  1451. sscanf(message, "%15s", map_name);
  1452. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1453. strcat(map_name, ".gat");
  1454. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1455. map_id = sd->bl.m;
  1456. }
  1457. count = 0;
  1458. GM_level = pc_isGM(sd);
  1459. pl_allsd = map_getallusers(&users);
  1460. for (i = 0; i < users; i++) {
  1461. if ((pl_sd = pl_allsd[i])) {
  1462. pl_GM_level = pc_isGM(pl_sd);
  1463. 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
  1464. if (pl_sd->bl.m == map_id) {
  1465. if (pl_GM_level > 0)
  1466. 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);
  1467. else
  1468. 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);
  1469. clif_displaymessage(fd, atcmd_output);
  1470. count++;
  1471. }
  1472. }
  1473. }
  1474. }
  1475. if (count == 0)
  1476. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  1477. else if (count == 1)
  1478. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  1479. else {
  1480. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  1481. }
  1482. clif_displaymessage(fd, atcmd_output);
  1483. return 0;
  1484. }
  1485. /*==========================================
  1486. *
  1487. *------------------------------------------
  1488. */
  1489. int atcommand_whomap2(
  1490. const int fd, struct map_session_data* sd,
  1491. const char* command, const char* message)
  1492. {
  1493. struct map_session_data *pl_sd, **pl_allsd;
  1494. int i, count, users;
  1495. int pl_GM_level, GM_level;
  1496. int map_id = 0;
  1497. char map_name[MAP_NAME_LENGTH];
  1498. nullpo_retr(-1, sd);
  1499. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1500. memset(map_name, '\0', sizeof(map_name));
  1501. if (!message || !*message)
  1502. map_id = sd->bl.m;
  1503. else {
  1504. sscanf(message, "%15s", map_name);
  1505. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1506. strcat(map_name, ".gat");
  1507. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1508. map_id = sd->bl.m;
  1509. }
  1510. count = 0;
  1511. GM_level = pc_isGM(sd);
  1512. pl_allsd = map_getallusers(&users);
  1513. for (i = 0; i < users; i++) {
  1514. if ((pl_sd = pl_allsd[i])) {
  1515. pl_GM_level = pc_isGM(pl_sd);
  1516. 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
  1517. if (pl_sd->bl.m == map_id) {
  1518. if (pl_GM_level > 0)
  1519. 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);
  1520. else
  1521. 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);
  1522. clif_displaymessage(fd, atcmd_output);
  1523. count++;
  1524. }
  1525. }
  1526. }
  1527. }
  1528. if (count == 0)
  1529. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1530. else if (count == 1)
  1531. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1532. else {
  1533. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1534. }
  1535. clif_displaymessage(fd, atcmd_output);
  1536. return 0;
  1537. }
  1538. /*==========================================
  1539. *
  1540. *------------------------------------------
  1541. */
  1542. int atcommand_whomap(
  1543. const int fd, struct map_session_data* sd,
  1544. const char* command, const char* message)
  1545. {
  1546. char temp0[100];
  1547. char temp1[100];
  1548. struct map_session_data *pl_sd, **pl_allsd;
  1549. int i, count, users;
  1550. int pl_GM_level, GM_level;
  1551. int map_id = 0;
  1552. char map_name[MAP_NAME_LENGTH];
  1553. struct guild *g;
  1554. struct party *p;
  1555. nullpo_retr(-1, sd);
  1556. memset(temp0, '\0', sizeof(temp0));
  1557. memset(temp1, '\0', sizeof(temp1));
  1558. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1559. memset(map_name, '\0', sizeof(map_name));
  1560. if (!message || !*message)
  1561. map_id = sd->bl.m;
  1562. else {
  1563. sscanf(message, "%15s", map_name);
  1564. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  1565. strcat(map_name, ".gat");
  1566. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1567. map_id = sd->bl.m;
  1568. }
  1569. count = 0;
  1570. GM_level = pc_isGM(sd);
  1571. pl_allsd = map_getallusers(&users);
  1572. for (i = 0; i < users; i++) {
  1573. if ((pl_sd = pl_allsd[i])) {
  1574. pl_GM_level = pc_isGM(pl_sd);
  1575. 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
  1576. if (pl_sd->bl.m == map_id) {
  1577. g = guild_search(pl_sd->status.guild_id);
  1578. if (g == NULL)
  1579. sprintf(temp1, "None");
  1580. else
  1581. sprintf(temp1, "%s", g->name);
  1582. p = party_search(pl_sd->status.party_id);
  1583. if (p == NULL)
  1584. sprintf(temp0, "None");
  1585. else
  1586. sprintf(temp0, "%s", p->name);
  1587. if (pl_GM_level > 0)
  1588. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  1589. else
  1590. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  1591. clif_displaymessage(fd, atcmd_output);
  1592. count++;
  1593. }
  1594. }
  1595. }
  1596. }
  1597. if (count == 0)
  1598. sprintf(atcmd_output, msg_table[54], map[map_id].name); // No player found in map '%s'.
  1599. else if (count == 1)
  1600. sprintf(atcmd_output, msg_table[55], map[map_id].name); // 1 player found in map '%s'.
  1601. else {
  1602. sprintf(atcmd_output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'.
  1603. }
  1604. clif_displaymessage(fd, atcmd_output);
  1605. return 0;
  1606. }
  1607. /*==========================================
  1608. *
  1609. *------------------------------------------
  1610. */
  1611. int atcommand_whogm(
  1612. const int fd, struct map_session_data* sd,
  1613. const char* command, const char* message)
  1614. {
  1615. char temp0[100];
  1616. char temp1[100];
  1617. struct map_session_data *pl_sd, **pl_allsd;
  1618. int i, j, count, users;
  1619. int pl_GM_level, GM_level;
  1620. char match_text[100];
  1621. char player_name[NAME_LENGTH];
  1622. struct guild *g;
  1623. struct party *p;
  1624. nullpo_retr(-1, sd);
  1625. memset(temp0, '\0', sizeof(temp0));
  1626. memset(temp1, '\0', sizeof(temp1));
  1627. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1628. memset(match_text, '\0', sizeof(match_text));
  1629. memset(player_name, '\0', sizeof(player_name));
  1630. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1631. strcpy(match_text, "");
  1632. for (j = 0; match_text[j]; j++)
  1633. match_text[j] = tolower(match_text[j]);
  1634. count = 0;
  1635. GM_level = pc_isGM(sd);
  1636. pl_allsd = map_getallusers(&users);
  1637. for (i = 0; i < users; i++) {
  1638. if ((pl_sd = pl_allsd[i])) {
  1639. pl_GM_level = pc_isGM(pl_sd);
  1640. if (pl_GM_level > 0) {
  1641. 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
  1642. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1643. for (j = 0; player_name[j]; j++)
  1644. player_name[j] = tolower(player_name[j]);
  1645. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1646. 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);
  1647. clif_displaymessage(fd, atcmd_output);
  1648. 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);
  1649. clif_displaymessage(fd, atcmd_output);
  1650. g = guild_search(pl_sd->status.guild_id);
  1651. if (g == NULL)
  1652. sprintf(temp1, "None");
  1653. else
  1654. sprintf(temp1, "%s", g->name);
  1655. p = party_search(pl_sd->status.party_id);
  1656. if (p == NULL)
  1657. sprintf(temp0, "None");
  1658. else
  1659. sprintf(temp0, "%s", p->name);
  1660. sprintf(atcmd_output, " Party: '%s' | Guild: '%s'", temp0, temp1);
  1661. clif_displaymessage(fd, atcmd_output);
  1662. count++;
  1663. }
  1664. }
  1665. }
  1666. }
  1667. }
  1668. if (count == 0)
  1669. clif_displaymessage(fd, msg_table[150]); // No GM found.
  1670. else if (count == 1)
  1671. clif_displaymessage(fd, msg_table[151]); // 1 GM found.
  1672. else {
  1673. sprintf(atcmd_output, msg_table[152], count); // %d GMs found.
  1674. clif_displaymessage(fd, atcmd_output);
  1675. }
  1676. return 0;
  1677. }
  1678. int atcommand_whozeny(
  1679. const int fd, struct map_session_data* sd,
  1680. const char* command, const char* message)
  1681. {
  1682. struct map_session_data *pl_sd, **pl_allsd;
  1683. int i, j, count,c, users;
  1684. char match_text[100];
  1685. char player_name[NAME_LENGTH];
  1686. int *zeny;
  1687. int *counted;
  1688. nullpo_retr(-1, sd);
  1689. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1690. memset(match_text, '\0', sizeof(match_text));
  1691. memset(player_name, '\0', sizeof(player_name));
  1692. if (sscanf(message, "%99[^\n]", match_text) < 1)
  1693. strcpy(match_text, "");
  1694. for (j = 0; match_text[j]; j++)
  1695. match_text[j] = tolower(match_text[j]);
  1696. count = 0;
  1697. pl_allsd = map_getallusers(&users);
  1698. if (users < 1)
  1699. {
  1700. clif_displaymessage(fd, msg_table[28]); // No player found.
  1701. return 0;
  1702. }
  1703. zeny = (int *)aCallocA(users, sizeof(int));
  1704. counted = (int *)aCallocA(users, sizeof(int));
  1705. for (i = 0; i < users; i++) {
  1706. if ((pl_sd = pl_allsd[i])) {
  1707. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  1708. for (j = 0; player_name[j]; j++)
  1709. player_name[j] = tolower(player_name[j]);
  1710. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  1711. zeny[count]=pl_sd->status.zeny;
  1712. counted[i]=0;
  1713. count++;
  1714. }
  1715. }
  1716. }
  1717. qsort(zeny, count, sizeof(int), hightolow_compare);
  1718. for (c = 0; c < count && c < 50; c++) {
  1719. if(!zeny[c])
  1720. continue;
  1721. for (i = 0; i < users; i++) {
  1722. if(!zeny[c])
  1723. continue;
  1724. if ((pl_sd = pl_allsd[i]) && counted[i]==0) {
  1725. if(pl_sd->status.zeny==zeny[c]) {
  1726. sprintf(atcmd_output, "Name: %s | Zeny: %d", pl_sd->status.name, pl_sd->status.zeny);
  1727. clif_displaymessage(fd, atcmd_output);
  1728. zeny[c]=0;
  1729. counted[i]=1;
  1730. }
  1731. }
  1732. }
  1733. }
  1734. if (count == 0)
  1735. clif_displaymessage(fd, msg_table[28]); // No player found.
  1736. else if (count == 1)
  1737. clif_displaymessage(fd, msg_table[29]); // 1 player found.
  1738. else {
  1739. sprintf(atcmd_output, msg_table[30], count); // %d players found.
  1740. clif_displaymessage(fd, atcmd_output);
  1741. }
  1742. aFree(zeny);
  1743. aFree(counted);
  1744. return 0;
  1745. }
  1746. // cause random emote on all online players [Valaris]
  1747. int atcommand_happyhappyjoyjoy(
  1748. const int fd, struct map_session_data* sd,
  1749. const char* command, const char* message)
  1750. {
  1751. struct map_session_data *pl_sd, **pl_allsd;
  1752. int i,e, users;
  1753. nullpo_retr(-1, sd);
  1754. pl_allsd = map_getallusers(&users);
  1755. for (i = 0; i < users; i++) {
  1756. if ((pl_sd = pl_allsd[i])) {
  1757. e=rand()%40;
  1758. if(e==34)
  1759. e = 0;
  1760. clif_emotion(&pl_sd->bl,e);
  1761. }
  1762. }
  1763. return 0;
  1764. }
  1765. /*==========================================
  1766. *
  1767. *------------------------------------------
  1768. */
  1769. int atcommand_save(
  1770. const int fd, struct map_session_data* sd,
  1771. const char* command, const char* message)
  1772. {
  1773. nullpo_retr(-1, sd);
  1774. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  1775. if (sd->status.pet_id > 0 && sd->pd)
  1776. intif_save_petdata(sd->status.account_id, &sd->pet);
  1777. chrif_save(sd,0);
  1778. clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
  1779. return 0;
  1780. }
  1781. /*==========================================
  1782. *
  1783. *------------------------------------------
  1784. */
  1785. int atcommand_load(
  1786. const int fd, struct map_session_data* sd,
  1787. const char* command, const char* message)
  1788. {
  1789. int m;
  1790. nullpo_retr(-1, sd);
  1791. m = map_mapindex2mapid(sd->status.save_point.map);
  1792. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1793. clif_displaymessage(fd, msg_table[249]);
  1794. return -1;
  1795. }
  1796. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  1797. clif_displaymessage(fd, msg_table[248]);
  1798. return -1;
  1799. }
  1800. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0);
  1801. clif_displaymessage(fd, msg_table[7]); // Warping to respawn point.
  1802. return 0;
  1803. }
  1804. /*==========================================
  1805. *
  1806. *------------------------------------------
  1807. */
  1808. int atcommand_speed(
  1809. const int fd, struct map_session_data* sd,
  1810. const char* command, const char* message)
  1811. {
  1812. int speed;
  1813. nullpo_retr(-1, sd);
  1814. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1815. if (!message || !*message) {
  1816. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1817. clif_displaymessage(fd, atcmd_output);
  1818. return -1;
  1819. }
  1820. speed = atoi(message);
  1821. if (speed >= MIN_WALK_SPEED && speed <= MAX_WALK_SPEED) {
  1822. sd->speed = speed;
  1823. //sd->walktimer = x;
  1824. //この文を追加 by れ�
  1825. clif_updatestatus(sd, SP_SPEED);
  1826. clif_displaymessage(fd, msg_table[8]); // Speed changed.
  1827. } else {
  1828. sprintf(atcmd_output, "Please, enter a valid speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  1829. clif_displaymessage(fd, atcmd_output);
  1830. return -1;
  1831. }
  1832. return 0;
  1833. }
  1834. /*==========================================
  1835. *
  1836. *------------------------------------------
  1837. */
  1838. int atcommand_storage(
  1839. const int fd, struct map_session_data* sd,
  1840. const char* command, const char* message)
  1841. {
  1842. struct storage *stor; //changes from Freya/Yor
  1843. nullpo_retr(-1, sd);
  1844. if (sd->state.storage_flag) {
  1845. clif_displaymessage(fd, msg_table[250]);
  1846. return -1;
  1847. }
  1848. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1849. clif_displaymessage(fd, msg_table[250]);
  1850. return -1;
  1851. }
  1852. storage_storageopen(sd);
  1853. return 0;
  1854. }
  1855. /*==========================================
  1856. *
  1857. *------------------------------------------
  1858. */
  1859. int atcommand_guildstorage(
  1860. const int fd, struct map_session_data* sd,
  1861. const char* command, const char* message)
  1862. {
  1863. struct storage *stor; //changes from Freya/Yor
  1864. nullpo_retr(-1, sd);
  1865. if (sd->status.guild_id > 0) {
  1866. if (sd->state.storage_flag) {
  1867. clif_displaymessage(fd, msg_table[251]);
  1868. return -1;
  1869. }
  1870. if ((stor = account2storage2(sd->status.account_id)) != NULL && stor->storage_status == 1) {
  1871. clif_displaymessage(fd, msg_table[251]);
  1872. return -1;
  1873. }
  1874. storage_guild_storageopen(sd);
  1875. } else {
  1876. clif_displaymessage(fd, msg_table[252]);
  1877. return -1;
  1878. }
  1879. return 0;
  1880. }
  1881. /*==========================================
  1882. *
  1883. *------------------------------------------
  1884. */
  1885. int atcommand_option(
  1886. const int fd, struct map_session_data* sd,
  1887. const char* command, const char* message)
  1888. {
  1889. int param1 = 0, param2 = 0, param3 = 0;
  1890. nullpo_retr(-1, sd);
  1891. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1892. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1893. return -1;
  1894. }
  1895. sd->sc.opt1 = param1;
  1896. sd->sc.opt2 = param2;
  1897. if (!(sd->sc.option & CART_MASK) && param3 & CART_MASK) {
  1898. if (sd->status.class_ == JOB_BABY_MERCHANT)
  1899. clif_cart_itemlist(sd);
  1900. clif_cart_equiplist(sd);
  1901. clif_updatestatus(sd, SP_CARTINFO);
  1902. }
  1903. pc_setoption(sd, param3);
  1904. clif_displaymessage(fd, msg_table[9]); // Options changed.
  1905. return 0;
  1906. }
  1907. /*==========================================
  1908. *
  1909. *------------------------------------------
  1910. */
  1911. int atcommand_hide(
  1912. const int fd, struct map_session_data* sd,
  1913. const char* command, const char* message)
  1914. {
  1915. nullpo_retr(-1, sd);
  1916. if (sd->sc.option & OPTION_INVISIBLE) {
  1917. sd->sc.option &= ~OPTION_INVISIBLE;
  1918. if (sd->disguise)
  1919. status_set_viewdata(&sd->bl, sd->disguise);
  1920. else
  1921. status_set_viewdata(&sd->bl, sd->status.class_);
  1922. clif_displaymessage(fd, msg_table[10]); // Invisible: Off
  1923. } else {
  1924. sd->sc.option |= OPTION_INVISIBLE;
  1925. sd->vd.class_ = INVISIBLE_CLASS;
  1926. clif_displaymessage(fd, msg_table[11]); // Invisible: On
  1927. }
  1928. clif_changeoption(&sd->bl);
  1929. return 0;
  1930. }
  1931. /*==========================================
  1932. * 転職する upperを指定すると転生や養子にもなれる
  1933. *------------------------------------------
  1934. */
  1935. int atcommand_jobchange(
  1936. const int fd, struct map_session_data* sd,
  1937. const char* command, const char* message)
  1938. {
  1939. int job = 0, upper = 0;
  1940. nullpo_retr(-1, sd);
  1941. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  1942. int i, found = 0;
  1943. const struct { char name[16]; int id; } jobs[] = {
  1944. { "novice", 0 },
  1945. { "swordsman", 1 },
  1946. { "mage", 2 },
  1947. { "archer", 3 },
  1948. { "acolyte", 4 },
  1949. { "merchant", 5 },
  1950. { "thief", 6 },
  1951. { "knight", 7 },
  1952. { "priest", 8 },
  1953. { "priestess", 8 },
  1954. { "wizard", 9 },
  1955. { "blacksmith", 10 },
  1956. { "hunter", 11 },
  1957. { "assassin", 12 },
  1958. { "crusader", 14 },
  1959. { "monk", 15 },
  1960. { "sage", 16 },
  1961. { "rogue", 17 },
  1962. { "alchemist", 18 },
  1963. { "bard", 19 },
  1964. { "dancer", 20 },
  1965. { "super novice", 23 },
  1966. { "supernovice", 23 },
  1967. { "gunslinger", 24 },
  1968. { "gunner", 24 },
  1969. { "ninja", 25 },
  1970. { "high novice", 4001 },
  1971. { "swordsman high", 4002 },
  1972. { "mage high", 4003 },
  1973. { "archer high", 4004 },
  1974. { "acolyte high", 4005 },
  1975. { "merchant high", 4006 },
  1976. { "thief high", 4007 },
  1977. { "lord knight", 4008 },
  1978. { "high priest", 4009 },
  1979. { "high priestess", 4009 },
  1980. { "high wizard", 4010 },
  1981. { "whitesmith", 4011 },
  1982. { "sniper", 4012 },
  1983. { "assassin cross", 4013 },
  1984. { "paladin", 4015 },
  1985. { "champion", 4016 },
  1986. { "professor", 4017 },
  1987. { "stalker", 4018 },
  1988. { "creator", 4019 },
  1989. { "clown", 4020 },
  1990. { "gypsy", 4021 },
  1991. { "baby novice", 4023 },
  1992. { "baby swordsman", 4024 },
  1993. { "baby mage", 4025 },
  1994. { "baby archer", 4026 },
  1995. { "baby acolyte", 4027 },
  1996. { "baby merchant", 4028 },
  1997. { "baby thief", 4029 },
  1998. { "baby knight", 4030 },
  1999. { "baby priest", 4031 },
  2000. { "baby priestess", 4031 },
  2001. { "baby wizard", 4032 },
  2002. { "baby blacksmith",4033 },
  2003. { "baby hunter", 4034 },
  2004. { "baby assassin", 4035 },
  2005. { "baby crusader", 4037 },
  2006. { "baby monk", 4038 },
  2007. { "baby sage", 4039 },
  2008. { "baby rogue", 4040 },
  2009. { "baby alchemist", 4041 },
  2010. { "baby bard", 4042 },
  2011. { "baby dancer", 4043 },
  2012. { "super baby", 4045 },
  2013. { "taekwon", 4046 },
  2014. { "taekwon boy", 4046 },
  2015. { "taekwon girl", 4046 },
  2016. { "star gladiator", 4047 },
  2017. { "soul linker", 4049 },
  2018. };
  2019. for (i=0; i < (int)(sizeof(jobs) / sizeof(jobs[0])); i++) {
  2020. if (strncmpi(message, jobs[i].name, 16) == 0) {
  2021. job = jobs[i].id;
  2022. upper = 0;
  2023. found = 1;
  2024. break;
  2025. }
  2026. }
  2027. if (!found) {
  2028. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job ID>).");
  2029. return -1;
  2030. }
  2031. }
  2032. if (job == 37 ||job == 45)
  2033. return 0;
  2034. if ((job >= 0 && job < MAX_PC_CLASS))
  2035. {
  2036. int j;
  2037. for (j=0; j < MAX_INVENTORY; j++) {
  2038. if(sd->status.inventory[j].nameid>0 && sd->status.inventory[j].equip!=0)
  2039. pc_unequipitem(sd, j, 3);
  2040. }
  2041. if (pc_jobchange(sd, job, upper) == 0)
  2042. clif_displaymessage(fd, msg_table[12]); // Your job has been changed.
  2043. else {
  2044. clif_displaymessage(fd, msg_table[155]); // Impossible to change your job.
  2045. return -1;
  2046. }
  2047. } else {
  2048. clif_displaymessage(fd, "Please, enter a valid job ID (usage: @job/@jobchange <job ID>).");
  2049. return -1;
  2050. }
  2051. return 0;
  2052. }
  2053. /*==========================================
  2054. *
  2055. *------------------------------------------
  2056. */
  2057. int atcommand_die(
  2058. const int fd, struct map_session_data* sd,
  2059. const char* command, const char* message)
  2060. {
  2061. nullpo_retr(-1, sd);
  2062. clif_specialeffect(&sd->bl,450,1);
  2063. pc_damage(NULL, sd, sd->status.hp);
  2064. clif_displaymessage(fd, msg_table[13]); // A pity! You've died.
  2065. return 0;
  2066. }
  2067. /*==========================================
  2068. *
  2069. *------------------------------------------
  2070. */
  2071. int atcommand_kill(
  2072. const int fd, struct map_session_data* sd,
  2073. const char* command, const char* message)
  2074. {
  2075. struct map_session_data *pl_sd;
  2076. nullpo_retr(-1, sd);
  2077. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2078. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2079. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <char name>).");
  2080. return -1;
  2081. }
  2082. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  2083. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  2084. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  2085. clif_displaymessage(fd, msg_table[14]); // Character killed.
  2086. } else {
  2087. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  2088. return -1;
  2089. }
  2090. } else {
  2091. clif_displaymessage(fd, msg_table[3]); // Character not found.
  2092. return -1;
  2093. }
  2094. return 0;
  2095. }
  2096. /*==========================================
  2097. *
  2098. *------------------------------------------
  2099. */
  2100. int atcommand_alive(
  2101. const int fd, struct map_session_data* sd,
  2102. const char* command, const char* message)
  2103. {
  2104. nullpo_retr(-1, sd);
  2105. if (pc_isdead(sd)) {
  2106. sd->status.hp = sd->status.max_hp;
  2107. sd->status.sp = sd->status.max_sp;
  2108. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2109. pc_setstand(sd);
  2110. if (battle_config.pc_invincible_time > 0)
  2111. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  2112. clif_updatestatus(sd, SP_HP);
  2113. clif_updatestatus(sd, SP_SP);
  2114. clif_resurrection(&sd->bl, 1);
  2115. clif_displaymessage(fd, msg_table[16]); // You've been revived! It's a miracle!
  2116. return 0;
  2117. }
  2118. return -1;
  2119. }
  2120. /*==========================================
  2121. * +kamic [LuzZza]
  2122. *------------------------------------------
  2123. */
  2124. int atcommand_kami(
  2125. const int fd, struct map_session_data* sd,
  2126. const char* command, const char* message)
  2127. {
  2128. unsigned long color=0;
  2129. nullpo_retr(-1, sd);
  2130. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2131. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  2132. if (!message || !*message) {
  2133. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  2134. return -1;
  2135. }
  2136. sscanf(message, "%199[^\n]", atcmd_output);
  2137. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  2138. } else {
  2139. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  2140. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  2141. return -1;
  2142. }
  2143. if(color < 0 || color > 0xFFFFFF) {
  2144. clif_displaymessage(fd, "Invalid color.");
  2145. return -1;
  2146. }
  2147. intif_announce(atcmd_output, strlen(atcmd_output) + 1, color, 0);
  2148. }
  2149. return 0;
  2150. }
  2151. /*==========================================
  2152. *
  2153. *------------------------------------------
  2154. */
  2155. int atcommand_heal(
  2156. const int fd, struct map_session_data* sd,
  2157. const char* command, const char* message)
  2158. {
  2159. int hp = 0, sp = 0; // [Valaris] thanks to fov
  2160. nullpo_retr(-1, sd);
  2161. sscanf(message, "%d %d", &hp, &sp);
  2162. if (hp == 0 && sp == 0) {
  2163. hp = sd->status.max_hp - sd->status.hp;
  2164. sp = sd->status.max_sp - sd->status.sp;
  2165. } else {
  2166. if (hp > 0 && (hp > sd->status.max_hp || hp > (sd->status.max_hp - sd->status.hp))) // fix positiv overflow
  2167. hp = sd->status.max_hp - sd->status.hp;
  2168. else if (hp < 0 && (hp < -sd->status.max_hp || hp < (1 - sd->status.hp))) // fix negativ overflow
  2169. hp = 1 - sd->status.hp;
  2170. if (sp > 0 && (sp > sd->status.max_sp || sp > (sd->status.max_sp - sd->status.sp))) // fix positiv overflow
  2171. sp = sd->status.max_sp - sd->status.sp;
  2172. else if (sp < 0 && (sp < -sd->status.max_sp || sp < (1 - sd->status.sp))) // fix negativ overflow
  2173. sp = 1 - sd->status.sp;
  2174. }
  2175. if (hp > 0) // display like heal
  2176. clif_heal(fd, SP_HP, hp);
  2177. else if (hp < 0) // display like damage
  2178. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0 , 4, 0);
  2179. if (sp > 0) // no display when we lost SP
  2180. clif_heal(fd, SP_SP, sp);
  2181. if (hp != 0 || sp != 0) {
  2182. pc_heal(sd, hp, sp);
  2183. if (hp >= 0 && sp >= 0)
  2184. clif_displaymessage(fd, msg_table[17]); // HP, SP recovered.
  2185. else
  2186. clif_displaymessage(fd, msg_table[156]); // HP or/and SP modified.
  2187. } else {
  2188. clif_displaymessage(fd, msg_table[157]); // HP and SP are already with the good value.
  2189. return -1;
  2190. }
  2191. return 0;
  2192. }
  2193. /*==========================================
  2194. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  2195. *------------------------------------------
  2196. */
  2197. int atcommand_item(
  2198. const int fd, struct map_session_data* sd,
  2199. const char* command, const char* message)
  2200. {
  2201. char item_name[100];
  2202. int number = 0, item_id, flag;
  2203. struct item item_tmp;
  2204. struct item_data *item_data;
  2205. int get_count, i, pet_id;
  2206. nullpo_retr(-1, sd);
  2207. memset(item_name, '\0', sizeof(item_name));
  2208. if (!message || !*message || sscanf(message, "%99s %d", item_name, &number) < 1) {
  2209. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  2210. return -1;
  2211. }
  2212. if (number <= 0)
  2213. number = 1;
  2214. item_id = 0;
  2215. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2216. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2217. item_id = item_data->nameid;
  2218. if (item_id >= 500) {
  2219. get_count = number;
  2220. // check pet egg
  2221. pet_id = search_petDB_index(item_id, PET_EGG);
  2222. if (item_data->type == 4 || item_data->type == 5 ||
  2223. item_data->type == 7 || item_data->type == 8) {
  2224. get_count = 1;
  2225. }
  2226. for (i = 0; i < number; i += get_count) {
  2227. // if pet egg
  2228. if (pet_id >= 0) {
  2229. sd->catch_target_class = pet_db[pet_id].class_;
  2230. intif_create_pet(sd->status.account_id, sd->status.char_id,
  2231. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2232. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2233. 100, 0, 1, pet_db[pet_id].jname);
  2234. // if not pet egg
  2235. } else {
  2236. memset(&item_tmp, 0, sizeof(item_tmp));
  2237. item_tmp.nameid = item_id;
  2238. item_tmp.identify = 1;
  2239. if ((flag = pc_additem((struct map_session_data*)sd, &item_tmp, get_count)))
  2240. clif_additem((struct map_session_data*)sd, 0, 0, flag);
  2241. }
  2242. }
  2243. //Logs (A)dmins items [Lupus]
  2244. if(log_config.pick > 0 ) {
  2245. log_pick(sd, "A", 0, item_id, number, NULL);
  2246. }
  2247. //Logs
  2248. clif_displaymessage(fd, msg_table[18]); // Item created.
  2249. } else {
  2250. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2251. return -1;
  2252. }
  2253. return 0;
  2254. }
  2255. /*==========================================
  2256. *
  2257. *------------------------------------------
  2258. */
  2259. int atcommand_item2(
  2260. const int fd, struct map_session_data* sd,
  2261. const char* command, const char* message)
  2262. {
  2263. struct item item_tmp;
  2264. struct item_data *item_data;
  2265. char item_name[100];
  2266. int item_id, number = 0;
  2267. int identify = 0, refine = 0, attr = 0;
  2268. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  2269. int flag;
  2270. int loop, get_count, i;
  2271. nullpo_retr(-1, sd);
  2272. memset(item_name, '\0', sizeof(item_name));
  2273. 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) {
  2274. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  2275. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  2276. return -1;
  2277. }
  2278. if (number <= 0)
  2279. number = 1;
  2280. item_id = 0;
  2281. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  2282. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  2283. item_id = item_data->nameid;
  2284. if (item_id > 500) {
  2285. loop = 1;
  2286. get_count = number;
  2287. if (item_data->type == 4 || item_data->type == 5 ||
  2288. item_data->type == 7 || item_data->type == 8) {
  2289. loop = number;
  2290. get_count = 1;
  2291. if (item_data->type == 7) {
  2292. identify = 1;
  2293. refine = 0;
  2294. }
  2295. if (item_data->type == 8)
  2296. refine = 0;
  2297. if (refine > 10)
  2298. refine = 10;
  2299. } else {
  2300. identify = 1;
  2301. refine = attr = 0;
  2302. }
  2303. for (i = 0; i < loop; i++) {
  2304. memset(&item_tmp, 0, sizeof(item_tmp));
  2305. item_tmp.nameid = item_id;
  2306. item_tmp.identify = identify;
  2307. item_tmp.refine = refine;
  2308. item_tmp.attribute = attr;
  2309. item_tmp.card[0] = c1;
  2310. item_tmp.card[1] = c2;
  2311. item_tmp.card[2] = c3;
  2312. item_tmp.card[3] = c4;
  2313. if ((flag = pc_additem(sd, &item_tmp, get_count)))
  2314. clif_additem(sd, 0, 0, flag);
  2315. }
  2316. //Logs (A)dmins items [Lupus]
  2317. if(log_config.pick > 0 ) {
  2318. log_pick(sd, "A", 0, item_tmp.nameid, number, &item_tmp);
  2319. }
  2320. //Logs
  2321. clif_displaymessage(fd, msg_table[18]); // Item created.
  2322. } else {
  2323. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  2324. return -1;
  2325. }
  2326. return 0;
  2327. }
  2328. /*==========================================
  2329. *
  2330. *------------------------------------------
  2331. */
  2332. int atcommand_itemreset(
  2333. const int fd, struct map_session_data* sd,
  2334. const char* command, const char* message)
  2335. {
  2336. int i;
  2337. nullpo_retr(-1, sd);
  2338. for (i = 0; i < MAX_INVENTORY; i++) {
  2339. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  2340. //Logs (A)dmins items [Lupus]
  2341. if(log_config.pick > 0 ) {
  2342. log_pick(sd, "A", 0, sd->status.inventory[i].nameid, -sd->status.inventory[i].amount, &sd->status.inventory[i]);
  2343. }
  2344. //Logs
  2345. pc_delitem(sd, i, sd->status.inventory[i].amount, 0);
  2346. }
  2347. }
  2348. clif_displaymessage(fd, msg_table[20]); // All of your items have been removed.
  2349. return 0;
  2350. }
  2351. /*==========================================
  2352. *
  2353. *------------------------------------------
  2354. */
  2355. int atcommand_itemcheck(
  2356. const int fd, struct map_session_data* sd,
  2357. const char* command, const char* message)
  2358. {
  2359. nullpo_retr(-1, sd);
  2360. pc_checkitem(sd);
  2361. return 0;
  2362. }
  2363. /*==========================================
  2364. * Atcommand @lvlup
  2365. *------------------------------------------
  2366. */
  2367. int atcommand_baselevelup(
  2368. const int fd, struct map_session_data* sd,
  2369. const char* command, const char* message)
  2370. {
  2371. int level=0, i=0, status_point=0;
  2372. nullpo_retr(-1, sd);
  2373. level = atoi(message);
  2374. if (!message || !*message || !level) {
  2375. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  2376. return -1;
  2377. }
  2378. if (level > 0) {
  2379. if (sd->status.base_level == pc_maxbaselv(sd)) { /* check for max level by Valaris */
  2380. clif_displaymessage(fd, msg_table[47]); /* Base level can't go any higher. */
  2381. return -1;
  2382. } /* End Addition */
  2383. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  2384. level = pc_maxbaselv(sd) - sd->status.base_level;
  2385. for (i = 1; i <= level; i++)
  2386. status_point += (sd->status.base_level + i + 14) / 5;
  2387. if (sd->status.status_point > USHRT_MAX - status_point)
  2388. sd->status.status_point = USHRT_MAX;
  2389. else
  2390. sd->status.status_point += status_point;
  2391. sd->status.base_level += (unsigned int)level;
  2392. clif_updatestatus(sd, SP_BASELEVEL);
  2393. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2394. clif_updatestatus(sd, SP_STATUSPOINT);
  2395. status_calc_pc(sd, 0);
  2396. pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
  2397. clif_misceffect(&sd->bl, 0);
  2398. clif_displaymessage(fd, msg_table[21]); /* Base level raised. */
  2399. } else {
  2400. if (sd->status.base_level == 1) {
  2401. clif_displaymessage(fd, msg_table[158]); /* Base level can't go any lower. */
  2402. return -1;
  2403. }
  2404. level*=-1;
  2405. if ((unsigned int)level >= sd->status.base_level)
  2406. level = sd->status.base_level-1;
  2407. if (sd->status.status_point > 0) {
  2408. for (i = 0; i > -level; i--)
  2409. status_point += (sd->status.base_level + i + 14) / 5;
  2410. if (sd->status.status_point < status_point)
  2411. sd->status.status_point = 0;
  2412. else
  2413. sd->status.status_point -= status_point;
  2414. clif_updatestatus(sd, SP_STATUSPOINT);
  2415. } /* to add: remove status points from stats */
  2416. sd->status.base_level -= (unsigned int)level;
  2417. clif_updatestatus(sd, SP_BASELEVEL);
  2418. clif_updatestatus(sd, SP_NEXTBASEEXP);
  2419. status_calc_pc(sd, 0);
  2420. clif_displaymessage(fd, msg_table[22]); /* Base level lowered. */
  2421. }
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. *
  2426. *------------------------------------------
  2427. */
  2428. int atcommand_joblevelup(
  2429. const int fd, struct map_session_data* sd,
  2430. const char* command, const char* message)
  2431. {
  2432. int level=0;
  2433. nullpo_retr(-1, sd);
  2434. level = atoi(message);
  2435. if (!message || !*message || !level) {
  2436. clif_displaymessage(fd, "Please, enter a level adjustement (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  2437. return -1;
  2438. }
  2439. if (level > 0) {
  2440. if (sd->status.job_level == pc_maxjoblv(sd)) {
  2441. clif_displaymessage(fd, msg_table[23]); // Job level can't go any higher.
  2442. return -1;
  2443. }
  2444. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  2445. level = pc_maxjoblv(sd) - sd->status.job_level;
  2446. sd->status.job_level += (unsigned int)level;
  2447. clif_updatestatus(sd, SP_JOBLEVEL);
  2448. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2449. if (sd->status.skill_point > USHRT_MAX - level)
  2450. sd->status.skill_point = USHRT_MAX;
  2451. else
  2452. sd->status.skill_point += level;
  2453. clif_updatestatus(sd, SP_SKILLPOINT);
  2454. status_calc_pc(sd, 0);
  2455. clif_misceffect(&sd->bl, 1);
  2456. clif_displaymessage(fd, msg_table[24]); // Job level raised.
  2457. } else {
  2458. if (sd->status.job_level == 1) {
  2459. clif_displaymessage(fd, msg_table[159]); // Job level can't go any lower.
  2460. return -1;
  2461. }
  2462. level *=-1;
  2463. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  2464. level = sd->status.job_level-1;
  2465. sd->status.job_level -= (unsigned int)level;
  2466. clif_updatestatus(sd, SP_JOBLEVEL);
  2467. clif_updatestatus(sd, SP_NEXTJOBEXP);
  2468. if (sd->status.skill_point < level)
  2469. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  2470. if (sd->status.skill_point < level)
  2471. sd->status.skill_point = 0;
  2472. else
  2473. sd->status.skill_point -= level;
  2474. clif_updatestatus(sd, SP_SKILLPOINT);
  2475. status_calc_pc(sd, 0);
  2476. clif_displaymessage(fd, msg_table[25]); // Job level lowered.
  2477. }
  2478. return 0;
  2479. }
  2480. /*==========================================
  2481. * @help
  2482. *------------------------------------------
  2483. */
  2484. int atcommand_help(
  2485. const int fd, struct map_session_data* sd,
  2486. const char* command, const char* message)
  2487. {
  2488. char buf[2048], w1[2048], w2[2048];
  2489. int i, gm_level;
  2490. FILE* fp;
  2491. nullpo_retr(-1, sd);
  2492. memset(buf, '\0', sizeof(buf));
  2493. if ((fp = fopen(help_txt, "r")) != NULL) {
  2494. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2495. gm_level = pc_isGM(sd);
  2496. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2497. if (buf[0] == '/' && buf[1] == '/')
  2498. continue;
  2499. for (i = 0; buf[i] != '\0'; i++) {
  2500. if (buf[i] == '\r' || buf[i] == '\n') {
  2501. buf[i] = '\0';
  2502. break;
  2503. }
  2504. }
  2505. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2506. clif_displaymessage(fd, buf);
  2507. else if (gm_level >= atoi(w1))
  2508. clif_displaymessage(fd, w2);
  2509. }
  2510. fclose(fp);
  2511. } else {
  2512. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2513. return -1;
  2514. }
  2515. return 0;
  2516. }
  2517. /*==========================================
  2518. * @help2 - Char commands [Kayla]
  2519. *------------------------------------------
  2520. */
  2521. int atcommand_help2(
  2522. const int fd, struct map_session_data* sd,
  2523. const char* command, const char* message)
  2524. {
  2525. char buf[2048], w1[2048], w2[2048];
  2526. int i, gm_level;
  2527. FILE* fp;
  2528. nullpo_retr(-1, sd);
  2529. memset(buf, '\0', sizeof(buf));
  2530. if ((fp = fopen(help2_txt, "r")) != NULL) {
  2531. clif_displaymessage(fd, msg_table[26]); /* Help commands: */
  2532. gm_level = pc_isGM(sd);
  2533. while(fgets(buf, sizeof(buf) - 1, fp) != NULL) {
  2534. if (buf[0] == '/' && buf[1] == '/')
  2535. continue;
  2536. for (i = 0; buf[i] != '\0'; i++) {
  2537. if (buf[i] == '\r' || buf[i] == '\n') {
  2538. buf[i] = '\0';
  2539. break;
  2540. }
  2541. }
  2542. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  2543. clif_displaymessage(fd, buf);
  2544. else if (gm_level >= atoi(w1))
  2545. clif_displaymessage(fd, w2);
  2546. }
  2547. fclose(fp);
  2548. } else {
  2549. clif_displaymessage(fd, msg_table[27]); /* File help.txt not found. */
  2550. return -1;
  2551. }
  2552. return 0;
  2553. }
  2554. /*==========================================
  2555. * @gm
  2556. *------------------------------------------
  2557. */
  2558. int atcommand_gm(
  2559. const int fd, struct map_session_data* sd,
  2560. const char* command, const char* message)
  2561. {
  2562. char password[100];
  2563. nullpo_retr(-1, sd);
  2564. memset(password, '\0', sizeof(password));
  2565. if (!message || !*message || sscanf(message, "%99[^\n]", password) < 1) {
  2566. clif_displaymessage(fd, "Please, enter a password (usage: @gm <password>).");
  2567. return -1;
  2568. }
  2569. if (pc_isGM(sd)) { /* a GM can not use this function. only a normal player (become gm is not for gm!) */
  2570. clif_displaymessage(fd, msg_table[50]); /* You already have some GM powers. */
  2571. return -1;
  2572. } else
  2573. chrif_changegm(sd->status.account_id, password, strlen(password) + 1);
  2574. return 0;
  2575. }
  2576. /*==========================================
  2577. *
  2578. *------------------------------------------
  2579. */
  2580. int atcommand_pvpoff(
  2581. const int fd, struct map_session_data* sd,
  2582. const char* command, const char* message)
  2583. {
  2584. struct map_session_data *pl_sd, **pl_allsd;
  2585. int i, users;
  2586. nullpo_retr(-1, sd);
  2587. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2588. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2589. return -1;
  2590. }
  2591. if (map[sd->bl.m].flag.pvp) {
  2592. map[sd->bl.m].flag.pvp = 0;
  2593. clif_send0199(sd->bl.m, 0);
  2594. pl_allsd = map_getallusers(&users);
  2595. for (i = 0; i < users; i++) { //人数分ループ
  2596. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m) {
  2597. clif_pvpset(pl_sd, 0, 0, 2);
  2598. if (pl_sd->pvp_timer != -1) {
  2599. delete_timer(pl_sd->pvp_timer, pc_calc_pvprank_timer);
  2600. pl_sd->pvp_timer = -1;
  2601. }
  2602. }
  2603. }
  2604. clif_displaymessage(fd, msg_table[31]); // PvP: Off.
  2605. } else {
  2606. clif_displaymessage(fd, msg_table[160]); // PvP is already Off.
  2607. return -1;
  2608. }
  2609. return 0;
  2610. }
  2611. /*==========================================
  2612. *
  2613. *------------------------------------------
  2614. */
  2615. int atcommand_pvpon(
  2616. const int fd, struct map_session_data* sd,
  2617. const char* command, const char* message)
  2618. {
  2619. struct map_session_data *pl_sd, **pl_allsd;
  2620. int i, users;
  2621. nullpo_retr(-1, sd);
  2622. if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris]
  2623. clif_displaymessage(fd, msg_table[52]); // This option cannot be used in PK Mode.
  2624. return -1;
  2625. }
  2626. if (!map[sd->bl.m].flag.pvp) {
  2627. map[sd->bl.m].flag.pvp = 1;
  2628. clif_send0199(sd->bl.m, 1);
  2629. pl_allsd = map_getallusers(&users);
  2630. for (i = 0; i < users; i++) {
  2631. if ((pl_sd = pl_allsd[i]) && sd->bl.m == pl_sd->bl.m && pl_sd->pvp_timer == -1) {
  2632. pl_sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, pl_sd->bl.id, 0);
  2633. pl_sd->pvp_rank = 0;
  2634. pl_sd->pvp_lastusers = 0;
  2635. pl_sd->pvp_point = 5;
  2636. pl_sd->pvp_won = 0;
  2637. pl_sd->pvp_lost = 0;
  2638. }
  2639. }
  2640. clif_displaymessage(fd, msg_table[32]); // PvP: On.
  2641. } else {
  2642. clif_displaymessage(fd, msg_table[161]); // PvP is already On.
  2643. return -1;
  2644. }
  2645. return 0;
  2646. }
  2647. /*==========================================
  2648. *
  2649. *------------------------------------------
  2650. */
  2651. int atcommand_gvgoff(
  2652. const int fd, struct map_session_data* sd,
  2653. const char* command, const char* message)
  2654. {
  2655. nullpo_retr(-1, sd);
  2656. if (map[sd->bl.m].flag.gvg) {
  2657. map[sd->bl.m].flag.gvg = 0;
  2658. clif_send0199(sd->bl.m, 0);
  2659. clif_displaymessage(fd, msg_table[33]); // GvG: Off.
  2660. } else {
  2661. clif_displaymessage(fd, msg_table[162]); // GvG is already Off.
  2662. return -1;
  2663. }
  2664. return 0;
  2665. }
  2666. /*==========================================
  2667. *
  2668. *------------------------------------------
  2669. */
  2670. int atcommand_gvgon(
  2671. const int fd, struct map_session_data* sd,
  2672. const char* command, const char* message)
  2673. {
  2674. nullpo_retr(-1, sd);
  2675. if (!map[sd->bl.m].flag.gvg) {
  2676. map[sd->bl.m].flag.gvg = 1;
  2677. clif_send0199(sd->bl.m, 3);
  2678. clif_displaymessage(fd, msg_table[34]); // GvG: On.
  2679. } else {
  2680. clif_displaymessage(fd, msg_table[163]); // GvG is already On.
  2681. return -1;
  2682. }
  2683. return 0;
  2684. }
  2685. /*==========================================
  2686. *
  2687. *------------------------------------------
  2688. */
  2689. int atcommand_model(
  2690. const int fd, struct map_session_data* sd,
  2691. const char* command, const char* message)
  2692. {
  2693. int hair_style = 0, hair_color = 0, cloth_color = 0;
  2694. nullpo_retr(-1, sd);
  2695. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2696. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  2697. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  2698. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2699. clif_displaymessage(fd, atcmd_output);
  2700. return -1;
  2701. }
  2702. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  2703. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  2704. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2705. /* Removed because this check is TOO strange. [Skotlex]
  2706. //秒フ色変更
  2707. if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2708. //The hell? Why Rogue/Assassins can't... change their option if they have clothes colors and are males? o.O [Skotlex]
  2709. //秒フ色未実装職の判定
  2710. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2711. return -1;
  2712. } else {
  2713. */
  2714. pc_changelook(sd, LOOK_HAIR, hair_style);
  2715. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2716. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2717. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2718. // }
  2719. } else {
  2720. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2721. return -1;
  2722. }
  2723. return 0;
  2724. }
  2725. /*==========================================
  2726. * @dye && @ccolor
  2727. *------------------------------------------
  2728. */
  2729. int atcommand_dye(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2730. {
  2731. int cloth_color = 0;
  2732. nullpo_retr(-1, sd);
  2733. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2734. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  2735. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  2736. clif_displaymessage(fd, atcmd_output);
  2737. return -1;
  2738. }
  2739. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  2740. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  2741. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2742. } else {
  2743. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2744. return -1;
  2745. }
  2746. return 0;
  2747. }
  2748. /*==========================================
  2749. * @hairstyle && @hstyle
  2750. *------------------------------------------
  2751. */
  2752. int atcommand_hair_style(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2753. {
  2754. int hair_style = 0;
  2755. nullpo_retr(-1, sd);
  2756. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2757. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  2758. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  2759. clif_displaymessage(fd, atcmd_output);
  2760. return -1;
  2761. }
  2762. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  2763. /* Removed because this check is TOO strange. [Skotlex]
  2764. if (hair_style != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) { //???
  2765. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2766. return -1;
  2767. } else {
  2768. */
  2769. pc_changelook(sd, LOOK_HAIR, hair_style);
  2770. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2771. // }
  2772. } else {
  2773. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2774. return -1;
  2775. }
  2776. return 0;
  2777. }
  2778. /*==========================================
  2779. * @charhairstyle by [MouseJstr]
  2780. *------------------------------------------
  2781. */
  2782. int
  2783. atcommand_charhairstyle(const int fd, struct map_session_data* sd,
  2784. const char* command, const char* message)
  2785. {
  2786. nullpo_retr(-1, sd);
  2787. return 0;
  2788. }
  2789. /*==========================================
  2790. * @haircolor && @hcolor
  2791. *------------------------------------------
  2792. */
  2793. int atcommand_hair_color(const int fd, struct map_session_data* sd, const char* command, const char* message)
  2794. {
  2795. int hair_color = 0;
  2796. nullpo_retr(-1, sd);
  2797. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2798. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  2799. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  2800. clif_displaymessage(fd, atcmd_output);
  2801. return -1;
  2802. }
  2803. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  2804. /* Removed for being such a strange check. [Skotlex]
  2805. if (hair_color != 0 && sd->status.sex == 1 && (sd->status.class_ == JOB_ASSASSIN || sd->status.class_ == JOB_ROGUE)) {
  2806. clif_displaymessage(fd, msg_table[35]); // You can't use this command with this class.
  2807. return -1;
  2808. } else {
  2809. */
  2810. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  2811. clif_displaymessage(fd, msg_table[36]); // Appearence changed.
  2812. // }
  2813. } else {
  2814. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  2815. return -1;
  2816. }
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. * @go [city_number or city_name] - Updated by Harbin
  2821. *------------------------------------------
  2822. */
  2823. int atcommand_go(
  2824. const int fd, struct map_session_data* sd,
  2825. const char* command, const char* message)
  2826. {
  2827. int i;
  2828. int town;
  2829. char map_name[MAP_NAME_LENGTH];
  2830. int m;
  2831. const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
  2832. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  2833. { MAP_MORROC, 156, 93 }, // 1=Morroc
  2834. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  2835. { MAP_PAYON, 162, 233 }, // 3=Payon
  2836. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  2837. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  2838. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  2839. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  2840. { MAP_COMODO, 209, 143 }, // 8=Comodo
  2841. { MAP_YUNO, 157, 51 }, // 9=Yuno
  2842. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  2843. { MAP_GONRYUN, 160, 120 }, // 11=Gon Ryun
  2844. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  2845. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  2846. { MAP_LOUYANG, 217, 40 }, // 14=Lou Yang
  2847. { "new_1-1.gat", 53, 111 }, // 15=Training Grounds
  2848. { MAP_JAIL, 23, 61 }, // 16=Prison
  2849. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  2850. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  2851. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  2852. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  2853. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  2854. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2855. };
  2856. nullpo_retr(-1, sd);
  2857. if(map[sd->bl.m].flag.nogo) {
  2858. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2859. return 0;
  2860. }
  2861. memset(map_name, '\0', sizeof(map_name));
  2862. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2863. // get the number
  2864. town = atoi(message);
  2865. // if no value, display all value
  2866. if (!message || !*message || sscanf(message, "%15s", map_name) < 1 || town < -3 || town >= (int)(sizeof(data) / sizeof(data[0]))) {
  2867. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2868. clif_displaymessage(fd, msg_table[82]); // Please, use one of this number/name:
  2869. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2870. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2871. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2872. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gon Ryun");
  2873. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Lou Yang");
  2874. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2875. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2876. clif_displaymessage(fd, " 21=Einbech 22=Hugel");
  2877. return -1;
  2878. } else {
  2879. // get possible name of the city and add .gat if not in the name
  2880. map_name[MAP_NAME_LENGTH-1] = '\0';
  2881. for (i = 0; map_name[i]; i++)
  2882. map_name[i] = tolower(map_name[i]);
  2883. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  2884. strcat(map_name, ".gat");
  2885. // try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
  2886. if (strncmp(map_name, "prontera.gat", 3) == 0) { // 3 first characters
  2887. town = 0;
  2888. } else if (strncmp(map_name, "morocc.gat", 3) == 0) { // 3 first characters
  2889. town = 1;
  2890. } else if (strncmp(map_name, "geffen.gat", 3) == 0) { // 3 first characters
  2891. town = 2;
  2892. } else if (strncmp(map_name, "payon.gat", 3) == 0 || // 3 first characters
  2893. strncmp(map_name, "paion.gat", 3) == 0) { // writing error (3 first characters)
  2894. town = 3;
  2895. } else if (strncmp(map_name, "alberta.gat", 3) == 0) { // 3 first characters
  2896. town = 4;
  2897. } else if (strncmp(map_name, "izlude.gat", 3) == 0 || // 3 first characters
  2898. strncmp(map_name, "islude.gat", 3) == 0) { // writing error (3 first characters)
  2899. town = 5;
  2900. } else if (strncmp(map_name, "aldebaran.gat", 3) == 0 || // 3 first characters
  2901. strcmp(map_name, "al.gat") == 0) { // al (de baran)
  2902. town = 6;
  2903. } else if (strncmp(map_name, "lutie.gat", 3) == 0 || // name of the city, not name of the map (3 first characters)
  2904. strcmp(map_name, "christmas.gat") == 0 || // name of the symbol
  2905. strncmp(map_name, "xmas.gat", 3) == 0 || // 3 first characters
  2906. strncmp(map_name, "x-mas.gat", 3) == 0) { // writing error (3 first characters)
  2907. town = 7;
  2908. } else if (strncmp(map_name, "comodo.gat", 3) == 0) { // 3 first characters
  2909. town = 8;
  2910. } else if (strncmp(map_name, "yuno.gat", 3) == 0) { // 3 first characters
  2911. town = 9;
  2912. } else if (strncmp(map_name, "amatsu.gat", 3) == 0 || // 3 first characters
  2913. strncmp(map_name, "ammatsu.gat", 3) == 0) { // writing error (3 first characters)
  2914. town = 10;
  2915. } else if (strncmp(map_name, "gonryun.gat", 3) == 0) { // 3 first characters
  2916. town = 11;
  2917. } else if (strncmp(map_name, "umbala.gat", 3) == 0) { // 3 first characters
  2918. town = 12;
  2919. } else if (strncmp(map_name, "niflheim.gat", 3) == 0) { // 3 first characters
  2920. town = 13;
  2921. } else if (strncmp(map_name, "louyang.gat", 3) == 0) { // 3 first characters
  2922. town = 14;
  2923. } else if (strncmp(map_name, "new_1-1.gat", 3) == 0 || // 3 first characters (or "newbies")
  2924. strncmp(map_name, "startpoint.gat", 3) == 0 || // name of the position (3 first characters)
  2925. strncmp(map_name, "begining.gat", 3) == 0) { // name of the position (3 first characters)
  2926. town = 15;
  2927. } else if (strncmp(map_name, "sec_pri.gat", 3) == 0 || // 3 first characters
  2928. strncmp(map_name, "prison.gat", 3) == 0 || // name of the position (3 first characters)
  2929. strncmp(map_name, "jails.gat", 3) == 0) { // name of the position
  2930. town = 16;
  2931. } else if (strncmp(map_name, "jawaii.gat", 3) == 0 || // 3 first characters
  2932. strncmp(map_name, "jawai.gat", 3) == 0) { // writing error (3 first characters)
  2933. town = 17;
  2934. } else if (strncmp(map_name, "ayothaya.gat", 2) == 0 || // 2 first characters
  2935. strncmp(map_name, "ayotaya.gat", 2) == 0) { // writing error (2 first characters)
  2936. town = 18;
  2937. } else if (strncmp(map_name, "einbroch.gat", 3) == 0 || // 3 first characters
  2938. strncmp(map_name, "ainbroch.gat", 3) == 0) { // writing error (3 first characters)
  2939. town = 19;
  2940. } else if (strncmp(map_name, "lighthalzen.gat", 3) == 0 || // 3 first characters
  2941. strncmp(map_name, "reichthalzen.gat", 3) == 0) { // 'alternative' name (3 first characters)
  2942. town = 20;
  2943. } else if (strncmp(map_name, "einbech.gat", 5) == 0) { // 5 first characters
  2944. town = 21;
  2945. } else if (strncmp(map_name, "hugel.gat", 3) == 0) { // 3 first characters
  2946. town = 22;
  2947. }
  2948. if (town >= -3 && town <= -1) {
  2949. if (sd->status.memo_point[-town-1].map) {
  2950. m = map_mapindex2mapid(sd->status.memo_point[-town-1].map);
  2951. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2952. clif_displaymessage(fd, msg_table[247]);
  2953. return -1;
  2954. }
  2955. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2956. clif_displaymessage(fd, msg_table[248]);
  2957. return -1;
  2958. }
  2959. 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) {
  2960. clif_displaymessage(fd, msg_table[0]); // Warped.
  2961. } else {
  2962. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2963. return -1;
  2964. }
  2965. } else {
  2966. sprintf(atcmd_output, msg_table[164], -town-1); // Your memo point #%d doesn't exist.
  2967. clif_displaymessage(fd, atcmd_output);
  2968. return -1;
  2969. }
  2970. } else if (town >= 0 && town < (int)(sizeof(data) / sizeof(data[0]))) {
  2971. m = map_mapname2mapid((char *)data[town].map);
  2972. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2973. clif_displaymessage(fd, msg_table[247]);
  2974. return -1;
  2975. }
  2976. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2977. clif_displaymessage(fd, msg_table[248]);
  2978. return -1;
  2979. }
  2980. if (pc_setpos(sd, mapindex_name2id((char *)data[town].map), data[town].x, data[town].y, 3) == 0) {
  2981. clif_displaymessage(fd, msg_table[0]); // Warped.
  2982. } else {
  2983. clif_displaymessage(fd, msg_table[1]); // Map not found.
  2984. return -1;
  2985. }
  2986. } else { // if you arrive here, you have an error in town variable when reading of names
  2987. clif_displaymessage(fd, msg_table[38]); // Invalid location number or name.
  2988. return -1;
  2989. }
  2990. }
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. *
  2995. *------------------------------------------
  2996. */
  2997. int atcommand_monster(
  2998. const int fd, struct map_session_data* sd,
  2999. const char* command, const char* message)
  3000. {
  3001. char name[NAME_LENGTH];
  3002. char monster[NAME_LENGTH];
  3003. int mob_id;
  3004. int number = 0;
  3005. int count;
  3006. int i, k, range;
  3007. short mx, my;
  3008. nullpo_retr(-1, sd);
  3009. memset(name, '\0', sizeof(name));
  3010. memset(monster, '\0', sizeof(monster));
  3011. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3012. if (!message || !*message) {
  3013. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3014. return -1;
  3015. }
  3016. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  3017. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  3018. //All data can be left as it is.
  3019. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  3020. //Here, it is possible name was not given and we are using monster for it.
  3021. if (count < 3) //Blank mob's name.
  3022. name[0] = '\0';
  3023. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  3024. //All data can be left as it is.
  3025. } else if (sscanf(message, "%23s", monster) > 0) {
  3026. //As before, name may be already filled.
  3027. name[0] = '\0';
  3028. } else {
  3029. clif_displaymessage(fd, msg_table[80]); // Give a display name and monster name/id please.
  3030. return -1;
  3031. }
  3032. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3033. mob_id = mobdb_checkid(atoi(monster));
  3034. if (mob_id == 0) {
  3035. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3036. return -1;
  3037. }
  3038. if (mob_id == MOBID_EMPERIUM) {
  3039. clif_displaymessage(fd, msg_table[83]); // Cannot spawn emperium.
  3040. return -1;
  3041. }
  3042. if (number <= 0)
  3043. number = 1;
  3044. if (strlen(name) < 1)
  3045. strcpy(name, "--ja--");
  3046. // 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
  3047. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  3048. number = battle_config.atc_spawn_quantity_limit;
  3049. if (battle_config.etc_log)
  3050. ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y);
  3051. count = 0;
  3052. range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around)
  3053. for (i = 0; i < number; i++) {
  3054. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  3055. k = mob_once_spawn(sd, "this", mx, my, name, mob_id, 1, "");
  3056. count += (k != 0) ? 1 : 0;
  3057. }
  3058. if (count != 0)
  3059. if (number == count)
  3060. clif_displaymessage(fd, msg_table[39]); // All monster summoned!
  3061. else {
  3062. sprintf(atcmd_output, msg_table[240], count); // %d monster(s) summoned!
  3063. clif_displaymessage(fd, atcmd_output);
  3064. }
  3065. else {
  3066. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  3067. return -1;
  3068. }
  3069. return 0;
  3070. }
  3071. // small monster spawning [Valaris]
  3072. int atcommand_monstersmall(
  3073. const int fd, struct map_session_data* sd,
  3074. const char* command, const char* message) {
  3075. char name[NAME_LENGTH] = "";
  3076. char monster[NAME_LENGTH] = "";
  3077. int mob_id = 0;
  3078. int number = 0;
  3079. int x = 0;
  3080. int y = 0;
  3081. int count;
  3082. int i;
  3083. nullpo_retr(-1, sd);
  3084. if (!message || !*message) {
  3085. clif_displaymessage(fd, "Give a monster name/id please.");
  3086. return -1;
  3087. }
  3088. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3089. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3090. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3091. clif_displaymessage(fd, "Give a monster name/id please.");
  3092. return -1;
  3093. }
  3094. // If monster identifier/name argument is a name
  3095. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3096. mob_id = atoi(monster);
  3097. if (mob_id == 0) {
  3098. clif_displaymessage(fd, msg_table[40]);
  3099. return -1;
  3100. }
  3101. if (mob_id == MOBID_EMPERIUM) {
  3102. clif_displaymessage(fd, msg_table[83]);
  3103. return -1;
  3104. }
  3105. if (mobdb_checkid(mob_id) == 0) {
  3106. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3107. return -1;
  3108. }
  3109. if (number <= 0)
  3110. number = 1;
  3111. if (strlen(name) < 1)
  3112. strcpy(name, "--ja--");
  3113. // 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
  3114. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3115. number = battle_config.atc_spawn_quantity_limit;
  3116. count = 0;
  3117. for (i = 0; i < number; i++) {
  3118. int mx, my;
  3119. if (x <= 0)
  3120. mx = sd->bl.x + (rand() % 11 - 5);
  3121. else
  3122. mx = x;
  3123. if (y <= 0)
  3124. my = sd->bl.y + (rand() % 11 - 5);
  3125. else
  3126. my = y;
  3127. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  3128. }
  3129. if (count != 0)
  3130. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3131. else
  3132. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3133. return 0;
  3134. }
  3135. // big monster spawning [Valaris]
  3136. int atcommand_monsterbig(
  3137. const int fd, struct map_session_data* sd,
  3138. const char* command, const char* message) {
  3139. char name[NAME_LENGTH] = "";
  3140. char monster[NAME_LENGTH] = "";
  3141. int mob_id = 0;
  3142. int number = 0;
  3143. int x = 0;
  3144. int y = 0;
  3145. int count;
  3146. int i;
  3147. nullpo_retr(-1, sd);
  3148. if (!message || !*message) {
  3149. clif_displaymessage(fd, "Give a monster name/id please.");
  3150. return -1;
  3151. }
  3152. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  3153. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  3154. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  3155. clif_displaymessage(fd, "Give a monster name/id please.");
  3156. return -1;
  3157. }
  3158. // If monster identifier/name argument is a name
  3159. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  3160. mob_id = atoi(monster);
  3161. if (mob_id == 0) {
  3162. clif_displaymessage(fd, msg_table[40]);
  3163. return -1;
  3164. }
  3165. if (mob_id == MOBID_EMPERIUM) {
  3166. clif_displaymessage(fd, msg_table[83]);
  3167. return -1;
  3168. }
  3169. if (mobdb_checkid(mob_id) == 0) {
  3170. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  3171. return -1;
  3172. }
  3173. if (number <= 0)
  3174. number = 1;
  3175. if (strlen(name) < 1)
  3176. strcpy(name, "--ja--");
  3177. // 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
  3178. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  3179. number = battle_config.atc_spawn_quantity_limit;
  3180. count = 0;
  3181. for (i = 0; i < number; i++) {
  3182. int mx, my;
  3183. if (x <= 0)
  3184. mx = sd->bl.x + (rand() % 11 - 5);
  3185. else
  3186. mx = x;
  3187. if (y <= 0)
  3188. my = sd->bl.y + (rand() % 11 - 5);
  3189. else
  3190. my = y;
  3191. count += (mob_once_spawn((struct map_session_data*)sd, "this", mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  3192. }
  3193. if (count != 0)
  3194. clif_displaymessage(fd, msg_table[39]); // Monster Summoned!!
  3195. else
  3196. clif_displaymessage(fd, msg_table[40]); // Invalid Monster ID.
  3197. return 0;
  3198. }
  3199. /*==========================================
  3200. *
  3201. *------------------------------------------
  3202. */
  3203. static int atkillmonster_sub(struct block_list *bl, va_list ap) {
  3204. struct mob_data *md;
  3205. int flag;
  3206. nullpo_retr(0, ap);
  3207. nullpo_retr(0, md=(struct mob_data *)bl);
  3208. flag = va_arg(ap, int);
  3209. if (md->guardian_data)
  3210. return 0; //Do not touch WoE mobs!
  3211. if (flag)
  3212. mob_damage(NULL, md, md->hp, 2);
  3213. else
  3214. unit_remove_map(&md->bl,1);
  3215. return 1;
  3216. }
  3217. void atcommand_killmonster_sub(
  3218. const int fd, struct map_session_data* sd, const char* message,
  3219. const int drop)
  3220. {
  3221. int map_id;
  3222. char map_name[MAP_NAME_LENGTH];
  3223. if (!sd) return;
  3224. memset(map_name, '\0', sizeof(map_name));
  3225. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  3226. map_id = sd->bl.m;
  3227. else {
  3228. if (strstr(map_name, ".gat") == NULL && strstr(map_name, ".afm") == NULL && strlen(map_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  3229. strcat(map_name, ".gat");
  3230. if ((map_id = map_mapname2mapid(map_name)) < 0)
  3231. map_id = sd->bl.m;
  3232. }
  3233. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  3234. clif_displaymessage(fd, msg_table[165]); // All monsters killed!
  3235. return;
  3236. }
  3237. /*==========================================
  3238. *
  3239. *------------------------------------------
  3240. */
  3241. int atcommand_killmonster(
  3242. const int fd, struct map_session_data* sd,
  3243. const char* command, const char* message)
  3244. {
  3245. if (!sd) return 0;
  3246. atcommand_killmonster_sub(fd, sd, message, 1);
  3247. return 0;
  3248. }
  3249. /*==========================================
  3250. *
  3251. *------------------------------------------
  3252. */
  3253. int atcommand_killmonster2(
  3254. const int fd, struct map_session_data* sd,
  3255. const char* command, const char* message)
  3256. {
  3257. if (!sd) return 0;
  3258. atcommand_killmonster_sub(fd, sd, message, 0);
  3259. return 0;
  3260. }
  3261. /*==========================================
  3262. *
  3263. *------------------------------------------
  3264. */
  3265. int atcommand_refine(
  3266. const int fd, struct map_session_data* sd,
  3267. const char* command, const char* message)
  3268. {
  3269. int i, position = 0, refine = 0, current_position, final_refine;
  3270. int count;
  3271. nullpo_retr(-1, sd);
  3272. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3273. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  3274. clif_displaymessage(fd, "Please, enter a position and a amount (usage: @refine <equip position> <+/- amount>).");
  3275. return -1;
  3276. }
  3277. if (refine < -10)
  3278. refine = -10;
  3279. else if (refine > 10)
  3280. refine = 10;
  3281. else if (refine == 0)
  3282. refine = 1;
  3283. count = 0;
  3284. for (i = 0; i < MAX_INVENTORY; i++) {
  3285. if (sd->status.inventory[i].nameid && // 該当個所の装備を精錬する
  3286. (sd->status.inventory[i].equip & position ||
  3287. (sd->status.inventory[i].equip && !position))) {
  3288. final_refine = sd->status.inventory[i].refine + refine;
  3289. if (final_refine > 10)
  3290. final_refine = 10;
  3291. else if (final_refine < 0)
  3292. final_refine = 0;
  3293. if (sd->status.inventory[i].refine != final_refine) {
  3294. sd->status.inventory[i].refine = final_refine;
  3295. current_position = sd->status.inventory[i].equip;
  3296. pc_unequipitem(sd, i, 3);
  3297. clif_refine(fd, sd, 0, i, sd->status.inventory[i].refine);
  3298. clif_delitem(sd, i, 1);
  3299. clif_additem(sd, i, 1, 0);
  3300. pc_equipitem(sd, i, current_position);
  3301. clif_misceffect((struct block_list*)&sd->bl, 3);
  3302. count++;
  3303. }
  3304. }
  3305. }
  3306. if (count == 0)
  3307. clif_displaymessage(fd, msg_table[166]); // No item has been refined!
  3308. else if (count == 1)
  3309. clif_displaymessage(fd, msg_table[167]); // 1 item has been refined!
  3310. else {
  3311. sprintf(atcmd_output, msg_table[168], count); // %d items have been refined!
  3312. clif_displaymessage(fd, atcmd_output);
  3313. }
  3314. return 0;
  3315. }
  3316. /*==========================================
  3317. *
  3318. *------------------------------------------
  3319. */
  3320. int atcommand_produce(
  3321. const int fd, struct map_session_data* sd,
  3322. const char* command, const char* message)
  3323. {
  3324. char item_name[100];
  3325. int item_id, attribute = 0, star = 0;
  3326. int flag = 0;
  3327. struct item_data *item_data;
  3328. struct item tmp_item;
  3329. nullpo_retr(-1, sd);
  3330. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3331. memset(item_name, '\0', sizeof(item_name));
  3332. if (!message || !*message || sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1) {
  3333. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  3334. return -1;
  3335. }
  3336. item_id = 0;
  3337. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  3338. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  3339. item_id = item_data->nameid;
  3340. if (itemdb_exists(item_id) &&
  3341. (item_id <= 500 || item_id > 1099) &&
  3342. (item_id < 4001 || item_id > 4148) &&
  3343. (item_id < 7001 || item_id > 10019) &&
  3344. itemdb_isequip(item_id)) {
  3345. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  3346. attribute = ATTRIBUTE_NORMAL;
  3347. if (star < MIN_STAR || star > MAX_STAR)
  3348. star = 0;
  3349. memset(&tmp_item, 0, sizeof tmp_item);
  3350. tmp_item.nameid = item_id;
  3351. tmp_item.amount = 1;
  3352. tmp_item.identify = 1;
  3353. tmp_item.card[0] = 0x00ff;
  3354. tmp_item.card[1] = ((star * 5) << 8) + attribute;
  3355. tmp_item.card[2] = GetWord(sd->char_id, 0);
  3356. tmp_item.card[3] = GetWord(sd->char_id, 1);
  3357. clif_produceeffect(sd, 0, item_id); // 製造エフェクトパケット
  3358. clif_misceffect(&sd->bl, 3); // 他人にも成功を通知
  3359. //Logs (A)dmins items [Lupus]
  3360. if(log_config.pick > 0 ) {
  3361. log_pick(sd, "A", 0, tmp_item.nameid, 1, &tmp_item);
  3362. }
  3363. //Logs
  3364. if ((flag = pc_additem(sd, &tmp_item, 1)))
  3365. clif_additem(sd, 0, 0, flag);
  3366. } else {
  3367. if (battle_config.error_log)
  3368. ShowError("@produce NOT WEAPON [%d]\n", item_id);
  3369. if (item_id != 0 && itemdb_exists(item_id))
  3370. sprintf(atcmd_output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment.
  3371. else
  3372. sprintf(atcmd_output, msg_table[170]); // This item is not an equipment.
  3373. clif_displaymessage(fd, atcmd_output);
  3374. return -1;
  3375. }
  3376. return 0;
  3377. }
  3378. /*==========================================
  3379. * Sub-function to display actual memo points
  3380. *------------------------------------------
  3381. */
  3382. void atcommand_memo_sub(struct map_session_data* sd) {
  3383. int i;
  3384. if (!sd) return;
  3385. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3386. clif_displaymessage(sd->fd, "Your actual memo positions are (except respawn point):");
  3387. for (i = MIN_PORTAL_MEMO; i <= MAX_PORTAL_MEMO; i++) {
  3388. if (sd->status.memo_point[i].map)
  3389. 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);
  3390. else
  3391. sprintf(atcmd_output, msg_table[171], i); // %d - void
  3392. clif_displaymessage(sd->fd, atcmd_output);
  3393. }
  3394. return;
  3395. }
  3396. /*==========================================
  3397. *
  3398. *------------------------------------------
  3399. */
  3400. int atcommand_memo(
  3401. const int fd, struct map_session_data* sd,
  3402. const char* command, const char* message)
  3403. {
  3404. int position = 0;
  3405. nullpo_retr(-1, sd);
  3406. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3407. if (!message || !*message || sscanf(message, "%d", &position) < 1)
  3408. atcommand_memo_sub(sd);
  3409. else {
  3410. if (position >= MIN_PORTAL_MEMO && position <= MAX_PORTAL_MEMO) {
  3411. 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)) {
  3412. clif_displaymessage(fd, msg_table[253]);
  3413. return -1;
  3414. }
  3415. if (sd->status.memo_point[position].map) {
  3416. 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).
  3417. clif_displaymessage(fd, atcmd_output);
  3418. }
  3419. sd->status.memo_point[position].map = map[sd->bl.m].index;
  3420. sd->status.memo_point[position].x = sd->bl.x;
  3421. sd->status.memo_point[position].y = sd->bl.y;
  3422. clif_skill_memo(sd, 0);
  3423. if (pc_checkskill(sd, AL_WARP) <= (position + 1))
  3424. clif_displaymessage(fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it.
  3425. atcommand_memo_sub(sd);
  3426. } else {
  3427. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", MIN_PORTAL_MEMO, MAX_PORTAL_MEMO);
  3428. clif_displaymessage(fd, atcmd_output);
  3429. atcommand_memo_sub(sd);
  3430. return -1;
  3431. }
  3432. }
  3433. return 0;
  3434. }
  3435. /*==========================================
  3436. *
  3437. *------------------------------------------
  3438. */
  3439. int atcommand_gat(
  3440. const int fd, struct map_session_data* sd,
  3441. const char* command, const char* message)
  3442. {
  3443. int y;
  3444. nullpo_retr(-1, sd);
  3445. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3446. for (y = 2; y >= -2; y--) {
  3447. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  3448. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  3449. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  3450. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  3451. map_getcell(sd->bl.m, sd->bl.x, 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 + 2, sd->bl.y + y, CELL_GETTYPE));
  3454. clif_displaymessage(fd, atcmd_output);
  3455. }
  3456. return 0;
  3457. }
  3458. /*==========================================
  3459. *
  3460. *------------------------------------------
  3461. */
  3462. int atcommand_packet(
  3463. const int fd, struct map_session_data* sd,
  3464. const char* command, const char* message)
  3465. {
  3466. static int packet_mode = 0;
  3467. int i, x = 0, y = 0;
  3468. nullpo_retr(-1, sd);
  3469. if (strstr(command, "packetmode")) {
  3470. packet_mode = atoi(message);
  3471. clif_displaymessage(fd, "Packet mode changed.");
  3472. return 0;
  3473. }
  3474. if (!message || !*message || (i = sscanf(message, "%d %d", &x, &y)) < 1) {
  3475. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @packet <status type> <flag>).");
  3476. return -1;
  3477. }
  3478. if (i == 1) y = 1;
  3479. switch (packet_mode)
  3480. {
  3481. case 0:
  3482. clif_status_change(&sd->bl, x, y);
  3483. break;
  3484. case 1:
  3485. sd->status.skill[sd->cloneskill_id].id=0;
  3486. sd->status.skill[sd->cloneskill_id].lv=0;
  3487. sd->status.skill[sd->cloneskill_id].flag=0;
  3488. sd->cloneskill_id = x;
  3489. sd->status.skill[x].id = x;
  3490. sd->status.skill[x].lv = skill_get_max(x);
  3491. sd->status.skill[x].flag = 13;//cloneskill flag
  3492. clif_skillinfoblock(sd);
  3493. break;
  3494. case 2:
  3495. clif_skill_nodamage(&sd->bl,&sd->bl,x,y,1);
  3496. case 3:
  3497. clif_skill_poseffect(&sd->bl,x,y,sd->bl.x,sd->bl.y,gettick());
  3498. default:
  3499. break;
  3500. //added later
  3501. }
  3502. return 0;
  3503. }
  3504. /*==========================================
  3505. * @waterlevel [Skotlex]
  3506. *------------------------------------------
  3507. */
  3508. int atcommand_waterlevel(
  3509. const int fd, struct map_session_data* sd,
  3510. const char* command, const char* message)
  3511. {
  3512. int newlevel;
  3513. if (!message || !*message || sscanf(message, "%d", &newlevel) < 1) {
  3514. sprintf(atcmd_output, "%s's current water level: %d", map[sd->bl.m].name, map_waterheight(map[sd->bl.m].name));
  3515. clif_displaymessage(fd, atcmd_output);
  3516. return 0;
  3517. }
  3518. if (map_setwaterheight(sd->bl.m, map[sd->bl.m].name, newlevel)) {
  3519. if (newlevel > 0)
  3520. sprintf(atcmd_output, "%s's water level changed to: %d", map[sd->bl.m].name, newlevel);
  3521. else
  3522. sprintf(atcmd_output, "Removed %s's water level information.", map[sd->bl.m].name);
  3523. clif_displaymessage(fd, atcmd_output);
  3524. } else {
  3525. sprintf(atcmd_output, "Failed to change %s's water level.", map[sd->bl.m].name);
  3526. clif_displaymessage(fd, atcmd_output);
  3527. }
  3528. return 0;
  3529. }
  3530. /*==========================================
  3531. * @stpoint (Rewritten by [Yor])
  3532. *------------------------------------------
  3533. */
  3534. int atcommand_statuspoint(
  3535. const int fd, struct map_session_data* sd,
  3536. const char* command, const char* message)
  3537. {
  3538. int point, new_status_point;
  3539. if (!message || !*message || (point = atoi(message)) == 0) {
  3540. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  3541. return -1;
  3542. }
  3543. if (point > 0 && sd->status.status_point > USHRT_MAX - point)
  3544. new_status_point = USHRT_MAX;
  3545. else
  3546. if (point < 0 && sd->status.status_point < -point)
  3547. new_status_point = 0;
  3548. else
  3549. new_status_point = sd->status.status_point + point;
  3550. if (new_status_point != (int)sd->status.status_point) {
  3551. sd->status.status_point = (unsigned 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. if (point > 0 && sd->status.skill_point > USHRT_MAX - point)
  3578. new_skill_point = USHRT_MAX;
  3579. else if (point < 0 && sd->status.skill_point < -point)
  3580. new_skill_point = 0;
  3581. else
  3582. new_skill_point = sd->status.skill_point + point;
  3583. if (new_skill_point != (int)sd->status.skill_point) {
  3584. sd->status.skill_point = (unsigned short)new_skill_point;
  3585. clif_updatestatus(sd, SP_SKILLPOINT);
  3586. clif_displaymessage(fd, msg_table[175]); // Number of skill points changed!
  3587. } else {
  3588. if (point < 0)
  3589. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3590. else
  3591. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3592. return -1;
  3593. }
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. * @zeny (Rewritten by [Yor])
  3598. *------------------------------------------
  3599. */
  3600. int atcommand_zeny(
  3601. const int fd, struct map_session_data* sd,
  3602. const char* command, const char* message)
  3603. {
  3604. int zeny, new_zeny;
  3605. nullpo_retr(-1, sd);
  3606. if (!message || !*message || (zeny = atoi(message)) == 0) {
  3607. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  3608. return -1;
  3609. }
  3610. new_zeny = sd->status.zeny + zeny;
  3611. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  3612. new_zeny = MAX_ZENY;
  3613. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  3614. new_zeny = 0;
  3615. if (new_zeny != sd->status.zeny) {
  3616. sd->status.zeny = new_zeny;
  3617. clif_updatestatus(sd, SP_ZENY);
  3618. clif_displaymessage(fd, msg_table[176]); // Number of zenys changed!
  3619. } else {
  3620. if (zeny < 0)
  3621. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3622. else
  3623. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3624. return -1;
  3625. }
  3626. return 0;
  3627. }
  3628. /*==========================================
  3629. *
  3630. *------------------------------------------
  3631. */
  3632. int atcommand_param(
  3633. const int fd, struct map_session_data* sd,
  3634. const char* command, const char* message)
  3635. {
  3636. int index, value = 0, new_value, max;
  3637. const char* param[] = { "@str", "@agi", "@vit", "@int", "@dex", "@luk", NULL };
  3638. short* status[6];
  3639. //we don't use direct initialization because it isn't part of the c standard.
  3640. nullpo_retr(-1, sd);
  3641. status[0] = &sd->status.str;
  3642. status[1] = &sd->status.agi;
  3643. status[2] = &sd->status.vit;
  3644. status[3] = &sd->status.int_;
  3645. status[4] = &sd->status.dex;
  3646. status[5] = &sd->status.luk;
  3647. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3648. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  3649. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3650. clif_displaymessage(fd, atcmd_output);
  3651. return -1;
  3652. }
  3653. index = -1;
  3654. for (index = 0; index < sizeof(param)/sizeof(param[0]); index++) {
  3655. if (strcmpi(command, param[index]) == 0)
  3656. break;
  3657. }
  3658. if (index == sizeof(param)/sizeof(param[0]) || index > MAX_STATUS_TYPE) {
  3659. // normaly impossible...
  3660. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustement>).");
  3661. clif_displaymessage(fd, atcmd_output);
  3662. return -1;
  3663. }
  3664. max = pc_maxparameter(sd);
  3665. if (value > 0 && *status[index] > max - value)
  3666. new_value = max;
  3667. else if (value < 0 && *status[index] <= -value)
  3668. new_value = 1;
  3669. else
  3670. new_value = *status[index] + value;
  3671. if (new_value != (int)*status[index]) {
  3672. *status[index] = new_value;
  3673. clif_updatestatus(sd, SP_STR + index);
  3674. clif_updatestatus(sd, SP_USTR + index);
  3675. status_calc_pc(sd, 0);
  3676. clif_displaymessage(fd, msg_table[42]); // Stat changed.
  3677. } else {
  3678. if (value < 0)
  3679. clif_displaymessage(fd, msg_table[41]); // Impossible to decrease the number/value.
  3680. else
  3681. clif_displaymessage(fd, msg_table[149]); // Impossible to increase the number/value.
  3682. return -1;
  3683. }
  3684. return 0;
  3685. }
  3686. /*==========================================
  3687. *
  3688. *------------------------------------------
  3689. */
  3690. //** Stat all by fritz (rewritten by [Yor])
  3691. int atcommand_stat_all(
  3692. const int fd, struct map_session_data* sd,
  3693. const char* command, const char* message)
  3694. {
  3695. int index, count, value = 0, max, new_value;
  3696. short* status[6];
  3697. //we don't use direct initialization because it isn't part of the c standard.
  3698. nullpo_retr(-1, sd);
  3699. status[0] = &sd->status.str;
  3700. status[1] = &sd->status.agi;
  3701. status[2] = &sd->status.vit;
  3702. status[3] = &sd->status.int_;
  3703. status[4] = &sd->status.dex;
  3704. status[5] = &sd->status.luk;
  3705. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0)
  3706. value = pc_maxparameter(sd);
  3707. count = 0;
  3708. max = pc_maxparameter(sd);
  3709. for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
  3710. if (value > 0 && *status[index] > max - value)
  3711. new_value = max;
  3712. else if (value < 0 && *status[index] <= -value)
  3713. new_value = 1;
  3714. else
  3715. new_value = *status[index] +value;
  3716. if (new_value != (int)*status[index]) {
  3717. *status[index] = new_value;
  3718. clif_updatestatus(sd, SP_STR + index);
  3719. clif_updatestatus(sd, SP_USTR + index);
  3720. status_calc_pc(sd, 0);
  3721. count++;
  3722. }
  3723. }
  3724. if (count > 0) // if at least 1 stat modified
  3725. clif_displaymessage(fd, msg_table[84]); // All stats changed!
  3726. else {
  3727. if (value < 0)
  3728. clif_displaymessage(fd, msg_table[177]); // Impossible to decrease a stat.
  3729. else
  3730. clif_displaymessage(fd, msg_table[178]); // Impossible to increase a stat.
  3731. return -1;
  3732. }
  3733. return 0;
  3734. }
  3735. /*==========================================
  3736. *
  3737. *------------------------------------------
  3738. */
  3739. int atcommand_guildlevelup(
  3740. const int fd, struct map_session_data* sd,
  3741. const char* command, const char* message)
  3742. {
  3743. int level = 0;
  3744. short added_level;
  3745. struct guild *guild_info;
  3746. nullpo_retr(-1, sd);
  3747. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  3748. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  3749. return -1;
  3750. }
  3751. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  3752. clif_displaymessage(fd, msg_table[43]); // You're not in a guild.
  3753. return -1;
  3754. }
  3755. if (strcmp(sd->status.name, guild_info->master) != 0) {
  3756. clif_displaymessage(fd, msg_table[44]); // You're not the master of your guild.
  3757. return -1;
  3758. }
  3759. added_level = (short)level;
  3760. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  3761. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  3762. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  3763. added_level = 1 - guild_info->guild_lv;
  3764. if (added_level != 0) {
  3765. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, 2);
  3766. clif_displaymessage(fd, msg_table[179]); // Guild level changed.
  3767. } else {
  3768. clif_displaymessage(fd, msg_table[45]); // Guild level change failed.
  3769. return -1;
  3770. }
  3771. return 0;
  3772. }
  3773. /*==========================================
  3774. *
  3775. *------------------------------------------
  3776. */
  3777. int atcommand_makeegg(
  3778. const int fd, struct map_session_data* sd,
  3779. const char* command, const char* message)
  3780. {
  3781. struct item_data *item_data;
  3782. int id, pet_id;
  3783. nullpo_retr(-1, sd);
  3784. if (!message || !*message) {
  3785. clif_displaymessage(fd, "Please, enter a monter/egg name/id (usage: @makeegg <pet_id>).");
  3786. return -1;
  3787. }
  3788. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  3789. id = item_data->nameid;
  3790. else if ((id = mobdb_searchname(message)) == 0) // for monster name
  3791. id = atoi(message);
  3792. pet_id = search_petDB_index(id, PET_CLASS);
  3793. if (pet_id < 0)
  3794. pet_id = search_petDB_index(id, PET_EGG);
  3795. if (pet_id >= 0) {
  3796. sd->catch_target_class = pet_db[pet_id].class_;
  3797. intif_create_pet(
  3798. sd->status.account_id, sd->status.char_id,
  3799. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  3800. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  3801. 100, 0, 1, pet_db[pet_id].jname);
  3802. } else {
  3803. clif_displaymessage(fd, msg_table[180]); // The monter/egg name/id doesn't exist.
  3804. return -1;
  3805. }
  3806. return 0;
  3807. }
  3808. /*==========================================
  3809. *
  3810. *------------------------------------------
  3811. */
  3812. int atcommand_hatch(
  3813. const int fd, struct map_session_data* sd,
  3814. const char* command, const char* message)
  3815. {
  3816. nullpo_retr(-1, sd);
  3817. if (sd->status.pet_id <= 0)
  3818. clif_sendegg(sd);
  3819. else {
  3820. clif_displaymessage(fd, msg_table[181]); // You already have a pet.
  3821. return -1;
  3822. }
  3823. return 0;
  3824. }
  3825. /*==========================================
  3826. *
  3827. *------------------------------------------
  3828. */
  3829. int atcommand_petfriendly(
  3830. const int fd, struct map_session_data* sd,
  3831. const char* command, const char* message)
  3832. {
  3833. int friendly;
  3834. int t;
  3835. nullpo_retr(-1, sd);
  3836. if (!message || !*message || (friendly = atoi(message)) < 0) {
  3837. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  3838. return -1;
  3839. }
  3840. if (sd->status.pet_id > 0 && sd->pd) {
  3841. if (friendly >= 0 && friendly <= 1000) {
  3842. if (friendly != sd->pet.intimate) {
  3843. t = sd->pet.intimate;
  3844. sd->pet.intimate = friendly;
  3845. clif_send_petstatus(sd);
  3846. if (battle_config.pet_status_support) {
  3847. if ((sd->pet.intimate > 0 && t <= 0) ||
  3848. (sd->pet.intimate <= 0 && t > 0)) {
  3849. if (sd->bl.prev != NULL)
  3850. status_calc_pc(sd, 0);
  3851. else
  3852. status_calc_pc(sd, 2);
  3853. }
  3854. }
  3855. clif_displaymessage(fd, msg_table[182]); // Pet friendly value changed!
  3856. } else {
  3857. clif_displaymessage(fd, msg_table[183]); // Pet friendly is already the good value.
  3858. return -1;
  3859. }
  3860. } else {
  3861. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3862. return -1;
  3863. }
  3864. } else {
  3865. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3866. return -1;
  3867. }
  3868. return 0;
  3869. }
  3870. /*==========================================
  3871. *
  3872. *------------------------------------------
  3873. */
  3874. int atcommand_pethungry(
  3875. const int fd, struct map_session_data* sd,
  3876. const char* command, const char* message)
  3877. {
  3878. int hungry;
  3879. nullpo_retr(-1, sd);
  3880. if (!message || !*message || (hungry = atoi(message)) < 0) {
  3881. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  3882. return -1;
  3883. }
  3884. if (sd->status.pet_id > 0 && sd->pd) {
  3885. if (hungry >= 0 && hungry <= 100) {
  3886. if (hungry != sd->pet.hungry) {
  3887. sd->pet.hungry = hungry;
  3888. clif_send_petstatus(sd);
  3889. clif_displaymessage(fd, msg_table[185]); // Pet hungry value changed!
  3890. } else {
  3891. clif_displaymessage(fd, msg_table[186]); // Pet hungry is already the good value.
  3892. return -1;
  3893. }
  3894. } else {
  3895. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  3896. return -1;
  3897. }
  3898. } else {
  3899. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3900. return -1;
  3901. }
  3902. return 0;
  3903. }
  3904. /*==========================================
  3905. *
  3906. *------------------------------------------
  3907. */
  3908. int atcommand_petrename(
  3909. const int fd, struct map_session_data* sd,
  3910. const char* command, const char* message)
  3911. {
  3912. nullpo_retr(-1, sd);
  3913. if (sd->status.pet_id > 0 && sd->pd) {
  3914. if (sd->pet.rename_flag != 0) {
  3915. sd->pet.rename_flag = 0;
  3916. intif_save_petdata(sd->status.account_id, &sd->pet);
  3917. clif_send_petstatus(sd);
  3918. clif_displaymessage(fd, msg_table[187]); // You can now rename your pet.
  3919. } else {
  3920. clif_displaymessage(fd, msg_table[188]); // You can already rename your pet.
  3921. return -1;
  3922. }
  3923. } else {
  3924. clif_displaymessage(fd, msg_table[184]); // Sorry, but you have no pet.
  3925. return -1;
  3926. }
  3927. return 0;
  3928. }
  3929. /*==========================================
  3930. *
  3931. *------------------------------------------
  3932. */
  3933. int
  3934. atcommand_recall(
  3935. const int fd, struct map_session_data* sd,
  3936. const char* command, const char* message)
  3937. {
  3938. struct map_session_data *pl_sd = NULL;
  3939. nullpo_retr(-1, sd);
  3940. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3941. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <char name>).");
  3942. return -1;
  3943. }
  3944. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  3945. if(sscanf(message, "%23[^\n]", atcmd_player_name) < 1)
  3946. return -1;
  3947. if(strncmp(sd->status.name,atcmd_player_name,NAME_LENGTH)==0)
  3948. return -1;
  3949. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3950. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  3951. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3952. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3953. return -1;
  3954. }
  3955. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3956. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3957. return -1;
  3958. }
  3959. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  3960. sprintf(atcmd_output, msg_table[46], atcmd_player_name); // %s recalled!
  3961. clif_displaymessage(fd, atcmd_output);
  3962. } else {
  3963. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  3964. return -1;
  3965. }
  3966. } else {
  3967. clif_displaymessage(fd, msg_table[3]); // Character not found.
  3968. return -1;
  3969. }
  3970. return 0;
  3971. }
  3972. /*==========================================
  3973. *
  3974. *------------------------------------------
  3975. */
  3976. int atcommand_revive(
  3977. const int fd, struct map_session_data* sd,
  3978. const char* command, const char* message)
  3979. {
  3980. struct map_session_data *pl_sd;
  3981. nullpo_retr(-1, sd);
  3982. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3983. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3984. clif_displaymessage(fd, "Please, enter a player name (usage: @revive <char name>).");
  3985. return -1;
  3986. }
  3987. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3988. if (pc_isdead(pl_sd)) {
  3989. pl_sd->status.hp = pl_sd->status.max_hp;
  3990. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3991. pc_setstand(pl_sd);
  3992. if (battle_config.pc_invincible_time > 0)
  3993. pc_setinvincibletimer(pl_sd, battle_config.pc_invincible_time);
  3994. clif_updatestatus(pl_sd, SP_HP);
  3995. clif_updatestatus(pl_sd, SP_SP);
  3996. clif_resurrection(&pl_sd->bl, 1);
  3997. clif_displaymessage(fd, msg_table[51]); // Character revived.
  3998. return 0;
  3999. }
  4000. return -1;
  4001. } else {
  4002. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4003. return -1;
  4004. }
  4005. return 0;
  4006. }
  4007. /*==========================================
  4008. * charblock command (usage: charblock <player_name>)
  4009. * This command do a definitiv ban on a player
  4010. *------------------------------------------
  4011. */
  4012. int atcommand_char_block(
  4013. const int fd, struct map_session_data* sd,
  4014. const char* command, const char* message)
  4015. {
  4016. nullpo_retr(-1, sd);
  4017. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4018. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4019. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  4020. return -1;
  4021. }
  4022. // check player name
  4023. if (strlen(atcmd_player_name) < 4) {
  4024. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4025. return -1;
  4026. } else if (strlen(atcmd_player_name) > 23) {
  4027. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4028. return -1;
  4029. } else {
  4030. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  4031. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4032. }
  4033. return 0;
  4034. }
  4035. /*==========================================
  4036. * charban command (usage: charban <time> <player_name>)
  4037. * This command do a limited ban on a player
  4038. * Time is done as follows:
  4039. * Adjustment value (-1, 1, +1, etc...)
  4040. * Modified element:
  4041. * a or y: year
  4042. * m: month
  4043. * j or d: day
  4044. * h: hour
  4045. * mn: minute
  4046. * s: second
  4047. * <example> @ban +1m-2mn1s-6y test_player
  4048. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  4049. *------------------------------------------
  4050. */
  4051. int atcommand_char_ban(
  4052. const int fd, struct map_session_data* sd,
  4053. const char* command, const char* message)
  4054. {
  4055. char * modif_p;
  4056. int year, month, day, hour, minute, second, value;
  4057. nullpo_retr(-1, sd);
  4058. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4059. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4060. if (!message || !*message || sscanf(message, "%s %99[^\n]", atcmd_output, atcmd_player_name) < 2) {
  4061. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  4062. return -1;
  4063. }
  4064. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4065. modif_p = atcmd_output;
  4066. year = month = day = hour = minute = second = 0;
  4067. while (modif_p[0] != '\0') {
  4068. value = atoi(modif_p);
  4069. if (value == 0)
  4070. modif_p++;
  4071. else {
  4072. if (modif_p[0] == '-' || modif_p[0] == '+')
  4073. modif_p++;
  4074. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4075. modif_p++;
  4076. if (modif_p[0] == 's') {
  4077. second = value;
  4078. modif_p++;
  4079. } else if (modif_p[0] == 'n' || (modif_p[0] == 'm' && modif_p[1] == 'n')) {
  4080. minute = value;
  4081. modif_p = modif_p + 2;
  4082. } else if (modif_p[0] == 'h') {
  4083. hour = value;
  4084. modif_p++;
  4085. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4086. day = value;
  4087. modif_p++;
  4088. } else if (modif_p[0] == 'm') {
  4089. month = value;
  4090. modif_p++;
  4091. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4092. year = value;
  4093. modif_p++;
  4094. } else if (modif_p[0] != '\0') {
  4095. modif_p++;
  4096. }
  4097. }
  4098. }
  4099. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  4100. clif_displaymessage(fd, msg_table[85]); // Invalid time for ban command.
  4101. return -1;
  4102. }
  4103. // check player name
  4104. if (strlen(atcmd_player_name) < 4) {
  4105. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4106. return -1;
  4107. } else if (strlen(atcmd_player_name) > 23) {
  4108. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4109. return -1;
  4110. } else {
  4111. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  4112. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4113. }
  4114. return 0;
  4115. }
  4116. /*==========================================
  4117. * charunblock command (usage: charunblock <player_name>)
  4118. *------------------------------------------
  4119. */
  4120. int atcommand_char_unblock(
  4121. const int fd, struct map_session_data* sd,
  4122. const char* command, const char* message)
  4123. {
  4124. nullpo_retr(-1, sd);
  4125. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4126. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4127. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  4128. return -1;
  4129. }
  4130. // check player name
  4131. if (strlen(atcmd_player_name) < 4) {
  4132. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4133. return -1;
  4134. } else if (strlen(atcmd_player_name) > 23) {
  4135. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4136. return -1;
  4137. } else {
  4138. // send answer to login server via char-server
  4139. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  4140. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4141. }
  4142. return 0;
  4143. }
  4144. /*==========================================
  4145. * charunban command (usage: charunban <player_name>)
  4146. *------------------------------------------
  4147. */
  4148. int atcommand_char_unban(
  4149. const int fd, struct map_session_data* sd,
  4150. const char* command, const char* message)
  4151. {
  4152. nullpo_retr(-1, sd);
  4153. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4154. if (!message || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  4155. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  4156. return -1;
  4157. }
  4158. // check player name
  4159. if (strlen(atcmd_player_name) < 4) {
  4160. clif_displaymessage(fd, msg_table[86]); // Sorry, but a player name have at least 4 characters.
  4161. return -1;
  4162. } else if (strlen(atcmd_player_name) > 23) {
  4163. clif_displaymessage(fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum.
  4164. return -1;
  4165. } else {
  4166. // send answer to login server via char-server
  4167. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  4168. clif_displaymessage(fd, msg_table[88]); // Character name sends to char-server to ask it.
  4169. }
  4170. return 0;
  4171. }
  4172. /*==========================================
  4173. *
  4174. *------------------------------------------
  4175. */
  4176. int atcommand_night(
  4177. const int fd, struct map_session_data* sd,
  4178. const char* command, const char* message)
  4179. {
  4180. nullpo_retr(-1, sd);
  4181. if (night_flag != 1) {
  4182. map_night_timer(night_timer_tid, 0, 0, 1);
  4183. } else {
  4184. clif_displaymessage(fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command.
  4185. return -1;
  4186. }
  4187. return 0;
  4188. }
  4189. /*==========================================
  4190. *
  4191. *------------------------------------------
  4192. */
  4193. int atcommand_day(
  4194. const int fd, struct map_session_data* sd,
  4195. const char* command, const char* message)
  4196. {
  4197. nullpo_retr(-1, sd);
  4198. if (night_flag != 0) {
  4199. map_day_timer(day_timer_tid, 0, 0, 1);
  4200. } else {
  4201. clif_displaymessage(fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command.
  4202. return -1;
  4203. }
  4204. return 0;
  4205. }
  4206. /*==========================================
  4207. *
  4208. *------------------------------------------
  4209. */
  4210. int atcommand_doom(
  4211. const int fd, struct map_session_data* sd,
  4212. const char* command, const char* message)
  4213. {
  4214. struct map_session_data *pl_sd, **pl_allsd;
  4215. int i, users;
  4216. nullpo_retr(-1, sd);
  4217. clif_specialeffect(&sd->bl,450,2);
  4218. pl_allsd = map_getallusers(&users);
  4219. for(i = 0; i < users; i++) {
  4220. 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
  4221. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4222. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4223. }
  4224. }
  4225. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4226. return 0;
  4227. }
  4228. /*==========================================
  4229. *
  4230. *------------------------------------------
  4231. */
  4232. int atcommand_doommap(
  4233. const int fd, struct map_session_data* sd,
  4234. const char* command, const char* message)
  4235. {
  4236. struct map_session_data *pl_sd, **pl_allsd;
  4237. int i, users;
  4238. nullpo_retr(-1, sd);
  4239. clif_specialeffect(&sd->bl,450,3);
  4240. pl_allsd = map_getallusers(&users);
  4241. for (i = 0; i < users; i++) {
  4242. if ((pl_sd = pl_allsd[i]) && pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m &&
  4243. pc_isGM(sd) >= pc_isGM(pl_sd)) // you can doom only lower or same gm level
  4244. {
  4245. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  4246. // clif_specialeffect(&pl_sd->bl,450,1);
  4247. clif_displaymessage(pl_sd->fd, msg_table[61]); // The holy messenger has given judgement.
  4248. }
  4249. }
  4250. clif_displaymessage(fd, msg_table[62]); // Judgement was made.
  4251. return 0;
  4252. }
  4253. /*==========================================
  4254. *
  4255. *------------------------------------------
  4256. */
  4257. static void atcommand_raise_sub(struct map_session_data* sd)
  4258. {
  4259. if (sd && sd->state.auth && pc_isdead(sd)) {
  4260. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  4261. sd->status.hp = sd->status.max_hp;
  4262. sd->status.sp = sd->status.max_sp;
  4263. pc_setstand(sd);
  4264. clif_updatestatus(sd, SP_HP);
  4265. clif_updatestatus(sd, SP_SP);
  4266. clif_resurrection(&sd->bl, 1);
  4267. if (battle_config.pc_invincible_time > 0)
  4268. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  4269. clif_displaymessage(sd->fd, msg_table[63]); // Mercy has been shown.
  4270. }
  4271. }
  4272. /*==========================================
  4273. *
  4274. *------------------------------------------
  4275. */
  4276. int atcommand_raise(
  4277. const int fd, struct map_session_data* sd,
  4278. const char* command, const char* message)
  4279. {
  4280. int i, users;
  4281. struct map_session_data **all_sd;
  4282. nullpo_retr(-1, sd);
  4283. all_sd = map_getallusers(&users);
  4284. for (i = 0; i < users; i++) {
  4285. atcommand_raise_sub(all_sd[i]);
  4286. }
  4287. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4288. return 0;
  4289. }
  4290. /*==========================================
  4291. *
  4292. *------------------------------------------
  4293. */
  4294. int atcommand_raisemap(
  4295. const int fd, struct map_session_data* sd,
  4296. const char* command, const char* message)
  4297. {
  4298. struct map_session_data **pl_allsd;
  4299. int i, users;
  4300. nullpo_retr(-1, sd);
  4301. pl_allsd = map_getallusers(&users);
  4302. for (i = 0; i < users; i++) {
  4303. if (sd->bl.m == pl_allsd[i]->bl.m)
  4304. atcommand_raise_sub(pl_allsd[i]);
  4305. }
  4306. clif_displaymessage(fd, msg_table[64]); // Mercy has been granted.
  4307. return 0;
  4308. }
  4309. /*==========================================
  4310. *
  4311. *------------------------------------------
  4312. */
  4313. int atcommand_kick(
  4314. const int fd, struct map_session_data* sd,
  4315. const char* command, const char* message)
  4316. {
  4317. struct map_session_data *pl_sd;
  4318. nullpo_retr(-1, sd);
  4319. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4320. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4321. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <charname>).");
  4322. return -1;
  4323. }
  4324. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4325. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  4326. clif_GM_kick(sd, pl_sd, 1);
  4327. else {
  4328. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  4329. return -1;
  4330. }
  4331. } else {
  4332. clif_displaymessage(fd, msg_table[3]); // Character not found.
  4333. return -1;
  4334. }
  4335. return 0;
  4336. }
  4337. /*==========================================
  4338. *
  4339. *------------------------------------------
  4340. */
  4341. int atcommand_kickall(
  4342. const int fd, struct map_session_data* sd,
  4343. const char* command, const char* message)
  4344. {
  4345. struct map_session_data *pl_sd, **pl_allsd;
  4346. int i, users;
  4347. nullpo_retr(-1, sd);
  4348. pl_allsd = map_getallusers(&users);
  4349. for (i = 0; i < users; i++) {
  4350. if ((pl_sd = pl_allsd[i]) && pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  4351. if (sd->status.account_id != pl_sd->status.account_id)
  4352. clif_GM_kick(sd, pl_sd, 0);
  4353. }
  4354. }
  4355. clif_displaymessage(fd, msg_table[195]); // All players have been kicked!
  4356. return 0;
  4357. }
  4358. /*==========================================
  4359. *
  4360. *------------------------------------------
  4361. */
  4362. int atcommand_allskill(
  4363. const int fd, struct map_session_data* sd,
  4364. const char* command, const char* message)
  4365. {
  4366. nullpo_retr(-1, sd);
  4367. pc_allskillup(sd); // all skills
  4368. sd->status.skill_point = 0; // 0 skill points
  4369. clif_updatestatus(sd, SP_SKILLPOINT); // update
  4370. clif_displaymessage(fd, msg_table[76]); // You have received all skills.
  4371. return 0;
  4372. }
  4373. /*==========================================
  4374. *
  4375. *------------------------------------------
  4376. */
  4377. int atcommand_questskill(
  4378. const int fd, struct map_session_data* sd,
  4379. const char* command, const char* message)
  4380. {
  4381. int skill_id;
  4382. nullpo_retr(-1, sd);
  4383. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4384. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  4385. return -1;
  4386. }
  4387. if (skill_id >= 0 && skill_id < MAX_SKILL_DB) {
  4388. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4389. if (pc_checkskill(sd, skill_id) == 0) {
  4390. pc_skill(sd, skill_id, 1, 0);
  4391. clif_displaymessage(fd, msg_table[70]); // You have learned the skill.
  4392. } else {
  4393. clif_displaymessage(fd, msg_table[196]); // You already have this quest skill.
  4394. return -1;
  4395. }
  4396. } else {
  4397. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4398. return -1;
  4399. }
  4400. } else {
  4401. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4402. return -1;
  4403. }
  4404. return 0;
  4405. }
  4406. /*==========================================
  4407. *
  4408. *------------------------------------------
  4409. */
  4410. int atcommand_lostskill(
  4411. const int fd, struct map_session_data* sd,
  4412. const char* command, const char* message)
  4413. {
  4414. int skill_id;
  4415. nullpo_retr(-1, sd);
  4416. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  4417. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  4418. return -1;
  4419. }
  4420. if (skill_id >= 0 && skill_id < MAX_SKILL) {
  4421. if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) {
  4422. if (pc_checkskill(sd, skill_id) > 0) {
  4423. sd->status.skill[skill_id].lv = 0;
  4424. sd->status.skill[skill_id].flag = 0;
  4425. clif_skillinfoblock(sd);
  4426. clif_displaymessage(fd, msg_table[71]); // You have forgotten the skill.
  4427. } else {
  4428. clif_displaymessage(fd, msg_table[201]); // You don't have this quest skill.
  4429. return -1;
  4430. }
  4431. } else {
  4432. clif_displaymessage(fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill.
  4433. return -1;
  4434. }
  4435. } else {
  4436. clif_displaymessage(fd, msg_table[198]); // This skill number doesn't exist.
  4437. return -1;
  4438. }
  4439. return 0;
  4440. }
  4441. /*==========================================
  4442. *
  4443. *------------------------------------------
  4444. */
  4445. int atcommand_spiritball(
  4446. const int fd, struct map_session_data* sd,
  4447. const char* command, const char* message)
  4448. {
  4449. int number;
  4450. nullpo_retr(-1, sd);
  4451. if (!message || !*message || (number = atoi(message)) < 0) {
  4452. clif_displaymessage(fd, "Please, enter a spirit ball number (usage: @spiritball <number: 0-1000>).");
  4453. return -1;
  4454. }
  4455. // set max number to avoid server/client crash (500 create big balls of several balls: no visial difference with more)
  4456. if (number > 500)
  4457. number = 500;
  4458. if (number >= 0 && number <= 0x7FFF) {
  4459. if (sd->spiritball != number || number > 499) {
  4460. if (sd->spiritball > 0)
  4461. pc_delspiritball(sd, sd->spiritball, 1);
  4462. sd->spiritball = number;
  4463. clif_spiritball(sd);
  4464. // no message, player can look the difference
  4465. if (number > 1000)
  4466. clif_displaymessage(fd, msg_table[204]); // WARNING: more than 1000 spiritballs can CRASH your server and/or client!
  4467. } else {
  4468. clif_displaymessage(fd, msg_table[205]); // You already have this number of spiritballs.
  4469. return -1;
  4470. }
  4471. } else {
  4472. clif_displaymessage(fd, msg_table[37]); // An invalid number was specified.
  4473. return -1;
  4474. }
  4475. return 0;
  4476. }
  4477. /*==========================================
  4478. *
  4479. *------------------------------------------
  4480. */
  4481. int atcommand_party(
  4482. const int fd, struct map_session_data* sd,
  4483. const char* command, const char* message)
  4484. {
  4485. char party[NAME_LENGTH];
  4486. nullpo_retr(-1, sd);
  4487. memset(party, '\0', sizeof(party));
  4488. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  4489. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  4490. return -1;
  4491. }
  4492. party_create(sd, party, 0, 0);
  4493. return 0;
  4494. }
  4495. /*==========================================
  4496. *
  4497. *------------------------------------------
  4498. */
  4499. int atcommand_guild(
  4500. const int fd, struct map_session_data* sd,
  4501. const char* command, const char* message)
  4502. {
  4503. char guild[NAME_LENGTH];
  4504. int prev;
  4505. nullpo_retr(-1, sd);
  4506. memset(guild, '\0', sizeof(guild));
  4507. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  4508. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  4509. return -1;
  4510. }
  4511. prev = battle_config.guild_emperium_check;
  4512. battle_config.guild_emperium_check = 0;
  4513. guild_create(sd, guild);
  4514. battle_config.guild_emperium_check = prev;
  4515. return 0;
  4516. }
  4517. /*==========================================
  4518. *
  4519. *------------------------------------------
  4520. */
  4521. int atcommand_agitstart(
  4522. const int fd, struct map_session_data* sd,
  4523. const char* command, const char* message)
  4524. {
  4525. nullpo_retr(-1, sd);
  4526. if (agit_flag == 1) {
  4527. clif_displaymessage(fd, msg_table[73]); // Already it has started siege warfare.
  4528. return -1;
  4529. }
  4530. agit_flag = 1;
  4531. guild_agit_start();
  4532. clif_displaymessage(fd, msg_table[72]); // Guild siege warfare start!
  4533. return 0;
  4534. }
  4535. /*==========================================
  4536. *
  4537. *------------------------------------------
  4538. */
  4539. int atcommand_agitend(
  4540. const int fd, struct map_session_data* sd,
  4541. const char* command, const char* message)
  4542. {
  4543. nullpo_retr(-1, sd);
  4544. if (agit_flag == 0) {
  4545. clif_displaymessage(fd, msg_table[75]); // Siege warfare hasn't started yet.
  4546. return -1;
  4547. }
  4548. agit_flag = 0;
  4549. guild_agit_end();
  4550. clif_displaymessage(fd, msg_table[74]); // Guild siege warfare end!
  4551. return 0;
  4552. }
  4553. /*==========================================
  4554. * @mapexitでマップサーバーを終了させる
  4555. *------------------------------------------
  4556. */
  4557. int atcommand_mapexit(
  4558. const int fd, struct map_session_data* sd,
  4559. const char* command, const char* message)
  4560. {
  4561. struct map_session_data *pl_sd, **pl_allsd;
  4562. int i, users;
  4563. nullpo_retr(-1, sd);
  4564. pl_allsd = map_getallusers(&users);
  4565. for (i = 0; i < users; i++) {
  4566. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id)
  4567. clif_GM_kick(sd, pl_sd, 0);
  4568. }
  4569. clif_GM_kick(sd, sd, 0);
  4570. flush_fifos();
  4571. runflag = 0;
  4572. return 0;
  4573. }
  4574. /*==========================================
  4575. * idsearch <part_of_name>: revrited by [Yor]
  4576. *------------------------------------------
  4577. */
  4578. int atcommand_idsearch(
  4579. const int fd, struct map_session_data* sd,
  4580. const char* command, const char* message)
  4581. {
  4582. char item_name[100];
  4583. unsigned int i, match;
  4584. struct item_data *item_array[MAX_SEARCH];
  4585. nullpo_retr(-1, sd);
  4586. memset(item_name, '\0', sizeof(item_name));
  4587. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4588. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  4589. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  4590. return -1;
  4591. }
  4592. sprintf(atcmd_output, msg_table[77], item_name); // The reference result of '%s' (name: id):
  4593. clif_displaymessage(fd, atcmd_output);
  4594. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  4595. if (match > MAX_SEARCH) {
  4596. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, match);
  4597. clif_displaymessage(fd, atcmd_output);
  4598. match = MAX_SEARCH;
  4599. }
  4600. for(i = 0; i < match; i++) {
  4601. sprintf(atcmd_output, msg_table[78], item_array[i]->jname, item_array[i]->nameid); // %s: %d
  4602. clif_displaymessage(fd, atcmd_output);
  4603. }
  4604. sprintf(atcmd_output, msg_table[79], match); // It is %d affair above.
  4605. clif_displaymessage(fd, atcmd_output);
  4606. return 0;
  4607. }
  4608. /*==========================================
  4609. * Recall All Characters Online To Your Location
  4610. *------------------------------------------
  4611. */
  4612. int atcommand_recallall(
  4613. const int fd, struct map_session_data* sd,
  4614. const char* command, const char* message)
  4615. {
  4616. struct map_session_data *pl_sd, **pl_allsd;
  4617. int i;
  4618. int count, users;
  4619. nullpo_retr(-1, sd);
  4620. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4621. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4622. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4623. return -1;
  4624. }
  4625. count = 0;
  4626. pl_allsd = map_getallusers(&users);
  4627. for (i = 0; i < users; i++) {
  4628. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4629. pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  4630. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4631. count++;
  4632. else {
  4633. if (pc_isdead(pl_sd)) { //Wake them up
  4634. pc_setstand(pl_sd);
  4635. pc_setrestartvalue(pl_sd,1);
  4636. }
  4637. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4638. }
  4639. }
  4640. }
  4641. clif_displaymessage(fd, msg_table[92]); // All characters recalled!
  4642. if (count) {
  4643. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4644. clif_displaymessage(fd, atcmd_output);
  4645. }
  4646. return 0;
  4647. }
  4648. /*==========================================
  4649. * Recall online characters of a guild to your location
  4650. *------------------------------------------
  4651. */
  4652. int atcommand_guildrecall(
  4653. const int fd, struct map_session_data* sd,
  4654. const char* command, const char* message)
  4655. {
  4656. struct map_session_data *pl_sd, **pl_allsd;
  4657. int i, users, count;
  4658. char guild_name[NAME_LENGTH];
  4659. struct guild *g;
  4660. nullpo_retr(-1, sd);
  4661. memset(guild_name, '\0', sizeof(guild_name));
  4662. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4663. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4664. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  4665. return -1;
  4666. }
  4667. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4668. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4669. return -1;
  4670. }
  4671. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4672. (g = guild_search(atoi(message))) != NULL) {
  4673. count = 0;
  4674. pl_allsd = map_getallusers(&users);
  4675. for (i = 0; i < users; i++) {
  4676. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4677. pl_sd->status.guild_id == g->guild_id) {
  4678. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4679. continue; //Skip GMs greater than you.
  4680. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4681. count++;
  4682. else
  4683. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4684. }
  4685. }
  4686. sprintf(atcmd_output, msg_table[93], g->name); // All online characters of the %s guild are near you.
  4687. clif_displaymessage(fd, atcmd_output);
  4688. if (count) {
  4689. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4690. clif_displaymessage(fd, atcmd_output);
  4691. }
  4692. } else {
  4693. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  4694. return -1;
  4695. }
  4696. return 0;
  4697. }
  4698. /*==========================================
  4699. * Recall online characters of a party to your location
  4700. *------------------------------------------
  4701. */
  4702. int atcommand_partyrecall(
  4703. const int fd, struct map_session_data* sd,
  4704. const char* command, const char* message)
  4705. {
  4706. int i;
  4707. struct map_session_data *pl_sd, **pl_allsd;
  4708. char party_name[NAME_LENGTH];
  4709. struct party *p;
  4710. int count, users;
  4711. nullpo_retr(-1, sd);
  4712. memset(party_name, '\0', sizeof(party_name));
  4713. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4714. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4715. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  4716. return -1;
  4717. }
  4718. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  4719. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  4720. return -1;
  4721. }
  4722. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4723. (p = party_search(atoi(message))) != NULL) {
  4724. count = 0;
  4725. pl_allsd = map_getallusers(&users);
  4726. for (i = 0; i < users; i++) {
  4727. if ((pl_sd = pl_allsd[i]) && sd->status.account_id != pl_sd->status.account_id &&
  4728. pl_sd->status.party_id == p->party_id) {
  4729. if (pc_isGM(pl_sd) > pc_isGM(sd))
  4730. continue; //Skip GMs greater than you.
  4731. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  4732. count++;
  4733. else
  4734. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  4735. }
  4736. }
  4737. sprintf(atcmd_output, msg_table[95], p->name); // All online characters of the %s party are near you.
  4738. clif_displaymessage(fd, atcmd_output);
  4739. if (count) {
  4740. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  4741. clif_displaymessage(fd, atcmd_output);
  4742. }
  4743. } else {
  4744. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  4745. return -1;
  4746. }
  4747. return 0;
  4748. }
  4749. /*==========================================
  4750. *
  4751. *------------------------------------------
  4752. */
  4753. int atcommand_reloaditemdb(
  4754. const int fd, struct map_session_data* sd,
  4755. const char* command, const char* message)
  4756. {
  4757. nullpo_retr(-1, sd);
  4758. itemdb_reload();
  4759. clif_displaymessage(fd, msg_table[97]); // Item database reloaded.
  4760. return 0;
  4761. }
  4762. /*==========================================
  4763. *
  4764. *------------------------------------------
  4765. */
  4766. int atcommand_reloadmobdb(
  4767. const int fd, struct map_session_data* sd,
  4768. const char* command, const char* message)
  4769. {
  4770. nullpo_retr(-1, sd);
  4771. mob_reload();
  4772. do_final_pet();
  4773. read_petdb();
  4774. clif_displaymessage(fd, msg_table[98]); // Monster database reloaded.
  4775. return 0;
  4776. }
  4777. /*==========================================
  4778. *
  4779. *------------------------------------------
  4780. */
  4781. int atcommand_reloadskilldb(
  4782. const int fd, struct map_session_data* sd,
  4783. const char* command, const char* message)
  4784. {
  4785. nullpo_retr(-1, sd);
  4786. skill_reload();
  4787. clif_displaymessage(fd, msg_table[99]); // Skill database reloaded.
  4788. return 0;
  4789. }
  4790. /*==========================================
  4791. * @reloadatcommand
  4792. * atcommand_athena.conf のリロード
  4793. *------------------------------------------
  4794. */
  4795. int
  4796. atcommand_reloadatcommand(
  4797. const int fd, struct map_session_data* sd,
  4798. const char* command, const char* message)
  4799. {
  4800. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  4801. clif_displaymessage(fd, msg_table[254]);
  4802. return 0;
  4803. }
  4804. /*==========================================
  4805. * @reloadbattleconf
  4806. * battle_athena.conf のリロード
  4807. *------------------------------------------
  4808. */
  4809. int
  4810. atcommand_reloadbattleconf(
  4811. const int fd, struct map_session_data* sd,
  4812. const char* command, const char* message)
  4813. {
  4814. battle_config_read(BATTLE_CONF_FILENAME);
  4815. mob_reload(); //Needed as well so rate changes take effect.
  4816. clif_displaymessage(fd, msg_table[255]);
  4817. return 0;
  4818. }
  4819. /*==========================================
  4820. * @reloadstatusdb
  4821. * job_db1.txt job_db2.txt job_db2-2.txt
  4822. * refine_db.txt size_fix.txt
  4823. * のリロード
  4824. *------------------------------------------
  4825. */
  4826. int
  4827. atcommand_reloadstatusdb(
  4828. const int fd, struct map_session_data* sd,
  4829. const char* command, const char* message)
  4830. {
  4831. status_readdb();
  4832. clif_displaymessage(fd, msg_table[256]);
  4833. return 0;
  4834. }
  4835. /*==========================================
  4836. * @reloadpcdb
  4837. * exp.txt skill_tree.txt attr_fix.txt
  4838. * のリロード
  4839. *------------------------------------------
  4840. */
  4841. int
  4842. atcommand_reloadpcdb(
  4843. const int fd, struct map_session_data* sd,
  4844. const char* command, const char* message)
  4845. {
  4846. pc_readdb();
  4847. clif_displaymessage(fd, msg_table[257]);
  4848. return 0;
  4849. }
  4850. /*==========================================
  4851. * @reloadmotd [Valaris]
  4852. * Reloads motd.txt
  4853. *------------------------------------------
  4854. */
  4855. int
  4856. atcommand_reloadmotd(
  4857. const int fd, struct map_session_data* sd,
  4858. const char* command, const char* message)
  4859. {
  4860. pc_read_motd();
  4861. clif_displaymessage(fd, msg_table[268]);
  4862. return 0;
  4863. }
  4864. /*==========================================
  4865. *
  4866. *------------------------------------------
  4867. */
  4868. int atcommand_reloadscript(
  4869. const int fd, struct map_session_data* sd,
  4870. const char* command, const char* message)
  4871. {
  4872. nullpo_retr(-1, sd);
  4873. atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  4874. atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  4875. atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  4876. flush_fifos();
  4877. //do_init_npc();
  4878. script_reload();
  4879. npc_reload();
  4880. clif_displaymessage(fd, msg_table[100]); // Scripts reloaded.
  4881. return 0;
  4882. }
  4883. /*==========================================
  4884. *
  4885. *------------------------------------------
  4886. */
  4887. int atcommand_reloadgmdb( // by [Yor]
  4888. const int fd, struct map_session_data* sd,
  4889. const char* command, const char* message)
  4890. {
  4891. nullpo_retr(-1, sd);
  4892. chrif_reloadGMdb();
  4893. clif_displaymessage(fd, msg_table[101]); // Login-server asked to reload GM accounts and their level.
  4894. return 0;
  4895. }
  4896. /*==========================================
  4897. * @mapinfo <map name> [0-3] by MC_Cameri
  4898. * => Shows information about the map [map name]
  4899. * 0 = no additional information
  4900. * 1 = Show users in that map and their location
  4901. * 2 = Shows NPCs in that map
  4902. * 3 = Shows the shops/chats in that map (not implemented)
  4903. *------------------------------------------
  4904. */
  4905. int atcommand_mapinfo(
  4906. const int fd, struct map_session_data* sd,
  4907. const char* command, const char* message)
  4908. {
  4909. struct map_session_data *pl_sd, **pl_allsd;
  4910. struct npc_data *nd = NULL;
  4911. struct chat_data *cd = NULL;
  4912. char direction[12];
  4913. int m_id, i, chat_num, users, list = 0;
  4914. unsigned short m_index;
  4915. nullpo_retr(-1, sd);
  4916. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4917. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4918. memset(direction, '\0', sizeof(direction));
  4919. sscanf(message, "%d %23[^\n]", &list, atcmd_player_name);
  4920. if (list < 0 || list > 3) {
  4921. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4922. return -1;
  4923. }
  4924. if (atcmd_player_name[0] == '\0') {
  4925. memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  4926. atcmd_player_name[MAP_NAME_LENGTH] = '\0';
  4927. m_id = map_mapindex2mapid(sd->mapindex);
  4928. } else {
  4929. if (strstr(atcmd_player_name, ".gat") == NULL && strstr(atcmd_player_name, ".afm") == NULL && strlen(atcmd_player_name) < MAP_NAME_LENGTH-4) // 16 - 4 (.gat)
  4930. strcat(atcmd_player_name, ".gat");
  4931. m_id = map_mapname2mapid(atcmd_player_name);
  4932. }
  4933. if (m_id < 0) {
  4934. clif_displaymessage(fd, msg_table[1]); // Map not found.
  4935. return -1;
  4936. }
  4937. m_index = mapindex_name2id(atcmd_player_name); //This one shouldn't fail since the previous seek did not.
  4938. clif_displaymessage(fd, "------ Map Info ------");
  4939. chat_num = 0;
  4940. pl_allsd = map_getallusers(&users);
  4941. for (i = 0; i < users; i++) {
  4942. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID))) {
  4943. chat_num++;
  4944. }
  4945. }
  4946. 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);
  4947. clif_displaymessage(fd, atcmd_output);
  4948. if (map[m_id].flag.alias)
  4949. strcat(atcmd_output, "This map is an alias (a named clone of some other map).");
  4950. clif_displaymessage(fd, "------ Map Flags ------");
  4951. strcpy(atcmd_output,"PvP Flags: ");
  4952. if (map[m_id].flag.pvp)
  4953. strcat(atcmd_output, "Pvp ON | ");
  4954. if (map[m_id].flag.pvp_noguild)
  4955. strcat(atcmd_output, "NoGuild | ");
  4956. if (map[m_id].flag.pvp_noparty)
  4957. strcat(atcmd_output, "NoParty | ");
  4958. if (map[m_id].flag.pvp_nightmaredrop)
  4959. strcat(atcmd_output, "NightmareDrop | ");
  4960. if (map[m_id].flag.pvp_nocalcrank)
  4961. strcat(atcmd_output, "NoCalcRank | ");
  4962. clif_displaymessage(fd, atcmd_output);
  4963. strcpy(atcmd_output,"GvG Flags: ");
  4964. if (map[m_id].flag.gvg)
  4965. strcat(atcmd_output, "GvG ON | ");
  4966. if (map[m_id].flag.gvg_dungeon)
  4967. strcat(atcmd_output, "GvG Dungeon | ");
  4968. if (map[m_id].flag.gvg_castle)
  4969. strcat(atcmd_output, "GvG Castle | ");
  4970. if (map[m_id].flag.gvg_noparty)
  4971. strcat(atcmd_output, "NoParty | ");
  4972. clif_displaymessage(fd, atcmd_output);
  4973. strcpy(atcmd_output,"Teleport Flags: ");
  4974. if (map[m_id].flag.noteleport)
  4975. strcat(atcmd_output, "NoTeleport | ");
  4976. if (map[m_id].flag.monster_noteleport)
  4977. strcat(atcmd_output, "Monster NoTeleport | ");
  4978. if (map[m_id].flag.nowarp)
  4979. strcat(atcmd_output, "NoWarp | ");
  4980. if (map[m_id].flag.nowarpto)
  4981. strcat(atcmd_output, "NoWarpTo | ");
  4982. if (map[m_id].flag.noreturn)
  4983. strcat(atcmd_output, "NoReturn | ");
  4984. if (map[m_id].flag.nogo)
  4985. strcat(atcmd_output, "NoGo | ");
  4986. if (map[m_id].flag.nomemo)
  4987. strcat(atcmd_output, "NoMemo | ");
  4988. clif_displaymessage(fd, atcmd_output);
  4989. sprintf(atcmd_output, "No Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.nopenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  4990. clif_displaymessage(fd, atcmd_output);
  4991. if (map[m_id].flag.nosave) {
  4992. if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  4993. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  4994. else
  4995. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  4996. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  4997. clif_displaymessage(fd, atcmd_output);
  4998. }
  4999. strcpy(atcmd_output,"Weather Flags: ");
  5000. if (map[m_id].flag.snow)
  5001. strcat(atcmd_output, "Snow | ");
  5002. if (map[m_id].flag.fog)
  5003. strcat(atcmd_output, "Fog | ");
  5004. if (map[m_id].flag.sakura)
  5005. strcat(atcmd_output, "Sakura | ");
  5006. if (map[m_id].flag.clouds)
  5007. strcat(atcmd_output, "Clouds | ");
  5008. if (map[m_id].flag.clouds2)
  5009. strcat(atcmd_output, "Clouds2 | ");
  5010. if (map[m_id].flag.fireworks)
  5011. strcat(atcmd_output, "Fireworks | ");
  5012. if (map[m_id].flag.leaves)
  5013. strcat(atcmd_output, "Leaves | ");
  5014. if (map[m_id].flag.rain)
  5015. strcat(atcmd_output, "Rain | ");
  5016. if (map[m_id].flag.indoors)
  5017. strcat(atcmd_output, "Indoors | ");
  5018. if (map[m_id].flag.nightenabled)
  5019. strcat(atcmd_output, "Displays Night | ");
  5020. clif_displaymessage(fd, atcmd_output);
  5021. strcpy(atcmd_output,"Other Flags: ");
  5022. if (map[m_id].flag.nobranch)
  5023. strcat(atcmd_output, "NoBranch | ");
  5024. if (map[m_id].flag.notrade)
  5025. strcat(atcmd_output, "NoTrade | ");
  5026. if (map[m_id].flag.nodrop)
  5027. strcat(atcmd_output, "NoDrop | ");
  5028. if (map[m_id].flag.noskill)
  5029. strcat(atcmd_output, "NoSkill | ");
  5030. if (map[m_id].flag.noicewall)
  5031. strcat(atcmd_output, "NoIcewall | ");
  5032. if (map[m_id].flag.nocommand)
  5033. strcat(atcmd_output, "NoCommand | ");
  5034. clif_displaymessage(fd, atcmd_output);
  5035. strcpy(atcmd_output,"Other Flags: ");
  5036. if (map[m_id].flag.nobaseexp)
  5037. strcat(atcmd_output, "NoBaseEXP | ");
  5038. if (map[m_id].flag.nojobexp)
  5039. strcat(atcmd_output, "NoJobEXP | ");
  5040. if (map[m_id].flag.nomobloot)
  5041. strcat(atcmd_output, "NoMobLoot | ");
  5042. if (map[m_id].flag.nomvploot)
  5043. strcat(atcmd_output, "NoMVPLoot | ");
  5044. clif_displaymessage(fd, atcmd_output);
  5045. switch (list) {
  5046. case 0:
  5047. // Do nothing. It's list 0, no additional display.
  5048. break;
  5049. case 1:
  5050. clif_displaymessage(fd, "----- Players in Map -----");
  5051. for (i = 0; i < users; i++) {
  5052. if ((pl_sd = pl_allsd[i]) && pl_sd->mapindex == m_index) {
  5053. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  5054. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  5055. clif_displaymessage(fd, atcmd_output);
  5056. }
  5057. }
  5058. break;
  5059. case 2:
  5060. clif_displaymessage(fd, "----- NPCs in Map -----");
  5061. for (i = 0; i < map[m_id].npc_num;) {
  5062. nd = map[m_id].npc[i];
  5063. switch(nd->ud.dir) {
  5064. case 0: strcpy(direction, "North"); break;
  5065. case 1: strcpy(direction, "North West"); break;
  5066. case 2: strcpy(direction, "West"); break;
  5067. case 3: strcpy(direction, "South West"); break;
  5068. case 4: strcpy(direction, "South"); break;
  5069. case 5: strcpy(direction, "South East"); break;
  5070. case 6: strcpy(direction, "East"); break;
  5071. case 7: strcpy(direction, "North East"); break;
  5072. case 9: strcpy(direction, "North"); break;
  5073. default: strcpy(direction, "Unknown"); break;
  5074. }
  5075. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  5076. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  5077. clif_displaymessage(fd, atcmd_output);
  5078. }
  5079. break;
  5080. case 3:
  5081. clif_displaymessage(fd, "----- Chats in Map -----");
  5082. for (i = 0; i < users; i++) {
  5083. if ((pl_sd = pl_allsd[i]) && (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) &&
  5084. pl_sd->mapindex == m_index &&
  5085. cd->usersd[0] == pl_sd) {
  5086. sprintf(atcmd_output, "Chat %d: %s | Player: %s | Location: %d %d",
  5087. i, cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  5088. clif_displaymessage(fd, atcmd_output);
  5089. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  5090. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  5091. clif_displaymessage(fd, atcmd_output);
  5092. }
  5093. }
  5094. break;
  5095. default: // normally impossible to arrive here
  5096. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  5097. return -1;
  5098. break;
  5099. }
  5100. return 0;
  5101. }
  5102. /*==========================================
  5103. *
  5104. *------------------------------------------
  5105. */
  5106. int atcommand_mount_peco(
  5107. const int fd, struct map_session_data* sd,
  5108. const char* command, const char* message)
  5109. {
  5110. nullpo_retr(-1, sd);
  5111. if (!pc_isriding(sd)) { // if actually no peco
  5112. if (pc_checkskill(sd, KN_RIDING)) {
  5113. pc_setoption(sd, sd->sc.option | 0x0020);
  5114. clif_displaymessage(fd, msg_table[102]); // Mounted Peco.
  5115. } else {
  5116. clif_displaymessage(fd, msg_table[213]); // You can not mount a peco with your job.
  5117. return -1;
  5118. }
  5119. } else { //Dismount
  5120. pc_setoption(sd, sd->sc.option & ~0x0020);
  5121. clif_displaymessage(fd, msg_table[214]); // Unmounted Peco.
  5122. }
  5123. return 0;
  5124. }
  5125. /*==========================================
  5126. *
  5127. *------------------------------------------
  5128. */
  5129. int atcommand_char_mount_peco(
  5130. const int fd, struct map_session_data* sd,
  5131. const char* command, const char* message)
  5132. {
  5133. struct map_session_data *pl_sd;
  5134. nullpo_retr(-1, sd);
  5135. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5136. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5137. clif_displaymessage(fd, "Please, enter a player name (usage: @charmountpeco <char_name>).");
  5138. return -1;
  5139. }
  5140. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5141. if (!pc_isriding(pl_sd)) { // if actually no peco
  5142. if (pc_checkskill(pl_sd, KN_RIDING)) {
  5143. pc_setoption(pl_sd, pl_sd->sc.option | 0x0020);
  5144. clif_displaymessage(fd, msg_table[216]); // Mounted Peco.
  5145. } else {
  5146. clif_displaymessage(fd, msg_table[217]); // You can not mount a peco with your job.
  5147. return -1;
  5148. }
  5149. } else { //Dismount
  5150. pc_setoption(pl_sd, pl_sd->sc.option & ~0x0020);
  5151. clif_displaymessage(fd, msg_table[218]); // Unmounted Peco.
  5152. }
  5153. } else {
  5154. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5155. return -1;
  5156. }
  5157. return 0;
  5158. }
  5159. /*==========================================
  5160. *Spy Commands by Syrus22
  5161. *------------------------------------------
  5162. */
  5163. int atcommand_guildspy(
  5164. const int fd, struct map_session_data* sd,
  5165. const char* command, const char* message)
  5166. {
  5167. char guild_name[NAME_LENGTH];
  5168. struct guild *g;
  5169. nullpo_retr(-1, sd);
  5170. memset(guild_name, '\0', sizeof(guild_name));
  5171. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5172. if (!enable_spy)
  5173. {
  5174. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5175. return -1;
  5176. }
  5177. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  5178. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  5179. return -1;
  5180. }
  5181. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  5182. (g = guild_search(atoi(message))) != NULL) {
  5183. if (sd->guildspy == g->guild_id) {
  5184. sd->guildspy = 0;
  5185. sprintf(atcmd_output, msg_table[103], g->name); // No longer spying on the %s guild.
  5186. clif_displaymessage(fd, atcmd_output);
  5187. } else {
  5188. sd->guildspy = g->guild_id;
  5189. sprintf(atcmd_output, msg_table[104], g->name); // Spying on the %s guild.
  5190. clif_displaymessage(fd, atcmd_output);
  5191. }
  5192. } else {
  5193. clif_displaymessage(fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online.
  5194. return -1;
  5195. }
  5196. return 0;
  5197. }
  5198. /*==========================================
  5199. *
  5200. *------------------------------------------
  5201. */
  5202. int atcommand_partyspy(
  5203. const int fd, struct map_session_data* sd,
  5204. const char* command, const char* message)
  5205. {
  5206. char party_name[NAME_LENGTH];
  5207. struct party *p;
  5208. nullpo_retr(-1, sd);
  5209. memset(party_name, '\0', sizeof(party_name));
  5210. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5211. if (!enable_spy)
  5212. {
  5213. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  5214. return -1;
  5215. }
  5216. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  5217. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  5218. return -1;
  5219. }
  5220. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  5221. (p = party_search(atoi(message))) != NULL) {
  5222. if (sd->partyspy == p->party_id) {
  5223. sd->partyspy = 0;
  5224. sprintf(atcmd_output, msg_table[105], p->name); // No longer spying on the %s party.
  5225. clif_displaymessage(fd, atcmd_output);
  5226. } else {
  5227. sd->partyspy = p->party_id;
  5228. sprintf(atcmd_output, msg_table[106], p->name); // Spying on the %s party.
  5229. clif_displaymessage(fd, atcmd_output);
  5230. }
  5231. } else {
  5232. clif_displaymessage(fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online.
  5233. return -1;
  5234. }
  5235. return 0;
  5236. }
  5237. /*==========================================
  5238. * @repairall [Valaris]
  5239. *------------------------------------------
  5240. */
  5241. int atcommand_repairall(
  5242. const int fd, struct map_session_data* sd,
  5243. const char* command, const char* message)
  5244. {
  5245. int count, i;
  5246. nullpo_retr(-1, sd);
  5247. count = 0;
  5248. for (i = 0; i < MAX_INVENTORY; i++) {
  5249. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  5250. sd->status.inventory[i].attribute = 0;
  5251. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  5252. count++;
  5253. }
  5254. }
  5255. if (count > 0) {
  5256. clif_misceffect(&sd->bl, 3);
  5257. clif_equiplist(sd);
  5258. clif_displaymessage(fd, msg_table[107]); // All items have been repaired.
  5259. } else {
  5260. clif_displaymessage(fd, msg_table[108]); // No item need to be repaired.
  5261. return -1;
  5262. }
  5263. return 0;
  5264. }
  5265. // Removed @nuke for now in favor of alchemist marine sphere skill [Valaris]
  5266. int atcommand_nuke(
  5267. const int fd, struct map_session_data* sd,
  5268. const char* command, const char* message)
  5269. {
  5270. struct map_session_data *pl_sd;
  5271. nullpo_retr(-1, sd);
  5272. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5273. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5274. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  5275. return -1;
  5276. }
  5277. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5278. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  5279. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  5280. clif_displaymessage(fd, msg_table[109]); // Player has been nuked!
  5281. } else {
  5282. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5283. return -1;
  5284. }
  5285. } else {
  5286. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5287. return -1;
  5288. }
  5289. return 0;
  5290. }
  5291. /*==========================================
  5292. * @tonpc
  5293. *------------------------------------------
  5294. */
  5295. int atcommand_tonpc(const int fd, struct map_session_data* sd,
  5296. const char* command, const char* message)
  5297. {
  5298. char npcname[NAME_LENGTH];
  5299. struct npc_data *nd;
  5300. nullpo_retr(-1, sd);
  5301. memset(npcname, 0, sizeof(npcname));
  5302. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  5303. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  5304. return -1;
  5305. }
  5306. if ((nd = npc_name2id(npcname)) != NULL) {
  5307. if (pc_setpos(sd, map[nd->bl.m].index, nd->bl.x, nd->bl.y, 3) == 0)
  5308. clif_displaymessage(fd, msg_table[0]); // Warped.
  5309. else
  5310. return -1;
  5311. } else {
  5312. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5313. return -1;
  5314. }
  5315. return 0;
  5316. }
  5317. /*==========================================
  5318. *
  5319. *------------------------------------------
  5320. */
  5321. int atcommand_shownpc(const int fd, struct map_session_data* sd,
  5322. const char* command, const char* message)
  5323. {
  5324. char NPCname[NAME_LENGTH];
  5325. nullpo_retr(-1, sd);
  5326. memset(NPCname, '\0', sizeof(NPCname));
  5327. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5328. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  5329. return -1;
  5330. }
  5331. if (npc_name2id(NPCname) != NULL) {
  5332. npc_enable(NPCname, 1);
  5333. clif_displaymessage(fd, msg_table[110]); // Npc Enabled.
  5334. } else {
  5335. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5336. return -1;
  5337. }
  5338. return 0;
  5339. }
  5340. /*==========================================
  5341. *
  5342. *------------------------------------------
  5343. */
  5344. int atcommand_hidenpc(const int fd, struct map_session_data* sd,
  5345. const char* command, const char* message)
  5346. {
  5347. char NPCname[NAME_LENGTH];
  5348. nullpo_retr(-1, sd);
  5349. memset(NPCname, '\0', sizeof(NPCname));
  5350. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5351. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5352. return -1;
  5353. }
  5354. if (npc_name2id(NPCname) != NULL) {
  5355. npc_enable(NPCname, 0);
  5356. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5357. } else {
  5358. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5359. return -1;
  5360. }
  5361. return 0;
  5362. }
  5363. int atcommand_loadnpc(const int fd, struct map_session_data* sd,
  5364. const char* command, const char* message)
  5365. {
  5366. FILE *fp;
  5367. if (!message || !*message) {
  5368. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  5369. return -1;
  5370. }
  5371. // check if script file exists
  5372. if ((fp = fopen(message, "r")) == NULL) {
  5373. clif_displaymessage(fd, msg_table[261]);
  5374. return -1;
  5375. }
  5376. fclose(fp);
  5377. // add to list of script sources and run it
  5378. npc_addsrcfile((char *)message);
  5379. npc_parsesrcfile((char *)message);
  5380. clif_displaymessage(fd, msg_table[262]);
  5381. return 0;
  5382. }
  5383. int atcommand_unloadnpc(const int fd, struct map_session_data* sd,
  5384. const char* command, const char* message)
  5385. {
  5386. struct npc_data *nd;
  5387. char NPCname[NAME_LENGTH];
  5388. nullpo_retr(-1, sd);
  5389. memset(NPCname, '\0', sizeof(NPCname));
  5390. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  5391. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  5392. return -1;
  5393. }
  5394. if ((nd = npc_name2id(NPCname)) != NULL) {
  5395. npc_unload(nd);
  5396. clif_displaymessage(fd, msg_table[112]); // Npc Disabled.
  5397. } else {
  5398. clif_displaymessage(fd, msg_table[111]); // This NPC doesn't exist.
  5399. return -1;
  5400. }
  5401. return 0;
  5402. }
  5403. /*==========================================
  5404. * time in txt for time command (by [Yor])
  5405. *------------------------------------------
  5406. */
  5407. char * txt_time(unsigned int duration) {
  5408. int days, hours, minutes, seconds;
  5409. char temp[256];
  5410. static char temp1[256];
  5411. memset(temp, '\0', sizeof(temp));
  5412. memset(temp1, '\0', sizeof(temp1));
  5413. if (duration < 0)
  5414. duration = 0;
  5415. days = duration / (60 * 60 * 24);
  5416. duration = duration - (60 * 60 * 24 * days);
  5417. hours = duration / (60 * 60);
  5418. duration = duration - (60 * 60 * hours);
  5419. minutes = duration / 60;
  5420. seconds = duration - (60 * minutes);
  5421. if (days < 2)
  5422. sprintf(temp, msg_table[219], days); // %d day
  5423. else
  5424. sprintf(temp, msg_table[220], days); // %d days
  5425. if (hours < 2)
  5426. sprintf(temp1, msg_table[221], temp, hours); // %s %d hour
  5427. else
  5428. sprintf(temp1, msg_table[222], temp, hours); // %s %d hours
  5429. if (minutes < 2)
  5430. sprintf(temp, msg_table[223], temp1, minutes); // %s %d minute
  5431. else
  5432. sprintf(temp, msg_table[224], temp1, minutes); // %s %d minutes
  5433. if (seconds < 2)
  5434. sprintf(temp1, msg_table[225], temp, seconds); // %s and %d second
  5435. else
  5436. sprintf(temp1, msg_table[226], temp, seconds); // %s and %d seconds
  5437. return temp1;
  5438. }
  5439. /*==========================================
  5440. * @time/@date/@server_date/@serverdate/@server_time/@servertime: Display the date/time of the server (by [Yor]
  5441. * Calculation management of GM modification (@day/@night GM commands) is done
  5442. *------------------------------------------
  5443. */
  5444. int atcommand_servertime(const int fd, struct map_session_data* sd,
  5445. const char* command, const char* message)
  5446. {
  5447. struct TimerData * timer_data;
  5448. struct TimerData * timer_data2;
  5449. time_t time_server; // variable for number of seconds (used with time() function)
  5450. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  5451. char temp[256];
  5452. nullpo_retr(-1, sd);
  5453. memset(temp, '\0', sizeof(temp));
  5454. time(&time_server); // get time in seconds since 1/1/1970
  5455. datetime = localtime(&time_server); // convert seconds in structure
  5456. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  5457. strftime(temp, sizeof(temp)-1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X.
  5458. clif_displaymessage(fd, temp);
  5459. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  5460. if (night_flag == 0)
  5461. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5462. else
  5463. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5464. } else if (battle_config.night_duration == 0)
  5465. if (night_flag == 1) { // we start with night
  5466. timer_data = get_timer(day_timer_tid);
  5467. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  5468. clif_displaymessage(fd, temp);
  5469. clif_displaymessage(fd, msg_table[234]); // Game time: After, the game will be in permanent daylight.
  5470. } else
  5471. clif_displaymessage(fd, msg_table[231]); // Game time: The game is in permanent daylight.
  5472. else if (battle_config.day_duration == 0)
  5473. if (night_flag == 0) { // we start with day
  5474. timer_data = get_timer(night_timer_tid);
  5475. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5476. clif_displaymessage(fd, temp);
  5477. clif_displaymessage(fd, msg_table[236]); // Game time: After, the game will be in permanent night.
  5478. } else
  5479. clif_displaymessage(fd, msg_table[232]); // Game time: The game is in permanent night.
  5480. else {
  5481. if (night_flag == 0) {
  5482. timer_data = get_timer(night_timer_tid);
  5483. timer_data2 = get_timer(day_timer_tid);
  5484. sprintf(temp, msg_table[235], txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  5485. clif_displaymessage(fd, temp);
  5486. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  5487. 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.
  5488. else
  5489. 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.
  5490. clif_displaymessage(fd, temp);
  5491. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5492. clif_displaymessage(fd, temp);
  5493. } else {
  5494. timer_data = get_timer(day_timer_tid);
  5495. timer_data2 = get_timer(night_timer_tid);
  5496. sprintf(temp, msg_table[233], txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  5497. clif_displaymessage(fd, temp);
  5498. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  5499. 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.
  5500. else
  5501. 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.
  5502. clif_displaymessage(fd, temp);
  5503. sprintf(temp, msg_table[238], txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  5504. clif_displaymessage(fd, temp);
  5505. }
  5506. }
  5507. return 0;
  5508. }
  5509. /*==========================================
  5510. * @chardelitem <item_name_or_ID> <quantity> <player> (by [Yor]
  5511. * removes <quantity> item from a character
  5512. * item can be equiped or not.
  5513. * Inspired from a old command created by RoVeRT
  5514. *------------------------------------------
  5515. */
  5516. int atcommand_chardelitem(const int fd, struct map_session_data* sd,
  5517. const char* command, const char* message)
  5518. {
  5519. struct map_session_data *pl_sd;
  5520. char item_name[100];
  5521. int i, number = 0, item_id, item_position, count;
  5522. struct item_data *item_data;
  5523. nullpo_retr(-1, sd);
  5524. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5525. memset(item_name, '\0', sizeof(item_name));
  5526. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5527. if (!message || !*message || sscanf(message, "%s %d %99[^\n]", item_name, &number, atcmd_player_name) < 3 || number < 1) {
  5528. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: @chardelitem <item_name_or_ID> <quantity> <player>).");
  5529. return -1;
  5530. }
  5531. item_id = 0;
  5532. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  5533. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  5534. item_id = item_data->nameid;
  5535. if (item_id > 500) {
  5536. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5537. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  5538. item_position = pc_search_inventory(pl_sd, item_id);
  5539. if (item_position >= 0) {
  5540. count = 0;
  5541. for(i = 0; i < number && item_position >= 0; i++) {
  5542. //Logs (A)dmins items [Lupus]
  5543. if(log_config.pick > 0 ) {
  5544. log_pick(pl_sd, "A", 0, pl_sd->status.inventory[item_position].nameid, -1, &pl_sd->status.inventory[item_position]);
  5545. }
  5546. //Logs
  5547. pc_delitem(pl_sd, item_position, 1, 0);
  5548. count++;
  5549. item_position = pc_search_inventory(pl_sd, item_id); // for next loop
  5550. }
  5551. sprintf(atcmd_output, msg_table[113], count); // %d item(s) removed by a GM.
  5552. clif_displaymessage(pl_sd->fd, atcmd_output);
  5553. if (number == count)
  5554. sprintf(atcmd_output, msg_table[114], count); // %d item(s) removed from the player.
  5555. else
  5556. sprintf(atcmd_output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items.
  5557. clif_displaymessage(fd, atcmd_output);
  5558. } else {
  5559. clif_displaymessage(fd, msg_table[116]); // Character does not have the item.
  5560. return -1;
  5561. }
  5562. } else {
  5563. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5564. return -1;
  5565. }
  5566. } else {
  5567. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5568. return -1;
  5569. }
  5570. } else {
  5571. clif_displaymessage(fd, msg_table[19]); // Invalid item ID or name.
  5572. return -1;
  5573. }
  5574. return 0;
  5575. }
  5576. /*==========================================
  5577. * @jail <char_name> by [Yor]
  5578. * Special warp! No check with nowarp and nowarpto flag
  5579. *------------------------------------------
  5580. */
  5581. int atcommand_jail(
  5582. const int fd, struct map_session_data* sd,
  5583. const char* command, const char* message)
  5584. {
  5585. struct map_session_data *pl_sd;
  5586. int x, y;
  5587. unsigned short m_index;
  5588. nullpo_retr(-1, sd);
  5589. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5590. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5591. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  5592. return -1;
  5593. }
  5594. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5595. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5596. switch(rand() % 2) {
  5597. case 0:
  5598. x = 24;
  5599. y = 75;
  5600. break;
  5601. default:
  5602. x = 49;
  5603. y = 75;
  5604. break;
  5605. }
  5606. m_index = mapindex_name2id(MAP_JAIL);
  5607. if (pc_setpos(pl_sd, m_index, x, y, 3) == 0) {
  5608. pc_setsavepoint(pl_sd, m_index, x, y); // Save Char Respawn Point in the jail room [Lupus]
  5609. clif_displaymessage(pl_sd->fd, msg_table[117]); // GM has send you in jails.
  5610. clif_displaymessage(fd, msg_table[118]); // Player warped in jails.
  5611. } else {
  5612. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5613. return -1;
  5614. }
  5615. } else {
  5616. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5617. return -1;
  5618. }
  5619. } else {
  5620. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5621. return -1;
  5622. }
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @unjail/@discharge <char_name> by [Yor]
  5627. * Special warp! No check with nowarp and nowarpto flag
  5628. *------------------------------------------
  5629. */
  5630. int atcommand_unjail(
  5631. const int fd, struct map_session_data* sd,
  5632. const char* command, const char* message)
  5633. {
  5634. struct map_session_data *pl_sd;
  5635. unsigned short m_index;
  5636. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5637. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5638. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  5639. return -1;
  5640. }
  5641. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5642. m_index = mapindex_name2id(MAP_PRONTERA);
  5643. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can jail only lower or same GM
  5644. if (pl_sd->bl.m != map_mapname2mapid(MAP_JAIL)) {
  5645. clif_displaymessage(fd, msg_table[119]); // This player is not in jails.
  5646. return -1;
  5647. } else if (pc_setpos(pl_sd, m_index, 0, 0, 3) == 0) { //old coords: 156,191
  5648. pc_setsavepoint(pl_sd, m_index, 0, 0); // Save char respawn point in Prontera
  5649. clif_displaymessage(pl_sd->fd, msg_table[120]); // GM has discharge you.
  5650. clif_displaymessage(fd, msg_table[121]); // Player warped to Prontera.
  5651. } else {
  5652. clif_displaymessage(fd, msg_table[1]); // Map not found.
  5653. return -1;
  5654. }
  5655. } else {
  5656. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5657. return -1;
  5658. }
  5659. } else {
  5660. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5661. return -1;
  5662. }
  5663. return 0;
  5664. }
  5665. /*==========================================
  5666. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  5667. *------------------------------------------
  5668. */
  5669. int atcommand_disguise(
  5670. const int fd, struct map_session_data* sd,
  5671. const char* command, const char* message)
  5672. {
  5673. int id = 0;
  5674. nullpo_retr(-1, sd);
  5675. if (!message || !*message) {
  5676. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  5677. return -1;
  5678. }
  5679. if ((id = atoi(message)) > 0)
  5680. { //Acquired an ID
  5681. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  5682. id = 0; //Invalid id for either mobs or npcs.
  5683. } else { //Acquired a Name
  5684. if ((id = mobdb_searchname(message)) == 0)
  5685. {
  5686. struct npc_data* nd = npc_name2id(message);
  5687. if (nd != NULL)
  5688. id = nd->n;
  5689. }
  5690. }
  5691. if (id == 0)
  5692. { // Monster/NPC name/id hasn't been found.
  5693. clif_displaymessage(fd, msg_table[123]);
  5694. return -1;
  5695. }
  5696. pc_disguise(sd, id);
  5697. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5698. return 0;
  5699. }
  5700. /*==========================================
  5701. * DisguiseAll
  5702. *------------------------------------------
  5703. */
  5704. int atcommand_disguiseall(
  5705. const int fd, struct map_session_data* sd,
  5706. const char* command, const char* message)
  5707. {
  5708. int mob_id=0, i=0, users;
  5709. struct map_session_data *pl_sd, **pl_allsd;
  5710. nullpo_retr(-1, sd);
  5711. if (!message || !*message) {
  5712. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster_name_or_monster_ID>).");
  5713. return -1;
  5714. }
  5715. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  5716. mob_id = atoi(message);
  5717. if (mobdb_checkid(mob_id) || npcdb_checkid(mob_id)) { //if mob or npc...
  5718. pl_allsd = map_getallusers(&users);
  5719. for(i=0; i < users; i++) {
  5720. if((pl_sd = pl_allsd[i]))
  5721. pc_disguise(pl_sd, mob_id);
  5722. }
  5723. clif_displaymessage(fd, msg_table[122]); // Disguise applied.
  5724. } else {
  5725. return -1;
  5726. }
  5727. return 0;
  5728. }
  5729. /*==========================================
  5730. * @undisguise by [Yor]
  5731. *------------------------------------------
  5732. */
  5733. int atcommand_undisguise(
  5734. const int fd, struct map_session_data* sd,
  5735. const char* command, const char* message)
  5736. {
  5737. nullpo_retr(-1, sd);
  5738. if (sd->disguise) {
  5739. pc_disguise(sd, 0);
  5740. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5741. } else {
  5742. clif_displaymessage(fd, msg_table[125]); // You're not disguised.
  5743. return -1;
  5744. }
  5745. return 0;
  5746. }
  5747. /*==========================================
  5748. * UndisguiseAll
  5749. *------------------------------------------
  5750. */
  5751. int atcommand_undisguiseall(
  5752. const int fd, struct map_session_data* sd,
  5753. const char* command, const char* message)
  5754. {
  5755. struct map_session_data *pl_sd, **pl_allsd;
  5756. int i, users;
  5757. nullpo_retr(-1, sd);
  5758. pl_allsd = map_getallusers(&users);
  5759. for(i=0; i < users; i++) {
  5760. if((pl_sd = pl_allsd[i]) && pl_sd->disguise)
  5761. pc_disguise(pl_sd, 0);
  5762. }
  5763. clif_displaymessage(fd, msg_table[124]); // Undisguise applied.
  5764. return 0;
  5765. }
  5766. /*==========================================
  5767. * @exp by [Skotlex]
  5768. *------------------------------------------
  5769. */
  5770. int atcommand_exp(
  5771. const int fd, struct map_session_data* sd,
  5772. const char* command, const char* message)
  5773. {
  5774. char output[200];
  5775. double nextb, nextj;
  5776. nullpo_retr(-1, sd);
  5777. memset(output, '\0', sizeof(output));
  5778. nextb = pc_nextbaseexp(sd);
  5779. if (nextb)
  5780. nextb = sd->status.base_exp*100.0/nextb;
  5781. nextj = pc_nextjobexp(sd);
  5782. if (nextj)
  5783. nextj = sd->status.job_exp*100.0/nextj;
  5784. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  5785. clif_displaymessage(fd, output);
  5786. return 0;
  5787. }
  5788. /*==========================================
  5789. * @broadcast by [Valaris]
  5790. *------------------------------------------
  5791. */
  5792. int atcommand_broadcast(
  5793. const int fd, struct map_session_data* sd,
  5794. const char* command, const char* message)
  5795. {
  5796. nullpo_retr(-1, sd);
  5797. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5798. if (!message || !*message) {
  5799. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  5800. return -1;
  5801. }
  5802. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5803. intif_GMmessage(atcmd_output, strlen(atcmd_output) + 1, 0);
  5804. return 0;
  5805. }
  5806. /*==========================================
  5807. * @localbroadcast by [Valaris]
  5808. *------------------------------------------
  5809. */
  5810. int atcommand_localbroadcast(
  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: @localbroadcast <message>).");
  5818. return -1;
  5819. }
  5820. sprintf(atcmd_output, "%s : %s", sd->status.name, message);
  5821. clif_GMmessage(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 1); // 1: ALL_SAMEMAP
  5822. return 0;
  5823. }
  5824. /*==========================================
  5825. * @chardisguise <mob_id> <character> by Kalaspuff (based off Valaris' and Yor's work)
  5826. *------------------------------------------
  5827. */
  5828. int atcommand_chardisguise(
  5829. const int fd, struct map_session_data* sd,
  5830. const char* command, const char* message)
  5831. {
  5832. int mob_id;
  5833. char mob_name[NAME_LENGTH];
  5834. struct map_session_data* pl_sd;
  5835. nullpo_retr(-1, sd);
  5836. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5837. memset(mob_name, '\0', sizeof(mob_name));
  5838. if (!message || !*message || sscanf(message, "%s %23[^\n]", mob_name, atcmd_player_name) < 2) {
  5839. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id and a player name (usage: @chardisguise <monster_name_or_monster_ID> <char name>).");
  5840. return -1;
  5841. }
  5842. if ((mob_id = atoi(mob_name)) > 0)
  5843. { //Acquired an ID
  5844. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id))
  5845. mob_id = 0; //Invalid id for either mobs or npcs.
  5846. } else { //Acquired a Name
  5847. if ((mob_id = mobdb_searchname(mob_name)) == 0)
  5848. {
  5849. struct npc_data* nd = npc_name2id(mob_name);
  5850. if (nd != NULL)
  5851. mob_id = nd->n;
  5852. }
  5853. }
  5854. if (mob_id == 0)
  5855. {
  5856. clif_displaymessage(fd, msg_table[123]); // Monster/NPC name/id hasn't been found.
  5857. return -1;
  5858. }
  5859. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5860. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can disguise only lower or same level
  5861. pc_disguise(pl_sd, mob_id);
  5862. clif_displaymessage(fd, msg_table[140]); // Character's disguise applied.
  5863. } else {
  5864. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5865. return -1;
  5866. }
  5867. } else {
  5868. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5869. return -1;
  5870. }
  5871. return 0;
  5872. }
  5873. /*==========================================
  5874. * @charundisguise <character> by Kalaspuff (based off Yor's work)
  5875. *------------------------------------------
  5876. */
  5877. int atcommand_charundisguise(
  5878. const int fd, struct map_session_data* sd,
  5879. const char* command, const char* message)
  5880. {
  5881. struct map_session_data* pl_sd;
  5882. nullpo_retr(-1, sd);
  5883. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5884. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5885. clif_displaymessage(fd, "Please, enter a player name (usage: @charundisguise <char name>).");
  5886. return -1;
  5887. }
  5888. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5889. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can undisguise only lower or same level
  5890. if (pl_sd->disguise)
  5891. pc_disguise(pl_sd, 0);
  5892. else {
  5893. clif_displaymessage(fd, msg_table[142]); // Character is not disguised.
  5894. return -1;
  5895. }
  5896. } else {
  5897. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  5898. return -1;
  5899. }
  5900. } else {
  5901. clif_displaymessage(fd, msg_table[3]); // Character not found.
  5902. return -1;
  5903. }
  5904. return 0;
  5905. }
  5906. /*==========================================
  5907. * @email <actual@email> <new@email> by [Yor]
  5908. *------------------------------------------
  5909. */
  5910. int atcommand_email(
  5911. const int fd, struct map_session_data* sd,
  5912. const char* command, const char* message)
  5913. {
  5914. char actual_email[100];
  5915. char new_email[100];
  5916. nullpo_retr(-1, sd);
  5917. memset(actual_email, '\0', sizeof(actual_email));
  5918. memset(new_email, '\0', sizeof(new_email));
  5919. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  5920. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  5921. return -1;
  5922. }
  5923. if (e_mail_check(actual_email) == 0) {
  5924. clif_displaymessage(fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com.
  5925. return -1;
  5926. } else if (e_mail_check(new_email) == 0) {
  5927. clif_displaymessage(fd, msg_table[145]); // Invalid new email. Please enter a real e-mail.
  5928. return -1;
  5929. } else if (strcmpi(new_email, "a@a.com") == 0) {
  5930. clif_displaymessage(fd, msg_table[146]); // New email must be a real e-mail.
  5931. return -1;
  5932. } else if (strcmpi(actual_email, new_email) == 0) {
  5933. clif_displaymessage(fd, msg_table[147]); // New email must be different of the actual e-mail.
  5934. return -1;
  5935. } else {
  5936. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  5937. clif_displaymessage(fd, msg_table[148]); // Information sended to login-server via char-server.
  5938. }
  5939. return 0;
  5940. }
  5941. /*==========================================
  5942. *@effect
  5943. *------------------------------------------
  5944. */
  5945. int atcommand_effect(
  5946. const int fd, struct map_session_data* sd,
  5947. const char* command, const char* message)
  5948. {
  5949. struct map_session_data *pl_sd, **pl_allsd;
  5950. int type = 0, flag = 0, i, users;
  5951. nullpo_retr(-1, sd);
  5952. if (!message || !*message || sscanf(message, "%d %d", &type,&flag) < 2) {
  5953. clif_displaymessage(fd, "Please, enter at least a option (usage: @effect <type+>).");
  5954. return -1;
  5955. }
  5956. if(flag <=0){
  5957. clif_specialeffect(&sd->bl, type, flag);
  5958. clif_displaymessage(fd, msg_table[229]); // Your effect has changed.
  5959. }
  5960. else{
  5961. pl_allsd = map_getallusers(&users);
  5962. for (i = 0; i < users; i++) {
  5963. if ((pl_sd = pl_allsd[i])) {
  5964. clif_specialeffect(&pl_sd->bl, type, flag);
  5965. clif_displaymessage(pl_sd->fd, msg_table[229]); // Your effect has changed.
  5966. }
  5967. }
  5968. }
  5969. return 0;
  5970. }
  5971. /*==========================================
  5972. * @charcartlist <character>: Displays the items list of a player's cart.
  5973. *------------------------------------------
  5974. */
  5975. int
  5976. atcommand_character_cart_list(
  5977. const int fd, struct map_session_data* sd,
  5978. const char* command, const char* message)
  5979. {
  5980. char outputtmp[200];
  5981. struct map_session_data *pl_sd;
  5982. struct item_data *item_data, *item_temp;
  5983. int i, j, count, counter, counter2;
  5984. nullpo_retr(-1, sd);
  5985. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5986. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5987. memset(outputtmp, '\0', sizeof(outputtmp));
  5988. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5989. clif_displaymessage(fd, "Please, enter a player name (usage: @charitemlist <char name>).");
  5990. return -1;
  5991. }
  5992. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  5993. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can look items only lower or same level
  5994. counter = 0;
  5995. count = 0;
  5996. for (i = 0; i < MAX_CART; i++) {
  5997. if (pl_sd->status.cart[i].nameid > 0 && (item_data = itemdb_search(pl_sd->status.cart[i].nameid)) != NULL) {
  5998. counter = counter + pl_sd->status.cart[i].amount;
  5999. count++;
  6000. if (count == 1) {
  6001. sprintf(atcmd_output, "------ Cart items list of '%s' ------", pl_sd->status.name);
  6002. clif_displaymessage(fd, atcmd_output);
  6003. }
  6004. if (pl_sd->status.cart[i].refine)
  6005. 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);
  6006. else
  6007. 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);
  6008. clif_displaymessage(fd, atcmd_output);
  6009. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6010. counter2 = 0;
  6011. for (j = 0; j < item_data->slot; j++) {
  6012. if (pl_sd->status.cart[i].card[j]) {
  6013. if ( (item_temp = itemdb_search(pl_sd->status.cart[i].card[j])) != NULL) {
  6014. if (atcmd_output[0] == '\0')
  6015. sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6016. else
  6017. sprintf(outputtmp, "#%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
  6018. strcat(atcmd_output, outputtmp);
  6019. }
  6020. }
  6021. }
  6022. if (atcmd_output[0] != '\0') {
  6023. atcmd_output[strlen(atcmd_output) - 2] = ')';
  6024. atcmd_output[strlen(atcmd_output) - 1] = '\0';
  6025. clif_displaymessage(fd, atcmd_output);
  6026. }
  6027. }
  6028. }
  6029. if (count == 0)
  6030. clif_displaymessage(fd, "No item found in the cart of this player.");
  6031. else {
  6032. sprintf(atcmd_output, "%d item(s) found in %d kind(s) of items.", counter, count);
  6033. clif_displaymessage(fd, atcmd_output);
  6034. }
  6035. } else {
  6036. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  6037. return -1;
  6038. }
  6039. } else {
  6040. clif_displaymessage(fd, msg_table[3]); // Character not found.
  6041. return -1;
  6042. }
  6043. return 0;
  6044. }
  6045. /*==========================================
  6046. * @killer by MouseJstr
  6047. * enable killing players even when not in pvp
  6048. *------------------------------------------
  6049. */
  6050. int
  6051. atcommand_killer(
  6052. const int fd, struct map_session_data* sd,
  6053. const char* command, const char* message)
  6054. {
  6055. nullpo_retr(-1, sd);
  6056. sd->special_state.killer = !sd->special_state.killer;
  6057. if(sd->special_state.killer)
  6058. clif_displaymessage(fd, msg_table[241]);
  6059. else
  6060. clif_displaymessage(fd, msg_table[242]);
  6061. return 0;
  6062. }
  6063. /*==========================================
  6064. * @killable by MouseJstr
  6065. * enable other people killing you
  6066. *------------------------------------------
  6067. */
  6068. int
  6069. atcommand_killable(
  6070. const int fd, struct map_session_data* sd,
  6071. const char* command, const char* message)
  6072. {
  6073. nullpo_retr(-1, sd);
  6074. sd->special_state.killable = !sd->special_state.killable;
  6075. if(sd->special_state.killable)
  6076. clif_displaymessage(fd, msg_table[242]);
  6077. else
  6078. clif_displaymessage(fd, msg_table[241]);
  6079. return 0;
  6080. }
  6081. /*==========================================
  6082. * @charkillable by MouseJstr
  6083. * enable another player to be killed
  6084. *------------------------------------------
  6085. */
  6086. int
  6087. atcommand_charkillable(
  6088. const int fd, struct map_session_data* sd,
  6089. const char* command, const char* message)
  6090. {
  6091. struct map_session_data *pl_sd = NULL;
  6092. nullpo_retr(-1, sd);
  6093. if (!message || !*message)
  6094. return -1;
  6095. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6096. return -1;
  6097. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  6098. if(pl_sd->special_state.killable)
  6099. clif_displaymessage(fd, "The player is now killable");
  6100. else
  6101. clif_displaymessage(fd, "The player is no longer killable");
  6102. return 0;
  6103. }
  6104. /*==========================================
  6105. * @skillon by MouseJstr
  6106. * turn skills on for the map
  6107. *------------------------------------------
  6108. */
  6109. int
  6110. atcommand_skillon(
  6111. const int fd, struct map_session_data* sd,
  6112. const char* command, const char* message)
  6113. {
  6114. nullpo_retr(-1, sd);
  6115. map[sd->bl.m].flag.noskill = 0;
  6116. clif_displaymessage(fd, msg_table[244]);
  6117. return 0;
  6118. }
  6119. /*==========================================
  6120. * @skilloff by MouseJstr
  6121. * Turn skills off on the map
  6122. *------------------------------------------
  6123. */
  6124. int
  6125. atcommand_skilloff(
  6126. const int fd, struct map_session_data* sd,
  6127. const char* command, const char* message)
  6128. {
  6129. nullpo_retr(-1, sd);
  6130. map[sd->bl.m].flag.noskill = 1;
  6131. clif_displaymessage(fd, msg_table[243]);
  6132. return 0;
  6133. }
  6134. /*==========================================
  6135. * @npcmove by MouseJstr
  6136. *
  6137. * move a npc
  6138. *------------------------------------------
  6139. */
  6140. int
  6141. atcommand_npcmove(const int fd, struct map_session_data* sd,
  6142. const char* command, const char* message)
  6143. {
  6144. int x = 0, y = 0, m;
  6145. struct npc_data *nd = 0;
  6146. nullpo_retr(-1, sd);
  6147. if (!message || !*message)
  6148. return -1;
  6149. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  6150. if (sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  6151. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  6152. return -1;
  6153. }
  6154. //Who's idea was this? nullpo's are meant to check pointers that SHOULDN'T be null unless there's a bug... [Skotlex]
  6155. // nullpo_retr(-1, (nd = npc_name2id(atcmd_player_name)));
  6156. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  6157. return -1;
  6158. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  6159. return -1; //Not on a map.
  6160. if (x < 0) x = 0;
  6161. else if (x >= map[m].xs) x = map[m].xs-1;
  6162. if (y < 0) y = 0;
  6163. else if (y >= map[m].ys) y = map[m].ys-1;
  6164. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6165. map_moveblock(&nd->bl, x, y, gettick());
  6166. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  6167. return 0;
  6168. }
  6169. /*==========================================
  6170. * @addwarp by MouseJstr
  6171. *
  6172. * Create a new static warp point.
  6173. *------------------------------------------
  6174. */
  6175. int
  6176. atcommand_addwarp(const int fd, struct map_session_data* sd,
  6177. const char* command, const char* message)
  6178. {
  6179. char w1[64], w3[64], w4[64];
  6180. int x,y,ret;
  6181. nullpo_retr(-1, sd);
  6182. if (!message || !*message)
  6183. return -1;
  6184. if (sscanf(message, "%99s %d %d[^\n]", atcmd_player_name, &x, &y ) < 3)
  6185. return -1;
  6186. sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y);
  6187. sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y);
  6188. sprintf(w4,"1,1,%s.gat,%d,%d", atcmd_player_name, x, y);
  6189. ret = npc_parse_warp(w1, "warp", w3, w4);
  6190. sprintf(atcmd_output, "New warp NPC => %s",w3);
  6191. clif_displaymessage(fd, atcmd_output);
  6192. return ret;
  6193. }
  6194. /*==========================================
  6195. * @follow by [MouseJstr]
  6196. *
  6197. * Follow a player .. staying no more then 5 spaces away
  6198. *------------------------------------------
  6199. */
  6200. int
  6201. atcommand_follow(const int fd, struct map_session_data* sd,
  6202. const char* command, const char* message)
  6203. {
  6204. struct map_session_data *pl_sd = NULL;
  6205. nullpo_retr(-1, sd);
  6206. if (!message || !*message) {
  6207. if (sd->followtarget == -1)
  6208. return -1;
  6209. pc_stop_following (sd);
  6210. clif_displaymessage(fd, "Stop following");
  6211. return 0;
  6212. }
  6213. if ((pl_sd = map_nick2sd((char *) message)) != NULL) {
  6214. if (sd->followtarget == pl_sd->bl.id)
  6215. pc_stop_following (sd);
  6216. else
  6217. pc_follow(sd, pl_sd->bl.id);
  6218. return 0;
  6219. }
  6220. return 1;
  6221. }
  6222. /*==========================================
  6223. * @dropall by [MouseJstr]
  6224. *
  6225. * Drop all your possession on the ground
  6226. *------------------------------------------
  6227. */
  6228. int
  6229. atcommand_dropall(const int fd, struct map_session_data* sd,
  6230. const char* command, const char* message)
  6231. {
  6232. int i;
  6233. nullpo_retr(-1, sd);
  6234. for (i = 0; i < MAX_INVENTORY; i++) {
  6235. if (sd->status.inventory[i].amount) {
  6236. if(sd->status.inventory[i].equip != 0)
  6237. pc_unequipitem(sd, i, 3);
  6238. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  6239. }
  6240. }
  6241. return 0;
  6242. }
  6243. /*==========================================
  6244. * @chardropall by [MouseJstr]
  6245. *
  6246. * Throw all the characters possessions on the ground. Normally
  6247. * done in response to them being disrespectful of a GM
  6248. *------------------------------------------
  6249. */
  6250. int
  6251. atcommand_chardropall(const int fd, struct map_session_data* sd,
  6252. const char* command, const char* message)
  6253. {
  6254. int i;
  6255. struct map_session_data *pl_sd = NULL;
  6256. nullpo_retr(-1, sd);
  6257. if (!message || !*message)
  6258. return -1;
  6259. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6260. return -1;
  6261. for (i = 0; i < MAX_INVENTORY; i++) {
  6262. if (pl_sd->status.inventory[i].amount) {
  6263. if(pl_sd->status.inventory[i].equip != 0)
  6264. pc_unequipitem(pl_sd, i, 3);
  6265. pc_dropitem(pl_sd, i, pl_sd->status.inventory[i].amount);
  6266. }
  6267. }
  6268. clif_displaymessage(pl_sd->fd, "Ever play 52 card pickup?");
  6269. clif_displaymessage(fd, "It is done");
  6270. //clif_displaymessage(fd, "It is offical.. your a jerk");
  6271. return 0;
  6272. }
  6273. /*==========================================
  6274. * @storeall by [MouseJstr]
  6275. *
  6276. * Put everything into storage to simplify your inventory to make
  6277. * debugging easie
  6278. *------------------------------------------
  6279. */
  6280. int
  6281. atcommand_storeall(const int fd, struct map_session_data* sd,
  6282. const char* command, const char* message)
  6283. {
  6284. int i;
  6285. nullpo_retr(-1, sd);
  6286. if (storage_storageopen(sd) == 1) {
  6287. clif_displaymessage(fd, "run this command again..");
  6288. return 0;
  6289. }
  6290. for (i = 0; i < MAX_INVENTORY; i++) {
  6291. if (sd->status.inventory[i].amount) {
  6292. if(sd->status.inventory[i].equip != 0)
  6293. pc_unequipitem(sd, i, 3);
  6294. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  6295. }
  6296. }
  6297. storage_storageclose(sd);
  6298. clif_displaymessage(fd, "It is done");
  6299. return 0;
  6300. }
  6301. /*==========================================
  6302. * @charstoreall by [MouseJstr]
  6303. *
  6304. * A way to screw with players who piss you off
  6305. *------------------------------------------
  6306. */
  6307. int
  6308. atcommand_charstoreall(const int fd, struct map_session_data* sd,
  6309. const char* command, const char* message)
  6310. {
  6311. int i;
  6312. struct map_session_data *pl_sd = NULL;
  6313. nullpo_retr(-1, sd);
  6314. if (!message || !*message)
  6315. return -1;
  6316. if((pl_sd=map_nick2sd((char *) message)) == NULL)
  6317. return -1;
  6318. if (storage_storageopen(pl_sd) == 1) {
  6319. clif_displaymessage(fd, "Had to open the characters storage window...");
  6320. clif_displaymessage(fd, "run this command again..");
  6321. return 0;
  6322. }
  6323. for (i = 0; i < MAX_INVENTORY; i++) {
  6324. if (pl_sd->status.inventory[i].amount) {
  6325. if(pl_sd->status.inventory[i].equip != 0)
  6326. pc_unequipitem(pl_sd, i, 3);
  6327. storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
  6328. }
  6329. }
  6330. storage_storageclose(pl_sd);
  6331. clif_displaymessage(pl_sd->fd, "Everything you own has been put away for safe keeping.");
  6332. clif_displaymessage(pl_sd->fd, "go to the nearest kafka to retrieve it..");
  6333. clif_displaymessage(pl_sd->fd, " -- the management");
  6334. clif_displaymessage(fd, "It is done");
  6335. return 0;
  6336. }
  6337. /*==========================================
  6338. * @skillid by [MouseJstr]
  6339. *
  6340. * lookup a skill by name
  6341. *------------------------------------------
  6342. */
  6343. int
  6344. atcommand_skillid(const int fd, struct map_session_data* sd,
  6345. const char* command, const char* message)
  6346. {
  6347. int skillen, idx;
  6348. nullpo_retr(-1, sd);
  6349. if (!message || !*message)
  6350. return -1;
  6351. skillen = strlen(message);
  6352. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  6353. if ((skill_db[idx].name != NULL && strnicmp(skill_db[idx].name, message, skillen) == 0) ||
  6354. (skill_db[idx].desc != NULL && strnicmp(skill_db[idx].desc, message, skillen) == 0))
  6355. {
  6356. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  6357. clif_displaymessage(fd, atcmd_output);
  6358. }
  6359. }
  6360. return 0;
  6361. }
  6362. /*==========================================
  6363. * @useskill by [MouseJstr]
  6364. *
  6365. * A way of using skills without having to find them in the skills menu
  6366. *------------------------------------------
  6367. */
  6368. int
  6369. atcommand_useskill(const int fd, struct map_session_data* sd,
  6370. const char* command, const char* message)
  6371. {
  6372. struct map_session_data *pl_sd = NULL;
  6373. int skillnum;
  6374. int skilllv;
  6375. char target[255];
  6376. nullpo_retr(-1, sd);
  6377. if (!message || !*message)
  6378. return -1;
  6379. if(sscanf(message, "%d %d %99[^\n]", &skillnum, &skilllv, target) != 3) {
  6380. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  6381. return -1;
  6382. }
  6383. if((pl_sd=map_nick2sd(target)) == NULL) {
  6384. return -1;
  6385. }
  6386. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  6387. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  6388. else
  6389. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, skilllv);
  6390. return 0;
  6391. }
  6392. /*==========================================
  6393. * @skilltree by [MouseJstr]
  6394. *
  6395. * prints the skill tree for a player required to get to a skill
  6396. *------------------------------------------
  6397. */
  6398. int
  6399. atcommand_skilltree(const int fd, struct map_session_data* sd,
  6400. const char* command, const char* message)
  6401. {
  6402. struct map_session_data *pl_sd = NULL;
  6403. int skillnum, skillidx = -1;
  6404. int meets = 1, j, c=0;
  6405. char target[NAME_LENGTH], *tbl;
  6406. struct skill_tree_entry *ent;
  6407. nullpo_retr(-1, sd);
  6408. if (!message || !*message)
  6409. return -1;
  6410. if(sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  6411. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  6412. return -1;
  6413. }
  6414. if((pl_sd=map_nick2sd(target)) == NULL)
  6415. return -1;
  6416. c = pc_calc_skilltree_normalize_job(pl_sd);
  6417. tbl = job_name(c);
  6418. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)",
  6419. tbl, pc_checkskill(pl_sd, 1));
  6420. clif_displaymessage(fd, atcmd_output);
  6421. for (j = 0; skill_tree[c][j].id != 0; j++) {
  6422. if (skill_tree[c][j].id == skillnum) {
  6423. skillidx = j;
  6424. break;
  6425. }
  6426. }
  6427. if (skillidx == -1) {
  6428. sprintf(atcmd_output, "I do not believe the player can use that skill");
  6429. clif_displaymessage(fd, atcmd_output);
  6430. return 0;
  6431. }
  6432. ent = &skill_tree[c][skillidx];
  6433. for(j=0;j<5;j++)
  6434. if( ent->need[j].id &&
  6435. pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  6436. {
  6437. char *desc = (skill_db[ ent->need[j].id ].desc) ? skill_db[ ent->need[j].id ].desc : "Unknown skill";
  6438. sprintf(atcmd_output, "player requires level %d of skill %s",
  6439. ent->need[j].lv, desc);
  6440. clif_displaymessage(fd, atcmd_output);
  6441. meets = 0;
  6442. }
  6443. if (meets == 1) {
  6444. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  6445. clif_displaymessage(fd, atcmd_output);
  6446. }
  6447. return 0;
  6448. }
  6449. // Hand a ring with partners name on it to this char
  6450. void getring (struct map_session_data *sd)
  6451. {
  6452. int flag,item_id = 0;
  6453. struct item item_tmp;
  6454. if(sd->status.sex==0)
  6455. item_id = 2635;
  6456. else
  6457. item_id = 2634;
  6458. memset(&item_tmp,0,sizeof(item_tmp));
  6459. item_tmp.nameid=item_id;
  6460. item_tmp.identify=1;
  6461. item_tmp.card[0]=255;
  6462. item_tmp.card[2]=sd->status.partner_id;
  6463. item_tmp.card[3]=sd->status.partner_id >> 16;
  6464. //Logs (A)dmins items [Lupus]
  6465. if(log_config.pick > 0 ) {
  6466. log_pick(sd, "A", 0, item_id, 1, &item_tmp);
  6467. }
  6468. //Logs
  6469. if((flag = pc_additem(sd,&item_tmp,1))) {
  6470. clif_additem(sd,0,0,flag);
  6471. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,NULL,NULL,NULL,0);
  6472. }
  6473. }
  6474. /*==========================================
  6475. * @marry by [MouseJstr], fixed by Lupus
  6476. *
  6477. * Marry two players
  6478. *------------------------------------------
  6479. */
  6480. int
  6481. atcommand_marry(const int fd, struct map_session_data* sd,
  6482. const char* command, const char* message)
  6483. {
  6484. struct map_session_data *pl_sd1 = NULL;
  6485. struct map_session_data *pl_sd2 = NULL;
  6486. char player1[128], player2[128]; //Length used for return error msgs
  6487. nullpo_retr(-1, sd);
  6488. if (!message || !*message || sscanf(message, "%23[^,],%23[^\r\n]", player1, player2) != 2) {
  6489. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  6490. return -1;
  6491. }
  6492. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6493. sprintf(player2, "Cannot find player '%s' online", player1);
  6494. clif_displaymessage(fd, player2);
  6495. return -1;
  6496. }
  6497. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6498. sprintf(player1, "Cannot find player '%s' online", player2);
  6499. clif_displaymessage(fd, player1);
  6500. return -1;
  6501. }
  6502. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  6503. clif_displaymessage(fd, "They are married.. wish them well");
  6504. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  6505. // Auto-give named rings (Aru)
  6506. getring (pl_sd1);
  6507. getring (pl_sd2);
  6508. return 0;
  6509. }
  6510. return -1;
  6511. }
  6512. /*==========================================
  6513. * @divorce by [MouseJstr], fixed by [Lupus]
  6514. *
  6515. * divorce two players
  6516. *------------------------------------------
  6517. */
  6518. int
  6519. atcommand_divorce(const int fd, struct map_session_data* sd,
  6520. const char* command, const char* message)
  6521. {
  6522. struct map_session_data *pl_sd = NULL;
  6523. nullpo_retr(-1, sd);
  6524. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  6525. clif_displaymessage(fd, "Usage: @divorce <player>.");
  6526. return -1;
  6527. }
  6528. if((pl_sd=map_nick2sd((char *) atcmd_player_name)) != NULL) {
  6529. if (pc_divorce(pl_sd) != 0) {
  6530. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  6531. clif_displaymessage(fd, atcmd_output);
  6532. return -1;
  6533. } else {
  6534. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  6535. clif_displaymessage(fd, atcmd_output);
  6536. return 0;
  6537. }
  6538. }
  6539. sprintf(atcmd_output, "Cannot find player '%s' online", atcmd_player_name);
  6540. clif_displaymessage(fd, atcmd_output);
  6541. return -1;
  6542. }
  6543. #ifdef DMALLOC
  6544. unsigned long dmark_;
  6545. int
  6546. atcommand_dmstart(const int fd, struct map_session_data* sd,
  6547. const char* command, const char* message)
  6548. {
  6549. dmark_ = dmalloc_mark();
  6550. clif_displaymessage(fd, "debug mark set");
  6551. return 0;
  6552. }
  6553. int
  6554. atcommand_dmtick(const int fd, struct map_session_data* sd,
  6555. const char* command, const char* message)
  6556. {
  6557. dmalloc_log_changed ( dmark_, 1, 0, 1 ) ;
  6558. dmark_ = dmalloc_mark();
  6559. clif_displaymessage(fd, "malloc changes logged");
  6560. return 0;
  6561. }
  6562. #endif
  6563. /*==========================================
  6564. * @grind by [MouseJstr]
  6565. *------------------------------------------
  6566. */
  6567. int
  6568. atcommand_grind(const int fd, struct map_session_data* sd,
  6569. const char* command, const char* message)
  6570. {
  6571. struct map_session_data *pl_sd = NULL;
  6572. int skillnum;
  6573. int inf;
  6574. char target[NAME_LENGTH];
  6575. nullpo_retr(-1, sd);
  6576. if (!message || !*message)
  6577. return -1;
  6578. if(sscanf(message, "%23s", target) != 1) {
  6579. clif_displaymessage(fd, "Usage: @grind <target>");
  6580. return -1;
  6581. }
  6582. if((pl_sd=map_nick2sd(target)) == NULL)
  6583. return -1;
  6584. for (skillnum = 1; skillnum < 500; skillnum++) {
  6585. sd->status.sp = sd->status.max_sp;
  6586. atcommand_alive(fd, sd, command, message);
  6587. inf = skill_get_inf(skillnum);
  6588. if (inf & INF_GROUND_SKILL)
  6589. unit_skilluse_pos(&sd->bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, 1);
  6590. else if (!(inf & INF_SUPPORT_SKILL))
  6591. unit_skilluse_id(&sd->bl, pl_sd->bl.id, skillnum, 1);
  6592. }
  6593. return 0;
  6594. }
  6595. /*==========================================
  6596. * @grind2 by [MouseJstr]
  6597. *------------------------------------------
  6598. */
  6599. int
  6600. atcommand_grind2(const int fd, struct map_session_data* sd,
  6601. const char* command, const char* message)
  6602. {
  6603. int i;
  6604. short x, y;
  6605. for (i = 1000; i < MAX_MOB_DB; i++) {
  6606. if (!mobdb_checkid(i))
  6607. continue;
  6608. map_search_freecell(&sd->bl, 0, &x, &y, 5, 5, 0);
  6609. mob_once_spawn(sd, "this", x, y, "--ja--", i, 1, "");
  6610. }
  6611. return 0;
  6612. }
  6613. /*==========================================
  6614. * @changelook by [Celest]
  6615. *------------------------------------------
  6616. */
  6617. int
  6618. atcommand_changelook(const int fd, struct map_session_data* sd,
  6619. const char* command, const char* message)
  6620. {
  6621. int i, j = 0, k = 0;
  6622. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  6623. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  6624. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  6625. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  6626. return -1;
  6627. } else if (i == 2) {
  6628. if (j < 1) j = 1;
  6629. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  6630. j = pos[j - 1];
  6631. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  6632. k = j; // swap
  6633. j = LOOK_HEAD_TOP;
  6634. }
  6635. clif_changelook(&sd->bl,j,k);
  6636. return 0;
  6637. }
  6638. /*==========================================
  6639. *Turns on/off Autotrade for a specific player
  6640. *------------------------------------------
  6641. *by durf (changed by Lupus)
  6642. */
  6643. int
  6644. atcommand_autotrade(
  6645. const int fd, struct map_session_data* sd,
  6646. const char* command, const char* message)
  6647. {
  6648. nullpo_retr(-1, sd);
  6649. if (sd->vender_id) //check if player's vending
  6650. {
  6651. sd->state.autotrade = 1;
  6652. clif_authfail_fd(fd, 15);
  6653. }
  6654. else
  6655. {
  6656. //"You should be vending to use @Autotrade."
  6657. clif_displaymessage(fd, msg_txt(549));
  6658. }
  6659. return 0;
  6660. }
  6661. /*==========================================
  6662. * Changes Master of your Guild to a specified guild member
  6663. *------------------------------------------
  6664. *by durf (changed by Lupus)
  6665. */
  6666. int
  6667. atcommand_changegm(
  6668. const int fd, struct map_session_data* sd,
  6669. const char* command, const char* message)
  6670. {
  6671. struct guild *g;
  6672. struct map_session_data *pl_sd;
  6673. nullpo_retr(-1, sd);
  6674. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  6675. {
  6676. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  6677. return -1;
  6678. }
  6679. if (strlen(message)==0)
  6680. {
  6681. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  6682. return -1;
  6683. }
  6684. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  6685. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  6686. return -1;
  6687. }
  6688. guild_gm_change(sd->status.guild_id, pl_sd);
  6689. return 0;
  6690. }
  6691. /*==========================================
  6692. *Changes the leader of a party.
  6693. *------------------------------------------
  6694. *by Skotlex
  6695. */
  6696. int
  6697. atcommand_changeleader(
  6698. const int fd, struct map_session_data* sd,
  6699. const char* command, const char* message)
  6700. {
  6701. struct party *p;
  6702. struct map_session_data *pl_sd;
  6703. int mi, pl_mi;
  6704. nullpo_retr(-1, sd);
  6705. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  6706. {
  6707. clif_displaymessage(fd, "You need to be a party's leader to use this command.");
  6708. return -1;
  6709. }
  6710. for (mi = 0; mi < MAX_PARTY && p->member[mi].sd != sd; mi++);
  6711. if (mi == MAX_PARTY)
  6712. return -1; //Shouldn't happen
  6713. if (!p->member[mi].leader)
  6714. {
  6715. clif_displaymessage(fd, "You need to be the party's leader to use this command.");
  6716. return -1;
  6717. }
  6718. if (strlen(message)==0)
  6719. {
  6720. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  6721. return -1;
  6722. }
  6723. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.party_id != sd->status.party_id) {
  6724. clif_displaymessage(fd, "Target character must be online and be in your party.");
  6725. return -1;
  6726. }
  6727. for (pl_mi = 0; pl_mi < MAX_PARTY && p->member[pl_mi].sd != pl_sd; pl_mi++);
  6728. if (pl_mi == MAX_PARTY)
  6729. return -1; //Shouldn't happen
  6730. //Change leadership.
  6731. p->member[mi].leader = 0;
  6732. if (p->member[mi].sd->fd)
  6733. clif_displaymessage(p->member[mi].sd->fd, "Leadership transferred.");
  6734. p->member[pl_mi].leader = 1;
  6735. if (p->member[pl_mi].sd->fd)
  6736. clif_displaymessage(p->member[pl_mi].sd->fd, "You've become the party leader.");
  6737. intif_party_leaderchange(p->party_id,p->member[pl_mi].account_id,p->member[pl_mi].char_id);
  6738. //Update info.
  6739. clif_party_main_info(p,-1);
  6740. clif_party_info(p,-1);
  6741. return 0;
  6742. }
  6743. /*==========================================
  6744. *Turns on/off AutoLoot for a specific player
  6745. *------------------------------------------
  6746. *by Upa-Kun
  6747. */
  6748. int
  6749. atcommand_autoloot(
  6750. const int fd, struct map_session_data* sd,
  6751. const char* command, const char* message)
  6752. {
  6753. int rate;
  6754. double drate;
  6755. nullpo_retr(-1, sd);
  6756. if (!message || !*message) {
  6757. if (sd->state.autoloot)
  6758. rate = 0;
  6759. else
  6760. rate = 10000;
  6761. } else {
  6762. drate = atof(message);
  6763. rate = (int)(drate*100);
  6764. }
  6765. if (rate < 0) rate = 0;
  6766. sd->state.autoloot = rate;
  6767. if (sd->state.autoloot) {
  6768. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  6769. clif_displaymessage(fd, atcmd_output);
  6770. }else
  6771. clif_displaymessage(fd, "Autoloot is now off.");
  6772. return 0;
  6773. }
  6774. /*==========================================
  6775. * It is made to rain.
  6776. *------------------------------------------
  6777. */
  6778. int
  6779. atcommand_rain(
  6780. const int fd, struct map_session_data* sd,
  6781. const char* command, const char* message)
  6782. {
  6783. nullpo_retr(-1, sd);
  6784. if (map[sd->bl.m].flag.rain) {
  6785. map[sd->bl.m].flag.rain=0;
  6786. clif_weather(sd->bl.m);
  6787. clif_displaymessage(fd, "The rain has stopped.");
  6788. } else {
  6789. map[sd->bl.m].flag.rain=1;
  6790. clif_weather(sd->bl.m);
  6791. clif_displaymessage(fd, "It is made to rain.");
  6792. }
  6793. return 0;
  6794. }
  6795. /*==========================================
  6796. * It is made to snow.
  6797. *------------------------------------------
  6798. */
  6799. int
  6800. atcommand_snow(
  6801. const int fd, struct map_session_data* sd,
  6802. const char* command, const char* message)
  6803. {
  6804. nullpo_retr(-1, sd);
  6805. if (map[sd->bl.m].flag.snow) {
  6806. map[sd->bl.m].flag.snow=0;
  6807. clif_weather(sd->bl.m);
  6808. clif_displaymessage(fd, "Snow has stopped falling.");
  6809. } else {
  6810. map[sd->bl.m].flag.snow=1;
  6811. clif_weather(sd->bl.m);
  6812. clif_displaymessage(fd, "It is made to snow.");
  6813. }
  6814. return 0;
  6815. }
  6816. /*==========================================
  6817. * Cherry tree snowstorm is made to fall. (Sakura)
  6818. *------------------------------------------
  6819. */
  6820. int
  6821. atcommand_sakura(
  6822. const int fd, struct map_session_data* sd,
  6823. const char* command, const char* message)
  6824. {
  6825. nullpo_retr(-1, sd);
  6826. if (map[sd->bl.m].flag.sakura) {
  6827. map[sd->bl.m].flag.sakura=0;
  6828. clif_weather(sd->bl.m);
  6829. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  6830. } else {
  6831. map[sd->bl.m].flag.sakura=1;
  6832. clif_weather(sd->bl.m);
  6833. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  6834. }
  6835. return 0;
  6836. }
  6837. /*==========================================
  6838. * Clouds appear.
  6839. *------------------------------------------
  6840. */
  6841. int
  6842. atcommand_clouds(
  6843. const int fd, struct map_session_data* sd,
  6844. const char* command, const char* message)
  6845. {
  6846. nullpo_retr(-1, sd);
  6847. if (map[sd->bl.m].flag.clouds) {
  6848. map[sd->bl.m].flag.clouds=0;
  6849. clif_weather(sd->bl.m);
  6850. clif_displaymessage(fd, "The clouds has disappear.");
  6851. } else {
  6852. map[sd->bl.m].flag.clouds=1;
  6853. clif_weather(sd->bl.m);
  6854. clif_displaymessage(fd, "Clouds appear.");
  6855. }
  6856. return 0;
  6857. }
  6858. /*==========================================
  6859. * Different type of clouds using effect 516
  6860. *------------------------------------------
  6861. */
  6862. int
  6863. atcommand_clouds2(
  6864. const int fd, struct map_session_data* sd,
  6865. const char* command, const char* message)
  6866. {
  6867. nullpo_retr(-1, sd);
  6868. if (map[sd->bl.m].flag.clouds2) {
  6869. map[sd->bl.m].flag.clouds2=0;
  6870. clif_weather(sd->bl.m);
  6871. clif_displaymessage(fd, "The alternative clouds disappear.");
  6872. } else {
  6873. map[sd->bl.m].flag.clouds2=1;
  6874. clif_weather(sd->bl.m);
  6875. clif_displaymessage(fd, "Alternative clouds appear.");
  6876. }
  6877. return 0;
  6878. }
  6879. /*==========================================
  6880. * Fog hangs over.
  6881. *------------------------------------------
  6882. */
  6883. int
  6884. atcommand_fog(
  6885. const int fd, struct map_session_data* sd,
  6886. const char* command, const char* message)
  6887. {
  6888. nullpo_retr(-1, sd);
  6889. if (map[sd->bl.m].flag.fog) {
  6890. map[sd->bl.m].flag.fog=0;
  6891. clif_weather(sd->bl.m);
  6892. clif_displaymessage(fd, "The fog has gone.");
  6893. } else {
  6894. map[sd->bl.m].flag.fog=1;
  6895. clif_weather(sd->bl.m);
  6896. clif_displaymessage(fd, "Fog hangs over.");
  6897. }
  6898. return 0;
  6899. }
  6900. /*==========================================
  6901. * Fallen leaves fall.
  6902. *------------------------------------------
  6903. */
  6904. int
  6905. atcommand_leaves(
  6906. const int fd, struct map_session_data* sd,
  6907. const char* command, const char* message)
  6908. {
  6909. nullpo_retr(-1, sd);
  6910. if (map[sd->bl.m].flag.leaves) {
  6911. map[sd->bl.m].flag.leaves=0;
  6912. clif_weather(sd->bl.m);
  6913. clif_displaymessage(fd, "Leaves no longer fall.");
  6914. } else {
  6915. map[sd->bl.m].flag.leaves=1;
  6916. clif_weather(sd->bl.m);
  6917. clif_displaymessage(fd, "Fallen leaves fall.");
  6918. }
  6919. return 0;
  6920. }
  6921. /*==========================================
  6922. * Fireworks appear.
  6923. *------------------------------------------
  6924. */
  6925. int
  6926. atcommand_fireworks(
  6927. const int fd, struct map_session_data* sd,
  6928. const char* command, const char* message)
  6929. {
  6930. nullpo_retr(-1, sd);
  6931. if (map[sd->bl.m].flag.fireworks) {
  6932. map[sd->bl.m].flag.fireworks=0;
  6933. clif_weather(sd->bl.m);
  6934. clif_displaymessage(fd, "Fireworks are ended.");
  6935. } else {
  6936. map[sd->bl.m].flag.fireworks=1;
  6937. clif_weather(sd->bl.m);
  6938. clif_displaymessage(fd, "Fireworks are launched.");
  6939. }
  6940. return 0;
  6941. }
  6942. /*==========================================
  6943. * Clearing Weather Effects by Dexity
  6944. *------------------------------------------
  6945. */
  6946. int
  6947. atcommand_clearweather(
  6948. const int fd, struct map_session_data* sd,
  6949. const char* command, const char* message)
  6950. {
  6951. nullpo_retr(-1, sd);
  6952. map[sd->bl.m].flag.rain=0;
  6953. map[sd->bl.m].flag.snow=0;
  6954. map[sd->bl.m].flag.sakura=0;
  6955. map[sd->bl.m].flag.clouds=0;
  6956. map[sd->bl.m].flag.clouds2=0;
  6957. map[sd->bl.m].flag.fog=0;
  6958. map[sd->bl.m].flag.fireworks=0;
  6959. map[sd->bl.m].flag.leaves=0;
  6960. clif_weather(sd->bl.m);
  6961. return 0;
  6962. }
  6963. /*===============================================================
  6964. * Sound Command - plays a sound for everyone! [Codemaster]
  6965. *---------------------------------------------------------------
  6966. */
  6967. int
  6968. atcommand_sound(
  6969. const int fd, struct map_session_data *sd,
  6970. const char *command, const char *message)
  6971. {
  6972. char sound_file[100];
  6973. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6974. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  6975. return -1;
  6976. }
  6977. memset(sound_file, '\0', sizeof(sound_file));
  6978. if(sscanf(message, "%99[^\n]", sound_file) < 1)
  6979. return -1;
  6980. if(strstr(sound_file, ".wav") == NULL)
  6981. strcat(sound_file, ".wav");
  6982. clif_soundeffectall(&sd->bl, sound_file,0,2);
  6983. return 0;
  6984. }
  6985. /*==========================================
  6986. * MOB Search
  6987. *------------------------------------------
  6988. */
  6989. static int atmobsearch_sub(struct block_list *bl,va_list ap)
  6990. {
  6991. int mob_id,fd;
  6992. static int number=0;
  6993. struct mob_data *md;
  6994. nullpo_retr(0, bl);
  6995. if(!ap){
  6996. number=0;
  6997. return 0;
  6998. }
  6999. mob_id = va_arg(ap,int);
  7000. fd = va_arg(ap,int);
  7001. md = (struct mob_data *)bl;
  7002. if(md && fd && (mob_id==-1 || (md->class_==mob_id))){
  7003. snprintf(atcmd_output, sizeof atcmd_output, "%2d[%3d:%3d] %s",
  7004. ++number,bl->x, bl->y,md->name);
  7005. clif_displaymessage(fd, atcmd_output);
  7006. }
  7007. return 0;
  7008. }
  7009. int atcommand_mobsearch(
  7010. const int fd, struct map_session_data* sd,
  7011. const char* command, const char* message)
  7012. {
  7013. char mob_name[100];
  7014. int mob_id,map_id = 0;
  7015. nullpo_retr(-1, sd);
  7016. if (sscanf(message, "%99[^\n]", mob_name) < 0)
  7017. return -1;
  7018. if ((mob_id = atoi(mob_name)) == 0)
  7019. mob_id = mobdb_searchname(mob_name);
  7020. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  7021. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  7022. clif_displaymessage(fd, atcmd_output);
  7023. return 0;
  7024. }
  7025. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  7026. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  7027. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  7028. map_id = sd->bl.m;
  7029. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  7030. mob_name, mapindex_id2name(sd->mapindex));
  7031. clif_displaymessage(fd, atcmd_output);
  7032. map_foreachinmap(atmobsearch_sub, map_id, BL_MOB, mob_id, fd);
  7033. atmobsearch_sub(&sd->bl,0); // 番号リセット
  7034. return 0;
  7035. }
  7036. /*==========================================
  7037. * ドロップアイテムの掃除
  7038. *------------------------------------------
  7039. */
  7040. /*==========================================
  7041. * cleanmap
  7042. *------------------------------------------
  7043. */
  7044. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  7045. {
  7046. nullpo_retr(0, bl);
  7047. map_clearflooritem(bl->id);
  7048. return 0;
  7049. }
  7050. int
  7051. atcommand_cleanmap(
  7052. const int fd, struct map_session_data* sd,
  7053. const char* command, const char* message)
  7054. {
  7055. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  7056. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  7057. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  7058. BL_ITEM);
  7059. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  7060. return 0;
  7061. }
  7062. /*==========================================
  7063. * NPC/PETに話させる
  7064. *------------------------------------------
  7065. */
  7066. int
  7067. atcommand_npctalk(
  7068. const int fd, struct map_session_data* sd,
  7069. const char* command, const char* message)
  7070. {
  7071. char name[NAME_LENGTH],mes[100],temp[100];
  7072. struct npc_data *nd;
  7073. if (sscanf(message, "%23[^,],%99[^\n]", name, mes) < 2)
  7074. return -1;
  7075. if (!(nd = npc_name2id(name)))
  7076. return -1;
  7077. snprintf(temp, sizeof temp ,"%s : %s",name,mes);
  7078. clif_message(&nd->bl, temp);
  7079. return 0;
  7080. }
  7081. int
  7082. atcommand_pettalk(
  7083. const int fd, struct map_session_data* sd,
  7084. const char* command, const char* message)
  7085. {
  7086. char mes[100],temp[100];
  7087. struct pet_data *pd;
  7088. nullpo_retr(-1, sd);
  7089. if(!sd->status.pet_id || !(pd=sd->pd))
  7090. return -1;
  7091. if (sscanf(message, "%99[^\n]", mes) < 1)
  7092. return -1;
  7093. snprintf(temp, sizeof temp ,"%s : %s",sd->pet.name,mes);
  7094. clif_message(&pd->bl, temp);
  7095. return 0;
  7096. }
  7097. /*==========================================
  7098. * @users
  7099. * サーバー内の人数マップを表示させる
  7100. * 手抜きのため汚くなっているのは仕様です。
  7101. *------------------------------------------
  7102. */
  7103. static struct dbt *users_db = NULL;
  7104. static int users_all;
  7105. static int atcommand_users_sub1(struct map_session_data* sd,va_list va) {
  7106. int users = (int)(uidb_get(users_db,(unsigned int)sd->mapindex)) + 1;
  7107. users_all++;
  7108. uidb_put(users_db,(unsigned int)sd->mapindex,(void *)users);
  7109. return 0;
  7110. }
  7111. static int atcommand_users_sub2(DBKey key,void* val,va_list va) {
  7112. char buf[256];
  7113. struct map_session_data* sd = va_arg(va,struct map_session_data*);
  7114. sprintf(buf,"%s : %d (%d%%)",mapindex_id2name(key.i),(int)val,(int)val * 100 / users_all);
  7115. clif_displaymessage(sd->fd,buf);
  7116. return 0;
  7117. }
  7118. int
  7119. atcommand_users(
  7120. const int fd, struct map_session_data* sd,
  7121. const char* command, const char* message)
  7122. {
  7123. char buf[256];
  7124. users_all = 0;
  7125. users_db->clear(users_db, NULL);
  7126. clif_foreachclient(atcommand_users_sub1);
  7127. users_db->foreach(users_db,atcommand_users_sub2,sd);
  7128. sprintf(buf,"all : %d",users_all);
  7129. clif_displaymessage(fd,buf);
  7130. return 0;
  7131. }
  7132. /*==========================================
  7133. *
  7134. *------------------------------------------
  7135. */
  7136. int
  7137. atcommand_summon(
  7138. const int fd, struct map_session_data* sd,
  7139. const char* command, const char* message)
  7140. {
  7141. char name[NAME_LENGTH];
  7142. int mob_id = 0;
  7143. int x = 0;
  7144. int y = 0;
  7145. int id = 0;
  7146. int duration = 0;
  7147. struct mob_data *md;
  7148. unsigned int tick=gettick();
  7149. nullpo_retr(-1, sd);
  7150. if (!message || !*message)
  7151. return -1;
  7152. if (sscanf(message, "%23s %d", name, &duration) < 1)
  7153. return -1;
  7154. if (duration < 1)
  7155. duration =1;
  7156. else if (duration > 60)
  7157. duration =60;
  7158. if ((mob_id = atoi(name)) == 0)
  7159. mob_id = mobdb_searchname(name);
  7160. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  7161. return -1;
  7162. x = sd->bl.x + (rand() % 10 - 5);
  7163. y = sd->bl.y + (rand() % 10 - 5);
  7164. id = mob_once_spawn(sd,"this", x, y, "--ja--", mob_id, 1, "");
  7165. if((md=(struct mob_data *)map_id2bl(id))){
  7166. md->master_id=sd->bl.id;
  7167. md->special_state.ai=1;
  7168. md->mode=md->db->mode|MD_AGGRESSIVE;
  7169. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,id,0);
  7170. clif_misceffect2(&md->bl,344);
  7171. }
  7172. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,x,y,tick);
  7173. return 0;
  7174. }
  7175. /*==========================================
  7176. * @adjcmdlvl by [MouseJstr]
  7177. *
  7178. * Temp adjust the GM level required to use a GM command
  7179. *
  7180. * Used during beta testing to allow players to use GM commands
  7181. * for short periods of time
  7182. *------------------------------------------
  7183. */
  7184. int
  7185. atcommand_adjcmdlvl(
  7186. const int fd, struct map_session_data* sd,
  7187. const char* command, const char* message)
  7188. {
  7189. int i, newlev;
  7190. char cmd[100];
  7191. nullpo_retr(-1, sd);
  7192. if (!message || !*message || sscanf(message, "%d %s", &newlev, cmd) != 2) {
  7193. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <command>.");
  7194. return -1;
  7195. }
  7196. for (i = 0; (atcommand_info[i].command) && atcommand_info[i].type != AtCommand_None; i++)
  7197. if (strcmpi(cmd, atcommand_info[i].command+1) == 0) {
  7198. atcommand_info[i].level = newlev;
  7199. clif_displaymessage(fd, "@command level changed.");
  7200. return 0;
  7201. }
  7202. clif_displaymessage(fd, "@command not found.");
  7203. return -1;
  7204. }
  7205. /*==========================================
  7206. * @adjgmlvl by [MouseJstr]
  7207. *
  7208. * Create a temp GM
  7209. *
  7210. * Used during beta testing to allow players to use GM commands
  7211. * for short periods of time
  7212. *------------------------------------------
  7213. */
  7214. int
  7215. atcommand_adjgmlvl(
  7216. const int fd, struct map_session_data* sd,
  7217. const char* command, const char* message)
  7218. {
  7219. int newlev;
  7220. char user[NAME_LENGTH];
  7221. struct map_session_data *pl_sd;
  7222. nullpo_retr(-1, sd);
  7223. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  7224. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  7225. return -1;
  7226. }
  7227. if((pl_sd=map_nick2sd((char *) user)) == NULL)
  7228. return -1;
  7229. pc_set_gm_level(pl_sd->status.account_id, newlev);
  7230. return 0;
  7231. }
  7232. /*==========================================
  7233. * @trade by [MouseJstr]
  7234. *
  7235. * Open a trade window with a remote player
  7236. *
  7237. * If I have to jump to a remote player one more time, I am
  7238. * gonna scream!
  7239. *------------------------------------------
  7240. */
  7241. int
  7242. atcommand_trade(
  7243. const int fd, struct map_session_data* sd,
  7244. const char* command, const char* message)
  7245. {
  7246. struct map_session_data *pl_sd = NULL;
  7247. nullpo_retr(-1, sd);
  7248. if (!message || !*message)
  7249. return -1;
  7250. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7251. trade_traderequest(sd, pl_sd->bl.id);
  7252. return 0;
  7253. }
  7254. return -1;
  7255. }
  7256. /*==========================================
  7257. * @setbattleflag by [MouseJstr]
  7258. *
  7259. * set a battle_config flag without having to reboot
  7260. */
  7261. int
  7262. atcommand_setbattleflag(
  7263. const int fd, struct map_session_data* sd,
  7264. const char* command, const char* message)
  7265. {
  7266. char flag[128], value[128];
  7267. nullpo_retr(-1, sd);
  7268. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  7269. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  7270. return -1;
  7271. }
  7272. if (battle_set_value(flag, value) == 0)
  7273. clif_displaymessage(fd, "unknown battle_config flag");
  7274. else
  7275. clif_displaymessage(fd, "battle_config set as requested");
  7276. return 0;
  7277. }
  7278. /*===========================
  7279. * @unmute [Valaris]
  7280. *===========================
  7281. */
  7282. int atcommand_unmute(
  7283. const int fd, struct map_session_data* sd,
  7284. const char* command, const char* message)
  7285. {
  7286. struct map_session_data *pl_sd = NULL;
  7287. nullpo_retr(-1, sd);
  7288. if(!battle_config.muting_players) {
  7289. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7290. return 0;
  7291. }
  7292. if (!message || !*message)
  7293. return -1;
  7294. if((pl_sd=map_nick2sd((char *) message)) != NULL) {
  7295. if(pl_sd->sc.data[SC_NOCHAT].timer!=-1) {
  7296. pl_sd->status.manner = 0; // have to set to 0 first [celest]
  7297. status_change_end(&pl_sd->bl,SC_NOCHAT,-1);
  7298. clif_displaymessage(sd->fd,"Player unmuted");
  7299. }
  7300. else
  7301. clif_displaymessage(sd->fd,"Player is not muted");
  7302. }
  7303. return 0;
  7304. }
  7305. /*==========================================
  7306. * @uptime by MC Cameri
  7307. *------------------------------------------
  7308. */
  7309. int
  7310. atcommand_uptime(
  7311. const int fd, struct map_session_data* sd,
  7312. const char* command, const char* message)
  7313. {
  7314. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  7315. minute = 60, days = 0, hours = 0, minutes = 0;
  7316. nullpo_retr(-1, sd);
  7317. seconds = get_uptime();
  7318. days = seconds/day;
  7319. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  7320. hours = seconds/hour;
  7321. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  7322. minutes = seconds/minute;
  7323. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  7324. snprintf(atcmd_output, sizeof(atcmd_output), msg_table[245], days, hours, minutes, seconds);
  7325. clif_displaymessage(fd, atcmd_output);
  7326. return 0;
  7327. }
  7328. /*==========================================
  7329. * @changesex <sex>
  7330. * => Changes one's sex. Argument sex can be
  7331. * 0 or 1, m or f, male or female.
  7332. *------------------------------------------
  7333. */
  7334. int
  7335. atcommand_changesex(
  7336. const int fd, struct map_session_data* sd,
  7337. const char* command, const char* message)
  7338. {
  7339. nullpo_retr(-1, sd);
  7340. chrif_char_ask_name(sd->status.account_id,sd->status.name, 5,0,0,0,0,0,0);
  7341. return 0;
  7342. }
  7343. /*================================================
  7344. * @mute - Mutes a player for a set amount of time
  7345. *------------------------------------------------
  7346. */
  7347. int atcommand_mute(
  7348. const int fd, struct map_session_data* sd,
  7349. const char* command, const char* message)
  7350. {
  7351. struct map_session_data *pl_sd = NULL;
  7352. int manner;
  7353. nullpo_retr(-1, sd);
  7354. if(!battle_config.muting_players) {
  7355. clif_displaymessage(fd, "Please enable the muting system before using it.");
  7356. return 0;
  7357. }
  7358. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  7359. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  7360. return -1;
  7361. }
  7362. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  7363. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  7364. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7365. return -1;
  7366. }
  7367. clif_GM_silence(sd, pl_sd, 0);
  7368. pl_sd->status.manner -= manner;
  7369. if(pl_sd->status.manner < 0)
  7370. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  7371. }
  7372. else {
  7373. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7374. return -1;
  7375. }
  7376. return 0;
  7377. }
  7378. /*==========================================
  7379. * @refresh (like @jumpto <<yourself>>)
  7380. *------------------------------------------
  7381. */
  7382. int atcommand_refresh(
  7383. const int fd, struct map_session_data* sd,
  7384. const char* command, const char* message)
  7385. {
  7386. nullpo_retr(-1, sd);
  7387. clif_refresh(sd);
  7388. return 0;
  7389. }
  7390. /*==========================================
  7391. * @petid <part of pet name>
  7392. * => Displays a list of matching pets.
  7393. *------------------------------------------
  7394. */
  7395. int
  7396. atcommand_petid(const int fd, struct map_session_data* sd,
  7397. const char* command, const char* message)
  7398. {
  7399. char searchtext[100];
  7400. char temp0[100];
  7401. char temp1[100];
  7402. int cnt = 0, i = 0;
  7403. nullpo_retr(-1, sd);
  7404. if (!message || !*message)
  7405. return -1;
  7406. if (sscanf(message, "%99s", searchtext) < 1)
  7407. return -1;
  7408. estr_lower(searchtext);
  7409. snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
  7410. clif_displaymessage(fd,temp0);
  7411. while (i < MAX_PET_DB) {
  7412. strcpy(temp1,pet_db[i].name);
  7413. strcpy(temp1, estr_lower(temp1));
  7414. strcpy(temp0,pet_db[i].jname);
  7415. strcpy(temp0, estr_lower(temp1));
  7416. if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) {
  7417. snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_,
  7418. pet_db[i].jname);
  7419. if (cnt >= 100) { // Only if there are custom pets
  7420. clif_displaymessage(fd, "Be more specific, can't send more than"
  7421. " 100 results.");
  7422. } else {
  7423. clif_displaymessage(fd, temp0);
  7424. }
  7425. cnt++;
  7426. }
  7427. i++;
  7428. }
  7429. snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext);
  7430. clif_displaymessage(fd, temp0);
  7431. return 0;
  7432. }
  7433. /*==========================================
  7434. * @identify
  7435. * => GM's magnifier.
  7436. *------------------------------------------
  7437. */
  7438. int
  7439. atcommand_identify(
  7440. const int fd, struct map_session_data* sd,
  7441. const char* command, const char* message)
  7442. {
  7443. int i,num;
  7444. nullpo_retr(-1, sd);
  7445. for(i=num=0;i<MAX_INVENTORY;i++){
  7446. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  7447. num++;
  7448. }
  7449. }
  7450. if (num > 0) {
  7451. clif_item_identify_list(sd);
  7452. } else {
  7453. clif_displaymessage(fd,"There are no items to appraise.");
  7454. }
  7455. return 0;
  7456. }
  7457. /*==========================================
  7458. * @gmotd (Global MOTD)
  7459. * by davidsiaw :P
  7460. *------------------------------------------
  7461. */
  7462. int
  7463. atcommand_gmotd(
  7464. const int fd, struct map_session_data* sd,
  7465. const char* command, const char* message)
  7466. {
  7467. char buf[256];
  7468. FILE *fp;
  7469. nullpo_retr(-1, sd);
  7470. if( (fp = fopen(motd_txt, "r"))!=NULL){
  7471. while (fgets(buf, 250, fp) != NULL){
  7472. int i;
  7473. for( i=0; buf[i]; i++){
  7474. if( buf[i]=='\r' || buf[i]=='\n'){
  7475. buf[i]=0;
  7476. break;
  7477. }
  7478. }
  7479. intif_GMmessage(buf,strlen(buf)+1,8);
  7480. }
  7481. fclose(fp);
  7482. }
  7483. return 0;
  7484. }
  7485. int atcommand_misceffect(
  7486. const int fd, struct map_session_data* sd,
  7487. const char* command, const char* message)
  7488. {
  7489. int effect = 0;
  7490. nullpo_retr(-1, sd);
  7491. if (!message || !*message)
  7492. return -1;
  7493. if (sscanf(message, "%d", &effect) < 1)
  7494. return -1;
  7495. clif_misceffect(&sd->bl,effect);
  7496. return 0;
  7497. }
  7498. int charid2sessionid(int charid)
  7499. {
  7500. struct map_session_data *pl_sd = NULL;
  7501. pl_sd = map_charid2sd(charid);
  7502. if (pl_sd) return pl_sd->fd;
  7503. return 0;
  7504. }
  7505. int accountid2sessionid(int accountid)
  7506. {
  7507. struct map_session_data *pl_sd = NULL;
  7508. pl_sd = map_id2sd(accountid);
  7509. if (pl_sd) return pl_sd->fd;
  7510. return 0;
  7511. }
  7512. /*==========================================
  7513. * Jump to a player by PID number
  7514. * Original by Dino9021
  7515. * Added in by nsstrunks
  7516. *------------------------------------------
  7517. */
  7518. int atcommand_jumptoid(
  7519. const int fd, struct map_session_data* sd,
  7520. const char* command, const char* message)
  7521. {
  7522. int cid=0;
  7523. int session_id=0;
  7524. struct map_session_data *pl_sd;
  7525. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7526. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7527. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7528. clif_displaymessage(fd, "Please, enter a player CID (usage: @jumptoid/@warptoid/@gotoid <char id>).");
  7529. return -1;
  7530. }
  7531. cid=atoi(message);
  7532. if ((session_id=charid2sessionid(cid))!=0)
  7533. {
  7534. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7535. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7536. clif_displaymessage(fd, msg_table[247]);
  7537. return -1;
  7538. }
  7539. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7540. clif_displaymessage(fd, msg_table[248]);
  7541. return -1;
  7542. }
  7543. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7544. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7545. clif_displaymessage(fd, atcmd_output);
  7546. } else {
  7547. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7548. return -1;
  7549. }
  7550. }
  7551. else
  7552. {
  7553. clif_displaymessage(fd,msg_table[3]);
  7554. }
  7555. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7556. return 0;
  7557. }
  7558. /*==========================================
  7559. * Jump to a player by PID number
  7560. * Original by Dino9021
  7561. * Added in by nsstrunks
  7562. *------------------------------------------
  7563. */
  7564. int atcommand_jumptoid2(
  7565. const int fd, struct map_session_data* sd,
  7566. const char* command, const char* message)
  7567. {
  7568. int aid=0;
  7569. int session_id=0;
  7570. struct map_session_data *pl_sd;
  7571. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7572. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7573. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7574. clif_displaymessage(fd, "Please, enter a player AID (usage: @jumptoid/@warptoid/@gotoid <account id>).");
  7575. return -1;
  7576. }
  7577. aid=atoi(message);
  7578. if ((session_id=accountid2sessionid(aid))!=0)
  7579. {
  7580. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7581. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7582. clif_displaymessage(fd, msg_table[247]);
  7583. return -1;
  7584. }
  7585. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7586. clif_displaymessage(fd, msg_table[248]);
  7587. return -1;
  7588. }
  7589. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, 3);
  7590. sprintf(atcmd_output, msg_table[4], pl_sd->status.name); // Jump to %s
  7591. clif_displaymessage(fd, atcmd_output);
  7592. } else {
  7593. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7594. return -1;
  7595. }
  7596. }
  7597. else
  7598. {
  7599. clif_displaymessage(fd,msg_table[3]);
  7600. }
  7601. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7602. return 0;
  7603. }
  7604. /*==========================================
  7605. * Recall a player by PID number
  7606. * Original by Dino9021
  7607. * Added in by nsstrunks
  7608. *------------------------------------------
  7609. */
  7610. int atcommand_recallid(
  7611. const int fd, struct map_session_data* sd,
  7612. const char* command, const char* message)
  7613. {
  7614. int cid=0;
  7615. int session_id=0;
  7616. struct map_session_data *pl_sd;
  7617. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7618. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7619. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7620. clif_displaymessage(fd, "Please, enter a player CID (usage: @recallid <char id>).");
  7621. return -1;
  7622. }
  7623. cid=atoi(message);
  7624. if ((session_id=charid2sessionid(cid))!=0)
  7625. {
  7626. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7627. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7628. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7629. clif_displaymessage(fd, msg_table[247]);
  7630. return -1;
  7631. }
  7632. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7633. clif_displaymessage(fd, msg_table[248]);
  7634. return -1;
  7635. }
  7636. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7637. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7638. clif_displaymessage(fd, atcmd_output);
  7639. } else {
  7640. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7641. return -1;
  7642. }
  7643. } else {
  7644. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7645. return -1;
  7646. }
  7647. }
  7648. else
  7649. {
  7650. clif_displaymessage(fd,msg_table[3]);
  7651. }
  7652. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7653. return 0;
  7654. }
  7655. /*==========================================
  7656. * Recall a player by PID number
  7657. * Original by Dino9021
  7658. * Added in by nsstrunks
  7659. *------------------------------------------
  7660. */
  7661. int atcommand_recallid2(
  7662. const int fd, struct map_session_data* sd,
  7663. const char* command, const char* message)
  7664. {
  7665. int aid=0;
  7666. int session_id=0;
  7667. struct map_session_data *pl_sd;
  7668. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7669. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7670. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7671. clif_displaymessage(fd, "Please, enter a player AID (usage: @recallid2 <account id>).");
  7672. return -1;
  7673. }
  7674. aid=atoi(message);
  7675. if ((session_id=accountid2sessionid(aid))!=0)
  7676. {
  7677. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7678. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can recall only lower or same level
  7679. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7680. clif_displaymessage(fd, msg_table[247]);
  7681. return -1;
  7682. }
  7683. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  7684. clif_displaymessage(fd, msg_table[248]);
  7685. return -1;
  7686. }
  7687. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, 2);
  7688. sprintf(atcmd_output, msg_table[46], pl_sd->status.name); // Jump to %s
  7689. clif_displaymessage(fd, atcmd_output);
  7690. } else {
  7691. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7692. return -1;
  7693. }
  7694. } else {
  7695. clif_displaymessage(fd, msg_table[154]); // Character not found.
  7696. return -1;
  7697. }
  7698. }
  7699. else
  7700. {
  7701. clif_displaymessage(fd,msg_table[3]);
  7702. }
  7703. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7704. return 0;
  7705. }
  7706. /*==========================================
  7707. * Kick a player by PID number
  7708. * Original by Dino9021
  7709. * Added in by nsstrunks
  7710. *------------------------------------------
  7711. */
  7712. int atcommand_kickid(
  7713. const int fd, struct map_session_data* sd,
  7714. const char* command, const char* message)
  7715. {
  7716. struct map_session_data *pl_sd;
  7717. int cid=0;
  7718. int session_id=0;
  7719. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7720. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7721. clif_displaymessage(fd, "Please, enter a player CID (usage: @kickid <char id>).");
  7722. return -1;
  7723. }
  7724. cid=atoi(message);
  7725. if ((session_id=charid2sessionid(cid))!=0)
  7726. {
  7727. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7728. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7729. clif_GM_kick(sd, pl_sd, 1);
  7730. else {
  7731. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7732. return -1;
  7733. }
  7734. } else {
  7735. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7736. return -1;
  7737. }
  7738. }
  7739. else
  7740. {
  7741. clif_displaymessage(fd,msg_table[3]);
  7742. }
  7743. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7744. return 0;
  7745. }
  7746. /*==========================================
  7747. * Kick a player by PID number
  7748. * Original by Dino9021
  7749. * Added in by nsstrunks
  7750. *------------------------------------------
  7751. */
  7752. int atcommand_kickid2(
  7753. const int fd, struct map_session_data* sd,
  7754. const char* command, const char* message)
  7755. {
  7756. struct map_session_data *pl_sd;
  7757. int aid=0;
  7758. int session_id=0;
  7759. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7760. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7761. clif_displaymessage(fd, "Please, enter a player AID (usage: @kickid2 <account id>).");
  7762. return -1;
  7763. }
  7764. aid=atoi(message);
  7765. if ((session_id=accountid2sessionid(aid))!=0)
  7766. {
  7767. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7768. if (pc_isGM(sd) >= pc_isGM(pl_sd)) // you can kick only lower or same gm level
  7769. clif_GM_kick(sd, pl_sd, 1);
  7770. else {
  7771. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7772. return -1;
  7773. }
  7774. } else {
  7775. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7776. return -1;
  7777. }
  7778. }
  7779. else
  7780. {
  7781. clif_displaymessage(fd,msg_table[3]);
  7782. }
  7783. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7784. return 0;
  7785. }
  7786. /*==========================================
  7787. * Revive a player by PID number
  7788. * Original by Dino9021
  7789. * Added in by nsstrunks
  7790. *------------------------------------------
  7791. */
  7792. int atcommand_reviveid(
  7793. const int fd, struct map_session_data* sd,
  7794. const char* command, const char* message)
  7795. {
  7796. int cid=0;
  7797. int session_id=0;
  7798. struct map_session_data *pl_sd;
  7799. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7800. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7801. clif_displaymessage(fd, "Please, enter a player CID (usage: @reviveid <char id>).");
  7802. return -1;
  7803. }
  7804. cid=atoi(message);
  7805. if ((session_id=charid2sessionid(cid))!=0)
  7806. {
  7807. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7808. pl_sd->status.hp = pl_sd->status.max_hp;
  7809. pc_setstand(pl_sd);
  7810. if (battle_config.pc_invincible_time > 0)
  7811. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7812. clif_updatestatus(pl_sd, SP_HP);
  7813. clif_updatestatus(pl_sd, SP_SP);
  7814. clif_resurrection(&pl_sd->bl, 1);
  7815. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7816. } else {
  7817. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7818. return -1;
  7819. }
  7820. }
  7821. else
  7822. {
  7823. clif_displaymessage(fd,msg_table[3]);
  7824. }
  7825. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7826. return 0;
  7827. }
  7828. /*==========================================
  7829. * Revive a player by PID number
  7830. * Original by Dino9021
  7831. * Added in by nsstrunks
  7832. *------------------------------------------
  7833. */
  7834. int atcommand_reviveid2(
  7835. const int fd, struct map_session_data* sd,
  7836. const char* command, const char* message)
  7837. {
  7838. int aid=0;
  7839. int session_id=0;
  7840. struct map_session_data *pl_sd;
  7841. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7842. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7843. clif_displaymessage(fd, "Please, enter a player AID (usage: @reviveid2 <account id>).");
  7844. return -1;
  7845. }
  7846. aid=atoi(message);
  7847. if ((session_id=accountid2sessionid(aid))!=0)
  7848. {
  7849. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7850. pl_sd->status.hp = pl_sd->status.max_hp;
  7851. pc_setstand(pl_sd);
  7852. if (battle_config.pc_invincible_time > 0)
  7853. pc_setinvincibletimer(sd, battle_config.pc_invincible_time);
  7854. clif_updatestatus(pl_sd, SP_HP);
  7855. clif_updatestatus(pl_sd, SP_SP);
  7856. clif_resurrection(&pl_sd->bl, 1);
  7857. clif_displaymessage(fd, msg_table[51]); // Character revived.
  7858. } else {
  7859. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7860. return -1;
  7861. }
  7862. }
  7863. else
  7864. {
  7865. clif_displaymessage(fd,msg_table[3]);
  7866. }
  7867. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7868. return 0;
  7869. }
  7870. /*==========================================
  7871. * Kill a player by PID number
  7872. * Original by Dino9021
  7873. * Added in by nsstrunks
  7874. *------------------------------------------
  7875. */
  7876. int atcommand_killid(
  7877. const int fd, struct map_session_data* sd,
  7878. const char* command, const char* message)
  7879. {
  7880. int cid=0;
  7881. int session_id=0;
  7882. struct map_session_data *pl_sd;
  7883. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7884. if (!message || (cid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7885. clif_displaymessage(fd, "Please, enter a player CID (usage: @killid <char id>).");
  7886. return -1;
  7887. }
  7888. cid=atoi(message);
  7889. if ((session_id=charid2sessionid(cid))!=0)
  7890. {
  7891. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7892. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7893. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7894. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7895. } else {
  7896. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7897. return -1;
  7898. }
  7899. } else {
  7900. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7901. return -1;
  7902. }
  7903. }
  7904. else
  7905. {
  7906. clif_displaymessage(fd,msg_table[3]);
  7907. }
  7908. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7909. return 0;
  7910. }
  7911. /*==========================================
  7912. * Kill a player by PID number
  7913. * Original by Dino9021
  7914. * Added in by nsstrunks
  7915. *------------------------------------------
  7916. */
  7917. int atcommand_killid2(
  7918. const int fd, struct map_session_data* sd,
  7919. const char* command, const char* message)
  7920. {
  7921. int aid=0;
  7922. int session_id=0;
  7923. struct map_session_data *pl_sd;
  7924. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7925. if (!message || (aid = atoi(message)) == 0 || !*message || sscanf(message, "%99[^\n]", atcmd_player_name) < 1) {
  7926. clif_displaymessage(fd, "Please, enter a player AID (usage: @killid2 <account id>).");
  7927. return -1;
  7928. }
  7929. aid=atoi(message);
  7930. if ((session_id=accountid2sessionid(aid))!=0)
  7931. {
  7932. if ((pl_sd = (struct map_session_data *) session[session_id]->session_data) != NULL) {
  7933. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same level
  7934. pc_damage(NULL, pl_sd, pl_sd->status.hp);
  7935. clif_displaymessage(fd, msg_table[14]); // Character killed.
  7936. } else {
  7937. clif_displaymessage(fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player.
  7938. return -1;
  7939. }
  7940. } else {
  7941. clif_displaymessage(fd, msg_table[3]); // Character not found.
  7942. return -1;
  7943. }
  7944. }
  7945. else
  7946. {
  7947. clif_displaymessage(fd,msg_table[3]);
  7948. }
  7949. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  7950. return 0;
  7951. }
  7952. /*==========================================
  7953. * Make a player killable, by PID
  7954. * Original by Dino9021
  7955. * Added in by nsstrunks
  7956. *------------------------------------------
  7957. */
  7958. int
  7959. atcommand_charkillableid(
  7960. const int fd, struct map_session_data* sd,
  7961. const char* command, const char* message)
  7962. {
  7963. struct map_session_data *pl_sd = NULL;
  7964. int cid=0;
  7965. int session_id=0;
  7966. if (!message || (cid = atoi(message)) == 0 || !*message)
  7967. return -1;
  7968. cid=atoi(message);
  7969. if ((session_id=charid2sessionid(cid))!=0)
  7970. {
  7971. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  7972. return -1;
  7973. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  7974. if(pl_sd->special_state.killable)
  7975. clif_displaymessage(fd, "The player is now killable");
  7976. else
  7977. clif_displaymessage(fd, "The player is no longer killable");
  7978. }
  7979. else
  7980. {
  7981. clif_displaymessage(fd,msg_table[3]);
  7982. }
  7983. //printf("Session_id = %d, cid = %d\n",session_id,cid);
  7984. return 0;
  7985. }
  7986. /*==========================================
  7987. * Make a player killable, by PID
  7988. * Original by Dino9021
  7989. * Added in by nsstrunks
  7990. *------------------------------------------
  7991. */
  7992. int
  7993. atcommand_charkillableid2(
  7994. const int fd, struct map_session_data* sd,
  7995. const char* command, const char* message)
  7996. {
  7997. struct map_session_data *pl_sd = NULL;
  7998. int aid=0;
  7999. int session_id=0;
  8000. if (!message || (aid = atoi(message)) == 0 || !*message)
  8001. return -1;
  8002. aid=atoi(message);
  8003. if ((session_id=accountid2sessionid(aid))!=0)
  8004. {
  8005. if((pl_sd= (struct map_session_data *) session[session_id]->session_data) == NULL)
  8006. return -1;
  8007. pl_sd->special_state.killable = !pl_sd->special_state.killable;
  8008. if(pl_sd->special_state.killable)
  8009. clif_displaymessage(fd, "The player is now killable");
  8010. else
  8011. clif_displaymessage(fd, "The player is no longer killable");
  8012. }
  8013. else
  8014. {
  8015. clif_displaymessage(fd,msg_table[3]);
  8016. }
  8017. //printf("Session_id = %d, aid = %d\n",session_id,aid);
  8018. return 0;
  8019. }
  8020. #ifndef TXT_ONLY /* Begin SQL-Only commands */
  8021. /*==========================================
  8022. * Mail System commands by [Valaris]
  8023. *------------------------------------------
  8024. */
  8025. int atcommand_listmail(
  8026. const int fd, struct map_session_data* sd,
  8027. const char* command, const char* message)
  8028. {
  8029. if(!mail_server_enable)
  8030. return 0;
  8031. nullpo_retr(-1, sd);
  8032. if(strlen(command)==12)
  8033. mail_check(sd,3);
  8034. else if(strlen(command)==9)
  8035. mail_check(sd,2);
  8036. else
  8037. mail_check(sd,1);
  8038. return 0;
  8039. }
  8040. int atcommand_readmail(
  8041. const int fd, struct map_session_data* sd,
  8042. const char* command, const char* message)
  8043. {
  8044. int index;
  8045. if(!mail_server_enable)
  8046. return 0;
  8047. nullpo_retr(-1, sd);
  8048. if (!message || !*message) {
  8049. clif_displaymessage(sd->fd,"You must specify a message number.");
  8050. return 0;
  8051. }
  8052. index = atoi(message);
  8053. if (index < 1) {
  8054. clif_displaymessage(sd->fd,"Message number cannot be negative or zero.");
  8055. return 0;
  8056. }
  8057. if(strlen(command)==11)
  8058. mail_delete(sd,index);
  8059. else
  8060. mail_read(sd,index);
  8061. return 0;
  8062. }
  8063. int atcommand_sendmail(
  8064. const int fd, struct map_session_data* sd,
  8065. const char* command, const char* message)
  8066. {
  8067. char name[NAME_LENGTH],text[80];
  8068. if(!mail_server_enable)
  8069. return 0;
  8070. nullpo_retr(-1, sd);
  8071. if (!message || !*message) {
  8072. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8073. return 0;
  8074. }
  8075. if ((sscanf(message, "\"%23[^\"]\" %79[^\n]", name, text) < 2) &&
  8076. (sscanf(message, "%23s %79[^\n]", name, text) < 2)) {
  8077. clif_displaymessage(sd->fd,"You must specify a recipient and a message.");
  8078. return 0;
  8079. }
  8080. if(strlen(command)==17)
  8081. mail_send(sd,name,text,1);
  8082. else
  8083. mail_send(sd,name,text,0);
  8084. return 0;
  8085. }
  8086. /*==========================================
  8087. * Refresh online command for SQL [Valaris]
  8088. * Will refresh and check online column of
  8089. * players and set correctly.
  8090. *------------------------------------------
  8091. */
  8092. int atcommand_refreshonline(
  8093. const int fd, struct map_session_data* sd,
  8094. const char* command, const char* message)
  8095. {
  8096. send_users_tochar(-1, gettick(), 0, 0);
  8097. return 0;
  8098. }
  8099. #endif /* end sql only */
  8100. /*==========================================
  8101. * Show Monster DB Info v 1.0
  8102. * originally by [Lupus] eAthena
  8103. *------------------------------------------
  8104. */
  8105. int atcommand_mobinfo(
  8106. const int fd, struct map_session_data* sd,
  8107. const char* command, const char* message)
  8108. {
  8109. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  8110. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  8111. unsigned char melement[11][8] = {"None", "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  8112. char atcmd_output2[200];
  8113. struct item_data *item_data;
  8114. struct mob_db *mob, *mob_array[MAX_SEARCH];
  8115. int mob_id, count;
  8116. int i, j, k;
  8117. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8118. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  8119. if (!message || !*message) {
  8120. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  8121. return -1;
  8122. }
  8123. // If monster identifier/name argument is a name
  8124. if ((mob_id = mobdb_checkid(atoi(message))))
  8125. {
  8126. mob_array[0] = mob_db(mob_id);
  8127. count = 1;
  8128. } else
  8129. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  8130. if (!count) {
  8131. clif_displaymessage(fd, msg_table[40]); // Invalid monster ID or name.
  8132. return -1;
  8133. }
  8134. if (count > MAX_SEARCH) {
  8135. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8136. clif_displaymessage(fd, atcmd_output);
  8137. count = MAX_SEARCH;
  8138. }
  8139. for (k = 0; k < count; k++) {
  8140. mob = mob_array[k];
  8141. // stats
  8142. if (mob->mexp)
  8143. sprintf(atcmd_output, "MVP Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8144. else
  8145. sprintf(atcmd_output, "Monster: '%s'/'%s' (%d)", mob->name, mob->jname, mob_id);
  8146. clif_displaymessage(fd, atcmd_output);
  8147. 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);
  8148. clif_displaymessage(fd, atcmd_output);
  8149. 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);
  8150. clif_displaymessage(fd, atcmd_output);
  8151. if (mob->element < 20) {
  8152. //Element - None, Level 0
  8153. i = 0;
  8154. j = 0;
  8155. } else {
  8156. i = mob->element % 20 + 1;
  8157. j = mob->element / 20;
  8158. }
  8159. 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);
  8160. clif_displaymessage(fd, atcmd_output);
  8161. // drops
  8162. clif_displaymessage(fd, " Drops:");
  8163. strcpy(atcmd_output, " ");
  8164. j = 0;
  8165. for (i = 0; i < 10; i++) {
  8166. if (mob->dropitem[i].nameid <= 0 || (item_data = itemdb_search(mob->dropitem[i].nameid)) == NULL)
  8167. continue;
  8168. if (mob->dropitem[i].p > 0) {
  8169. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->dropitem[i].p / 100);
  8170. strcat(atcmd_output, atcmd_output2);
  8171. if (++j % 3 == 0) {
  8172. clif_displaymessage(fd, atcmd_output);
  8173. strcpy(atcmd_output, " ");
  8174. }
  8175. }
  8176. }
  8177. if (j == 0)
  8178. clif_displaymessage(fd, "This monster has no drops.");
  8179. else if (j % 3 != 0)
  8180. clif_displaymessage(fd, atcmd_output);
  8181. // mvp
  8182. if (mob->mexp) {
  8183. sprintf(atcmd_output, " MVP Bonus EXP:%d %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  8184. clif_displaymessage(fd, atcmd_output);
  8185. strcpy(atcmd_output, " MVP Items:");
  8186. j = 0;
  8187. for (i = 0; i < 3; i++) {
  8188. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_search(mob->mvpitem[i].nameid)) == NULL)
  8189. continue;
  8190. if (mob->mvpitem[i].p > 0) {
  8191. j++;
  8192. if (j == 1)
  8193. sprintf(atcmd_output2, " %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8194. else
  8195. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->name, (float)mob->mvpitem[i].p / 100);
  8196. strcat(atcmd_output, atcmd_output2);
  8197. }
  8198. }
  8199. if (j == 0)
  8200. clif_displaymessage(fd, "This monster has no MVP prizes.");
  8201. else
  8202. clif_displaymessage(fd, atcmd_output);
  8203. }
  8204. }
  8205. return 0;
  8206. }
  8207. /*==========================================
  8208. * Show Items DB Info v 1.0
  8209. * originally by [Lupus] eAthena
  8210. *------------------------------------------
  8211. */
  8212. int atcommand_iteminfo(
  8213. const int fd, struct map_session_data* sd,
  8214. const char* command, const char* message)
  8215. {
  8216. char *itype[12] = {"Potion/Food", "BUG!", "Usable", "Etc", "Weapon", "Protection", "Card", "Egg", "Pet Acessory", "BUG!", "Arrow"};
  8217. //, "Lure/Scroll"}; No need, type 11 items are converted to type 2 upon loading [Skotlex]
  8218. struct item_data *item_data, *item_array[MAX_SEARCH];
  8219. int i, item_id=0, count = 1;
  8220. if (!message || !*message) {
  8221. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @iteminfo <item_name_or_ID>).");
  8222. return -1;
  8223. }
  8224. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8225. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8226. if (!count) {
  8227. clif_displaymessage(fd, "Item not found.");
  8228. return -1;
  8229. }
  8230. if (count > MAX_SEARCH) {
  8231. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8232. clif_displaymessage(fd, atcmd_output);
  8233. count = MAX_SEARCH;
  8234. }
  8235. for (i = 0; i < count; i++) {
  8236. item_data = item_array[i];
  8237. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  8238. item_data->name,item_data->jname,item_data->slot,item_id,
  8239. item_data->type < 12 ? itype[item_data->type] : "BUG!",
  8240. (item_data->script==NULL)? "None" : "With script"
  8241. );
  8242. clif_displaymessage(fd, atcmd_output);
  8243. 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 );
  8244. clif_displaymessage(fd, atcmd_output);
  8245. if (item_data->maxchance == 10000)
  8246. strcpy(atcmd_output, " - Available in the shops only");
  8247. else if (item_data->maxchance)
  8248. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  8249. else
  8250. strcpy(atcmd_output, " - Monsters don't drop this item");
  8251. clif_displaymessage(fd, atcmd_output);
  8252. }
  8253. return 0;
  8254. }
  8255. /*==========================================
  8256. * Show who drops the item.
  8257. *------------------------------------------
  8258. */
  8259. int atcommand_whodrops(
  8260. const int fd, struct map_session_data* sd,
  8261. const char* command, const char* message)
  8262. {
  8263. struct item_data *item_data, *item_array[MAX_SEARCH];
  8264. int i,j, count = 1;
  8265. if (!message || !*message) {
  8266. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item_name_or_ID>).");
  8267. return -1;
  8268. }
  8269. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  8270. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  8271. if (!count) {
  8272. clif_displaymessage(fd, "Item not found.");
  8273. return -1;
  8274. }
  8275. if (count > MAX_SEARCH) {
  8276. sprintf(atcmd_output, msg_table[269], MAX_SEARCH, count);
  8277. clif_displaymessage(fd, atcmd_output);
  8278. count = MAX_SEARCH;
  8279. }
  8280. for (i = 0; i < count; i++) {
  8281. item_data = item_array[i];
  8282. sprintf(atcmd_output, "Item: '%s'[%d]",
  8283. item_data->jname,item_data->slot);
  8284. clif_displaymessage(fd, atcmd_output);
  8285. if (item_data->mob[0].chance == 0) {
  8286. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  8287. clif_displaymessage(fd, atcmd_output);
  8288. } else {
  8289. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  8290. clif_displaymessage(fd, atcmd_output);
  8291. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  8292. {
  8293. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  8294. clif_displaymessage(fd, atcmd_output);
  8295. }
  8296. }
  8297. }
  8298. return 0;
  8299. }
  8300. /*==========================================
  8301. * @adopt by [Veider]
  8302. *
  8303. * adopt a novice
  8304. *------------------------------------------
  8305. */
  8306. int
  8307. atcommand_adopt(const int fd, struct map_session_data* sd,
  8308. const char* command, const char* message)
  8309. {
  8310. struct map_session_data *pl_sd1 = NULL;
  8311. struct map_session_data *pl_sd2 = NULL;
  8312. struct map_session_data *pl_sd3 = NULL;
  8313. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  8314. nullpo_retr(-1, sd);
  8315. if (!message || !*message)
  8316. return -1;
  8317. if (sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) != 3) {
  8318. clif_displaymessage(fd, "usage: @adopt <player1>,<player2>,<player3>.");
  8319. return -1;
  8320. }
  8321. if (battle_config.etc_log)
  8322. printf("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  8323. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  8324. sprintf(player2, "Cannot find player %s online", player1);
  8325. clif_displaymessage(fd, player2);
  8326. return -1;
  8327. }
  8328. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  8329. sprintf(player1, "Cannot find player %s online", player2);
  8330. clif_displaymessage(fd, player1);
  8331. return -1;
  8332. }
  8333. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  8334. sprintf(player1, "Cannot find player %s online", player3);
  8335. clif_displaymessage(fd, player1);
  8336. return -1;
  8337. }
  8338. if((pl_sd1->status.base_level < 70) || (pl_sd2->status.base_level < 70)){
  8339. clif_displaymessage(fd, "They are too young to be parents!");
  8340. return -1;
  8341. }
  8342. if (pc_adoption(pl_sd1, pl_sd2, pl_sd3) == 0) {
  8343. clif_displaymessage(fd, "They are family.. wish them luck");
  8344. return 0;
  8345. }
  8346. else
  8347. return -1;
  8348. }
  8349. int atcommand_version(
  8350. const int fd, struct map_session_data* sd,
  8351. const char* command, const char* message)
  8352. {
  8353. const char * revision;
  8354. if ((revision = get_svn_revision()) != 0) {
  8355. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  8356. clif_displaymessage(fd,atcmd_output);
  8357. } else
  8358. clif_displaymessage(fd,"Cannot determine SVN revision");
  8359. return 0;
  8360. }
  8361. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  8362. {
  8363. int time, id;
  8364. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  8365. if (pl_sd == NULL)
  8366. return 0;
  8367. id = va_arg(ap, int);
  8368. time = va_arg(ap, int);
  8369. if (id != bl->id && !pc_isGM(pl_sd)) {
  8370. pl_sd->status.manner -= time;
  8371. if (pl_sd->status.manner < 0)
  8372. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  8373. else if (pl_sd->sc.count && pl_sd->sc.data[SC_NOCHAT].timer != -1)
  8374. status_change_end(&pl_sd->bl, SC_NOCHAT, -1);
  8375. }
  8376. return 0;
  8377. }
  8378. /*==========================================
  8379. * @mutearea by MouseJstr
  8380. *------------------------------------------
  8381. */
  8382. int atcommand_mutearea(
  8383. const int fd, struct map_session_data* sd,
  8384. const char* command, const char* message)
  8385. {
  8386. int time;
  8387. nullpo_retr(0, sd);
  8388. if(!battle_config.muting_players) {
  8389. clif_displaymessage(fd, "Please enable the muting system before using it.");
  8390. return 0;
  8391. }
  8392. time = atoi(message);
  8393. if (!time)
  8394. time = 15; // 15 minutes default
  8395. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  8396. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  8397. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  8398. return 0;
  8399. }
  8400. static int atcommand_shuffle_sub(struct block_list *bl,va_list ap)
  8401. {
  8402. struct map_session_data *pl_sd = (struct map_session_data *) bl;
  8403. if (bl == NULL)
  8404. return 0;
  8405. if (!pc_isGM(pl_sd))
  8406. pc_setpos(pl_sd, pl_sd->mapindex, rand() % 399 + 1, rand() % 399 + 1, 3);
  8407. return 0;
  8408. }
  8409. /*==========================================
  8410. * @shuffle by MouseJstr
  8411. *------------------------------------------
  8412. */
  8413. int atcommand_shuffle(
  8414. const int fd, struct map_session_data* sd,
  8415. const char* command, const char* message)
  8416. {
  8417. nullpo_retr(0, sd);
  8418. if (strcmp(message, "area")== 0) {
  8419. map_foreachinarea(atcommand_shuffle_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);
  8422. } else if (strcmp(message, "map")== 0) {
  8423. map_foreachinmap(atcommand_shuffle_sub,sd->bl.m, BL_PC);
  8424. } else if (strcmp(message, "world") == 0) {
  8425. struct map_session_data **pl_allsd;
  8426. int i, users;
  8427. pl_allsd = map_getallusers(&users);
  8428. for (i = 0; i < users; i++)
  8429. atcommand_shuffle_sub(&pl_allsd[i]->bl, 0);
  8430. } else
  8431. clif_displaymessage(fd, "options are area, map, or world");
  8432. return 0;
  8433. }
  8434. int atcommand_rates(
  8435. const int fd, struct map_session_data* sd,
  8436. const char* command, const char* message)
  8437. {
  8438. char buf[255];
  8439. nullpo_retr(0, sd);
  8440. sprintf(buf, "Experience rates: Base %.1fx / Job %.1fx",
  8441. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  8442. clif_displaymessage(fd, buf);
  8443. return 0;
  8444. }
  8445. /*==========================================
  8446. * @me by lordalfa
  8447. * => Displays the OUTPUT string on top of
  8448. * the Visible players Heads.
  8449. *------------------------------------------
  8450. */
  8451. int atcommand_me(
  8452. const int fd, struct map_session_data* sd,
  8453. const char* command, const char* message)
  8454. {
  8455. char tempmes[200];
  8456. nullpo_retr(-1, sd);
  8457. memset(tempmes, '\0', sizeof(tempmes));
  8458. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8459. if (!message || !*message) {
  8460. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  8461. return -1;
  8462. }
  8463. sscanf(message, "%199[^\n]", tempmes);
  8464. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes);
  8465. clif_disp_overhead(sd, atcmd_output);
  8466. return 0;
  8467. }
  8468. /*==========================================
  8469. * @size
  8470. * => Resize your character sprite. [Valaris]
  8471. *------------------------------------------
  8472. */
  8473. int atcommand_size(
  8474. const int fd, struct map_session_data* sd,
  8475. const char* command, const char* message)
  8476. {
  8477. int size=0;
  8478. nullpo_retr(-1, sd);
  8479. if (!message || !*message)
  8480. return -1;
  8481. if (sscanf(message,"%d", &size) < 1)
  8482. return -1;
  8483. if(sd->state.size) {
  8484. sd->state.size=0;
  8485. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8486. }
  8487. if(size==1) {
  8488. sd->state.size=1;
  8489. clif_specialeffect(&sd->bl,420,0);
  8490. } else if(size==2) {
  8491. sd->state.size=2;
  8492. clif_specialeffect(&sd->bl,422,0);
  8493. }
  8494. return 0;
  8495. }
  8496. /*==========================================
  8497. * @monsterignore
  8498. * => Makes monsters ignore you. [Valaris]
  8499. *------------------------------------------
  8500. */
  8501. int atcommand_monsterignore(
  8502. const int fd, struct map_session_data* sd,
  8503. const char* command, const char* message)
  8504. {
  8505. nullpo_retr(-1, sd);
  8506. if (!sd->state.monster_ignore) {
  8507. sd->state.monster_ignore = 1;
  8508. clif_displaymessage(sd->fd, "Monsters will now ignore you.");
  8509. } else {
  8510. sd->state.monster_ignore = 0;
  8511. clif_displaymessage(sd->fd, "Monsters are no longer ignoring you.");
  8512. }
  8513. return 0;
  8514. }
  8515. /*==========================================
  8516. * @fakename
  8517. * => Gives your character a fake name. [Valaris]
  8518. *------------------------------------------
  8519. */
  8520. int atcommand_fakename(
  8521. const int fd, struct map_session_data* sd,
  8522. const char* command, const char* message)
  8523. {
  8524. char name[NAME_LENGTH];
  8525. nullpo_retr(-1, sd);
  8526. if((!message || !*message) && strlen(sd->fakename) > 1) {
  8527. sd->fakename[0]='\0';
  8528. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, 3);
  8529. clif_displaymessage(sd->fd,"Returned to real name.");
  8530. return 0;
  8531. }
  8532. if (!message || !*message) {
  8533. clif_displaymessage(sd->fd,"You must enter a name.");
  8534. return 0;
  8535. }
  8536. if (sscanf(message, "%23[^\n]", name) < 1) {
  8537. return 0;
  8538. }
  8539. if(strlen(name) < 2) {
  8540. clif_displaymessage(sd->fd,"Fake name must be at least two characters.");
  8541. return 0;
  8542. }
  8543. memcpy(sd->fakename,name,NAME_LENGTH-1);
  8544. clif_charnameack(0, &sd->bl);
  8545. clif_displaymessage(sd->fd,"Fake name enabled.");
  8546. return 0;
  8547. }
  8548. /*==========================================
  8549. * @mapflag [flagap name] [1|0|on|off] [map name] by Lupus
  8550. * => Shows information about the map flags [map name]
  8551. * Also set flags
  8552. *------------------------------------------
  8553. */
  8554. int atcommand_mapflag(
  8555. const int fd, struct map_session_data* sd,
  8556. const char* command, const char* message)
  8557. {
  8558. // WIP
  8559. return 0;
  8560. }
  8561. /*===================================
  8562. * Remove some messages
  8563. *-----------------------------------
  8564. */
  8565. int atcommand_showexp(
  8566. const int fd, struct map_session_data* sd,
  8567. const char* command, const char* message)
  8568. {
  8569. if (sd->state.showexp) {
  8570. sd->state.showexp = 0;
  8571. clif_displaymessage(fd, "Gained exp will not be shown.");
  8572. return 0;
  8573. }
  8574. sd->state.showexp = 1;
  8575. clif_displaymessage(fd, "Gained exp is now shown");
  8576. return 0;
  8577. }
  8578. int atcommand_showzeny(
  8579. const int fd, struct map_session_data* sd,
  8580. const char* command, const char* message)
  8581. {
  8582. if (sd->state.showzeny) {
  8583. sd->state.showzeny = 0;
  8584. clif_displaymessage(fd, "Gained zeny will not be shown.");
  8585. return 0;
  8586. }
  8587. sd->state.showzeny = 1;
  8588. clif_displaymessage(fd, "Gained zeny is now shown");
  8589. return 0;
  8590. }
  8591. int atcommand_showdelay(
  8592. const int fd, struct map_session_data* sd,
  8593. const char* command, const char* message)
  8594. {
  8595. if (sd->state.showdelay) {
  8596. sd->state.showdelay = 0;
  8597. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  8598. return 0;
  8599. }
  8600. sd->state.showdelay = 1;
  8601. clif_displaymessage(fd, "Skill delay failures are shown now.");
  8602. return 0;
  8603. }
  8604. /*==========================================
  8605. * Duel organizing functions [LuzZza]
  8606. *
  8607. * @duel [limit|nick] - create a duel
  8608. * @invite <nick> - invite player
  8609. * @accept - accept invitation
  8610. * @reject - reject invitation
  8611. * @leave - leave duel
  8612. *------------------------------------------
  8613. */
  8614. int atcommand_invite(
  8615. const int fd, struct map_session_data* sd,
  8616. const char* command, const char* message)
  8617. {
  8618. unsigned int did = sd->duel_group;
  8619. struct map_session_data *target_sd = map_nick2sd((char *)message);
  8620. if(did <= 0) {
  8621. // "Duel: @invite without @duel."
  8622. clif_displaymessage(fd, msg_txt(350));
  8623. return 0;
  8624. }
  8625. if(duel_list[did].max_players_limit > 0 &&
  8626. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  8627. // "Duel: Limit of players is reached."
  8628. clif_displaymessage(fd, msg_txt(351));
  8629. return 0;
  8630. }
  8631. if(target_sd == NULL) {
  8632. // "Duel: Player not found."
  8633. clif_displaymessage(fd, msg_txt(352));
  8634. return 0;
  8635. }
  8636. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8637. // "Duel: Player already in duel."
  8638. clif_displaymessage(fd, msg_txt(353));
  8639. return 0;
  8640. }
  8641. duel_invite(did, sd, target_sd);
  8642. // "Duel: Invitation has been sent."
  8643. clif_displaymessage(fd, msg_txt(354));
  8644. return 0;
  8645. }
  8646. int atcommand_duel(
  8647. const int fd, struct map_session_data* sd,
  8648. const char* command, const char* message)
  8649. {
  8650. char output[256];
  8651. unsigned int maxpl=0, newduel;
  8652. struct map_session_data *target_sd;
  8653. /* // Commnted because it can be disabled in at-comms conf.
  8654. if(!battle_config.duel_enable) {
  8655. clif_displaymessage(fd, "Duel: duel is disable.");
  8656. return 0;
  8657. }
  8658. */
  8659. if(sd->duel_group > 0) {
  8660. duel_showinfo(sd->duel_group, sd);
  8661. return 0;
  8662. }
  8663. if(sd->duel_invite > 0) {
  8664. // "Duel: @duel without @reject."
  8665. clif_displaymessage(fd, msg_txt(355));
  8666. return 0;
  8667. }
  8668. if(!duel_checktime(sd)) {
  8669. // "Duel: You can take part in duel only one time per %d minutes."
  8670. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8671. clif_displaymessage(fd, output);
  8672. return 0;
  8673. }
  8674. if(strlen(message) > 0) {
  8675. if(sscanf(message, "%d", &maxpl) >= 1) {
  8676. if(maxpl < 2 || maxpl > 65535) {
  8677. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  8678. return 0;
  8679. }
  8680. duel_create(sd, maxpl);
  8681. } else {
  8682. target_sd = map_nick2sd((char *)message);
  8683. if(target_sd != NULL) {
  8684. if((newduel = duel_create(sd, 2)) != -1) {
  8685. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  8686. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  8687. return 0;
  8688. }
  8689. duel_invite(newduel, sd, target_sd);
  8690. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  8691. }
  8692. } else {
  8693. // "Duel: Player not found."
  8694. clif_displaymessage(fd, msg_txt(352));
  8695. return 0;
  8696. }
  8697. }
  8698. } else
  8699. duel_create(sd, 0);
  8700. return 0;
  8701. }
  8702. int atcommand_leave(
  8703. const int fd, struct map_session_data* sd,
  8704. const char* command, const char* message)
  8705. {
  8706. if(sd->duel_group <= 0) {
  8707. // "Duel: @leave without @duel."
  8708. clif_displaymessage(fd, msg_txt(358));
  8709. return 0;
  8710. }
  8711. duel_leave(sd->duel_group, sd);
  8712. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  8713. return 0;
  8714. }
  8715. int atcommand_accept(
  8716. const int fd, struct map_session_data* sd,
  8717. const char* command, const char* message)
  8718. {
  8719. char output[256];
  8720. if(!duel_checktime(sd)) {
  8721. // "Duel: You can take part in duel only one time per %d minutes."
  8722. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  8723. clif_displaymessage(fd, output);
  8724. return 0;
  8725. }
  8726. if(sd->duel_invite <= 0) {
  8727. // "Duel: @accept without invititation."
  8728. clif_displaymessage(fd, msg_txt(360));
  8729. return 0;
  8730. }
  8731. duel_accept(sd->duel_invite, sd);
  8732. // "Duel: Invitation has been accepted."
  8733. clif_displaymessage(fd, msg_txt(361));
  8734. return 0;
  8735. }
  8736. int atcommand_reject(
  8737. const int fd, struct map_session_data* sd,
  8738. const char* command, const char* message)
  8739. {
  8740. if(sd->duel_invite <= 0) {
  8741. // "Duel: @reject without invititation."
  8742. clif_displaymessage(fd, msg_txt(362));
  8743. return 0;
  8744. }
  8745. duel_reject(sd->duel_invite, sd);
  8746. // "Duel: Invitation has been rejected."
  8747. clif_displaymessage(fd, msg_txt(363));
  8748. return 0;
  8749. }
  8750. /*===================================
  8751. * Away message (@away, @aw) [LuzZza]
  8752. *-----------------------------------
  8753. */
  8754. int atcommand_away(
  8755. const int fd, struct map_session_data* sd,
  8756. const char* command, const char* message)
  8757. {
  8758. if(strlen(message) > 0) {
  8759. if(strlen(message) > 128)
  8760. return -1;
  8761. strcpy(sd->away_message, message);
  8762. //"Away automessage has been activated."
  8763. clif_displaymessage(fd, msg_txt(546));
  8764. } else {
  8765. if(strlen(sd->away_message) > 0) {
  8766. sd->away_message[0] = 0;
  8767. //"Away automessage has been disabled."
  8768. clif_displaymessage(fd, msg_txt(547));
  8769. return 0;
  8770. }
  8771. //"Usage: @away,@aw <message>. Enter empty message for disable it."
  8772. clif_displaymessage(fd, msg_txt(548));
  8773. }
  8774. return 0;
  8775. }
  8776. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  8777. int atcommand_clone(
  8778. const int fd, struct map_session_data* sd,
  8779. const char* command, const char* message)
  8780. {
  8781. int x=0,y=0,flag=0,master=0,i=0;
  8782. struct map_session_data *pl_sd=NULL;
  8783. if (!message || !*message) {
  8784. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  8785. return 0;
  8786. }
  8787. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  8788. clif_displaymessage(fd, msg_txt(3));
  8789. return 0;
  8790. }
  8791. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  8792. clif_displaymessage(fd, msg_txt(126));
  8793. return 0;
  8794. }
  8795. if (strcmpi(command, "@clone") == 0)
  8796. flag = 1;
  8797. else if (strcmpi(command, "@slaveclone") == 0) {
  8798. flag = 2;
  8799. master = sd->bl.id;
  8800. if (battle_config.atc_slave_clone_limit
  8801. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  8802. clif_displaymessage(fd, msg_txt(127));
  8803. return 0;
  8804. }
  8805. }
  8806. do {
  8807. x = sd->bl.x + (rand() % 10 - 5);
  8808. y = sd->bl.y + (rand() % 10 - 5);
  8809. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  8810. if (i >= 10) {
  8811. x = sd->bl.x;
  8812. y = sd->bl.y;
  8813. }
  8814. if((x = mob_clone_spawn(pl_sd, (char*)mapindex_id2name(sd->mapindex), x, y, "", master, 0, flag?1:0, 0)) > 0) {
  8815. clif_displaymessage(fd, msg_txt(128+flag*2));
  8816. return 0;
  8817. }
  8818. clif_displaymessage(fd, msg_txt(129+flag*2));
  8819. return 0;
  8820. }
  8821. /*===================================
  8822. * Main chat [LuzZza]
  8823. * Usage: @main <on|off|message>
  8824. *-----------------------------------
  8825. */
  8826. int atcommand_main(
  8827. const int fd, struct map_session_data* sd,
  8828. const char* command, const char* message)
  8829. {
  8830. if(strlen(message) > 0) {
  8831. if(strcmpi(message, "on") == 0) {
  8832. if(!sd->state.mainchat) {
  8833. sd->state.mainchat = 1;
  8834. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8835. } else {
  8836. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  8837. }
  8838. } else if(strcmpi(message, "off") == 0) {
  8839. if(sd->state.mainchat) {
  8840. sd->state.mainchat = 0;
  8841. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  8842. } else {
  8843. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  8844. }
  8845. } else {
  8846. if(!sd->state.mainchat) {
  8847. sd->state.mainchat = 1;
  8848. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  8849. }
  8850. if (sd->sc.data[SC_NOCHAT].timer != -1) {
  8851. clif_displaymessage(fd, msg_txt(387));
  8852. return -1;
  8853. }
  8854. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  8855. // I use 0xFE000000 color for signalizing that this message is
  8856. // main chat message. 0xFE000000 is invalid color, same using
  8857. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  8858. intif_announce(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0);
  8859. }
  8860. } else {
  8861. if(sd->state.mainchat)
  8862. // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  8863. clif_displaymessage(fd, msg_txt(384));
  8864. else
  8865. // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  8866. clif_displaymessage(fd, msg_txt(385));
  8867. }
  8868. return 0;
  8869. }
  8870. void do_init_atcommand() {
  8871. users_db = db_alloc(__FILE__,__LINE__,DB_UINT,DB_OPT_BASE,sizeof(int));
  8872. duel_count = 0;
  8873. memset(&duel_list[0], 0, sizeof(duel_list));
  8874. return;
  8875. }
  8876. void do_final_atcommand() {
  8877. users_db->destroy(users_db,NULL);
  8878. }