atcommand.c 275 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "atcommand.h"
  14. #include "battle.h"
  15. #include "chat.h"
  16. #include "clif.h"
  17. #include "chrif.h"
  18. #include "duel.h"
  19. #include "intif.h"
  20. #include "itemdb.h"
  21. #include "log.h"
  22. #include "map.h"
  23. #include "pc.h"
  24. #include "status.h"
  25. #include "skill.h"
  26. #include "mob.h"
  27. #include "npc.h"
  28. #include "pet.h"
  29. #include "homunculus.h"
  30. #include "mercenary.h"
  31. #include "party.h"
  32. #include "guild.h"
  33. #include "script.h"
  34. #include "storage.h"
  35. #include "trade.h"
  36. #include "unit.h"
  37. #ifndef TXT_ONLY
  38. #include "mail.h"
  39. #endif
  40. #include <stdio.h>
  41. #include <stdlib.h>
  42. #include <string.h>
  43. #include <math.h>
  44. // extern variables
  45. char atcommand_symbol = '@'; // first char of the commands
  46. char charcommand_symbol = '#';
  47. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  48. // local declarations
  49. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  50. DBMap* atcommand_db = NULL;//name -> AtCommandInfo
  51. #define ATCOMMAND_LENGTH 50
  52. typedef struct AtCommandInfo {
  53. char command[ATCOMMAND_LENGTH];
  54. int level;
  55. int level2;
  56. AtCommandFunc func;
  57. } AtCommandInfo;
  58. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  59. ACMD_FUNC(commands);
  60. ACMD_FUNC(charcommands);
  61. /*=========================================
  62. * Generic variables
  63. *-----------------------------------------*/
  64. char atcmd_output[CHAT_SIZE_MAX];
  65. char atcmd_player_name[NAME_LENGTH];
  66. char atcmd_temp[100];
  67. // compare function for sorting high to lowest
  68. int hightolow_compare (const void * a, const void * b)
  69. {
  70. return ( *(int*)b - *(int*)a );
  71. }
  72. // compare function for sorting lowest to highest
  73. int lowtohigh_compare (const void * a, const void * b)
  74. {
  75. return ( *(int*)a - *(int*)b );
  76. }
  77. //-----------------------------------------------------------
  78. // Return the message string of the specified number by [Yor]
  79. //-----------------------------------------------------------
  80. const char* msg_txt(int msg_number)
  81. {
  82. if (msg_number >= 0 && msg_number < MAX_MSG &&
  83. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  84. return msg_table[msg_number];
  85. return "??";
  86. }
  87. //-----------------------------------------------------------
  88. // Returns Players title (from msg_athena.conf) [Lupus]
  89. //-----------------------------------------------------------
  90. static char* player_title_txt(int level)
  91. {
  92. const char* format;
  93. format = (level >= battle_config.title_lvl8) ? msg_txt(342)
  94. : (level >= battle_config.title_lvl7) ? msg_txt(341)
  95. : (level >= battle_config.title_lvl6) ? msg_txt(340)
  96. : (level >= battle_config.title_lvl5) ? msg_txt(339)
  97. : (level >= battle_config.title_lvl4) ? msg_txt(338)
  98. : (level >= battle_config.title_lvl3) ? msg_txt(337)
  99. : (level >= battle_config.title_lvl2) ? msg_txt(336)
  100. : (level >= battle_config.title_lvl1) ? msg_txt(335)
  101. : "";
  102. sprintf(atcmd_temp, format, level);
  103. return atcmd_temp;
  104. }
  105. /*==========================================
  106. * Read Message Data
  107. *------------------------------------------*/
  108. int msg_config_read(const char* cfgName)
  109. {
  110. int msg_number;
  111. char line[1024], w1[1024], w2[1024];
  112. FILE *fp;
  113. static int called = 1;
  114. if ((fp = fopen(cfgName, "r")) == NULL) {
  115. ShowError("Messages file not found: %s\n", cfgName);
  116. return 1;
  117. }
  118. if ((--called) == 0)
  119. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  120. while(fgets(line, sizeof(line), fp))
  121. {
  122. if (line[0] == '/' && line[1] == '/')
  123. continue;
  124. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  125. continue;
  126. if (strcmpi(w1, "import") == 0)
  127. msg_config_read(w2);
  128. else
  129. {
  130. msg_number = atoi(w1);
  131. if (msg_number >= 0 && msg_number < MAX_MSG)
  132. {
  133. if (msg_table[msg_number] != NULL)
  134. aFree(msg_table[msg_number]);
  135. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  136. strcpy(msg_table[msg_number],w2);
  137. }
  138. }
  139. }
  140. fclose(fp);
  141. return 0;
  142. }
  143. /*==========================================
  144. * Cleanup Message Data
  145. *------------------------------------------*/
  146. void do_final_msg(void)
  147. {
  148. int i;
  149. for (i = 0; i < MAX_MSG; i++)
  150. aFree(msg_table[i]);
  151. }
  152. /*==========================================
  153. * @send (used for testing packet sends from the client)
  154. *------------------------------------------*/
  155. ACMD_FUNC(send)
  156. {
  157. int len=0,off,end,type;
  158. long num;
  159. (void)command; // not used
  160. // read message type as hex number (without the 0x)
  161. if(!message || !*message ||
  162. !((sscanf(message, "len %x", &type)==1 && (len=1))
  163. || sscanf(message, "%x", &type)==1) )
  164. {
  165. clif_displaymessage(fd, "Usage:");
  166. clif_displaymessage(fd, " @send len <packet hex number>");
  167. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  168. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  169. return -1;
  170. }
  171. #define PARSE_ERROR(error,p) \
  172. {\
  173. clif_displaymessage(fd, (error));\
  174. sprintf(atcmd_output, ">%s", (p));\
  175. clif_displaymessage(fd, atcmd_output);\
  176. }
  177. //define PARSE_ERROR
  178. #define CHECK_EOS(p) \
  179. if(*(p) == 0){\
  180. clif_displaymessage(fd, "Unexpected end of string");\
  181. return -1;\
  182. }
  183. //define CHECK_EOS
  184. #define SKIP_VALUE(p) \
  185. {\
  186. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  187. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  188. }
  189. //define SKIP_VALUE
  190. #define GET_VALUE(p,num) \
  191. {\
  192. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  193. PARSE_ERROR("Invalid number in:",(p));\
  194. return -1;\
  195. }\
  196. }
  197. //define GET_VALUE
  198. if (type > 0 && type < MAX_PACKET_DB) {
  199. if(len)
  200. {// show packet length
  201. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  202. clif_displaymessage(fd, atcmd_output);
  203. return 0;
  204. }
  205. len=packet_db[sd->packet_ver][type].len;
  206. off=2;
  207. if(len == 0)
  208. {// unknown packet - ERROR
  209. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  210. clif_displaymessage(fd, atcmd_output);
  211. return -1;
  212. } else if(len == -1)
  213. {// dynamic packet
  214. len=SHRT_MAX-4; // maximum length
  215. off=4;
  216. }
  217. WFIFOHEAD(fd, len);
  218. WFIFOW(fd,0)=TOW(type);
  219. // parse packet contents
  220. SKIP_VALUE(message);
  221. while(*message != 0 && off < len){
  222. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  223. {// default (byte)
  224. GET_VALUE(message,num);
  225. WFIFOB(fd,off)=TOB(num);
  226. ++off;
  227. } else if(TOUPPER(*message) == 'B')
  228. {// byte
  229. ++message;
  230. GET_VALUE(message,num);
  231. WFIFOB(fd,off)=TOB(num);
  232. ++off;
  233. } else if(TOUPPER(*message) == 'W')
  234. {// word (2 bytes)
  235. ++message;
  236. GET_VALUE(message,num);
  237. WFIFOW(fd,off)=TOW(num);
  238. off+=2;
  239. } else if(TOUPPER(*message) == 'L')
  240. {// long word (4 bytes)
  241. ++message;
  242. GET_VALUE(message,num);
  243. WFIFOL(fd,off)=TOL(num);
  244. off+=4;
  245. } else if(TOUPPER(*message) == 'S')
  246. {// string - escapes are valid
  247. // get string length - num <= 0 means not fixed length (default)
  248. ++message;
  249. if(*message == '"'){
  250. num=0;
  251. } else {
  252. GET_VALUE(message,num);
  253. while(*message != '"')
  254. {// find start of string
  255. if(*message == 0 || ISSPACE(*message)){
  256. PARSE_ERROR("Not a string:",message);
  257. return -1;
  258. }
  259. ++message;
  260. }
  261. }
  262. // parse string
  263. ++message;
  264. CHECK_EOS(message);
  265. end=(num<=0? 0: min(off+((int)num),len));
  266. for(; *message != '"' && (off < end || end == 0); ++off){
  267. if(*message == '\\'){
  268. ++message;
  269. CHECK_EOS(message);
  270. switch(*message){
  271. case 'a': num=0x07; break; // Bell
  272. case 'b': num=0x08; break; // Backspace
  273. case 't': num=0x09; break; // Horizontal tab
  274. case 'n': num=0x0A; break; // Line feed
  275. case 'v': num=0x0B; break; // Vertical tab
  276. case 'f': num=0x0C; break; // Form feed
  277. case 'r': num=0x0D; break; // Carriage return
  278. case 'e': num=0x1B; break; // Escape
  279. default: num=*message; break;
  280. case 'x': // Hexadecimal
  281. {
  282. ++message;
  283. CHECK_EOS(message);
  284. if(!ISXDIGIT(*message)){
  285. PARSE_ERROR("Not a hexadecimal digit:",message);
  286. return -1;
  287. }
  288. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  289. if(ISXDIGIT(*message)){
  290. ++message;
  291. CHECK_EOS(message);
  292. num<<=8;
  293. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  294. }
  295. WFIFOB(fd,off)=TOB(num);
  296. ++message;
  297. CHECK_EOS(message);
  298. continue;
  299. }
  300. case '0':
  301. case '1':
  302. case '2':
  303. case '3':
  304. case '4':
  305. case '5':
  306. case '6':
  307. case '7': // Octal
  308. {
  309. num=*message-'0'; // 1st octal digit
  310. ++message;
  311. CHECK_EOS(message);
  312. if(ISDIGIT(*message) && *message < '8'){
  313. num<<=3;
  314. num+=*message-'0'; // 2nd octal digit
  315. ++message;
  316. CHECK_EOS(message);
  317. if(ISDIGIT(*message) && *message < '8'){
  318. num<<=3;
  319. num+=*message-'0'; // 3rd octal digit
  320. ++message;
  321. CHECK_EOS(message);
  322. }
  323. }
  324. WFIFOB(fd,off)=TOB(num);
  325. continue;
  326. }
  327. }
  328. } else
  329. num=*message;
  330. WFIFOB(fd,off)=TOB(num);
  331. ++message;
  332. CHECK_EOS(message);
  333. }//for
  334. while(*message != '"')
  335. {// ignore extra characters
  336. ++message;
  337. CHECK_EOS(message);
  338. }
  339. // terminate the string
  340. if(off < end)
  341. {// fill the rest with 0's
  342. memset(WFIFOP(fd,off),0,end-off);
  343. off=end;
  344. }
  345. } else
  346. {// unknown
  347. PARSE_ERROR("Unknown type of value in:",message);
  348. return -1;
  349. }
  350. SKIP_VALUE(message);
  351. }
  352. if(packet_db[sd->packet_ver][type].len == -1)
  353. {// send dynamic packet
  354. WFIFOW(fd,2)=TOW(off);
  355. WFIFOSET(fd,off);
  356. } else
  357. {// send static packet
  358. if(off < len)
  359. memset(WFIFOP(fd,off),0,len-off);
  360. WFIFOSET(fd,len);
  361. }
  362. } else {
  363. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  364. return -1;
  365. }
  366. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  367. clif_displaymessage(fd, atcmd_output);
  368. return 0;
  369. #undef PARSE_ERROR
  370. #undef CHECK_EOS
  371. #undef SKIP_VALUE
  372. #undef GET_VALUE
  373. }
  374. /*==========================================
  375. * @rura, @warp, @mapmove
  376. *------------------------------------------*/
  377. ACMD_FUNC(mapmove)
  378. {
  379. char map_name[MAP_NAME_LENGTH_EXT];
  380. unsigned short mapindex;
  381. short x = 0, y = 0;
  382. int m = -1;
  383. nullpo_retr(-1, sd);
  384. memset(map_name, '\0', sizeof(map_name));
  385. if (!message || !*message ||
  386. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  387. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  388. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  389. return -1;
  390. }
  391. mapindex = mapindex_name2id(map_name);
  392. if (mapindex)
  393. m = map_mapindex2mapid(mapindex);
  394. if (!mapindex) { // m < 0 means on different server! [Kevin]
  395. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  396. return -1;
  397. }
  398. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  399. { //This is to prevent the pc_setpos call from printing an error.
  400. clif_displaymessage(fd, msg_txt(2));
  401. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  402. x = y = 0; //Invalid cell, use random spot.
  403. }
  404. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  405. clif_displaymessage(fd, msg_txt(247));
  406. return -1;
  407. }
  408. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  409. clif_displaymessage(fd, msg_txt(248));
  410. return -1;
  411. }
  412. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  413. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  414. return -1;
  415. }
  416. clif_displaymessage(fd, msg_txt(0)); // Warped.
  417. return 0;
  418. }
  419. /*==========================================
  420. * Displays where a character is. Corrected version by Silent. [Skotlex]
  421. *------------------------------------------*/
  422. ACMD_FUNC(where)
  423. {
  424. struct map_session_data* pl_sd;
  425. nullpo_retr(-1, sd);
  426. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  427. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  428. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  429. return -1;
  430. }
  431. pl_sd = map_nick2sd(atcmd_player_name);
  432. if( pl_sd == NULL
  433. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  434. || (battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid))
  435. ) {
  436. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  437. return -1;
  438. }
  439. snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  440. clif_displaymessage(fd, atcmd_output);
  441. return 0;
  442. }
  443. /*==========================================
  444. *
  445. *------------------------------------------*/
  446. ACMD_FUNC(jumpto)
  447. {
  448. struct map_session_data *pl_sd = NULL;
  449. nullpo_retr(-1, sd);
  450. if (!message || !*message) {
  451. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  452. return -1;
  453. }
  454. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  455. {
  456. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  457. return -1;
  458. }
  459. if (pl_sd == sd)
  460. {
  461. clif_displaymessage(fd, "But you are already where you are...");
  462. return -1;
  463. }
  464. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  465. {
  466. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  467. return -1;
  468. }
  469. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  470. {
  471. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  472. return -1;
  473. }
  474. if( pc_isdead(sd) )
  475. {
  476. clif_displaymessage(fd, "You cannot use this command when dead.");
  477. return -1;
  478. }
  479. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  480. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  481. clif_displaymessage(fd, atcmd_output);
  482. return 0;
  483. }
  484. /*==========================================
  485. *
  486. *------------------------------------------*/
  487. ACMD_FUNC(jump)
  488. {
  489. short x = 0, y = 0;
  490. nullpo_retr(-1, sd);
  491. memset(atcmd_output, '\0', sizeof(atcmd_output));
  492. sscanf(message, "%hd %hd", &x, &y);
  493. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  494. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  495. return -1;
  496. }
  497. if( pc_isdead(sd) )
  498. {
  499. clif_displaymessage(fd, "You cannot use this command when dead.");
  500. return -1;
  501. }
  502. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  503. { //This is to prevent the pc_setpos call from printing an error.
  504. clif_displaymessage(fd, msg_txt(2));
  505. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  506. x = y = 0; //Invalid cell, use random spot.
  507. }
  508. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  509. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  510. clif_displaymessage(fd, atcmd_output);
  511. return 0;
  512. }
  513. /*==========================================
  514. * @who3 = Player name, his location
  515. *------------------------------------------*/
  516. ACMD_FUNC(who3)
  517. {
  518. char temp0[100];
  519. struct map_session_data *pl_sd;
  520. struct s_mapiterator* iter;
  521. int j, count;
  522. int pl_GM_level, GM_level;
  523. char match_text[100];
  524. char player_name[NAME_LENGTH];
  525. nullpo_retr(-1, sd);
  526. memset(atcmd_output, '\0', sizeof(atcmd_output));
  527. memset(match_text, '\0', sizeof(match_text));
  528. memset(player_name, '\0', sizeof(player_name));
  529. if (sscanf(message, "%99[^\n]", match_text) < 1)
  530. strcpy(match_text, "");
  531. for (j = 0; match_text[j]; j++)
  532. match_text[j] = TOLOWER(match_text[j]);
  533. count = 0;
  534. GM_level = pc_isGM(sd);
  535. iter = mapit_getallusers();
  536. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  537. {
  538. pl_GM_level = pc_isGM(pl_sd);
  539. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  540. {// you can look only lower or same level
  541. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  542. for (j = 0; player_name[j]; j++)
  543. player_name[j] = TOLOWER(player_name[j]);
  544. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  545. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  546. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  547. } else {
  548. atcmd_output[0]=0;
  549. }
  550. //Player name
  551. sprintf(temp0, msg_txt(343), pl_sd->status.name);
  552. strcat(atcmd_output,temp0);
  553. //Player title, if exists
  554. if (pl_GM_level > 0) {
  555. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  556. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  557. strcat(atcmd_output,temp0);
  558. }
  559. //Players Location: map x y
  560. sprintf(temp0, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  561. strcat(atcmd_output,temp0);
  562. clif_displaymessage(fd, atcmd_output);
  563. count++;
  564. }
  565. }
  566. }
  567. mapit_free(iter);
  568. if (count == 0)
  569. clif_displaymessage(fd, msg_txt(28)); // No player found.
  570. else if (count == 1)
  571. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  572. else {
  573. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  574. clif_displaymessage(fd, atcmd_output);
  575. }
  576. return 0;
  577. }
  578. /*==========================================
  579. * Player name, BLevel, Job,
  580. *------------------------------------------*/
  581. ACMD_FUNC(who2)
  582. {
  583. char temp0[100];
  584. struct map_session_data *pl_sd;
  585. struct s_mapiterator* iter;
  586. int j, count;
  587. int pl_GM_level, GM_level;
  588. char match_text[100];
  589. char player_name[NAME_LENGTH];
  590. nullpo_retr(-1, sd);
  591. memset(atcmd_output, '\0', sizeof(atcmd_output));
  592. memset(match_text, '\0', sizeof(match_text));
  593. memset(player_name, '\0', sizeof(player_name));
  594. if (sscanf(message, "%99[^\n]", match_text) < 1)
  595. strcpy(match_text, "");
  596. for (j = 0; match_text[j]; j++)
  597. match_text[j] = TOLOWER(match_text[j]);
  598. count = 0;
  599. GM_level = pc_isGM(sd);
  600. iter = mapit_getallusers();
  601. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  602. {
  603. pl_GM_level = pc_isGM(pl_sd);
  604. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  605. {// you can look only lower or same level
  606. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  607. for (j = 0; player_name[j]; j++)
  608. player_name[j] = TOLOWER(player_name[j]);
  609. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  610. //Players Name
  611. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  612. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  613. //Player title, if exists
  614. if (pl_GM_level > 0) {
  615. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  616. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  617. strcat(atcmd_output,temp0);
  618. }
  619. //Players Base Level / Job name
  620. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  621. sprintf(temp0, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  622. strcat(atcmd_output,temp0);
  623. clif_displaymessage(fd, atcmd_output);
  624. count++;
  625. }
  626. }
  627. }
  628. mapit_free(iter);
  629. if (count == 0)
  630. clif_displaymessage(fd, msg_txt(28)); // No player found.
  631. else if (count == 1)
  632. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  633. else {
  634. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  635. clif_displaymessage(fd, atcmd_output);
  636. }
  637. return 0;
  638. }
  639. /*==========================================
  640. * Player name, Playrs Party / Guild name
  641. *------------------------------------------*/
  642. ACMD_FUNC(who)
  643. {
  644. char temp0[100];
  645. struct map_session_data *pl_sd;
  646. struct s_mapiterator* iter;
  647. int j, count;
  648. int pl_GM_level, GM_level;
  649. char match_text[100];
  650. char player_name[NAME_LENGTH];
  651. struct guild *g;
  652. struct party_data *p;
  653. nullpo_retr(-1, sd);
  654. memset(temp0, '\0', sizeof(temp0));
  655. memset(atcmd_output, '\0', sizeof(atcmd_output));
  656. memset(match_text, '\0', sizeof(match_text));
  657. memset(player_name, '\0', sizeof(player_name));
  658. if (sscanf(message, "%99[^\n]", match_text) < 1)
  659. strcpy(match_text, "");
  660. for (j = 0; match_text[j]; j++)
  661. match_text[j] = TOLOWER(match_text[j]);
  662. count = 0;
  663. GM_level = pc_isGM(sd);
  664. iter = mapit_getallusers();
  665. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  666. {
  667. pl_GM_level = pc_isGM(pl_sd);
  668. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  669. {// you can look only lower or same level
  670. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  671. for (j = 0; player_name[j]; j++)
  672. player_name[j] = TOLOWER(player_name[j]);
  673. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  674. g = guild_search(pl_sd->status.guild_id);
  675. p = party_search(pl_sd->status.party_id);
  676. //Players Name
  677. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  678. //Player title, if exists
  679. if (pl_GM_level > 0) {
  680. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  681. strcat(atcmd_output,temp0);
  682. }
  683. //Players Party if exists
  684. if (p != NULL) {
  685. //sprintf(temp0," | Party: '%s'", p->name);
  686. sprintf(temp0, msg_txt(345), p->party.name);
  687. strcat(atcmd_output,temp0);
  688. }
  689. //Players Guild if exists
  690. if (g != NULL) {
  691. //sprintf(temp0," | Guild: '%s'", g->name);
  692. sprintf(temp0, msg_txt(346), g->name);
  693. strcat(atcmd_output,temp0);
  694. }
  695. clif_displaymessage(fd, atcmd_output);
  696. count++;
  697. }
  698. }
  699. }
  700. mapit_free(iter);
  701. if (count == 0)
  702. clif_displaymessage(fd, msg_txt(28)); // No player found.
  703. else if (count == 1)
  704. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  705. else {
  706. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  707. clif_displaymessage(fd, atcmd_output);
  708. }
  709. return 0;
  710. }
  711. /*==========================================
  712. *
  713. *------------------------------------------*/
  714. ACMD_FUNC(whomap3)
  715. {
  716. struct map_session_data *pl_sd;
  717. struct s_mapiterator* iter;
  718. int count;
  719. int pl_GM_level, GM_level;
  720. int map_id;
  721. char map_name[MAP_NAME_LENGTH_EXT];
  722. memset(atcmd_output, '\0', sizeof(atcmd_output));
  723. memset(map_name, '\0', sizeof(map_name));
  724. if (!message || !*message)
  725. map_id = sd->bl.m;
  726. else {
  727. sscanf(message, "%15s", map_name);
  728. if ((map_id = map_mapname2mapid(map_name)) < 0)
  729. map_id = sd->bl.m;
  730. }
  731. count = 0;
  732. GM_level = pc_isGM(sd);
  733. iter = mapit_getallusers();
  734. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  735. {
  736. pl_GM_level = pc_isGM(pl_sd);
  737. if( pl_sd->bl.m != map_id )
  738. continue;
  739. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  740. continue;
  741. if (pl_GM_level > 0)
  742. 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);
  743. else
  744. 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);
  745. clif_displaymessage(fd, atcmd_output);
  746. count++;
  747. }
  748. mapit_free(iter);
  749. if (count == 0)
  750. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  751. else if (count == 1)
  752. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  753. else {
  754. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  755. }
  756. clif_displaymessage(fd, atcmd_output);
  757. return 0;
  758. }
  759. /*==========================================
  760. *
  761. *------------------------------------------*/
  762. ACMD_FUNC(whomap2)
  763. {
  764. struct map_session_data *pl_sd;
  765. struct s_mapiterator* iter;
  766. int count;
  767. int pl_GM_level, GM_level;
  768. int map_id = 0;
  769. char map_name[MAP_NAME_LENGTH_EXT];
  770. nullpo_retr(-1, sd);
  771. memset(atcmd_output, '\0', sizeof(atcmd_output));
  772. memset(map_name, '\0', sizeof(map_name));
  773. if (!message || !*message)
  774. map_id = sd->bl.m;
  775. else {
  776. sscanf(message, "%15s", map_name);
  777. if ((map_id = map_mapname2mapid(map_name)) < 0)
  778. map_id = sd->bl.m;
  779. }
  780. count = 0;
  781. GM_level = pc_isGM(sd);
  782. iter = mapit_getallusers();
  783. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  784. {
  785. pl_GM_level = pc_isGM(pl_sd);
  786. if( pl_sd->bl.m != map_id )
  787. continue;
  788. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  789. continue;
  790. if (pl_GM_level > 0)
  791. 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);
  792. else
  793. 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);
  794. clif_displaymessage(fd, atcmd_output);
  795. count++;
  796. }
  797. mapit_free(iter);
  798. if (count == 0)
  799. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  800. else if (count == 1)
  801. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  802. else {
  803. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  804. }
  805. clif_displaymessage(fd, atcmd_output);
  806. return 0;
  807. }
  808. /*==========================================
  809. *
  810. *------------------------------------------*/
  811. ACMD_FUNC(whomap)
  812. {
  813. char temp0[100];
  814. char temp1[100];
  815. struct map_session_data *pl_sd;
  816. struct s_mapiterator* iter;
  817. int count;
  818. int pl_GM_level, GM_level;
  819. int map_id = 0;
  820. char map_name[MAP_NAME_LENGTH_EXT];
  821. struct guild *g;
  822. struct party_data *p;
  823. nullpo_retr(-1, sd);
  824. memset(temp0, '\0', sizeof(temp0));
  825. memset(temp1, '\0', sizeof(temp1));
  826. memset(atcmd_output, '\0', sizeof(atcmd_output));
  827. memset(map_name, '\0', sizeof(map_name));
  828. if (!message || !*message)
  829. map_id = sd->bl.m;
  830. else {
  831. sscanf(message, "%15s", map_name);
  832. if ((map_id = map_mapname2mapid(map_name)) < 0)
  833. map_id = sd->bl.m;
  834. }
  835. count = 0;
  836. GM_level = pc_isGM(sd);
  837. iter = mapit_getallusers();
  838. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  839. {
  840. pl_GM_level = pc_isGM(pl_sd);
  841. if( pl_sd->bl.m != map_id )
  842. continue;
  843. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  844. continue;
  845. g = guild_search(pl_sd->status.guild_id);
  846. if (g == NULL)
  847. sprintf(temp1, "None");
  848. else
  849. sprintf(temp1, "%s", g->name);
  850. p = party_search(pl_sd->status.party_id);
  851. if (p == NULL)
  852. sprintf(temp0, "None");
  853. else
  854. sprintf(temp0, "%s", p->party.name);
  855. if (pl_GM_level > 0)
  856. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  857. else
  858. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  859. clif_displaymessage(fd, atcmd_output);
  860. count++;
  861. }
  862. mapit_free(iter);
  863. if (count == 0)
  864. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  865. else if (count == 1)
  866. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  867. else {
  868. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  869. }
  870. clif_displaymessage(fd, atcmd_output);
  871. return 0;
  872. }
  873. /*==========================================
  874. *
  875. *------------------------------------------*/
  876. ACMD_FUNC(whogm)
  877. {
  878. struct map_session_data* pl_sd;
  879. struct s_mapiterator* iter;
  880. int j, count;
  881. int pl_GM_level, GM_level;
  882. char match_text[CHAT_SIZE_MAX];
  883. char player_name[NAME_LENGTH];
  884. struct guild *g;
  885. struct party_data *p;
  886. nullpo_retr(-1, sd);
  887. memset(atcmd_output, '\0', sizeof(atcmd_output));
  888. memset(match_text, '\0', sizeof(match_text));
  889. memset(player_name, '\0', sizeof(player_name));
  890. if (sscanf(message, "%199[^\n]", match_text) < 1)
  891. strcpy(match_text, "");
  892. for (j = 0; match_text[j]; j++)
  893. match_text[j] = TOLOWER(match_text[j]);
  894. count = 0;
  895. GM_level = pc_isGM(sd);
  896. iter = mapit_getallusers();
  897. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  898. {
  899. pl_GM_level = pc_isGM(pl_sd);
  900. if (!pl_GM_level)
  901. continue;
  902. if (match_text[0])
  903. {
  904. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  905. for (j = 0; player_name[j]; j++)
  906. player_name[j] = TOLOWER(player_name[j]);
  907. // search with no case sensitive
  908. if (strstr(player_name, match_text) == NULL)
  909. continue;
  910. }
  911. if (pl_GM_level > GM_level) {
  912. if (pl_sd->sc.option & OPTION_INVISIBLE)
  913. continue;
  914. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  915. clif_displaymessage(fd, atcmd_output);
  916. count++;
  917. continue;
  918. }
  919. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  920. pl_sd->status.name, pl_GM_level,
  921. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  922. clif_displaymessage(fd, atcmd_output);
  923. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  924. pl_sd->status.base_level,
  925. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  926. clif_displaymessage(fd, atcmd_output);
  927. p = party_search(pl_sd->status.party_id);
  928. g = guild_search(pl_sd->status.guild_id);
  929. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  930. p?p->party.name:"None", g?g->name:"None");
  931. clif_displaymessage(fd, atcmd_output);
  932. count++;
  933. }
  934. mapit_free(iter);
  935. if (count == 0)
  936. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  937. else if (count == 1)
  938. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  939. else {
  940. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  941. clif_displaymessage(fd, atcmd_output);
  942. }
  943. return 0;
  944. }
  945. /*==========================================
  946. *
  947. *------------------------------------------*/
  948. ACMD_FUNC(save)
  949. {
  950. nullpo_retr(-1, sd);
  951. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  952. if (sd->status.pet_id > 0 && sd->pd)
  953. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  954. chrif_save(sd,0);
  955. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  956. return 0;
  957. }
  958. /*==========================================
  959. *
  960. *------------------------------------------*/
  961. ACMD_FUNC(load)
  962. {
  963. int m;
  964. nullpo_retr(-1, sd);
  965. m = map_mapindex2mapid(sd->status.save_point.map);
  966. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  967. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  968. return -1;
  969. }
  970. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  971. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  972. return -1;
  973. }
  974. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  975. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  976. return 0;
  977. }
  978. /*==========================================
  979. *
  980. *------------------------------------------*/
  981. ACMD_FUNC(speed)
  982. {
  983. int speed;
  984. nullpo_retr(-1, sd);
  985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  986. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  987. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  988. clif_displaymessage(fd, atcmd_output);
  989. return -1;
  990. }
  991. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  992. status_calc_bl(&sd->bl, SCB_SPEED);
  993. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  994. return 0;
  995. }
  996. /*==========================================
  997. *
  998. *------------------------------------------*/
  999. ACMD_FUNC(storage)
  1000. {
  1001. nullpo_retr(-1, sd);
  1002. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1003. return -1;
  1004. if (storage_storageopen(sd) == 1)
  1005. { //Already open.
  1006. clif_displaymessage(fd, msg_txt(250));
  1007. return -1;
  1008. }
  1009. clif_displaymessage(fd, "Storage opened.");
  1010. return 0;
  1011. }
  1012. /*==========================================
  1013. *
  1014. *------------------------------------------*/
  1015. ACMD_FUNC(guildstorage)
  1016. {
  1017. nullpo_retr(-1, sd);
  1018. if (!sd->status.guild_id) {
  1019. clif_displaymessage(fd, msg_txt(252));
  1020. return -1;
  1021. }
  1022. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1023. return -1;
  1024. if (sd->state.storage_flag == 1) {
  1025. clif_displaymessage(fd, msg_txt(250));
  1026. return -1;
  1027. }
  1028. if (sd->state.storage_flag == 2) {
  1029. clif_displaymessage(fd, msg_txt(251));
  1030. return -1;
  1031. }
  1032. storage_guild_storageopen(sd);
  1033. clif_displaymessage(fd, "Guild storage opened.");
  1034. return 0;
  1035. }
  1036. /*==========================================
  1037. *
  1038. *------------------------------------------*/
  1039. ACMD_FUNC(option)
  1040. {
  1041. int param1 = 0, param2 = 0, param3 = 0;
  1042. nullpo_retr(-1, sd);
  1043. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1044. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1045. return -1;
  1046. }
  1047. sd->sc.opt1 = param1;
  1048. sd->sc.opt2 = param2;
  1049. pc_setoption(sd, param3);
  1050. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1051. return 0;
  1052. }
  1053. /*==========================================
  1054. *
  1055. *------------------------------------------*/
  1056. ACMD_FUNC(hide)
  1057. {
  1058. nullpo_retr(-1, sd);
  1059. if (sd->sc.option & OPTION_INVISIBLE) {
  1060. sd->sc.option &= ~OPTION_INVISIBLE;
  1061. if (sd->disguise)
  1062. status_set_viewdata(&sd->bl, sd->disguise);
  1063. else
  1064. status_set_viewdata(&sd->bl, sd->status.class_);
  1065. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1066. if( map[sd->bl.m].flag.pvp )
  1067. {// increment the number of pvp players on the map
  1068. map[sd->bl.m].users_pvp++;
  1069. if( !map[sd->bl.m].flag.pvp_nocalcrank )
  1070. {// register the player for ranking calculations
  1071. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  1072. }
  1073. }
  1074. //bugreport:2266
  1075. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  1076. } else {
  1077. sd->sc.option |= OPTION_INVISIBLE;
  1078. sd->vd.class_ = INVISIBLE_CLASS;
  1079. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1080. if( map[sd->bl.m].flag.pvp )
  1081. {// decrement the number of pvp players on the map
  1082. map[sd->bl.m].users_pvp--;
  1083. if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  1084. {// unregister the player for ranking
  1085. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  1086. sd->pvp_timer = INVALID_TIMER;
  1087. }
  1088. }
  1089. }
  1090. clif_changeoption(&sd->bl);
  1091. return 0;
  1092. }
  1093. /*==========================================
  1094. * Changes a character's class
  1095. *------------------------------------------*/
  1096. ACMD_FUNC(jobchange)
  1097. {
  1098. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1099. int job = 0, upper = 0;
  1100. nullpo_retr(-1, sd);
  1101. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1102. {
  1103. int i, found = 0;
  1104. const struct { char name[24]; int id; } jobs[] = {
  1105. { "novice", 0 },
  1106. { "swordsman", 1 },
  1107. { "mage", 2 },
  1108. { "archer", 3 },
  1109. { "acolyte", 4 },
  1110. { "merchant", 5 },
  1111. { "thief", 6 },
  1112. { "knight", 7 },
  1113. { "priest", 8 },
  1114. { "priestess", 8 },
  1115. { "wizard", 9 },
  1116. { "blacksmith", 10 },
  1117. { "hunter", 11 },
  1118. { "assassin", 12 },
  1119. { "crusader", 14 },
  1120. { "monk", 15 },
  1121. { "sage", 16 },
  1122. { "rogue", 17 },
  1123. { "alchemist", 18 },
  1124. { "bard", 19 },
  1125. { "dancer", 20 },
  1126. { "super novice", 23 },
  1127. { "supernovice", 23 },
  1128. { "gunslinger", 24 },
  1129. { "gunner", 24 },
  1130. { "ninja", 25 },
  1131. { "high novice", 4001 },
  1132. { "swordsman high", 4002 },
  1133. { "mage high", 4003 },
  1134. { "archer high", 4004 },
  1135. { "acolyte high", 4005 },
  1136. { "merchant high", 4006 },
  1137. { "thief high", 4007 },
  1138. { "lord knight", 4008 },
  1139. { "high priest", 4009 },
  1140. { "high priestess", 4009 },
  1141. { "high wizard", 4010 },
  1142. { "whitesmith", 4011 },
  1143. { "sniper", 4012 },
  1144. { "assassin cross", 4013 },
  1145. { "paladin", 4015 },
  1146. { "champion", 4016 },
  1147. { "professor", 4017 },
  1148. { "stalker", 4018 },
  1149. { "creator", 4019 },
  1150. { "clown", 4020 },
  1151. { "gypsy", 4021 },
  1152. { "baby novice", 4023 },
  1153. { "baby swordsman", 4024 },
  1154. { "baby mage", 4025 },
  1155. { "baby archer", 4026 },
  1156. { "baby acolyte", 4027 },
  1157. { "baby merchant", 4028 },
  1158. { "baby thief", 4029 },
  1159. { "baby knight", 4030 },
  1160. { "baby priest", 4031 },
  1161. { "baby priestess", 4031 },
  1162. { "baby wizard", 4032 },
  1163. { "baby blacksmith",4033 },
  1164. { "baby hunter", 4034 },
  1165. { "baby assassin", 4035 },
  1166. { "baby crusader", 4037 },
  1167. { "baby monk", 4038 },
  1168. { "baby sage", 4039 },
  1169. { "baby rogue", 4040 },
  1170. { "baby alchemist", 4041 },
  1171. { "baby bard", 4042 },
  1172. { "baby dancer", 4043 },
  1173. { "super baby", 4045 },
  1174. { "taekwon", 4046 },
  1175. { "taekwon boy", 4046 },
  1176. { "taekwon girl", 4046 },
  1177. { "star gladiator", 4047 },
  1178. { "soul linker", 4049 },
  1179. { "rune knight", 4054 },
  1180. { "warlock", 4055 },
  1181. { "ranger", 4056 },
  1182. { "arch bishop", 4057 },
  1183. { "mechanic", 4058 },
  1184. { "guillotine", 4059 },
  1185. { "rune knight (Trans)", 4060 },
  1186. { "warlock (Trans)", 4061 },
  1187. { "ranger (Trans)", 4062 },
  1188. { "arch bishop (Trans)", 4063 },
  1189. { "mechanic (Trans)", 4064 },
  1190. { "guillotine (Trans)", 4065 },
  1191. { "royal guard", 4066 },
  1192. { "sorcerer", 4067 },
  1193. { "minstrel", 4068 },
  1194. { "wanderer", 4069 },
  1195. { "sura", 4070 },
  1196. { "genetic", 4071 },
  1197. { "shadow chaser", 4072 },
  1198. { "royal guard (Trans)", 4073 },
  1199. { "sorcerer (Trans)", 4074 },
  1200. { "minstrel (Trans)", 4075 },
  1201. { "wanderer (Trans)", 4076 },
  1202. { "sura (Trans)", 4077 },
  1203. { "genetic (Trans)", 4078 },
  1204. { "shadow chaser (Trans)", 4079 },
  1205. };
  1206. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1207. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1208. job = jobs[i].id;
  1209. upper = 0;
  1210. found = 1;
  1211. break;
  1212. }
  1213. }
  1214. if (!found) {
  1215. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1216. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1217. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1218. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1219. clif_displaymessage(fd, "----- 2nd Class -----");
  1220. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1221. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1222. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1223. clif_displaymessage(fd, " 20 Dancer");
  1224. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1225. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1226. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1227. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1228. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1229. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1230. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1231. clif_displaymessage(fd, "4021 Gypsy");
  1232. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1233. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1234. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1235. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1236. clif_displaymessage(fd, "4072 Shadow Chaser");
  1237. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1238. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1239. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1240. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1241. clif_displaymessage(fd, "4079 Shadow Chaser");
  1242. clif_displaymessage(fd, "----- Expanded Class -----");
  1243. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1244. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1245. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1246. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1247. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1248. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1249. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1250. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1251. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1252. clif_displaymessage(fd, "4045 Super Baby");
  1253. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1254. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1255. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1256. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1257. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1258. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1259. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1260. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1261. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1262. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1263. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1264. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1265. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1266. return -1;
  1267. }
  1268. }
  1269. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1270. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1271. ) // Deny direct transformation into dummy jobs
  1272. return 0;
  1273. if (pcdb_checkid(job))
  1274. {
  1275. if (pc_jobchange(sd, job, upper) == 0)
  1276. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1277. else {
  1278. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1279. return -1;
  1280. }
  1281. } else {
  1282. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1283. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1284. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1285. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1286. clif_displaymessage(fd, "----- 2nd Class -----");
  1287. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1288. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1289. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1290. clif_displaymessage(fd, " 20 Dancer");
  1291. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1292. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1293. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1294. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1295. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1296. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1297. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1298. clif_displaymessage(fd, "4021 Gypsy");
  1299. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1300. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1301. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1302. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1303. clif_displaymessage(fd, "4072 Shadow Chaser");
  1304. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1305. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1306. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1307. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1308. clif_displaymessage(fd, "4079 Shadow Chaser");
  1309. clif_displaymessage(fd, "----- Expanded Class -----");
  1310. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1311. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1312. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1313. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1314. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1315. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1316. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1317. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1318. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1319. clif_displaymessage(fd, "4045 Super Baby");
  1320. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1321. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1322. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1323. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1324. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1325. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1326. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1327. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1328. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1329. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1330. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1331. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1332. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1333. return -1;
  1334. }
  1335. return 0;
  1336. }
  1337. /*==========================================
  1338. *
  1339. *------------------------------------------*/
  1340. ACMD_FUNC(die)
  1341. {
  1342. nullpo_retr(-1, sd);
  1343. clif_specialeffect(&sd->bl,450,SELF);
  1344. status_kill(&sd->bl);
  1345. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1346. return 0;
  1347. }
  1348. /*==========================================
  1349. *
  1350. *------------------------------------------*/
  1351. ACMD_FUNC(kill)
  1352. {
  1353. struct map_session_data *pl_sd;
  1354. nullpo_retr(-1, sd);
  1355. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1356. if (!message || !*message) {
  1357. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1358. return -1;
  1359. }
  1360. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1361. {
  1362. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1363. return -1;
  1364. }
  1365. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1366. { // you can kill only lower or same level
  1367. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1368. return -1;
  1369. }
  1370. status_kill(&pl_sd->bl);
  1371. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1372. if (fd != pl_sd->fd)
  1373. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1374. return 0;
  1375. }
  1376. /*==========================================
  1377. *
  1378. *------------------------------------------*/
  1379. ACMD_FUNC(alive)
  1380. {
  1381. nullpo_retr(-1, sd);
  1382. if (!status_revive(&sd->bl, 100, 100))
  1383. {
  1384. clif_displaymessage(fd, "You're not dead.");
  1385. return -1;
  1386. }
  1387. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1388. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1389. return 0;
  1390. }
  1391. /*==========================================
  1392. * +kamic [LuzZza]
  1393. *------------------------------------------*/
  1394. ACMD_FUNC(kami)
  1395. {
  1396. unsigned long color=0;
  1397. nullpo_retr(-1, sd);
  1398. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1399. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1400. if (!message || !*message) {
  1401. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1402. return -1;
  1403. }
  1404. sscanf(message, "%199[^\n]", atcmd_output);
  1405. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1406. } else {
  1407. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1408. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1409. return -1;
  1410. }
  1411. if(color > 0xFFFFFF) {
  1412. clif_displaymessage(fd, "Invalid color.");
  1413. return -1;
  1414. }
  1415. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1416. }
  1417. return 0;
  1418. }
  1419. /*==========================================
  1420. *
  1421. *------------------------------------------*/
  1422. ACMD_FUNC(heal)
  1423. {
  1424. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1425. nullpo_retr(-1, sd);
  1426. sscanf(message, "%d %d", &hp, &sp);
  1427. // some overflow checks
  1428. if( hp == INT_MIN ) hp++;
  1429. if( sp == INT_MIN ) sp++;
  1430. if ( hp == 0 && sp == 0 ) {
  1431. if (!status_percent_heal(&sd->bl, 100, 100))
  1432. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1433. else
  1434. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1435. return 0;
  1436. }
  1437. if ( hp > 0 && sp >= 0 ) {
  1438. if(!status_heal(&sd->bl, hp, sp, 0))
  1439. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1440. else
  1441. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1442. return 0;
  1443. }
  1444. if ( hp < 0 && sp <= 0 ) {
  1445. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1446. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1447. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1448. return 0;
  1449. }
  1450. //Opposing signs.
  1451. if ( hp ) {
  1452. if (hp > 0)
  1453. status_heal(&sd->bl, hp, 0, 0);
  1454. else {
  1455. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1456. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1457. }
  1458. }
  1459. if ( sp ) {
  1460. if (sp > 0)
  1461. status_heal(&sd->bl, 0, sp, 0);
  1462. else
  1463. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1464. }
  1465. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1466. return 0;
  1467. }
  1468. /*==========================================
  1469. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1470. *------------------------------------------*/
  1471. ACMD_FUNC(item)
  1472. {
  1473. char item_name[100];
  1474. int number = 0, item_id, flag;
  1475. struct item item_tmp;
  1476. struct item_data *item_data;
  1477. int get_count, i;
  1478. nullpo_retr(-1, sd);
  1479. memset(item_name, '\0', sizeof(item_name));
  1480. if (!message || !*message || (
  1481. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1482. sscanf(message, "%99s %d", item_name, &number) < 1
  1483. )) {
  1484. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1485. return -1;
  1486. }
  1487. if (number <= 0)
  1488. number = 1;
  1489. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1490. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1491. {
  1492. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1493. return -1;
  1494. }
  1495. item_id = item_data->nameid;
  1496. get_count = number;
  1497. //Check if it's stackable.
  1498. if (!itemdb_isstackable2(item_data))
  1499. get_count = 1;
  1500. for (i = 0; i < number; i += get_count) {
  1501. // if not pet egg
  1502. if (!pet_create_egg(sd, item_id)) {
  1503. memset(&item_tmp, 0, sizeof(item_tmp));
  1504. item_tmp.nameid = item_id;
  1505. item_tmp.identify = 1;
  1506. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1507. clif_additem(sd, 0, 0, flag);
  1508. }
  1509. }
  1510. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1511. return 0;
  1512. }
  1513. /*==========================================
  1514. *
  1515. *------------------------------------------*/
  1516. ACMD_FUNC(item2)
  1517. {
  1518. struct item item_tmp;
  1519. struct item_data *item_data;
  1520. char item_name[100];
  1521. int item_id, number = 0;
  1522. int identify = 0, refine = 0, attr = 0;
  1523. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1524. int flag;
  1525. int loop, get_count, i;
  1526. nullpo_retr(-1, sd);
  1527. memset(item_name, '\0', sizeof(item_name));
  1528. if (!message || !*message || (
  1529. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1530. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1531. )) {
  1532. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1533. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1534. return -1;
  1535. }
  1536. if (number <= 0)
  1537. number = 1;
  1538. item_id = 0;
  1539. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1540. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1541. item_id = item_data->nameid;
  1542. if (item_id > 500) {
  1543. loop = 1;
  1544. get_count = number;
  1545. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1546. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1547. loop = number;
  1548. get_count = 1;
  1549. if (item_data->type == IT_PETEGG) {
  1550. identify = 1;
  1551. refine = 0;
  1552. }
  1553. if (item_data->type == IT_PETARMOR)
  1554. refine = 0;
  1555. if (refine > MAX_REFINE)
  1556. refine = MAX_REFINE;
  1557. } else {
  1558. identify = 1;
  1559. refine = attr = 0;
  1560. }
  1561. for (i = 0; i < loop; i++) {
  1562. memset(&item_tmp, 0, sizeof(item_tmp));
  1563. item_tmp.nameid = item_id;
  1564. item_tmp.identify = identify;
  1565. item_tmp.refine = refine;
  1566. item_tmp.attribute = attr;
  1567. item_tmp.card[0] = c1;
  1568. item_tmp.card[1] = c2;
  1569. item_tmp.card[2] = c3;
  1570. item_tmp.card[3] = c4;
  1571. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1572. clif_additem(sd, 0, 0, flag);
  1573. }
  1574. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1575. } else {
  1576. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1577. return -1;
  1578. }
  1579. return 0;
  1580. }
  1581. /*==========================================
  1582. *
  1583. *------------------------------------------*/
  1584. ACMD_FUNC(itemreset)
  1585. {
  1586. int i;
  1587. nullpo_retr(-1, sd);
  1588. for (i = 0; i < MAX_INVENTORY; i++) {
  1589. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1590. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1591. }
  1592. }
  1593. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1594. return 0;
  1595. }
  1596. /*==========================================
  1597. * Atcommand @lvlup
  1598. *------------------------------------------*/
  1599. ACMD_FUNC(baselevelup)
  1600. {
  1601. int level=0, i=0, status_point=0;
  1602. nullpo_retr(-1, sd);
  1603. level = atoi(message);
  1604. if (!message || !*message || !level) {
  1605. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1606. return -1;
  1607. }
  1608. if (level > 0) {
  1609. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1610. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1611. return -1;
  1612. } // End Addition
  1613. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1614. level = pc_maxbaselv(sd) - sd->status.base_level;
  1615. for (i = 0; i < level; i++)
  1616. status_point += pc_gets_status_point(sd->status.base_level + i);
  1617. sd->status.status_point += status_point;
  1618. sd->status.base_level += (unsigned int)level;
  1619. status_percent_heal(&sd->bl, 100, 100);
  1620. clif_misceffect(&sd->bl, 0);
  1621. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1622. } else {
  1623. if (sd->status.base_level == 1) {
  1624. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1625. return -1;
  1626. }
  1627. level*=-1;
  1628. if ((unsigned int)level >= sd->status.base_level)
  1629. level = sd->status.base_level-1;
  1630. for (i = 0; i > -level; i--)
  1631. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1632. if (sd->status.status_point < status_point)
  1633. pc_resetstate(sd);
  1634. if (sd->status.status_point < status_point)
  1635. sd->status.status_point = 0;
  1636. else
  1637. sd->status.status_point -= status_point;
  1638. sd->status.base_level -= (unsigned int)level;
  1639. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1640. }
  1641. sd->status.base_exp = 0;
  1642. clif_updatestatus(sd, SP_STATUSPOINT);
  1643. clif_updatestatus(sd, SP_BASELEVEL);
  1644. clif_updatestatus(sd, SP_BASEEXP);
  1645. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1646. status_calc_pc(sd, 0);
  1647. if(sd->status.party_id)
  1648. party_send_levelup(sd);
  1649. return 0;
  1650. }
  1651. /*==========================================
  1652. *
  1653. *------------------------------------------*/
  1654. ACMD_FUNC(joblevelup)
  1655. {
  1656. int level=0;
  1657. nullpo_retr(-1, sd);
  1658. level = atoi(message);
  1659. if (!message || !*message || !level) {
  1660. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1661. return -1;
  1662. }
  1663. if (level > 0) {
  1664. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1665. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1666. return -1;
  1667. }
  1668. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1669. level = pc_maxjoblv(sd) - sd->status.job_level;
  1670. sd->status.job_level += (unsigned int)level;
  1671. sd->status.skill_point += level;
  1672. clif_misceffect(&sd->bl, 1);
  1673. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1674. } else {
  1675. if (sd->status.job_level == 1) {
  1676. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1677. return -1;
  1678. }
  1679. level *=-1;
  1680. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1681. level = sd->status.job_level-1;
  1682. sd->status.job_level -= (unsigned int)level;
  1683. if (sd->status.skill_point < level)
  1684. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1685. if (sd->status.skill_point < level)
  1686. sd->status.skill_point = 0;
  1687. else
  1688. sd->status.skill_point -= level;
  1689. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1690. }
  1691. sd->status.job_exp = 0;
  1692. clif_updatestatus(sd, SP_JOBLEVEL);
  1693. clif_updatestatus(sd, SP_JOBEXP);
  1694. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1695. clif_updatestatus(sd, SP_SKILLPOINT);
  1696. status_calc_pc(sd, 0);
  1697. return 0;
  1698. }
  1699. /*==========================================
  1700. * @help
  1701. *------------------------------------------*/
  1702. ACMD_FUNC(help)
  1703. {
  1704. char buf[2048], w1[2048], w2[2048];
  1705. int i, gm_level;
  1706. FILE* fp;
  1707. nullpo_retr(-1, sd);
  1708. memset(buf, '\0', sizeof(buf));
  1709. if ((fp = fopen(help_txt, "r")) != NULL) {
  1710. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1711. gm_level = pc_isGM(sd);
  1712. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1713. if (buf[0] == '/' && buf[1] == '/')
  1714. continue;
  1715. for (i = 0; buf[i] != '\0'; i++) {
  1716. if (buf[i] == '\r' || buf[i] == '\n') {
  1717. buf[i] = '\0';
  1718. break;
  1719. }
  1720. }
  1721. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1722. clif_displaymessage(fd, buf);
  1723. else if (gm_level >= atoi(w1))
  1724. clif_displaymessage(fd, w2);
  1725. }
  1726. fclose(fp);
  1727. } else {
  1728. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1729. return -1;
  1730. }
  1731. return 0;
  1732. }
  1733. /*==========================================
  1734. * @help2 - Char commands [Kayla]
  1735. *------------------------------------------*/
  1736. ACMD_FUNC(help2)
  1737. {
  1738. char buf[2048], w1[2048], w2[2048];
  1739. int i, gm_level;
  1740. FILE* fp;
  1741. nullpo_retr(-1, sd);
  1742. memset(buf, '\0', sizeof(buf));
  1743. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1744. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1745. gm_level = pc_isGM(sd);
  1746. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1747. if (buf[0] == '/' && buf[1] == '/')
  1748. continue;
  1749. for (i = 0; buf[i] != '\0'; i++) {
  1750. if (buf[i] == '\r' || buf[i] == '\n') {
  1751. buf[i] = '\0';
  1752. break;
  1753. }
  1754. }
  1755. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1756. clif_displaymessage(fd, buf);
  1757. else if (gm_level >= atoi(w1))
  1758. clif_displaymessage(fd, w2);
  1759. }
  1760. fclose(fp);
  1761. } else {
  1762. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1763. return -1;
  1764. }
  1765. return 0;
  1766. }
  1767. // helper function, used in foreach calls to stop auto-attack timers
  1768. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1769. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1770. {
  1771. struct unit_data *ud = unit_bl2ud(bl);
  1772. int id = va_arg(ap, int);
  1773. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1774. {
  1775. unit_stop_attack(bl);
  1776. return 1;
  1777. }
  1778. return 0;
  1779. }
  1780. /*==========================================
  1781. *
  1782. *------------------------------------------*/
  1783. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1784. {
  1785. TBL_PC* sd = (TBL_PC*)bl;
  1786. clif_pvpset(sd, 0, 0, 2);
  1787. if (sd->pvp_timer != INVALID_TIMER) {
  1788. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1789. sd->pvp_timer = INVALID_TIMER;
  1790. }
  1791. return 0;
  1792. }
  1793. ACMD_FUNC(pvpoff)
  1794. {
  1795. nullpo_retr(-1, sd);
  1796. if (!map[sd->bl.m].flag.pvp) {
  1797. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1798. return -1;
  1799. }
  1800. map[sd->bl.m].flag.pvp = 0;
  1801. if (!battle_config.pk_mode)
  1802. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1803. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1804. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1805. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1806. return 0;
  1807. }
  1808. /*==========================================
  1809. *
  1810. *------------------------------------------*/
  1811. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1812. {
  1813. TBL_PC* sd = (TBL_PC*)bl;
  1814. if (sd->pvp_timer == INVALID_TIMER) {
  1815. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1816. sd->pvp_rank = 0;
  1817. sd->pvp_lastusers = 0;
  1818. sd->pvp_point = 5;
  1819. sd->pvp_won = 0;
  1820. sd->pvp_lost = 0;
  1821. }
  1822. return 0;
  1823. }
  1824. ACMD_FUNC(pvpon)
  1825. {
  1826. nullpo_retr(-1, sd);
  1827. if (map[sd->bl.m].flag.pvp) {
  1828. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1829. return -1;
  1830. }
  1831. map[sd->bl.m].flag.pvp = 1;
  1832. if (!battle_config.pk_mode)
  1833. {// display pvp circle and rank
  1834. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1835. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1836. }
  1837. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1838. return 0;
  1839. }
  1840. /*==========================================
  1841. *
  1842. *------------------------------------------*/
  1843. ACMD_FUNC(gvgoff)
  1844. {
  1845. nullpo_retr(-1, sd);
  1846. if (!map[sd->bl.m].flag.gvg) {
  1847. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1848. return -1;
  1849. }
  1850. map[sd->bl.m].flag.gvg = 0;
  1851. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1852. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1853. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1854. return 0;
  1855. }
  1856. /*==========================================
  1857. *
  1858. *------------------------------------------*/
  1859. ACMD_FUNC(gvgon)
  1860. {
  1861. nullpo_retr(-1, sd);
  1862. if (map[sd->bl.m].flag.gvg) {
  1863. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1864. return -1;
  1865. }
  1866. map[sd->bl.m].flag.gvg = 1;
  1867. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1868. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1869. return 0;
  1870. }
  1871. /*==========================================
  1872. *
  1873. *------------------------------------------*/
  1874. ACMD_FUNC(model)
  1875. {
  1876. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1877. nullpo_retr(-1, sd);
  1878. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1879. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1880. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1881. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1882. clif_displaymessage(fd, atcmd_output);
  1883. return -1;
  1884. }
  1885. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1886. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1887. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1888. pc_changelook(sd, LOOK_HAIR, hair_style);
  1889. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1890. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1891. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1892. } else {
  1893. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1894. return -1;
  1895. }
  1896. return 0;
  1897. }
  1898. /*==========================================
  1899. * @dye && @ccolor
  1900. *------------------------------------------*/
  1901. ACMD_FUNC(dye)
  1902. {
  1903. int cloth_color = 0;
  1904. nullpo_retr(-1, sd);
  1905. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1906. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1907. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1908. clif_displaymessage(fd, atcmd_output);
  1909. return -1;
  1910. }
  1911. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1912. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1913. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1914. } else {
  1915. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1916. return -1;
  1917. }
  1918. return 0;
  1919. }
  1920. /*==========================================
  1921. * @hairstyle && @hstyle
  1922. *------------------------------------------*/
  1923. ACMD_FUNC(hair_style)
  1924. {
  1925. int hair_style = 0;
  1926. nullpo_retr(-1, sd);
  1927. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1928. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1929. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1930. clif_displaymessage(fd, atcmd_output);
  1931. return -1;
  1932. }
  1933. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1934. pc_changelook(sd, LOOK_HAIR, hair_style);
  1935. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1936. } else {
  1937. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1938. return -1;
  1939. }
  1940. return 0;
  1941. }
  1942. /*==========================================
  1943. * @haircolor && @hcolor
  1944. *------------------------------------------*/
  1945. ACMD_FUNC(hair_color)
  1946. {
  1947. int hair_color = 0;
  1948. nullpo_retr(-1, sd);
  1949. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1950. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1951. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1952. clif_displaymessage(fd, atcmd_output);
  1953. return -1;
  1954. }
  1955. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1956. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1957. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1958. } else {
  1959. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1960. return -1;
  1961. }
  1962. return 0;
  1963. }
  1964. /*==========================================
  1965. * @go [city_number or city_name] - Updated by Harbin
  1966. *------------------------------------------*/
  1967. ACMD_FUNC(go)
  1968. {
  1969. int i;
  1970. int town;
  1971. char map_name[MAP_NAME_LENGTH];
  1972. int m;
  1973. const struct {
  1974. char map[MAP_NAME_LENGTH];
  1975. int x, y;
  1976. } data[] = {
  1977. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1978. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1979. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1980. { MAP_PAYON, 162, 233 }, // 3=Payon
  1981. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1982. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1983. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1984. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1985. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1986. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1987. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1988. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1989. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1990. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1991. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1992. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1993. { MAP_JAIL, 23, 61 }, // 16=Prison
  1994. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1995. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1996. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1997. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1998. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1999. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  2000. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2001. { MAP_VEINS, 216, 123 }, // 24=Veins
  2002. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2003. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  2004. { MAP_MANUK, 282, 138 }, // 27=Manuk
  2005. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  2006. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  2007. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  2008. { MAP_MORA, 44, 151 }, // 31=Mora
  2009. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  2010. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  2011. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  2012. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  2013. };
  2014. nullpo_retr(-1, sd);
  2015. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2016. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2017. return 0;
  2018. }
  2019. memset(map_name, '\0', sizeof(map_name));
  2020. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2021. // get the number
  2022. town = atoi(message);
  2023. // if no value, display all value
  2024. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2025. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2026. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2027. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2028. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2029. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2030. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2031. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2032. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2033. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2034. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2035. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  2036. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  2037. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  2038. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  2039. return -1;
  2040. }
  2041. // get possible name of the city
  2042. map_name[MAP_NAME_LENGTH-1] = '\0';
  2043. for (i = 0; map_name[i]; i++)
  2044. map_name[i] = TOLOWER(map_name[i]);
  2045. // try to identify the map name
  2046. if (strncmp(map_name, "prontera", 3) == 0) {
  2047. town = 0;
  2048. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2049. town = 1;
  2050. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2051. town = 2;
  2052. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2053. strncmp(map_name, "paion", 3) == 0) {
  2054. town = 3;
  2055. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2056. town = 4;
  2057. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2058. strncmp(map_name, "islude", 3) == 0) {
  2059. town = 5;
  2060. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2061. strcmp(map_name, "al") == 0) {
  2062. town = 6;
  2063. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2064. strcmp(map_name, "christmas") == 0 ||
  2065. strncmp(map_name, "xmas", 3) == 0 ||
  2066. strncmp(map_name, "x-mas", 3) == 0) {
  2067. town = 7;
  2068. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2069. town = 8;
  2070. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2071. town = 9;
  2072. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2073. town = 10;
  2074. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2075. town = 11;
  2076. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2077. town = 12;
  2078. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2079. town = 13;
  2080. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2081. town = 14;
  2082. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2083. strncmp(map_name, "startpoint", 3) == 0 ||
  2084. strncmp(map_name, "begining", 3) == 0) {
  2085. town = 15;
  2086. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2087. strncmp(map_name, "prison", 3) == 0 ||
  2088. strncmp(map_name, "jails", 3) == 0) {
  2089. town = 16;
  2090. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2091. strncmp(map_name, "jawai", 3) == 0) {
  2092. town = 17;
  2093. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2094. strncmp(map_name, "ayotaya", 3) == 0) {
  2095. town = 18;
  2096. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2097. strncmp(map_name, "ainbroch", 5) == 0) {
  2098. town = 19;
  2099. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2100. town = 20;
  2101. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2102. town = 21;
  2103. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2104. town = 22;
  2105. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2106. town = 23;
  2107. } else if (strncmp(map_name, "veins", 3) == 0) {
  2108. town = 24;
  2109. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2110. town = 25;
  2111. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  2112. town = 26;
  2113. } else if (strncmp(map_name, "manuk", 3) == 0) {
  2114. town = 27;
  2115. } else if (strncmp(map_name, "splendide", 3) == 0) {
  2116. town = 28;
  2117. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  2118. town = 29;
  2119. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  2120. town = 30;
  2121. } else if (strncmp(map_name, "mora", 3) == 0) {
  2122. town = 31;
  2123. } else if (strncmp(map_name, "dewata", 3) == 0) {
  2124. town = 32;
  2125. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  2126. town = 33;
  2127. } else if (strncmp(map_name, "malaya", 3) == 0) {
  2128. town = 34;
  2129. } else if (strncmp(map_name, "eclage", 3) == 0) {
  2130. town = 35;
  2131. }
  2132. if (town >= 0 && town < ARRAYLENGTH(data))
  2133. {
  2134. m = map_mapname2mapid(data[town].map);
  2135. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2136. clif_displaymessage(fd, msg_txt(247));
  2137. return -1;
  2138. }
  2139. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2140. clif_displaymessage(fd, msg_txt(248));
  2141. return -1;
  2142. }
  2143. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2144. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2145. } else {
  2146. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2147. return -1;
  2148. }
  2149. } else { // if you arrive here, you have an error in town variable when reading of names
  2150. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2151. return -1;
  2152. }
  2153. return 0;
  2154. }
  2155. /*==========================================
  2156. *
  2157. *------------------------------------------*/
  2158. ACMD_FUNC(monster)
  2159. {
  2160. char name[NAME_LENGTH];
  2161. char monster[NAME_LENGTH];
  2162. int mob_id;
  2163. int number = 0;
  2164. int count;
  2165. int i, k, range;
  2166. short mx, my;
  2167. nullpo_retr(-1, sd);
  2168. memset(name, '\0', sizeof(name));
  2169. memset(monster, '\0', sizeof(monster));
  2170. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2171. if (!message || !*message) {
  2172. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2173. return -1;
  2174. }
  2175. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2176. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2177. //All data can be left as it is.
  2178. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2179. //Here, it is possible name was not given and we are using monster for it.
  2180. if (count < 3) //Blank mob's name.
  2181. name[0] = '\0';
  2182. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2183. //All data can be left as it is.
  2184. } else if (sscanf(message, "%23s", monster) > 0) {
  2185. //As before, name may be already filled.
  2186. name[0] = '\0';
  2187. } else {
  2188. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2189. return -1;
  2190. }
  2191. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2192. mob_id = mobdb_checkid(atoi(monster));
  2193. if (mob_id == 0) {
  2194. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2195. return -1;
  2196. }
  2197. if (mob_id == MOBID_EMPERIUM) {
  2198. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2199. return -1;
  2200. }
  2201. if (number <= 0)
  2202. number = 1;
  2203. if( !name[0] )
  2204. strcpy(name, "--ja--");
  2205. // 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
  2206. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2207. number = battle_config.atc_spawn_quantity_limit;
  2208. if (battle_config.etc_log)
  2209. 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);
  2210. count = 0;
  2211. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2212. for (i = 0; i < number; i++) {
  2213. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2214. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2215. count += (k != 0) ? 1 : 0;
  2216. }
  2217. if (count != 0)
  2218. if (number == count)
  2219. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2220. else {
  2221. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2222. clif_displaymessage(fd, atcmd_output);
  2223. }
  2224. else {
  2225. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2226. return -1;
  2227. }
  2228. return 0;
  2229. }
  2230. // small monster spawning [Valaris]
  2231. ACMD_FUNC(monstersmall)
  2232. {
  2233. char name[NAME_LENGTH] = "";
  2234. char monster[NAME_LENGTH] = "";
  2235. int mob_id = 0;
  2236. int number = 0;
  2237. int x = 0;
  2238. int y = 0;
  2239. int count;
  2240. int i;
  2241. nullpo_retr(-1, sd);
  2242. if (!message || !*message) {
  2243. clif_displaymessage(fd, "Give a monster name/id please.");
  2244. return -1;
  2245. }
  2246. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2247. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2248. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2249. clif_displaymessage(fd, "Give a monster name/id please.");
  2250. return -1;
  2251. }
  2252. // If monster identifier/name argument is a name
  2253. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2254. mob_id = atoi(monster);
  2255. if (mob_id == 0) {
  2256. clif_displaymessage(fd, msg_txt(40));
  2257. return -1;
  2258. }
  2259. if (mob_id == MOBID_EMPERIUM) {
  2260. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2261. return -1;
  2262. }
  2263. if (mobdb_checkid(mob_id) == 0) {
  2264. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2265. return -1;
  2266. }
  2267. if (number <= 0)
  2268. number = 1;
  2269. if( !name[0] )
  2270. strcpy(name, "--ja--");
  2271. // 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
  2272. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2273. number = battle_config.atc_spawn_quantity_limit;
  2274. count = 0;
  2275. for (i = 0; i < number; i++) {
  2276. int mx, my;
  2277. if (x <= 0)
  2278. mx = sd->bl.x + (rand() % 11 - 5);
  2279. else
  2280. mx = x;
  2281. if (y <= 0)
  2282. my = sd->bl.y + (rand() % 11 - 5);
  2283. else
  2284. my = y;
  2285. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2286. }
  2287. if (count != 0)
  2288. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2289. else
  2290. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2291. return 0;
  2292. }
  2293. // big monster spawning [Valaris]
  2294. ACMD_FUNC(monsterbig)
  2295. {
  2296. char name[NAME_LENGTH] = "";
  2297. char monster[NAME_LENGTH] = "";
  2298. int mob_id = 0;
  2299. int number = 0;
  2300. int x = 0;
  2301. int y = 0;
  2302. int count;
  2303. int i;
  2304. nullpo_retr(-1, sd);
  2305. if (!message || !*message) {
  2306. clif_displaymessage(fd, "Give a monster name/id please.");
  2307. return -1;
  2308. }
  2309. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2310. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2311. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2312. clif_displaymessage(fd, "Give a monster name/id please.");
  2313. return -1;
  2314. }
  2315. // If monster identifier/name argument is a name
  2316. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2317. mob_id = atoi(monster);
  2318. if (mob_id == 0) {
  2319. clif_displaymessage(fd, msg_txt(40));
  2320. return -1;
  2321. }
  2322. if (mob_id == MOBID_EMPERIUM) {
  2323. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2324. return -1;
  2325. }
  2326. if (mobdb_checkid(mob_id) == 0) {
  2327. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2328. return -1;
  2329. }
  2330. if (number <= 0)
  2331. number = 1;
  2332. if( !name[0] )
  2333. strcpy(name, "--ja--");
  2334. // 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
  2335. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2336. number = battle_config.atc_spawn_quantity_limit;
  2337. count = 0;
  2338. for (i = 0; i < number; i++) {
  2339. int mx, my;
  2340. if (x <= 0)
  2341. mx = sd->bl.x + (rand() % 11 - 5);
  2342. else
  2343. mx = x;
  2344. if (y <= 0)
  2345. my = sd->bl.y + (rand() % 11 - 5);
  2346. else
  2347. my = y;
  2348. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2349. }
  2350. if (count != 0)
  2351. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2352. else
  2353. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2354. return 0;
  2355. }
  2356. /*==========================================
  2357. *
  2358. *------------------------------------------*/
  2359. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2360. {
  2361. struct mob_data *md;
  2362. int flag;
  2363. nullpo_ret(md=(struct mob_data *)bl);
  2364. flag = va_arg(ap, int);
  2365. if (md->guardian_data)
  2366. return 0; //Do not touch WoE mobs!
  2367. if (flag)
  2368. status_zap(bl,md->status.hp, 0);
  2369. else
  2370. status_kill(bl);
  2371. return 1;
  2372. }
  2373. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2374. {
  2375. int map_id;
  2376. char map_name[MAP_NAME_LENGTH_EXT];
  2377. if (!sd) return;
  2378. memset(map_name, '\0', sizeof(map_name));
  2379. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2380. map_id = sd->bl.m;
  2381. else {
  2382. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2383. map_id = sd->bl.m;
  2384. }
  2385. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2386. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2387. return;
  2388. }
  2389. ACMD_FUNC(killmonster)
  2390. {
  2391. atcommand_killmonster_sub(fd, sd, message, 1);
  2392. return 0;
  2393. }
  2394. /*==========================================
  2395. *
  2396. *------------------------------------------*/
  2397. ACMD_FUNC(killmonster2)
  2398. {
  2399. atcommand_killmonster_sub(fd, sd, message, 0);
  2400. return 0;
  2401. }
  2402. /*==========================================
  2403. *
  2404. *------------------------------------------*/
  2405. ACMD_FUNC(refine)
  2406. {
  2407. int i,j, position = 0, refine = 0, current_position, final_refine;
  2408. int count;
  2409. nullpo_retr(-1, sd);
  2410. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2411. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2412. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2413. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2414. clif_displaymessage(fd, atcmd_output);
  2415. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2416. clif_displaymessage(fd, atcmd_output);
  2417. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2418. clif_displaymessage(fd, atcmd_output);
  2419. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2420. clif_displaymessage(fd, atcmd_output);
  2421. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2422. clif_displaymessage(fd, atcmd_output);
  2423. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2424. clif_displaymessage(fd, atcmd_output);
  2425. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2426. clif_displaymessage(fd, atcmd_output);
  2427. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2428. clif_displaymessage(fd, atcmd_output);
  2429. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2430. clif_displaymessage(fd, atcmd_output);
  2431. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2432. clif_displaymessage(fd, atcmd_output);
  2433. return -1;
  2434. }
  2435. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2436. count = 0;
  2437. for (j = 0; j < EQI_MAX-1; j++) {
  2438. if ((i = sd->equip_index[j]) < 0)
  2439. continue;
  2440. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2441. continue;
  2442. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2443. continue;
  2444. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2445. continue;
  2446. if(position && !(sd->status.inventory[i].equip & position))
  2447. continue;
  2448. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2449. if (sd->status.inventory[i].refine != final_refine) {
  2450. sd->status.inventory[i].refine = final_refine;
  2451. current_position = sd->status.inventory[i].equip;
  2452. pc_unequipitem(sd, i, 3);
  2453. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2454. clif_delitem(sd, i, 1, 3);
  2455. clif_additem(sd, i, 1, 0);
  2456. pc_equipitem(sd, i, current_position);
  2457. clif_misceffect(&sd->bl, 3);
  2458. count++;
  2459. }
  2460. }
  2461. if (count == 0)
  2462. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2463. else if (count == 1)
  2464. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2465. else {
  2466. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2467. clif_displaymessage(fd, atcmd_output);
  2468. }
  2469. return 0;
  2470. }
  2471. /*==========================================
  2472. *
  2473. *------------------------------------------*/
  2474. ACMD_FUNC(produce)
  2475. {
  2476. char item_name[100];
  2477. int item_id, attribute = 0, star = 0;
  2478. int flag = 0;
  2479. struct item_data *item_data;
  2480. struct item tmp_item;
  2481. nullpo_retr(-1, sd);
  2482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2483. memset(item_name, '\0', sizeof(item_name));
  2484. if (!message || !*message || (
  2485. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2486. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2487. )) {
  2488. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2489. return -1;
  2490. }
  2491. item_id = 0;
  2492. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2493. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2494. {
  2495. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2496. return -1;
  2497. }
  2498. item_id = item_data->nameid;
  2499. if (itemdb_isequip2(item_data)) {
  2500. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2501. attribute = ATTRIBUTE_NORMAL;
  2502. if (star < MIN_STAR || star > MAX_STAR)
  2503. star = 0;
  2504. memset(&tmp_item, 0, sizeof tmp_item);
  2505. tmp_item.nameid = item_id;
  2506. tmp_item.amount = 1;
  2507. tmp_item.identify = 1;
  2508. tmp_item.card[0] = CARD0_FORGE;
  2509. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2510. ((star*5) << 8) + attribute:0;
  2511. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2512. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2513. clif_produceeffect(sd, 0, item_id);
  2514. clif_misceffect(&sd->bl, 3);
  2515. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2516. clif_additem(sd, 0, 0, flag);
  2517. } else {
  2518. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2519. clif_displaymessage(fd, atcmd_output);
  2520. return -1;
  2521. }
  2522. return 0;
  2523. }
  2524. /*==========================================
  2525. *
  2526. *------------------------------------------*/
  2527. ACMD_FUNC(memo)
  2528. {
  2529. int position = 0;
  2530. nullpo_retr(-1, sd);
  2531. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2532. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2533. {
  2534. int i;
  2535. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2536. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2537. {
  2538. if( sd->status.memo_point[i].map )
  2539. 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);
  2540. else
  2541. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2542. clif_displaymessage(sd->fd, atcmd_output);
  2543. }
  2544. return 0;
  2545. }
  2546. if( position < 0 || position >= MAX_MEMOPOINTS )
  2547. {
  2548. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2549. clif_displaymessage(fd, atcmd_output);
  2550. return -1;
  2551. }
  2552. pc_memo(sd, position);
  2553. return 0;
  2554. }
  2555. /*==========================================
  2556. *
  2557. *------------------------------------------*/
  2558. ACMD_FUNC(gat)
  2559. {
  2560. int y;
  2561. nullpo_retr(-1, sd);
  2562. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2563. for (y = 2; y >= -2; y--) {
  2564. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2565. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2566. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2567. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2568. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2569. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2570. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2571. clif_displaymessage(fd, atcmd_output);
  2572. }
  2573. return 0;
  2574. }
  2575. /*==========================================
  2576. *
  2577. *------------------------------------------*/
  2578. ACMD_FUNC(displaystatus)
  2579. {
  2580. int i, type, flag, tick;
  2581. nullpo_retr(-1, sd);
  2582. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2583. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2584. return -1;
  2585. }
  2586. if (i < 2) flag = 1;
  2587. if (i < 3) tick = 0;
  2588. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2589. return 0;
  2590. }
  2591. /*==========================================
  2592. * @stpoint (Rewritten by [Yor])
  2593. *------------------------------------------*/
  2594. ACMD_FUNC(statuspoint)
  2595. {
  2596. int point;
  2597. unsigned int new_status_point;
  2598. if (!message || !*message || (point = atoi(message)) == 0) {
  2599. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2600. return -1;
  2601. }
  2602. if(point < 0)
  2603. {
  2604. if(sd->status.status_point < (unsigned int)(-point))
  2605. {
  2606. new_status_point = 0;
  2607. }
  2608. else
  2609. {
  2610. new_status_point = sd->status.status_point + point;
  2611. }
  2612. }
  2613. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2614. {
  2615. new_status_point = UINT_MAX;
  2616. }
  2617. else
  2618. {
  2619. new_status_point = sd->status.status_point + point;
  2620. }
  2621. if (new_status_point != sd->status.status_point) {
  2622. sd->status.status_point = new_status_point;
  2623. clif_updatestatus(sd, SP_STATUSPOINT);
  2624. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2625. } else {
  2626. if (point < 0)
  2627. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2628. else
  2629. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2630. return -1;
  2631. }
  2632. return 0;
  2633. }
  2634. /*==========================================
  2635. * @skpoint (Rewritten by [Yor])
  2636. *------------------------------------------*/
  2637. ACMD_FUNC(skillpoint)
  2638. {
  2639. int point;
  2640. unsigned int new_skill_point;
  2641. nullpo_retr(-1, sd);
  2642. if (!message || !*message || (point = atoi(message)) == 0) {
  2643. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2644. return -1;
  2645. }
  2646. if(point < 0)
  2647. {
  2648. if(sd->status.skill_point < (unsigned int)(-point))
  2649. {
  2650. new_skill_point = 0;
  2651. }
  2652. else
  2653. {
  2654. new_skill_point = sd->status.skill_point + point;
  2655. }
  2656. }
  2657. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2658. {
  2659. new_skill_point = UINT_MAX;
  2660. }
  2661. else
  2662. {
  2663. new_skill_point = sd->status.skill_point + point;
  2664. }
  2665. if (new_skill_point != sd->status.skill_point) {
  2666. sd->status.skill_point = new_skill_point;
  2667. clif_updatestatus(sd, SP_SKILLPOINT);
  2668. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2669. } else {
  2670. if (point < 0)
  2671. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2672. else
  2673. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2674. return -1;
  2675. }
  2676. return 0;
  2677. }
  2678. /*==========================================
  2679. * @zeny (Rewritten by [Yor])
  2680. *------------------------------------------*/
  2681. ACMD_FUNC(zeny)
  2682. {
  2683. int zeny, new_zeny;
  2684. nullpo_retr(-1, sd);
  2685. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2686. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2687. return -1;
  2688. }
  2689. new_zeny = sd->status.zeny + zeny;
  2690. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2691. new_zeny = MAX_ZENY;
  2692. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2693. new_zeny = 0;
  2694. if (new_zeny != sd->status.zeny) {
  2695. sd->status.zeny = new_zeny;
  2696. clif_updatestatus(sd, SP_ZENY);
  2697. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2698. } else {
  2699. if (zeny < 0)
  2700. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2701. else
  2702. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2703. return -1;
  2704. }
  2705. return 0;
  2706. }
  2707. /*==========================================
  2708. *
  2709. *------------------------------------------*/
  2710. ACMD_FUNC(param)
  2711. {
  2712. int i, value = 0, new_value, max;
  2713. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2714. short* status[6];
  2715. //we don't use direct initialization because it isn't part of the c standard.
  2716. nullpo_retr(-1, sd);
  2717. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2718. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2719. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2720. clif_displaymessage(fd, atcmd_output);
  2721. return -1;
  2722. }
  2723. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2724. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2725. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2726. clif_displaymessage(fd, atcmd_output);
  2727. return -1;
  2728. }
  2729. status[0] = &sd->status.str;
  2730. status[1] = &sd->status.agi;
  2731. status[2] = &sd->status.vit;
  2732. status[3] = &sd->status.int_;
  2733. status[4] = &sd->status.dex;
  2734. status[5] = &sd->status.luk;
  2735. if( battle_config.atcommand_max_stat_bypass )
  2736. max = SHRT_MAX;
  2737. else
  2738. max = pc_maxparameter(sd);
  2739. if(value < 0 && *status[i] <= -value) {
  2740. new_value = 1;
  2741. } else if(max - *status[i] < value) {
  2742. new_value = max;
  2743. } else {
  2744. new_value = *status[i] + value;
  2745. }
  2746. if (new_value != *status[i]) {
  2747. *status[i] = new_value;
  2748. clif_updatestatus(sd, SP_STR + i);
  2749. clif_updatestatus(sd, SP_USTR + i);
  2750. status_calc_pc(sd, 0);
  2751. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2752. } else {
  2753. if (value < 0)
  2754. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2755. else
  2756. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2757. return -1;
  2758. }
  2759. return 0;
  2760. }
  2761. /*==========================================
  2762. * Stat all by fritz (rewritten by [Yor])
  2763. *------------------------------------------*/
  2764. ACMD_FUNC(stat_all)
  2765. {
  2766. int index, count, value, max, new_value;
  2767. short* status[6];
  2768. //we don't use direct initialization because it isn't part of the c standard.
  2769. nullpo_retr(-1, sd);
  2770. status[0] = &sd->status.str;
  2771. status[1] = &sd->status.agi;
  2772. status[2] = &sd->status.vit;
  2773. status[3] = &sd->status.int_;
  2774. status[4] = &sd->status.dex;
  2775. status[5] = &sd->status.luk;
  2776. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2777. value = pc_maxparameter(sd);
  2778. max = pc_maxparameter(sd);
  2779. } else {
  2780. if( battle_config.atcommand_max_stat_bypass )
  2781. max = SHRT_MAX;
  2782. else
  2783. max = pc_maxparameter(sd);
  2784. }
  2785. count = 0;
  2786. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2787. if (value > 0 && *status[index] > max - value)
  2788. new_value = max;
  2789. else if (value < 0 && *status[index] <= -value)
  2790. new_value = 1;
  2791. else
  2792. new_value = *status[index] +value;
  2793. if (new_value != (int)*status[index]) {
  2794. *status[index] = new_value;
  2795. clif_updatestatus(sd, SP_STR + index);
  2796. clif_updatestatus(sd, SP_USTR + index);
  2797. count++;
  2798. }
  2799. }
  2800. if (count > 0) { // if at least 1 stat modified
  2801. status_calc_pc(sd, 0);
  2802. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2803. } else {
  2804. if (value < 0)
  2805. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2806. else
  2807. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2808. return -1;
  2809. }
  2810. return 0;
  2811. }
  2812. /*==========================================
  2813. *
  2814. *------------------------------------------*/
  2815. ACMD_FUNC(guildlevelup)
  2816. {
  2817. int level = 0;
  2818. short added_level;
  2819. struct guild *guild_info;
  2820. nullpo_retr(-1, sd);
  2821. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2822. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2823. return -1;
  2824. }
  2825. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2826. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2827. return -1;
  2828. }
  2829. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2830. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2831. // return -1;
  2832. //}
  2833. added_level = (short)level;
  2834. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2835. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2836. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2837. added_level = 1 - guild_info->guild_lv;
  2838. if (added_level != 0) {
  2839. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2840. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2841. } else {
  2842. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2843. return -1;
  2844. }
  2845. return 0;
  2846. }
  2847. /*==========================================
  2848. *
  2849. *------------------------------------------*/
  2850. ACMD_FUNC(makeegg)
  2851. {
  2852. struct item_data *item_data;
  2853. int id, pet_id;
  2854. nullpo_retr(-1, sd);
  2855. if (!message || !*message) {
  2856. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2857. return -1;
  2858. }
  2859. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2860. id = item_data->nameid;
  2861. else
  2862. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2863. ;
  2864. else
  2865. id = atoi(message);
  2866. pet_id = search_petDB_index(id, PET_CLASS);
  2867. if (pet_id < 0)
  2868. pet_id = search_petDB_index(id, PET_EGG);
  2869. if (pet_id >= 0) {
  2870. sd->catch_target_class = pet_db[pet_id].class_;
  2871. intif_create_pet(
  2872. sd->status.account_id, sd->status.char_id,
  2873. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2874. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2875. 100, 0, 1, pet_db[pet_id].jname);
  2876. } else {
  2877. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2878. return -1;
  2879. }
  2880. return 0;
  2881. }
  2882. /*==========================================
  2883. *
  2884. *------------------------------------------*/
  2885. ACMD_FUNC(hatch)
  2886. {
  2887. nullpo_retr(-1, sd);
  2888. if (sd->status.pet_id <= 0)
  2889. clif_sendegg(sd);
  2890. else {
  2891. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2892. return -1;
  2893. }
  2894. return 0;
  2895. }
  2896. /*==========================================
  2897. *
  2898. *------------------------------------------*/
  2899. ACMD_FUNC(petfriendly)
  2900. {
  2901. int friendly;
  2902. struct pet_data *pd;
  2903. nullpo_retr(-1, sd);
  2904. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2905. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2906. return -1;
  2907. }
  2908. pd = sd->pd;
  2909. if (!pd) {
  2910. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2911. return -1;
  2912. }
  2913. if (friendly < 0 || friendly > 1000)
  2914. {
  2915. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2916. return -1;
  2917. }
  2918. if (friendly == pd->pet.intimate) {
  2919. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2920. return -1;
  2921. }
  2922. pet_set_intimate(pd, friendly);
  2923. clif_send_petstatus(sd);
  2924. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2925. return 0;
  2926. }
  2927. /*==========================================
  2928. *
  2929. *------------------------------------------*/
  2930. ACMD_FUNC(pethungry)
  2931. {
  2932. int hungry;
  2933. struct pet_data *pd;
  2934. nullpo_retr(-1, sd);
  2935. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2936. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2937. return -1;
  2938. }
  2939. pd = sd->pd;
  2940. if (!sd->status.pet_id || !pd) {
  2941. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2942. return -1;
  2943. }
  2944. if (hungry < 0 || hungry > 100) {
  2945. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2946. return -1;
  2947. }
  2948. if (hungry == pd->pet.hungry) {
  2949. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2950. return -1;
  2951. }
  2952. pd->pet.hungry = hungry;
  2953. clif_send_petstatus(sd);
  2954. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2955. return 0;
  2956. }
  2957. /*==========================================
  2958. *
  2959. *------------------------------------------*/
  2960. ACMD_FUNC(petrename)
  2961. {
  2962. struct pet_data *pd;
  2963. nullpo_retr(-1, sd);
  2964. if (!sd->status.pet_id || !sd->pd) {
  2965. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2966. return -1;
  2967. }
  2968. pd = sd->pd;
  2969. if (!pd->pet.rename_flag) {
  2970. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2971. return -1;
  2972. }
  2973. pd->pet.rename_flag = 0;
  2974. intif_save_petdata(sd->status.account_id, &pd->pet);
  2975. clif_send_petstatus(sd);
  2976. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2977. return 0;
  2978. }
  2979. /*==========================================
  2980. *
  2981. *------------------------------------------*/
  2982. ACMD_FUNC(recall)
  2983. {
  2984. struct map_session_data *pl_sd = NULL;
  2985. nullpo_retr(-1, sd);
  2986. if (!message || !*message) {
  2987. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2988. return -1;
  2989. }
  2990. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2991. {
  2992. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2993. return -1;
  2994. }
  2995. if (pl_sd == sd)
  2996. {
  2997. clif_displaymessage(fd, "You are already where you are...");
  2998. return -1;
  2999. }
  3000. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3001. {
  3002. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3003. return -1;
  3004. }
  3005. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3006. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3007. return -1;
  3008. }
  3009. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3010. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3011. return -1;
  3012. }
  3013. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3014. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3015. clif_displaymessage(fd, atcmd_output);
  3016. return 0;
  3017. }
  3018. /*==========================================
  3019. * charblock command (usage: charblock <player_name>)
  3020. * This command do a definitiv ban on a player
  3021. *------------------------------------------*/
  3022. ACMD_FUNC(char_block)
  3023. {
  3024. nullpo_retr(-1, sd);
  3025. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3026. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3027. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3028. return -1;
  3029. }
  3030. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3031. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3032. return 0;
  3033. }
  3034. /*==========================================
  3035. * charban command (usage: charban <time> <player_name>)
  3036. * This command do a limited ban on a player
  3037. * Time is done as follows:
  3038. * Adjustment value (-1, 1, +1, etc...)
  3039. * Modified element:
  3040. * a or y: year
  3041. * m: month
  3042. * j or d: day
  3043. * h: hour
  3044. * mn: minute
  3045. * s: second
  3046. * <example> @ban +1m-2mn1s-6y test_player
  3047. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3048. *------------------------------------------*/
  3049. ACMD_FUNC(char_ban)
  3050. {
  3051. char * modif_p;
  3052. int year, month, day, hour, minute, second, value;
  3053. nullpo_retr(-1, sd);
  3054. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3055. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3056. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3057. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3058. return -1;
  3059. }
  3060. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3061. modif_p = atcmd_output;
  3062. year = month = day = hour = minute = second = 0;
  3063. while (modif_p[0] != '\0') {
  3064. value = atoi(modif_p);
  3065. if (value == 0)
  3066. modif_p++;
  3067. else {
  3068. if (modif_p[0] == '-' || modif_p[0] == '+')
  3069. modif_p++;
  3070. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3071. modif_p++;
  3072. if (modif_p[0] == 's') {
  3073. second = value;
  3074. modif_p++;
  3075. } else if (modif_p[0] == 'n') {
  3076. minute = value;
  3077. modif_p++;
  3078. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3079. minute = value;
  3080. modif_p = modif_p + 2;
  3081. } else if (modif_p[0] == 'h') {
  3082. hour = value;
  3083. modif_p++;
  3084. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3085. day = value;
  3086. modif_p++;
  3087. } else if (modif_p[0] == 'm') {
  3088. month = value;
  3089. modif_p++;
  3090. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3091. year = value;
  3092. modif_p++;
  3093. } else if (modif_p[0] != '\0') {
  3094. modif_p++;
  3095. }
  3096. }
  3097. }
  3098. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3099. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3100. return -1;
  3101. }
  3102. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3103. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3104. return 0;
  3105. }
  3106. /*==========================================
  3107. * charunblock command (usage: charunblock <player_name>)
  3108. *------------------------------------------*/
  3109. ACMD_FUNC(char_unblock)
  3110. {
  3111. nullpo_retr(-1, sd);
  3112. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3113. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3114. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3115. return -1;
  3116. }
  3117. // send answer to login server via char-server
  3118. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3119. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3120. return 0;
  3121. }
  3122. /*==========================================
  3123. * charunban command (usage: charunban <player_name>)
  3124. *------------------------------------------*/
  3125. ACMD_FUNC(char_unban)
  3126. {
  3127. nullpo_retr(-1, sd);
  3128. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3129. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3130. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3131. return -1;
  3132. }
  3133. // send answer to login server via char-server
  3134. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3135. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3136. return 0;
  3137. }
  3138. /*==========================================
  3139. *
  3140. *------------------------------------------*/
  3141. ACMD_FUNC(night)
  3142. {
  3143. nullpo_retr(-1, sd);
  3144. if (night_flag != 1) {
  3145. map_night_timer(night_timer_tid, 0, 0, 1);
  3146. } else {
  3147. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3148. return -1;
  3149. }
  3150. return 0;
  3151. }
  3152. /*==========================================
  3153. *
  3154. *------------------------------------------*/
  3155. ACMD_FUNC(day)
  3156. {
  3157. nullpo_retr(-1, sd);
  3158. if (night_flag != 0) {
  3159. map_day_timer(day_timer_tid, 0, 0, 1);
  3160. } else {
  3161. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3162. return -1;
  3163. }
  3164. return 0;
  3165. }
  3166. /*==========================================
  3167. *
  3168. *------------------------------------------*/
  3169. ACMD_FUNC(doom)
  3170. {
  3171. struct map_session_data* pl_sd;
  3172. struct s_mapiterator* iter;
  3173. nullpo_retr(-1, sd);
  3174. iter = mapit_getallusers();
  3175. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3176. {
  3177. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3178. {
  3179. status_kill(&pl_sd->bl);
  3180. clif_specialeffect(&pl_sd->bl,450,AREA);
  3181. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3182. }
  3183. }
  3184. mapit_free(iter);
  3185. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3186. return 0;
  3187. }
  3188. /*==========================================
  3189. *
  3190. *------------------------------------------*/
  3191. ACMD_FUNC(doommap)
  3192. {
  3193. struct map_session_data* pl_sd;
  3194. struct s_mapiterator* iter;
  3195. nullpo_retr(-1, sd);
  3196. iter = mapit_getallusers();
  3197. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3198. {
  3199. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3200. {
  3201. status_kill(&pl_sd->bl);
  3202. clif_specialeffect(&pl_sd->bl,450,AREA);
  3203. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3204. }
  3205. }
  3206. mapit_free(iter);
  3207. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3208. return 0;
  3209. }
  3210. /*==========================================
  3211. *
  3212. *------------------------------------------*/
  3213. static void atcommand_raise_sub(struct map_session_data* sd)
  3214. {
  3215. if (!status_isdead(&sd->bl))
  3216. return;
  3217. if(!status_revive(&sd->bl, 100, 100))
  3218. return;
  3219. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3220. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3221. }
  3222. /*==========================================
  3223. *
  3224. *------------------------------------------*/
  3225. ACMD_FUNC(raise)
  3226. {
  3227. struct map_session_data* pl_sd;
  3228. struct s_mapiterator* iter;
  3229. nullpo_retr(-1, sd);
  3230. iter = mapit_getallusers();
  3231. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3232. atcommand_raise_sub(pl_sd);
  3233. mapit_free(iter);
  3234. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3235. return 0;
  3236. }
  3237. /*==========================================
  3238. *
  3239. *------------------------------------------*/
  3240. ACMD_FUNC(raisemap)
  3241. {
  3242. struct map_session_data* pl_sd;
  3243. struct s_mapiterator* iter;
  3244. nullpo_retr(-1, sd);
  3245. iter = mapit_getallusers();
  3246. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3247. if (sd->bl.m == pl_sd->bl.m)
  3248. atcommand_raise_sub(pl_sd);
  3249. mapit_free(iter);
  3250. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3251. return 0;
  3252. }
  3253. /*==========================================
  3254. *
  3255. *------------------------------------------*/
  3256. ACMD_FUNC(kick)
  3257. {
  3258. struct map_session_data *pl_sd;
  3259. nullpo_retr(-1, sd);
  3260. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3261. if (!message || !*message) {
  3262. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3263. return -1;
  3264. }
  3265. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3266. {
  3267. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3268. return -1;
  3269. }
  3270. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3271. {
  3272. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3273. return -1;
  3274. }
  3275. clif_GM_kick(sd, pl_sd);
  3276. return 0;
  3277. }
  3278. /*==========================================
  3279. *
  3280. *------------------------------------------*/
  3281. ACMD_FUNC(kickall)
  3282. {
  3283. struct map_session_data* pl_sd;
  3284. struct s_mapiterator* iter;
  3285. nullpo_retr(-1, sd);
  3286. iter = mapit_getallusers();
  3287. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3288. {
  3289. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3290. if (sd->status.account_id != pl_sd->status.account_id)
  3291. clif_GM_kick(NULL, pl_sd);
  3292. }
  3293. }
  3294. mapit_free(iter);
  3295. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3296. return 0;
  3297. }
  3298. /*==========================================
  3299. *
  3300. *------------------------------------------*/
  3301. ACMD_FUNC(allskill)
  3302. {
  3303. nullpo_retr(-1, sd);
  3304. pc_allskillup(sd); // all skills
  3305. sd->status.skill_point = 0; // 0 skill points
  3306. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3307. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3308. return 0;
  3309. }
  3310. /*==========================================
  3311. *
  3312. *------------------------------------------*/
  3313. ACMD_FUNC(questskill)
  3314. {
  3315. int skill_id;
  3316. nullpo_retr(-1, sd);
  3317. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3318. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3319. return -1;
  3320. }
  3321. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3322. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3323. return -1;
  3324. }
  3325. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3326. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3327. return -1;
  3328. }
  3329. if (pc_checkskill(sd, skill_id) > 0) {
  3330. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3331. return -1;
  3332. }
  3333. pc_skill(sd, skill_id, 1, 0);
  3334. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3335. return 0;
  3336. }
  3337. /*==========================================
  3338. *
  3339. *------------------------------------------*/
  3340. ACMD_FUNC(lostskill)
  3341. {
  3342. int skill_id;
  3343. nullpo_retr(-1, sd);
  3344. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3345. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3346. return -1;
  3347. }
  3348. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3349. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3350. return -1;
  3351. }
  3352. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3353. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3354. return -1;
  3355. }
  3356. if (pc_checkskill(sd, skill_id) == 0) {
  3357. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3358. return -1;
  3359. }
  3360. sd->status.skill[skill_id].lv = 0;
  3361. sd->status.skill[skill_id].flag = 0;
  3362. clif_deleteskill(sd,skill_id);
  3363. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3364. return 0;
  3365. }
  3366. /*==========================================
  3367. *
  3368. *------------------------------------------*/
  3369. ACMD_FUNC(spiritball)
  3370. {
  3371. int max_spiritballs;
  3372. int number;
  3373. nullpo_retr(-1, sd);
  3374. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3375. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3376. {
  3377. char msg[CHAT_SIZE_MAX];
  3378. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3379. clif_displaymessage(fd, msg);
  3380. return -1;
  3381. }
  3382. if( sd->spiritball > 0 )
  3383. pc_delspiritball(sd, sd->spiritball, 1);
  3384. sd->spiritball = number;
  3385. clif_spiritball(sd);
  3386. // no message, player can look the difference
  3387. return 0;
  3388. }
  3389. /*==========================================
  3390. *
  3391. *------------------------------------------*/
  3392. ACMD_FUNC(party)
  3393. {
  3394. char party[NAME_LENGTH];
  3395. nullpo_retr(-1, sd);
  3396. memset(party, '\0', sizeof(party));
  3397. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3398. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3399. return -1;
  3400. }
  3401. party_create(sd, party, 0, 0);
  3402. return 0;
  3403. }
  3404. /*==========================================
  3405. *
  3406. *------------------------------------------*/
  3407. ACMD_FUNC(guild)
  3408. {
  3409. char guild[NAME_LENGTH];
  3410. int prev;
  3411. nullpo_retr(-1, sd);
  3412. memset(guild, '\0', sizeof(guild));
  3413. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3414. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3415. return -1;
  3416. }
  3417. prev = battle_config.guild_emperium_check;
  3418. battle_config.guild_emperium_check = 0;
  3419. guild_create(sd, guild);
  3420. battle_config.guild_emperium_check = prev;
  3421. return 0;
  3422. }
  3423. /*==========================================
  3424. *
  3425. *------------------------------------------*/
  3426. ACMD_FUNC(agitstart)
  3427. {
  3428. nullpo_retr(-1, sd);
  3429. if (agit_flag == 1) {
  3430. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3431. return -1;
  3432. }
  3433. agit_flag = 1;
  3434. guild_agit_start();
  3435. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3436. return 0;
  3437. }
  3438. /*==========================================
  3439. *
  3440. *------------------------------------------*/
  3441. ACMD_FUNC(agitstart2)
  3442. {
  3443. nullpo_retr(-1, sd);
  3444. if (agit2_flag == 1) {
  3445. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3446. return -1;
  3447. }
  3448. agit2_flag = 1;
  3449. guild_agit2_start();
  3450. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3451. return 0;
  3452. }
  3453. /*==========================================
  3454. *
  3455. *------------------------------------------*/
  3456. ACMD_FUNC(agitend)
  3457. {
  3458. nullpo_retr(-1, sd);
  3459. if (agit_flag == 0) {
  3460. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3461. return -1;
  3462. }
  3463. agit_flag = 0;
  3464. guild_agit_end();
  3465. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3466. return 0;
  3467. }
  3468. /*==========================================
  3469. *
  3470. *------------------------------------------*/
  3471. ACMD_FUNC(agitend2)
  3472. {
  3473. nullpo_retr(-1, sd);
  3474. if (agit2_flag == 0) {
  3475. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3476. return -1;
  3477. }
  3478. agit2_flag = 0;
  3479. guild_agit2_end();
  3480. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3481. return 0;
  3482. }
  3483. /*==========================================
  3484. * @mapexit - shuts down the map server
  3485. *------------------------------------------*/
  3486. ACMD_FUNC(mapexit)
  3487. {
  3488. nullpo_retr(-1, sd);
  3489. do_shutdown();
  3490. return 0;
  3491. }
  3492. /*==========================================
  3493. * idsearch <part_of_name>: revrited by [Yor]
  3494. *------------------------------------------*/
  3495. ACMD_FUNC(idsearch)
  3496. {
  3497. char item_name[100];
  3498. unsigned int i, match;
  3499. struct item_data *item_array[MAX_SEARCH];
  3500. nullpo_retr(-1, sd);
  3501. memset(item_name, '\0', sizeof(item_name));
  3502. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3503. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3504. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3505. return -1;
  3506. }
  3507. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3508. clif_displaymessage(fd, atcmd_output);
  3509. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3510. if (match > MAX_SEARCH) {
  3511. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3512. clif_displaymessage(fd, atcmd_output);
  3513. match = MAX_SEARCH;
  3514. }
  3515. for(i = 0; i < match; i++) {
  3516. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3517. clif_displaymessage(fd, atcmd_output);
  3518. }
  3519. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3520. clif_displaymessage(fd, atcmd_output);
  3521. return 0;
  3522. }
  3523. /*==========================================
  3524. * Recall All Characters Online To Your Location
  3525. *------------------------------------------*/
  3526. ACMD_FUNC(recallall)
  3527. {
  3528. struct map_session_data* pl_sd;
  3529. struct s_mapiterator* iter;
  3530. int count;
  3531. nullpo_retr(-1, sd);
  3532. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3533. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3534. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3535. return -1;
  3536. }
  3537. count = 0;
  3538. iter = mapit_getallusers();
  3539. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3540. {
  3541. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3542. {
  3543. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3544. count++;
  3545. else {
  3546. if (pc_isdead(pl_sd)) { //Wake them up
  3547. pc_setstand(pl_sd);
  3548. pc_setrestartvalue(pl_sd,1);
  3549. }
  3550. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3551. }
  3552. }
  3553. }
  3554. mapit_free(iter);
  3555. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3556. if (count) {
  3557. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3558. clif_displaymessage(fd, atcmd_output);
  3559. }
  3560. return 0;
  3561. }
  3562. /*==========================================
  3563. * Recall online characters of a guild to your location
  3564. *------------------------------------------*/
  3565. ACMD_FUNC(guildrecall)
  3566. {
  3567. struct map_session_data* pl_sd;
  3568. struct s_mapiterator* iter;
  3569. int count;
  3570. char guild_name[NAME_LENGTH];
  3571. struct guild *g;
  3572. nullpo_retr(-1, sd);
  3573. memset(guild_name, '\0', sizeof(guild_name));
  3574. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3575. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3576. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3577. return -1;
  3578. }
  3579. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3580. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3581. return -1;
  3582. }
  3583. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3584. (g = guild_search(atoi(message))) == NULL)
  3585. {
  3586. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3587. return -1;
  3588. }
  3589. count = 0;
  3590. iter = mapit_getallusers();
  3591. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3592. {
  3593. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3594. {
  3595. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3596. continue; //Skip GMs greater than you.
  3597. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3598. count++;
  3599. else
  3600. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3601. }
  3602. }
  3603. mapit_free(iter);
  3604. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3605. clif_displaymessage(fd, atcmd_output);
  3606. if (count) {
  3607. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3608. clif_displaymessage(fd, atcmd_output);
  3609. }
  3610. return 0;
  3611. }
  3612. /*==========================================
  3613. * Recall online characters of a party to your location
  3614. *------------------------------------------*/
  3615. ACMD_FUNC(partyrecall)
  3616. {
  3617. struct map_session_data* pl_sd;
  3618. struct s_mapiterator* iter;
  3619. char party_name[NAME_LENGTH];
  3620. struct party_data *p;
  3621. int count;
  3622. nullpo_retr(-1, sd);
  3623. memset(party_name, '\0', sizeof(party_name));
  3624. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3625. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3626. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3627. return -1;
  3628. }
  3629. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3630. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3631. return -1;
  3632. }
  3633. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3634. (p = party_search(atoi(message))) == NULL)
  3635. {
  3636. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3637. return -1;
  3638. }
  3639. count = 0;
  3640. iter = mapit_getallusers();
  3641. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3642. {
  3643. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3644. {
  3645. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3646. continue; //Skip GMs greater than you.
  3647. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3648. count++;
  3649. else
  3650. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3651. }
  3652. }
  3653. mapit_free(iter);
  3654. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3655. clif_displaymessage(fd, atcmd_output);
  3656. if (count) {
  3657. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3658. clif_displaymessage(fd, atcmd_output);
  3659. }
  3660. return 0;
  3661. }
  3662. /*==========================================
  3663. *
  3664. *------------------------------------------*/
  3665. ACMD_FUNC(reloaditemdb)
  3666. {
  3667. nullpo_retr(-1, sd);
  3668. itemdb_reload();
  3669. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3670. return 0;
  3671. }
  3672. /*==========================================
  3673. *
  3674. *------------------------------------------*/
  3675. ACMD_FUNC(reloadmobdb)
  3676. {
  3677. nullpo_retr(-1, sd);
  3678. mob_reload();
  3679. read_petdb();
  3680. merc_reload();
  3681. read_mercenarydb();
  3682. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3683. return 0;
  3684. }
  3685. /*==========================================
  3686. *
  3687. *------------------------------------------*/
  3688. ACMD_FUNC(reloadskilldb)
  3689. {
  3690. nullpo_retr(-1, sd);
  3691. skill_reload();
  3692. merc_skill_reload();
  3693. read_mercenary_skilldb();
  3694. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3695. return 0;
  3696. }
  3697. /*==========================================
  3698. * @reloadatcommand - reloads atcommand_athena.conf
  3699. *------------------------------------------*/
  3700. void atcommand_doload();
  3701. ACMD_FUNC(reloadatcommand) {
  3702. atcommand_doload();
  3703. clif_displaymessage(fd, msg_txt(254));
  3704. return 0;
  3705. }
  3706. /*==========================================
  3707. * @reloadbattleconf - reloads battle_athena.conf
  3708. *------------------------------------------*/
  3709. ACMD_FUNC(reloadbattleconf)
  3710. {
  3711. struct Battle_Config prev_config;
  3712. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3713. battle_config_read(BATTLE_CONF_FILENAME);
  3714. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3715. || prev_config.item_rate_common != battle_config.item_rate_common
  3716. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3717. || prev_config.item_rate_card != battle_config.item_rate_card
  3718. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3719. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3720. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3721. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3722. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3723. || prev_config.item_rate_use != battle_config.item_rate_use
  3724. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3725. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3726. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3727. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3728. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3729. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3730. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3731. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3732. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3733. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3734. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3735. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3736. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3737. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3738. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3739. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3740. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3741. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3742. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3743. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3744. )
  3745. { // Exp or Drop rates changed.
  3746. mob_reload(); //Needed as well so rate changes take effect.
  3747. #ifndef TXT_ONLY
  3748. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3749. #endif
  3750. }
  3751. clif_displaymessage(fd, msg_txt(255));
  3752. return 0;
  3753. }
  3754. /*==========================================
  3755. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3756. *------------------------------------------*/
  3757. ACMD_FUNC(reloadstatusdb)
  3758. {
  3759. status_readdb();
  3760. clif_displaymessage(fd, msg_txt(256));
  3761. return 0;
  3762. }
  3763. /*==========================================
  3764. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3765. *------------------------------------------*/
  3766. ACMD_FUNC(reloadpcdb)
  3767. {
  3768. pc_readdb();
  3769. clif_displaymessage(fd, msg_txt(257));
  3770. return 0;
  3771. }
  3772. /*==========================================
  3773. * @reloadmotd - reloads motd.txt
  3774. *------------------------------------------*/
  3775. ACMD_FUNC(reloadmotd)
  3776. {
  3777. pc_read_motd();
  3778. clif_displaymessage(fd, msg_txt(268));
  3779. return 0;
  3780. }
  3781. /*==========================================
  3782. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3783. *------------------------------------------*/
  3784. ACMD_FUNC(reloadscript)
  3785. {
  3786. nullpo_retr(-1, sd);
  3787. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3788. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3789. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3790. flush_fifos();
  3791. script_reload();
  3792. npc_reload();
  3793. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3794. return 0;
  3795. }
  3796. /*==========================================
  3797. * @mapinfo [0-3] <map name> by MC_Cameri
  3798. * => Shows information about the map [map name]
  3799. * 0 = no additional information
  3800. * 1 = Show users in that map and their location
  3801. * 2 = Shows NPCs in that map
  3802. * 3 = Shows the shops/chats in that map (not implemented)
  3803. *------------------------------------------*/
  3804. ACMD_FUNC(mapinfo)
  3805. {
  3806. struct map_session_data* pl_sd;
  3807. struct s_mapiterator* iter;
  3808. struct npc_data *nd = NULL;
  3809. struct chat_data *cd = NULL;
  3810. char direction[12];
  3811. int i, m_id, chat_num, list = 0;
  3812. unsigned short m_index;
  3813. char mapname[24];
  3814. nullpo_retr(-1, sd);
  3815. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3816. memset(mapname, '\0', sizeof(mapname));
  3817. memset(direction, '\0', sizeof(direction));
  3818. sscanf(message, "%d %23[^\n]", &list, mapname);
  3819. if (list < 0 || list > 3) {
  3820. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3821. return -1;
  3822. }
  3823. if (mapname[0] == '\0') {
  3824. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3825. m_id = map_mapindex2mapid(sd->mapindex);
  3826. } else {
  3827. m_id = map_mapname2mapid(mapname);
  3828. }
  3829. if (m_id < 0) {
  3830. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3831. return -1;
  3832. }
  3833. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3834. clif_displaymessage(fd, "------ Map Info ------");
  3835. // count chats (for initial message)
  3836. chat_num = 0;
  3837. iter = mapit_getallusers();
  3838. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3839. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3840. chat_num++;
  3841. mapit_free(iter);
  3842. sprintf(atcmd_output, "Map Name: %s | Players In Map: %d | NPCs In Map: %d | Chats In Map: %d", mapname, map[m_id].users, map[m_id].npc_num, chat_num);
  3843. clif_displaymessage(fd, atcmd_output);
  3844. clif_displaymessage(fd, "------ Map Flags ------");
  3845. if (map[m_id].flag.town)
  3846. clif_displaymessage(fd, "Town Map");
  3847. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3848. clif_displaymessage(fd, "Autotrade Enabled");
  3849. else
  3850. clif_displaymessage(fd, "Autotrade Disabled");
  3851. if (map[m_id].flag.battleground)
  3852. clif_displaymessage(fd, "Battlegrounds ON");
  3853. strcpy(atcmd_output,"PvP Flags: ");
  3854. if (map[m_id].flag.pvp)
  3855. strcat(atcmd_output, "Pvp ON | ");
  3856. if (map[m_id].flag.pvp_noguild)
  3857. strcat(atcmd_output, "NoGuild | ");
  3858. if (map[m_id].flag.pvp_noparty)
  3859. strcat(atcmd_output, "NoParty | ");
  3860. if (map[m_id].flag.pvp_nightmaredrop)
  3861. strcat(atcmd_output, "NightmareDrop | ");
  3862. if (map[m_id].flag.pvp_nocalcrank)
  3863. strcat(atcmd_output, "NoCalcRank | ");
  3864. clif_displaymessage(fd, atcmd_output);
  3865. strcpy(atcmd_output,"GvG Flags: ");
  3866. if (map[m_id].flag.gvg)
  3867. strcat(atcmd_output, "GvG ON | ");
  3868. if (map[m_id].flag.gvg_dungeon)
  3869. strcat(atcmd_output, "GvG Dungeon | ");
  3870. if (map[m_id].flag.gvg_castle)
  3871. strcat(atcmd_output, "GvG Castle | ");
  3872. if (map[m_id].flag.gvg_noparty)
  3873. strcat(atcmd_output, "NoParty | ");
  3874. clif_displaymessage(fd, atcmd_output);
  3875. strcpy(atcmd_output,"Teleport Flags: ");
  3876. if (map[m_id].flag.noteleport)
  3877. strcat(atcmd_output, "NoTeleport | ");
  3878. if (map[m_id].flag.monster_noteleport)
  3879. strcat(atcmd_output, "Monster NoTeleport | ");
  3880. if (map[m_id].flag.nowarp)
  3881. strcat(atcmd_output, "NoWarp | ");
  3882. if (map[m_id].flag.nowarpto)
  3883. strcat(atcmd_output, "NoWarpTo | ");
  3884. if (map[m_id].flag.noreturn)
  3885. strcat(atcmd_output, "NoReturn | ");
  3886. if (map[m_id].flag.nogo)
  3887. strcat(atcmd_output, "NoGo | ");
  3888. if (map[m_id].flag.nomemo)
  3889. strcat(atcmd_output, "NoMemo | ");
  3890. clif_displaymessage(fd, atcmd_output);
  3891. sprintf(atcmd_output, "No Exp Penalty: %s | No Zeny Penalty: %s", (map[m_id].flag.noexppenalty) ? "On" : "Off", (map[m_id].flag.nozenypenalty) ? "On" : "Off");
  3892. clif_displaymessage(fd, atcmd_output);
  3893. if (map[m_id].flag.nosave) {
  3894. if (!map[m_id].save.map)
  3895. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3896. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3897. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3898. else
  3899. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3900. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3901. clif_displaymessage(fd, atcmd_output);
  3902. }
  3903. strcpy(atcmd_output,"Weather Flags: ");
  3904. if (map[m_id].flag.snow)
  3905. strcat(atcmd_output, "Snow | ");
  3906. if (map[m_id].flag.fog)
  3907. strcat(atcmd_output, "Fog | ");
  3908. if (map[m_id].flag.sakura)
  3909. strcat(atcmd_output, "Sakura | ");
  3910. if (map[m_id].flag.clouds)
  3911. strcat(atcmd_output, "Clouds | ");
  3912. if (map[m_id].flag.clouds2)
  3913. strcat(atcmd_output, "Clouds2 | ");
  3914. if (map[m_id].flag.fireworks)
  3915. strcat(atcmd_output, "Fireworks | ");
  3916. if (map[m_id].flag.leaves)
  3917. strcat(atcmd_output, "Leaves | ");
  3918. /**
  3919. * No longer available, keeping here just in case it's back someday. [Ind]
  3920. **/
  3921. //if (map[m_id].flag.rain)
  3922. // strcat(atcmd_output, "Rain | ");
  3923. if (map[m_id].flag.nightenabled)
  3924. strcat(atcmd_output, "Displays Night | ");
  3925. clif_displaymessage(fd, atcmd_output);
  3926. strcpy(atcmd_output,"Other Flags: ");
  3927. if (map[m_id].flag.nobranch)
  3928. strcat(atcmd_output, "NoBranch | ");
  3929. if (map[m_id].flag.notrade)
  3930. strcat(atcmd_output, "NoTrade | ");
  3931. if (map[m_id].flag.novending)
  3932. strcat(atcmd_output, "NoVending | ");
  3933. if (map[m_id].flag.nodrop)
  3934. strcat(atcmd_output, "NoDrop | ");
  3935. if (map[m_id].flag.noskill)
  3936. strcat(atcmd_output, "NoSkill | ");
  3937. if (map[m_id].flag.noicewall)
  3938. strcat(atcmd_output, "NoIcewall | ");
  3939. if (map[m_id].flag.allowks)
  3940. strcat(atcmd_output, "AllowKS | ");
  3941. if (map[m_id].flag.reset)
  3942. strcat(atcmd_output, "Reset | ");
  3943. clif_displaymessage(fd, atcmd_output);
  3944. strcpy(atcmd_output,"Other Flags: ");
  3945. if (map[m_id].nocommand)
  3946. strcat(atcmd_output, "NoCommand | ");
  3947. if (map[m_id].flag.nobaseexp)
  3948. strcat(atcmd_output, "NoBaseEXP | ");
  3949. if (map[m_id].flag.nojobexp)
  3950. strcat(atcmd_output, "NoJobEXP | ");
  3951. if (map[m_id].flag.nomobloot)
  3952. strcat(atcmd_output, "NoMobLoot | ");
  3953. if (map[m_id].flag.nomvploot)
  3954. strcat(atcmd_output, "NoMVPLoot | ");
  3955. if (map[m_id].flag.partylock)
  3956. strcat(atcmd_output, "PartyLock | ");
  3957. if (map[m_id].flag.guildlock)
  3958. strcat(atcmd_output, "GuildLock | ");
  3959. clif_displaymessage(fd, atcmd_output);
  3960. switch (list) {
  3961. case 0:
  3962. // Do nothing. It's list 0, no additional display.
  3963. break;
  3964. case 1:
  3965. clif_displaymessage(fd, "----- Players in Map -----");
  3966. iter = mapit_getallusers();
  3967. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3968. {
  3969. if (pl_sd->mapindex == m_index) {
  3970. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3971. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3972. clif_displaymessage(fd, atcmd_output);
  3973. }
  3974. }
  3975. mapit_free(iter);
  3976. break;
  3977. case 2:
  3978. clif_displaymessage(fd, "----- NPCs in Map -----");
  3979. for (i = 0; i < map[m_id].npc_num;)
  3980. {
  3981. nd = map[m_id].npc[i];
  3982. switch(nd->ud.dir) {
  3983. case 0: strcpy(direction, "North"); break;
  3984. case 1: strcpy(direction, "North West"); break;
  3985. case 2: strcpy(direction, "West"); break;
  3986. case 3: strcpy(direction, "South West"); break;
  3987. case 4: strcpy(direction, "South"); break;
  3988. case 5: strcpy(direction, "South East"); break;
  3989. case 6: strcpy(direction, "East"); break;
  3990. case 7: strcpy(direction, "North East"); break;
  3991. case 9: strcpy(direction, "North"); break;
  3992. default: strcpy(direction, "Unknown"); break;
  3993. }
  3994. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3995. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3996. clif_displaymessage(fd, atcmd_output);
  3997. }
  3998. break;
  3999. case 3:
  4000. clif_displaymessage(fd, "----- Chats in Map -----");
  4001. iter = mapit_getallusers();
  4002. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4003. {
  4004. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4005. pl_sd->mapindex == m_index &&
  4006. cd->usersd[0] == pl_sd)
  4007. {
  4008. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4009. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4010. clif_displaymessage(fd, atcmd_output);
  4011. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4012. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4013. clif_displaymessage(fd, atcmd_output);
  4014. }
  4015. }
  4016. mapit_free(iter);
  4017. break;
  4018. default: // normally impossible to arrive here
  4019. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4020. return -1;
  4021. break;
  4022. }
  4023. return 0;
  4024. }
  4025. /*==========================================
  4026. *
  4027. *------------------------------------------*/
  4028. ACMD_FUNC(mount_peco)
  4029. {
  4030. nullpo_retr(-1, sd);
  4031. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4032. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4033. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4034. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4035. } else {
  4036. clif_displaymessage(sd->fd,"You have released your Dragon");
  4037. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4038. }
  4039. return 0;
  4040. }
  4041. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4042. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  4043. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4044. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4045. } else {
  4046. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4047. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4048. }
  4049. return 0;
  4050. }
  4051. if (!pc_isriding(sd)) { // if actually no peco
  4052. if (!pc_checkskill(sd, KN_RIDING))
  4053. {
  4054. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4055. return -1;
  4056. }
  4057. if (sd->disguise)
  4058. {
  4059. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4060. return -1;
  4061. }
  4062. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4063. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4064. } else { //Dismount
  4065. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4066. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4067. }
  4068. return 0;
  4069. }
  4070. /*==========================================
  4071. *Spy Commands by Syrus22
  4072. *------------------------------------------*/
  4073. ACMD_FUNC(guildspy)
  4074. {
  4075. char guild_name[NAME_LENGTH];
  4076. struct guild *g;
  4077. nullpo_retr(-1, sd);
  4078. memset(guild_name, '\0', sizeof(guild_name));
  4079. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4080. if (!enable_spy)
  4081. {
  4082. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4083. return -1;
  4084. }
  4085. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4086. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4087. return -1;
  4088. }
  4089. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4090. (g = guild_search(atoi(message))) != NULL) {
  4091. if (sd->guildspy == g->guild_id) {
  4092. sd->guildspy = 0;
  4093. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4094. clif_displaymessage(fd, atcmd_output);
  4095. } else {
  4096. sd->guildspy = g->guild_id;
  4097. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4098. clif_displaymessage(fd, atcmd_output);
  4099. }
  4100. } else {
  4101. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4102. return -1;
  4103. }
  4104. return 0;
  4105. }
  4106. /*==========================================
  4107. *
  4108. *------------------------------------------*/
  4109. ACMD_FUNC(partyspy)
  4110. {
  4111. char party_name[NAME_LENGTH];
  4112. struct party_data *p;
  4113. nullpo_retr(-1, sd);
  4114. memset(party_name, '\0', sizeof(party_name));
  4115. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4116. if (!enable_spy)
  4117. {
  4118. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4119. return -1;
  4120. }
  4121. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4122. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4123. return -1;
  4124. }
  4125. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4126. (p = party_search(atoi(message))) != NULL) {
  4127. if (sd->partyspy == p->party.party_id) {
  4128. sd->partyspy = 0;
  4129. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4130. clif_displaymessage(fd, atcmd_output);
  4131. } else {
  4132. sd->partyspy = p->party.party_id;
  4133. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4134. clif_displaymessage(fd, atcmd_output);
  4135. }
  4136. } else {
  4137. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4138. return -1;
  4139. }
  4140. return 0;
  4141. }
  4142. /*==========================================
  4143. * @repairall [Valaris]
  4144. *------------------------------------------*/
  4145. ACMD_FUNC(repairall)
  4146. {
  4147. int count, i;
  4148. nullpo_retr(-1, sd);
  4149. count = 0;
  4150. for (i = 0; i < MAX_INVENTORY; i++) {
  4151. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4152. sd->status.inventory[i].attribute = 0;
  4153. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4154. count++;
  4155. }
  4156. }
  4157. if (count > 0) {
  4158. clif_misceffect(&sd->bl, 3);
  4159. clif_equiplist(sd);
  4160. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4161. } else {
  4162. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4163. return -1;
  4164. }
  4165. return 0;
  4166. }
  4167. /*==========================================
  4168. * @nuke [Valaris]
  4169. *------------------------------------------*/
  4170. ACMD_FUNC(nuke)
  4171. {
  4172. struct map_session_data *pl_sd;
  4173. nullpo_retr(-1, sd);
  4174. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4175. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4176. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4177. return -1;
  4178. }
  4179. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4180. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4181. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4182. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4183. } else {
  4184. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4185. return -1;
  4186. }
  4187. } else {
  4188. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4189. return -1;
  4190. }
  4191. return 0;
  4192. }
  4193. /*==========================================
  4194. * @tonpc
  4195. *------------------------------------------*/
  4196. ACMD_FUNC(tonpc)
  4197. {
  4198. char npcname[NAME_LENGTH+1];
  4199. struct npc_data *nd;
  4200. nullpo_retr(-1, sd);
  4201. memset(npcname, 0, sizeof(npcname));
  4202. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4203. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4204. return -1;
  4205. }
  4206. if ((nd = npc_name2id(npcname)) != NULL) {
  4207. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4208. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4209. else
  4210. return -1;
  4211. } else {
  4212. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4213. return -1;
  4214. }
  4215. return 0;
  4216. }
  4217. /*==========================================
  4218. *
  4219. *------------------------------------------*/
  4220. ACMD_FUNC(shownpc)
  4221. {
  4222. char NPCname[NAME_LENGTH+1];
  4223. nullpo_retr(-1, sd);
  4224. memset(NPCname, '\0', sizeof(NPCname));
  4225. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4226. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4227. return -1;
  4228. }
  4229. if (npc_name2id(NPCname) != NULL) {
  4230. npc_enable(NPCname, 1);
  4231. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4232. } else {
  4233. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4234. return -1;
  4235. }
  4236. return 0;
  4237. }
  4238. /*==========================================
  4239. *
  4240. *------------------------------------------*/
  4241. ACMD_FUNC(hidenpc)
  4242. {
  4243. char NPCname[NAME_LENGTH+1];
  4244. nullpo_retr(-1, sd);
  4245. memset(NPCname, '\0', sizeof(NPCname));
  4246. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4247. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4248. return -1;
  4249. }
  4250. if (npc_name2id(NPCname) == NULL) {
  4251. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4252. return -1;
  4253. }
  4254. npc_enable(NPCname, 0);
  4255. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4256. return 0;
  4257. }
  4258. ACMD_FUNC(loadnpc)
  4259. {
  4260. FILE *fp;
  4261. if (!message || !*message) {
  4262. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4263. return -1;
  4264. }
  4265. // check if script file exists
  4266. if ((fp = fopen(message, "r")) == NULL) {
  4267. clif_displaymessage(fd, msg_txt(261));
  4268. return -1;
  4269. }
  4270. fclose(fp);
  4271. // add to list of script sources and run it
  4272. npc_addsrcfile(message);
  4273. npc_parsesrcfile(message);
  4274. npc_read_event_script();
  4275. clif_displaymessage(fd, msg_txt(262));
  4276. return 0;
  4277. }
  4278. ACMD_FUNC(unloadnpc)
  4279. {
  4280. struct npc_data *nd;
  4281. char NPCname[NAME_LENGTH+1];
  4282. nullpo_retr(-1, sd);
  4283. memset(NPCname, '\0', sizeof(NPCname));
  4284. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4285. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4286. return -1;
  4287. }
  4288. if ((nd = npc_name2id(NPCname)) == NULL) {
  4289. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4290. return -1;
  4291. }
  4292. npc_unload_duplicates(nd);
  4293. npc_unload(nd);
  4294. npc_read_event_script();
  4295. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4296. return 0;
  4297. }
  4298. /*==========================================
  4299. * time in txt for time command (by [Yor])
  4300. *------------------------------------------*/
  4301. char* txt_time(unsigned int duration)
  4302. {
  4303. int days, hours, minutes, seconds;
  4304. char temp[CHAT_SIZE_MAX];
  4305. static char temp1[CHAT_SIZE_MAX];
  4306. memset(temp, '\0', sizeof(temp));
  4307. memset(temp1, '\0', sizeof(temp1));
  4308. days = duration / (60 * 60 * 24);
  4309. duration = duration - (60 * 60 * 24 * days);
  4310. hours = duration / (60 * 60);
  4311. duration = duration - (60 * 60 * hours);
  4312. minutes = duration / 60;
  4313. seconds = duration - (60 * minutes);
  4314. if (days < 2)
  4315. sprintf(temp, msg_txt(219), days); // %d day
  4316. else
  4317. sprintf(temp, msg_txt(220), days); // %d days
  4318. if (hours < 2)
  4319. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4320. else
  4321. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4322. if (minutes < 2)
  4323. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4324. else
  4325. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4326. if (seconds < 2)
  4327. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4328. else
  4329. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4330. return temp1;
  4331. }
  4332. /*==========================================
  4333. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4334. * Calculation management of GM modification (@day/@night GM commands) is done
  4335. *------------------------------------------*/
  4336. ACMD_FUNC(servertime)
  4337. {
  4338. const struct TimerData * timer_data;
  4339. const struct TimerData * timer_data2;
  4340. time_t time_server; // variable for number of seconds (used with time() function)
  4341. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4342. char temp[CHAT_SIZE_MAX];
  4343. nullpo_retr(-1, sd);
  4344. memset(temp, '\0', sizeof(temp));
  4345. time(&time_server); // get time in seconds since 1/1/1970
  4346. datetime = localtime(&time_server); // convert seconds in structure
  4347. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4348. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4349. clif_displaymessage(fd, temp);
  4350. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4351. if (night_flag == 0)
  4352. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4353. else
  4354. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4355. } else if (battle_config.night_duration == 0)
  4356. if (night_flag == 1) { // we start with night
  4357. timer_data = get_timer(day_timer_tid);
  4358. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4359. clif_displaymessage(fd, temp);
  4360. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4361. } else
  4362. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4363. else if (battle_config.day_duration == 0)
  4364. if (night_flag == 0) { // we start with day
  4365. timer_data = get_timer(night_timer_tid);
  4366. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4367. clif_displaymessage(fd, temp);
  4368. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4369. } else
  4370. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4371. else {
  4372. if (night_flag == 0) {
  4373. timer_data = get_timer(night_timer_tid);
  4374. timer_data2 = get_timer(day_timer_tid);
  4375. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4376. clif_displaymessage(fd, temp);
  4377. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4378. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data->interval,DIFF_TICK(timer_data->tick,timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s.
  4379. else
  4380. sprintf(temp, msg_txt(237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4381. clif_displaymessage(fd, temp);
  4382. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4383. clif_displaymessage(fd, temp);
  4384. } else {
  4385. timer_data = get_timer(day_timer_tid);
  4386. timer_data2 = get_timer(night_timer_tid);
  4387. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4388. clif_displaymessage(fd, temp);
  4389. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4390. sprintf(temp, msg_txt(239), txt_time((timer_data->interval - DIFF_TICK(timer_data->tick, timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s.
  4391. else
  4392. sprintf(temp, msg_txt(239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4393. clif_displaymessage(fd, temp);
  4394. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4395. clif_displaymessage(fd, temp);
  4396. }
  4397. }
  4398. return 0;
  4399. }
  4400. //Added by Coltaro
  4401. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  4402. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4403. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4404. {
  4405. const int factor_year = 518400; //12*30*24*60 = 518400
  4406. const int factor_month = 43200; //30*24*60 = 43200
  4407. const int factor_day = 1440; //24*60 = 1440
  4408. const int factor_hour = 60;
  4409. *year = jailtime/factor_year;
  4410. jailtime -= *year*factor_year;
  4411. *month = jailtime/factor_month;
  4412. jailtime -= *month*factor_month;
  4413. *day = jailtime/factor_day;
  4414. jailtime -= *day*factor_day;
  4415. *hour = jailtime/factor_hour;
  4416. jailtime -= *hour*factor_hour;
  4417. *minute = jailtime;
  4418. *year = *year > 0? *year : 0;
  4419. *month = *month > 0? *month : 0;
  4420. *day = *day > 0? *day : 0;
  4421. *hour = *hour > 0? *hour : 0;
  4422. *minute = *minute > 0? *minute : 0;
  4423. return;
  4424. }
  4425. /*==========================================
  4426. * @jail <char_name> by [Yor]
  4427. * Special warp! No check with nowarp and nowarpto flag
  4428. *------------------------------------------*/
  4429. ACMD_FUNC(jail)
  4430. {
  4431. struct map_session_data *pl_sd;
  4432. int x, y;
  4433. unsigned short m_index;
  4434. nullpo_retr(-1, sd);
  4435. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4436. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4437. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4438. return -1;
  4439. }
  4440. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4441. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4442. return -1;
  4443. }
  4444. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4445. { // you can jail only lower or same GM
  4446. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4447. return -1;
  4448. }
  4449. if (pl_sd->sc.data[SC_JAILED])
  4450. {
  4451. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4452. return -1;
  4453. }
  4454. switch(rand() % 2) { //Jail Locations
  4455. case 0:
  4456. m_index = mapindex_name2id(MAP_JAIL);
  4457. x = 24;
  4458. y = 75;
  4459. break;
  4460. default:
  4461. m_index = mapindex_name2id(MAP_JAIL);
  4462. x = 49;
  4463. y = 75;
  4464. break;
  4465. }
  4466. //Duration of INT_MAX to specify infinity.
  4467. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4468. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4469. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4470. return 0;
  4471. }
  4472. /*==========================================
  4473. * @unjail/@discharge <char_name> by [Yor]
  4474. * Special warp! No check with nowarp and nowarpto flag
  4475. *------------------------------------------*/
  4476. ACMD_FUNC(unjail)
  4477. {
  4478. struct map_session_data *pl_sd;
  4479. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4480. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4481. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4482. return -1;
  4483. }
  4484. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4485. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4486. return -1;
  4487. }
  4488. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4489. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4490. return -1;
  4491. }
  4492. if (!pl_sd->sc.data[SC_JAILED])
  4493. {
  4494. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4495. return -1;
  4496. }
  4497. //Reset jail time to 1 sec.
  4498. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4499. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4500. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4501. return 0;
  4502. }
  4503. ACMD_FUNC(jailfor)
  4504. {
  4505. struct map_session_data *pl_sd = NULL;
  4506. int year, month, day, hour, minute, value;
  4507. char * modif_p;
  4508. int jailtime = 0,x,y;
  4509. short m_index = 0;
  4510. nullpo_retr(-1, sd);
  4511. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4512. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4513. return -1;
  4514. }
  4515. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4516. modif_p = atcmd_output;
  4517. year = month = day = hour = minute = 0;
  4518. while (modif_p[0] != '\0') {
  4519. value = atoi(modif_p);
  4520. if (value == 0)
  4521. modif_p++;
  4522. else {
  4523. if (modif_p[0] == '-' || modif_p[0] == '+')
  4524. modif_p++;
  4525. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4526. modif_p++;
  4527. if (modif_p[0] == 'n') {
  4528. minute = value;
  4529. modif_p++;
  4530. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4531. minute = value;
  4532. modif_p = modif_p + 2;
  4533. } else if (modif_p[0] == 'h') {
  4534. hour = value;
  4535. modif_p++;
  4536. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4537. day = value;
  4538. modif_p++;
  4539. } else if (modif_p[0] == 'm') {
  4540. month = value;
  4541. modif_p++;
  4542. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4543. year = value;
  4544. modif_p++;
  4545. } else if (modif_p[0] != '\0') {
  4546. modif_p++;
  4547. }
  4548. }
  4549. }
  4550. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4551. clif_displaymessage(fd, "Invalid time for jail command.");
  4552. return -1;
  4553. }
  4554. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4555. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4556. return -1;
  4557. }
  4558. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4559. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4560. return -1;
  4561. }
  4562. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4563. if(jailtime==0) {
  4564. clif_displaymessage(fd, "Invalid time for jail command.");
  4565. return -1;
  4566. }
  4567. //Added by Coltaro
  4568. if(pl_sd->sc.data[SC_JAILED] &&
  4569. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4570. { //Update the player's jail time
  4571. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4572. if (jailtime <= 0) {
  4573. jailtime = 0;
  4574. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4575. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4576. } else {
  4577. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4578. sprintf(atcmd_output,msg_txt(402),"You are now",year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4579. clif_displaymessage(pl_sd->fd, atcmd_output);
  4580. sprintf(atcmd_output,msg_txt(402),"This player is now",year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4581. clif_displaymessage(fd, atcmd_output);
  4582. }
  4583. } else if (jailtime < 0) {
  4584. clif_displaymessage(fd, "Invalid time for jail command.");
  4585. return -1;
  4586. }
  4587. //Jail locations, add more as you wish.
  4588. switch(rand()%2)
  4589. {
  4590. case 1: //Jail #1
  4591. m_index = mapindex_name2id(MAP_JAIL);
  4592. x = 49; y = 75;
  4593. break;
  4594. default: //Default Jail
  4595. m_index = mapindex_name2id(MAP_JAIL);
  4596. x = 24; y = 75;
  4597. break;
  4598. }
  4599. sc_start4(&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4600. return 0;
  4601. }
  4602. //By Coltaro
  4603. ACMD_FUNC(jailtime)
  4604. {
  4605. int year, month, day, hour, minute;
  4606. nullpo_retr(-1, sd);
  4607. if (!sd->sc.data[SC_JAILED]) {
  4608. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4609. return -1;
  4610. }
  4611. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4612. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4613. return 0;
  4614. }
  4615. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4616. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4617. return -1;
  4618. }
  4619. //Get remaining jail time
  4620. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4621. sprintf(atcmd_output,msg_txt(402),"You will remain",year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4622. clif_displaymessage(fd, atcmd_output);
  4623. return 0;
  4624. }
  4625. /*==========================================
  4626. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4627. *------------------------------------------*/
  4628. ACMD_FUNC(disguise)
  4629. {
  4630. int id = 0;
  4631. nullpo_retr(-1, sd);
  4632. if (!message || !*message) {
  4633. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4634. return -1;
  4635. }
  4636. if ((id = atoi(message)) > 0)
  4637. { //Acquired an ID
  4638. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4639. id = 0; //Invalid id for either mobs or npcs.
  4640. } else { //Acquired a Name
  4641. if ((id = mobdb_searchname(message)) == 0)
  4642. {
  4643. struct npc_data* nd = npc_name2id(message);
  4644. if (nd != NULL)
  4645. id = nd->class_;
  4646. }
  4647. }
  4648. if (id == 0)
  4649. {
  4650. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4651. return -1;
  4652. }
  4653. if(pc_isriding(sd))
  4654. {
  4655. //FIXME: wrong message [ultramage]
  4656. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4657. return -1;
  4658. }
  4659. pc_disguise(sd, id);
  4660. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4661. return 0;
  4662. }
  4663. /*==========================================
  4664. * DisguiseAll
  4665. *------------------------------------------*/
  4666. ACMD_FUNC(disguiseall)
  4667. {
  4668. int mob_id=0;
  4669. struct map_session_data *pl_sd;
  4670. struct s_mapiterator* iter;
  4671. nullpo_retr(-1, sd);
  4672. if (!message || !*message) {
  4673. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4674. return -1;
  4675. }
  4676. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4677. mob_id = atoi(message);
  4678. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4679. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4680. return -1;
  4681. }
  4682. iter = mapit_getallusers();
  4683. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4684. pc_disguise(pl_sd, mob_id);
  4685. mapit_free(iter);
  4686. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4687. return 0;
  4688. }
  4689. /*==========================================
  4690. * @undisguise by [Yor]
  4691. *------------------------------------------*/
  4692. ACMD_FUNC(undisguise)
  4693. {
  4694. nullpo_retr(-1, sd);
  4695. if (sd->disguise) {
  4696. pc_disguise(sd, 0);
  4697. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4698. } else {
  4699. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4700. return -1;
  4701. }
  4702. return 0;
  4703. }
  4704. /*==========================================
  4705. * UndisguiseAll
  4706. *------------------------------------------*/
  4707. ACMD_FUNC(undisguiseall)
  4708. {
  4709. struct map_session_data *pl_sd;
  4710. struct s_mapiterator* iter;
  4711. nullpo_retr(-1, sd);
  4712. iter = mapit_getallusers();
  4713. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4714. if( pl_sd->disguise )
  4715. pc_disguise(pl_sd, 0);
  4716. mapit_free(iter);
  4717. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4718. return 0;
  4719. }
  4720. /*==========================================
  4721. * @exp by [Skotlex]
  4722. *------------------------------------------*/
  4723. ACMD_FUNC(exp)
  4724. {
  4725. char output[CHAT_SIZE_MAX];
  4726. double nextb, nextj;
  4727. nullpo_retr(-1, sd);
  4728. memset(output, '\0', sizeof(output));
  4729. nextb = pc_nextbaseexp(sd);
  4730. if (nextb)
  4731. nextb = sd->status.base_exp*100.0/nextb;
  4732. nextj = pc_nextjobexp(sd);
  4733. if (nextj)
  4734. nextj = sd->status.job_exp*100.0/nextj;
  4735. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4736. clif_displaymessage(fd, output);
  4737. return 0;
  4738. }
  4739. /*==========================================
  4740. * @broadcast by [Valaris]
  4741. *------------------------------------------*/
  4742. ACMD_FUNC(broadcast)
  4743. {
  4744. nullpo_retr(-1, sd);
  4745. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4746. if (!message || !*message) {
  4747. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4748. return -1;
  4749. }
  4750. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4751. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4752. return 0;
  4753. }
  4754. /*==========================================
  4755. * @localbroadcast by [Valaris]
  4756. *------------------------------------------*/
  4757. ACMD_FUNC(localbroadcast)
  4758. {
  4759. nullpo_retr(-1, sd);
  4760. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4761. if (!message || !*message) {
  4762. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4763. return -1;
  4764. }
  4765. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4766. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4767. return 0;
  4768. }
  4769. /*==========================================
  4770. * @email <actual@email> <new@email> by [Yor]
  4771. *------------------------------------------*/
  4772. ACMD_FUNC(email)
  4773. {
  4774. char actual_email[100];
  4775. char new_email[100];
  4776. nullpo_retr(-1, sd);
  4777. memset(actual_email, '\0', sizeof(actual_email));
  4778. memset(new_email, '\0', sizeof(new_email));
  4779. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4780. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4781. return -1;
  4782. }
  4783. if (e_mail_check(actual_email) == 0) {
  4784. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4785. return -1;
  4786. } else if (e_mail_check(new_email) == 0) {
  4787. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4788. return -1;
  4789. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4790. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4791. return -1;
  4792. } else if (strcmpi(actual_email, new_email) == 0) {
  4793. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4794. return -1;
  4795. }
  4796. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4797. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4798. return 0;
  4799. }
  4800. /*==========================================
  4801. *@effect
  4802. *------------------------------------------*/
  4803. ACMD_FUNC(effect)
  4804. {
  4805. int type = 0, flag = 0;
  4806. nullpo_retr(-1, sd);
  4807. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4808. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4809. return -1;
  4810. }
  4811. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4812. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4813. return 0;
  4814. }
  4815. /*==========================================
  4816. * @killer by MouseJstr
  4817. * enable killing players even when not in pvp
  4818. *------------------------------------------*/
  4819. ACMD_FUNC(killer)
  4820. {
  4821. nullpo_retr(-1, sd);
  4822. sd->state.killer = !sd->state.killer;
  4823. if(sd->state.killer)
  4824. clif_displaymessage(fd, msg_txt(241));
  4825. else {
  4826. clif_displaymessage(fd, msg_txt(287));
  4827. pc_stop_attack(sd);
  4828. }
  4829. return 0;
  4830. }
  4831. /*==========================================
  4832. * @killable by MouseJstr
  4833. * enable other people killing you
  4834. *------------------------------------------*/
  4835. ACMD_FUNC(killable)
  4836. {
  4837. nullpo_retr(-1, sd);
  4838. sd->state.killable = !sd->state.killable;
  4839. if(sd->state.killable)
  4840. clif_displaymessage(fd, msg_txt(242));
  4841. else {
  4842. clif_displaymessage(fd, msg_txt(288));
  4843. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4844. }
  4845. return 0;
  4846. }
  4847. /*==========================================
  4848. * @skillon by MouseJstr
  4849. * turn skills on for the map
  4850. *------------------------------------------*/
  4851. ACMD_FUNC(skillon)
  4852. {
  4853. nullpo_retr(-1, sd);
  4854. map[sd->bl.m].flag.noskill = 0;
  4855. clif_displaymessage(fd, msg_txt(244));
  4856. return 0;
  4857. }
  4858. /*==========================================
  4859. * @skilloff by MouseJstr
  4860. * Turn skills off on the map
  4861. *------------------------------------------*/
  4862. ACMD_FUNC(skilloff)
  4863. {
  4864. nullpo_retr(-1, sd);
  4865. map[sd->bl.m].flag.noskill = 1;
  4866. clif_displaymessage(fd, msg_txt(243));
  4867. return 0;
  4868. }
  4869. /*==========================================
  4870. * @npcmove by MouseJstr
  4871. * move a npc
  4872. *------------------------------------------*/
  4873. ACMD_FUNC(npcmove)
  4874. {
  4875. int x = 0, y = 0, m;
  4876. struct npc_data *nd = 0;
  4877. nullpo_retr(-1, sd);
  4878. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4879. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4880. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4881. return -1;
  4882. }
  4883. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4884. {
  4885. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4886. return -1;
  4887. }
  4888. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4889. {
  4890. clif_displaymessage(fd, "NPC is not on this map.");
  4891. return -1; //Not on a map.
  4892. }
  4893. x = cap_value(x, 0, map[m].xs-1);
  4894. y = cap_value(y, 0, map[m].ys-1);
  4895. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4896. map_moveblock(&nd->bl, x, y, gettick());
  4897. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4898. clif_displaymessage(fd, "NPC moved.");
  4899. return 0;
  4900. }
  4901. /*==========================================
  4902. * @addwarp by MouseJstr
  4903. * Create a new static warp point.
  4904. *------------------------------------------*/
  4905. ACMD_FUNC(addwarp)
  4906. {
  4907. char mapname[32];
  4908. int x,y;
  4909. unsigned short m;
  4910. struct npc_data* nd;
  4911. nullpo_retr(-1, sd);
  4912. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4913. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4914. return -1;
  4915. }
  4916. m = mapindex_name2id(mapname);
  4917. if( m == 0 )
  4918. {
  4919. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4920. clif_displaymessage(fd, atcmd_output);
  4921. return -1;
  4922. }
  4923. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4924. if( nd == NULL )
  4925. return -1;
  4926. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4927. clif_displaymessage(fd, atcmd_output);
  4928. return 0;
  4929. }
  4930. /*==========================================
  4931. * @follow by [MouseJstr]
  4932. * Follow a player .. staying no more then 5 spaces away
  4933. *------------------------------------------*/
  4934. ACMD_FUNC(follow)
  4935. {
  4936. struct map_session_data *pl_sd = NULL;
  4937. nullpo_retr(-1, sd);
  4938. if (!message || !*message) {
  4939. if (sd->followtarget == -1)
  4940. return -1;
  4941. pc_stop_following (sd);
  4942. clif_displaymessage(fd, "Follow mode OFF.");
  4943. return 0;
  4944. }
  4945. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4946. {
  4947. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4948. return -1;
  4949. }
  4950. if (sd->followtarget == pl_sd->bl.id) {
  4951. pc_stop_following (sd);
  4952. clif_displaymessage(fd, "Follow mode OFF.");
  4953. } else {
  4954. pc_follow(sd, pl_sd->bl.id);
  4955. clif_displaymessage(fd, "Follow mode ON.");
  4956. }
  4957. return 0;
  4958. }
  4959. /*==========================================
  4960. * @dropall by [MouseJstr]
  4961. * Drop all your possession on the ground
  4962. *------------------------------------------*/
  4963. ACMD_FUNC(dropall)
  4964. {
  4965. int i;
  4966. nullpo_retr(-1, sd);
  4967. for (i = 0; i < MAX_INVENTORY; i++) {
  4968. if (sd->status.inventory[i].amount) {
  4969. if(sd->status.inventory[i].equip != 0)
  4970. pc_unequipitem(sd, i, 3);
  4971. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4972. }
  4973. }
  4974. return 0;
  4975. }
  4976. /*==========================================
  4977. * @storeall by [MouseJstr]
  4978. * Put everything into storage
  4979. *------------------------------------------*/
  4980. ACMD_FUNC(storeall)
  4981. {
  4982. int i;
  4983. nullpo_retr(-1, sd);
  4984. if (sd->state.storage_flag != 1)
  4985. { //Open storage.
  4986. if( storage_storageopen(sd) == 1 ) {
  4987. clif_displaymessage(fd, "You can't open the storage currently.");
  4988. return -1;
  4989. }
  4990. }
  4991. for (i = 0; i < MAX_INVENTORY; i++) {
  4992. if (sd->status.inventory[i].amount) {
  4993. if(sd->status.inventory[i].equip != 0)
  4994. pc_unequipitem(sd, i, 3);
  4995. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4996. }
  4997. }
  4998. storage_storageclose(sd);
  4999. clif_displaymessage(fd, "It is done");
  5000. return 0;
  5001. }
  5002. /*==========================================
  5003. * @skillid by [MouseJstr]
  5004. * lookup a skill by name
  5005. *------------------------------------------*/
  5006. ACMD_FUNC(skillid)
  5007. {
  5008. int skillen, idx;
  5009. nullpo_retr(-1, sd);
  5010. if (!message || !*message)
  5011. {
  5012. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5013. return -1;
  5014. }
  5015. skillen = strlen(message);
  5016. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5017. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5018. {
  5019. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5020. clif_displaymessage(fd, atcmd_output);
  5021. }
  5022. }
  5023. return 0;
  5024. }
  5025. /*==========================================
  5026. * @useskill by [MouseJstr]
  5027. * A way of using skills without having to find them in the skills menu
  5028. *------------------------------------------*/
  5029. ACMD_FUNC(useskill)
  5030. {
  5031. struct map_session_data *pl_sd = NULL;
  5032. struct block_list *bl;
  5033. int skillnum;
  5034. int skilllv;
  5035. char target[100];
  5036. nullpo_retr(-1, sd);
  5037. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5038. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5039. return -1;
  5040. }
  5041. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5042. {
  5043. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5044. return -1;
  5045. }
  5046. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5047. {
  5048. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5049. return -1;
  5050. }
  5051. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5052. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5053. bl = &sd->hd->bl;
  5054. else
  5055. bl = &sd->bl;
  5056. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5057. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5058. else
  5059. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5060. return 0;
  5061. }
  5062. /*==========================================
  5063. * @displayskill by [Skotlex]
  5064. * Debug command to locate new skill IDs. It sends the
  5065. * three possible skill-effect packets to the area.
  5066. *------------------------------------------*/
  5067. ACMD_FUNC(displayskill)
  5068. {
  5069. struct status_data * status;
  5070. unsigned int tick;
  5071. int skillnum;
  5072. int skilllv = 1;
  5073. nullpo_retr(-1, sd);
  5074. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5075. {
  5076. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5077. return -1;
  5078. }
  5079. status = status_get_status_data(&sd->bl);
  5080. tick = gettick();
  5081. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5082. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5083. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5084. return 0;
  5085. }
  5086. /*==========================================
  5087. * @skilltree by [MouseJstr]
  5088. * prints the skill tree for a player required to get to a skill
  5089. *------------------------------------------*/
  5090. ACMD_FUNC(skilltree)
  5091. {
  5092. struct map_session_data *pl_sd = NULL;
  5093. int skillnum;
  5094. int meets, j, c=0;
  5095. char target[NAME_LENGTH];
  5096. struct skill_tree_entry *ent;
  5097. nullpo_retr(-1, sd);
  5098. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5099. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5100. return -1;
  5101. }
  5102. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5103. {
  5104. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5105. return -1;
  5106. }
  5107. c = pc_calc_skilltree_normalize_job(pl_sd);
  5108. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5109. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  5110. clif_displaymessage(fd, atcmd_output);
  5111. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5112. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5113. {
  5114. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5115. clif_displaymessage(fd, atcmd_output);
  5116. return 0;
  5117. }
  5118. ent = &skill_tree[c][j];
  5119. meets = 1;
  5120. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5121. {
  5122. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5123. {
  5124. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5125. clif_displaymessage(fd, atcmd_output);
  5126. meets = 0;
  5127. }
  5128. }
  5129. if (meets == 1) {
  5130. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5131. clif_displaymessage(fd, atcmd_output);
  5132. }
  5133. return 0;
  5134. }
  5135. // Hand a ring with partners name on it to this char
  5136. void getring (struct map_session_data* sd)
  5137. {
  5138. int flag, item_id;
  5139. struct item item_tmp;
  5140. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5141. memset(&item_tmp, 0, sizeof(item_tmp));
  5142. item_tmp.nameid = item_id;
  5143. item_tmp.identify = 1;
  5144. item_tmp.card[0] = 255;
  5145. item_tmp.card[2] = sd->status.partner_id;
  5146. item_tmp.card[3] = sd->status.partner_id >> 16;
  5147. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5148. clif_additem(sd,0,0,flag);
  5149. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5150. }
  5151. }
  5152. /*==========================================
  5153. * @marry by [MouseJstr], fixed by Lupus
  5154. * Marry two players
  5155. *------------------------------------------*/
  5156. ACMD_FUNC(marry)
  5157. {
  5158. struct map_session_data *pl_sd1 = NULL;
  5159. struct map_session_data *pl_sd2 = NULL;
  5160. char player1[128], player2[128]; //Length used for return error msgs
  5161. nullpo_retr(-1, sd);
  5162. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5163. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5164. return -1;
  5165. }
  5166. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5167. sprintf(player2, "Cannot find player '%s' online", player1);
  5168. clif_displaymessage(fd, player2);
  5169. return -1;
  5170. }
  5171. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5172. sprintf(player1, "Cannot find player '%s' online", player2);
  5173. clif_displaymessage(fd, player1);
  5174. return -1;
  5175. }
  5176. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5177. clif_displaymessage(fd, "They are married.. wish them well");
  5178. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5179. // Auto-give named rings (Aru)
  5180. getring (pl_sd1);
  5181. getring (pl_sd2);
  5182. return 0;
  5183. }
  5184. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5185. return -1;
  5186. }
  5187. /*==========================================
  5188. * @divorce by [MouseJstr], fixed by [Lupus]
  5189. * divorce two players
  5190. *------------------------------------------*/
  5191. ACMD_FUNC(divorce)
  5192. {
  5193. struct map_session_data *pl_sd = NULL;
  5194. nullpo_retr(-1, sd);
  5195. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5196. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5197. return -1;
  5198. }
  5199. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5200. {
  5201. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5202. return -1;
  5203. }
  5204. if (pc_divorce(pl_sd) != 0) {
  5205. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5206. clif_displaymessage(fd, atcmd_output);
  5207. return -1;
  5208. }
  5209. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5210. clif_displaymessage(fd, atcmd_output);
  5211. return 0;
  5212. }
  5213. /*==========================================
  5214. * @changelook by [Celest]
  5215. *------------------------------------------*/
  5216. ACMD_FUNC(changelook)
  5217. {
  5218. int i, j = 0, k = 0;
  5219. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5220. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5221. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5222. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5223. return -1;
  5224. } else if (i == 2) {
  5225. if (j < 1) j = 1;
  5226. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5227. j = pos[j - 1];
  5228. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5229. k = j; // swap
  5230. j = LOOK_HEAD_TOP;
  5231. }
  5232. clif_changelook(&sd->bl,j,k);
  5233. return 0;
  5234. }
  5235. /*==========================================
  5236. * @autotrade by durf [Lupus] [Paradox924X]
  5237. * Turns on/off Autotrade for a specific player
  5238. *------------------------------------------*/
  5239. ACMD_FUNC(autotrade)
  5240. {
  5241. nullpo_retr(-1, sd);
  5242. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5243. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5244. return -1;
  5245. }
  5246. if( pc_isdead(sd) ) {
  5247. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5248. return -1;
  5249. }
  5250. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5251. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5252. return -1;
  5253. }
  5254. sd->state.autotrade = 1;
  5255. if( battle_config.at_timeout )
  5256. {
  5257. int timeout = atoi(message);
  5258. status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  5259. }
  5260. clif_authfail_fd(fd, 15);
  5261. return 0;
  5262. }
  5263. /*==========================================
  5264. * @changegm by durf (changed by Lupus)
  5265. * Changes Master of your Guild to a specified guild member
  5266. *------------------------------------------*/
  5267. ACMD_FUNC(changegm)
  5268. {
  5269. struct guild *g;
  5270. struct map_session_data *pl_sd;
  5271. nullpo_retr(-1, sd);
  5272. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5273. {
  5274. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5275. return -1;
  5276. }
  5277. if( map[sd->bl.m].flag.guildlock )
  5278. {
  5279. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5280. return -1;
  5281. }
  5282. if( !message[0] )
  5283. {
  5284. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5285. return -1;
  5286. }
  5287. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5288. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5289. return -1;
  5290. }
  5291. guild_gm_change(sd->status.guild_id, pl_sd);
  5292. return 0;
  5293. }
  5294. /*==========================================
  5295. * @changeleader by Skotlex
  5296. * Changes the leader of a party.
  5297. *------------------------------------------*/
  5298. ACMD_FUNC(changeleader)
  5299. {
  5300. nullpo_retr(-1, sd);
  5301. if( !message[0] )
  5302. {
  5303. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5304. return -1;
  5305. }
  5306. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5307. return 0;
  5308. return -1;
  5309. }
  5310. /*==========================================
  5311. * @partyoption by Skotlex
  5312. * Used to change the item share setting of a party.
  5313. *------------------------------------------*/
  5314. ACMD_FUNC(partyoption)
  5315. {
  5316. struct party_data *p;
  5317. int mi, option;
  5318. char w1[16], w2[16];
  5319. nullpo_retr(-1, sd);
  5320. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5321. {
  5322. clif_displaymessage(fd, msg_txt(282));
  5323. return -1;
  5324. }
  5325. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5326. if (mi == MAX_PARTY)
  5327. return -1; //Shouldn't happen
  5328. if (!p->party.member[mi].leader)
  5329. {
  5330. clif_displaymessage(fd, msg_txt(282));
  5331. return -1;
  5332. }
  5333. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5334. {
  5335. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5336. return -1;
  5337. }
  5338. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5339. //Change item share type.
  5340. if (option != p->party.item)
  5341. party_changeoption(sd, p->party.exp, option);
  5342. else
  5343. clif_displaymessage(fd, msg_txt(286));
  5344. return 0;
  5345. }
  5346. /*==========================================
  5347. * @autoloot by Upa-Kun
  5348. * Turns on/off AutoLoot for a specific player
  5349. *------------------------------------------*/
  5350. ACMD_FUNC(autoloot)
  5351. {
  5352. int rate;
  5353. double drate;
  5354. nullpo_retr(-1, sd);
  5355. // autoloot command without value
  5356. if(!message || !*message)
  5357. {
  5358. if (sd->state.autoloot)
  5359. rate = 0;
  5360. else
  5361. rate = 10000;
  5362. } else {
  5363. drate = atof(message);
  5364. rate = (int)(drate*100);
  5365. }
  5366. if (rate < 0) rate = 0;
  5367. if (rate > 10000) rate = 10000;
  5368. sd->state.autoloot = rate;
  5369. if (sd->state.autoloot) {
  5370. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5371. clif_displaymessage(fd, atcmd_output);
  5372. }else
  5373. clif_displaymessage(fd, "Autoloot is now off.");
  5374. return 0;
  5375. }
  5376. /*==========================================
  5377. * @alootid
  5378. *------------------------------------------*/
  5379. ACMD_FUNC(autolootitem)
  5380. {
  5381. struct item_data *item_data = NULL;
  5382. if (!message || !*message) {
  5383. if (sd->state.autolootid) {
  5384. sd->state.autolootid = 0;
  5385. clif_displaymessage(fd, "Autolootitem has been turned OFF.");
  5386. } else
  5387. clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
  5388. return -1;
  5389. }
  5390. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5391. item_data = itemdb_searchname(message);
  5392. if (!item_data) {
  5393. // No items founds in the DB with Id or Name
  5394. clif_displaymessage(fd, "Item not found.");
  5395. return -1;
  5396. }
  5397. sd->state.autolootid = item_data->nameid; // Autoloot Activated
  5398. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
  5399. item_data->name, item_data->jname, item_data->nameid);
  5400. clif_displaymessage(fd, atcmd_output);
  5401. return 0;
  5402. }
  5403. /**
  5404. * No longer available, keeping here just in case it's back someday. [Ind]
  5405. **/
  5406. /*==========================================
  5407. * It is made to rain.
  5408. *------------------------------------------*/
  5409. //ACMD_FUNC(rain)
  5410. //{
  5411. // nullpo_retr(-1, sd);
  5412. // if (map[sd->bl.m].flag.rain) {
  5413. // map[sd->bl.m].flag.rain=0;
  5414. // clif_weather(sd->bl.m);
  5415. // clif_displaymessage(fd, "The rain has stopped.");
  5416. // } else {
  5417. // map[sd->bl.m].flag.rain=1;
  5418. // clif_weather(sd->bl.m);
  5419. // clif_displaymessage(fd, "It is made to rain.");
  5420. // }
  5421. // return 0;
  5422. //}
  5423. /*==========================================
  5424. * It is made to snow.
  5425. *------------------------------------------*/
  5426. ACMD_FUNC(snow)
  5427. {
  5428. nullpo_retr(-1, sd);
  5429. if (map[sd->bl.m].flag.snow) {
  5430. map[sd->bl.m].flag.snow=0;
  5431. clif_weather(sd->bl.m);
  5432. clif_displaymessage(fd, "Snow has stopped falling.");
  5433. } else {
  5434. map[sd->bl.m].flag.snow=1;
  5435. clif_weather(sd->bl.m);
  5436. clif_displaymessage(fd, "It is made to snow.");
  5437. }
  5438. return 0;
  5439. }
  5440. /*==========================================
  5441. * Cherry tree snowstorm is made to fall. (Sakura)
  5442. *------------------------------------------*/
  5443. ACMD_FUNC(sakura)
  5444. {
  5445. nullpo_retr(-1, sd);
  5446. if (map[sd->bl.m].flag.sakura) {
  5447. map[sd->bl.m].flag.sakura=0;
  5448. clif_weather(sd->bl.m);
  5449. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5450. } else {
  5451. map[sd->bl.m].flag.sakura=1;
  5452. clif_weather(sd->bl.m);
  5453. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5454. }
  5455. return 0;
  5456. }
  5457. /*==========================================
  5458. * Clouds appear.
  5459. *------------------------------------------*/
  5460. ACMD_FUNC(clouds)
  5461. {
  5462. nullpo_retr(-1, sd);
  5463. if (map[sd->bl.m].flag.clouds) {
  5464. map[sd->bl.m].flag.clouds=0;
  5465. clif_weather(sd->bl.m);
  5466. clif_displaymessage(fd, "The clouds has disappear.");
  5467. } else {
  5468. map[sd->bl.m].flag.clouds=1;
  5469. clif_weather(sd->bl.m);
  5470. clif_displaymessage(fd, "Clouds appear.");
  5471. }
  5472. return 0;
  5473. }
  5474. /*==========================================
  5475. * Different type of clouds using effect 516
  5476. *------------------------------------------*/
  5477. ACMD_FUNC(clouds2)
  5478. {
  5479. nullpo_retr(-1, sd);
  5480. if (map[sd->bl.m].flag.clouds2) {
  5481. map[sd->bl.m].flag.clouds2=0;
  5482. clif_weather(sd->bl.m);
  5483. clif_displaymessage(fd, "The alternative clouds disappear.");
  5484. } else {
  5485. map[sd->bl.m].flag.clouds2=1;
  5486. clif_weather(sd->bl.m);
  5487. clif_displaymessage(fd, "Alternative clouds appear.");
  5488. }
  5489. return 0;
  5490. }
  5491. /*==========================================
  5492. * Fog hangs over.
  5493. *------------------------------------------*/
  5494. ACMD_FUNC(fog)
  5495. {
  5496. nullpo_retr(-1, sd);
  5497. if (map[sd->bl.m].flag.fog) {
  5498. map[sd->bl.m].flag.fog=0;
  5499. clif_weather(sd->bl.m);
  5500. clif_displaymessage(fd, "The fog has gone.");
  5501. } else {
  5502. map[sd->bl.m].flag.fog=1;
  5503. clif_weather(sd->bl.m);
  5504. clif_displaymessage(fd, "Fog hangs over.");
  5505. }
  5506. return 0;
  5507. }
  5508. /*==========================================
  5509. * Fallen leaves fall.
  5510. *------------------------------------------*/
  5511. ACMD_FUNC(leaves)
  5512. {
  5513. nullpo_retr(-1, sd);
  5514. if (map[sd->bl.m].flag.leaves) {
  5515. map[sd->bl.m].flag.leaves=0;
  5516. clif_weather(sd->bl.m);
  5517. clif_displaymessage(fd, "Leaves no longer fall.");
  5518. } else {
  5519. map[sd->bl.m].flag.leaves=1;
  5520. clif_weather(sd->bl.m);
  5521. clif_displaymessage(fd, "Fallen leaves fall.");
  5522. }
  5523. return 0;
  5524. }
  5525. /*==========================================
  5526. * Fireworks appear.
  5527. *------------------------------------------*/
  5528. ACMD_FUNC(fireworks)
  5529. {
  5530. nullpo_retr(-1, sd);
  5531. if (map[sd->bl.m].flag.fireworks) {
  5532. map[sd->bl.m].flag.fireworks=0;
  5533. clif_weather(sd->bl.m);
  5534. clif_displaymessage(fd, "Fireworks are ended.");
  5535. } else {
  5536. map[sd->bl.m].flag.fireworks=1;
  5537. clif_weather(sd->bl.m);
  5538. clif_displaymessage(fd, "Fireworks are launched.");
  5539. }
  5540. return 0;
  5541. }
  5542. /*==========================================
  5543. * Clearing Weather Effects by Dexity
  5544. *------------------------------------------*/
  5545. ACMD_FUNC(clearweather)
  5546. {
  5547. nullpo_retr(-1, sd);
  5548. /**
  5549. * No longer available, keeping here just in case it's back someday. [Ind]
  5550. **/
  5551. //map[sd->bl.m].flag.rain=0;
  5552. map[sd->bl.m].flag.snow=0;
  5553. map[sd->bl.m].flag.sakura=0;
  5554. map[sd->bl.m].flag.clouds=0;
  5555. map[sd->bl.m].flag.clouds2=0;
  5556. map[sd->bl.m].flag.fog=0;
  5557. map[sd->bl.m].flag.fireworks=0;
  5558. map[sd->bl.m].flag.leaves=0;
  5559. clif_weather(sd->bl.m);
  5560. clif_displaymessage(fd, msg_txt(291));
  5561. return 0;
  5562. }
  5563. /*===============================================================
  5564. * Sound Command - plays a sound for everyone around! [Codemaster]
  5565. *---------------------------------------------------------------*/
  5566. ACMD_FUNC(sound)
  5567. {
  5568. char sound_file[100];
  5569. memset(sound_file, '\0', sizeof(sound_file));
  5570. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5571. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5572. return -1;
  5573. }
  5574. if(strstr(sound_file, ".wav") == NULL)
  5575. strcat(sound_file, ".wav");
  5576. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5577. return 0;
  5578. }
  5579. /*==========================================
  5580. * MOB Search
  5581. *------------------------------------------*/
  5582. ACMD_FUNC(mobsearch)
  5583. {
  5584. char mob_name[100];
  5585. int mob_id;
  5586. int number = 0;
  5587. struct s_mapiterator* it;
  5588. nullpo_retr(-1, sd);
  5589. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5590. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5591. return -1;
  5592. }
  5593. if ((mob_id = atoi(mob_name)) == 0)
  5594. mob_id = mobdb_searchname(mob_name);
  5595. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5596. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5597. clif_displaymessage(fd, atcmd_output);
  5598. return -1;
  5599. }
  5600. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5601. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5602. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5603. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5604. clif_displaymessage(fd, atcmd_output);
  5605. it = mapit_geteachmob();
  5606. for(;;)
  5607. {
  5608. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5609. if( md == NULL )
  5610. break;// no more mobs
  5611. if( md->bl.m != sd->bl.m )
  5612. continue;
  5613. if( mob_id != -1 && md->class_ != mob_id )
  5614. continue;
  5615. ++number;
  5616. if( md->spawn_timer == INVALID_TIMER )
  5617. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5618. else
  5619. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5620. clif_displaymessage(fd, atcmd_output);
  5621. }
  5622. mapit_free(it);
  5623. return 0;
  5624. }
  5625. /*==========================================
  5626. * @cleanmap - cleans items on the ground
  5627. *------------------------------------------*/
  5628. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5629. {
  5630. nullpo_ret(bl);
  5631. map_clearflooritem(bl->id);
  5632. return 0;
  5633. }
  5634. ACMD_FUNC(cleanmap)
  5635. {
  5636. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5637. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5638. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5639. BL_ITEM);
  5640. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5641. return 0;
  5642. }
  5643. /*==========================================
  5644. * make a NPC/PET talk
  5645. * @npctalkc [SnakeDrak]
  5646. *------------------------------------------*/
  5647. ACMD_FUNC(npctalk)
  5648. {
  5649. char name[NAME_LENGTH],mes[100],temp[100];
  5650. struct npc_data *nd;
  5651. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5652. unsigned long color=0;
  5653. if (sd->sc.count && //no "chatting" while muted.
  5654. (sd->sc.data[SC_BERSERK] ||
  5655. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5656. return -1;
  5657. if(!ifcolor) {
  5658. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5659. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5660. return -1;
  5661. }
  5662. }
  5663. else {
  5664. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5665. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5666. return -1;
  5667. }
  5668. }
  5669. if (!(nd = npc_name2id(name))) {
  5670. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5671. return -1;
  5672. }
  5673. strtok(name, "#"); // discard extra name identifier if present
  5674. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5675. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5676. else clif_message(&nd->bl, temp);
  5677. return 0;
  5678. }
  5679. ACMD_FUNC(pettalk)
  5680. {
  5681. char mes[100],temp[100];
  5682. struct pet_data *pd;
  5683. nullpo_retr(-1, sd);
  5684. if(!sd->status.pet_id || !(pd=sd->pd))
  5685. {
  5686. clif_displaymessage(fd, msg_txt(184));
  5687. return -1;
  5688. }
  5689. if (sd->sc.count && //no "chatting" while muted.
  5690. (sd->sc.data[SC_BERSERK] ||
  5691. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5692. return -1;
  5693. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5694. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5695. return -1;
  5696. }
  5697. if (message[0] == '/')
  5698. {// pet emotion processing
  5699. const char* emo[] = {
  5700. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5701. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5702. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5703. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5704. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5705. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5706. };
  5707. int i;
  5708. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5709. if( i < ARRAYLENGTH(emo) )
  5710. {
  5711. clif_emotion(&pd->bl, i);
  5712. return 0;
  5713. }
  5714. }
  5715. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5716. clif_message(&pd->bl, temp);
  5717. return 0;
  5718. }
  5719. /// @users - displays the number of players present on each map (and percentage)
  5720. /// #users displays on the target user instead of self
  5721. ACMD_FUNC(users)
  5722. {
  5723. char buf[CHAT_SIZE_MAX];
  5724. int i;
  5725. int users[MAX_MAPINDEX];
  5726. int users_all;
  5727. struct s_mapiterator* iter;
  5728. memset(users, 0, sizeof(users));
  5729. users_all = 0;
  5730. // count users on each map
  5731. iter = mapit_getallusers();
  5732. for(;;)
  5733. {
  5734. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5735. if( sd2 == NULL )
  5736. break;// no more users
  5737. if( sd2->mapindex >= MAX_MAPINDEX )
  5738. continue;// invalid mapindex
  5739. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5740. if( users_all < INT_MAX ) ++users_all;
  5741. }
  5742. mapit_free(iter);
  5743. // display results for each map
  5744. for( i = 0; i < MAX_MAPINDEX; ++i )
  5745. {
  5746. if( users[i] == 0 )
  5747. continue;// empty
  5748. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5749. clif_displaymessage(sd->fd, buf);
  5750. }
  5751. // display overall count
  5752. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5753. clif_displaymessage(sd->fd, buf);
  5754. return 0;
  5755. }
  5756. /*==========================================
  5757. *
  5758. *------------------------------------------*/
  5759. ACMD_FUNC(reset)
  5760. {
  5761. pc_resetstate(sd);
  5762. pc_resetskill(sd,1);
  5763. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5764. clif_displaymessage(fd, atcmd_output);
  5765. return 0;
  5766. }
  5767. /*==========================================
  5768. *
  5769. *------------------------------------------*/
  5770. ACMD_FUNC(summon)
  5771. {
  5772. char name[NAME_LENGTH];
  5773. int mob_id = 0;
  5774. int duration = 0;
  5775. struct mob_data *md;
  5776. unsigned int tick=gettick();
  5777. nullpo_retr(-1, sd);
  5778. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5779. {
  5780. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5781. return -1;
  5782. }
  5783. if (duration < 1)
  5784. duration =1;
  5785. else if (duration > 60)
  5786. duration =60;
  5787. if ((mob_id = atoi(name)) == 0)
  5788. mob_id = mobdb_searchname(name);
  5789. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5790. {
  5791. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5792. return -1;
  5793. }
  5794. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5795. if(!md)
  5796. return -1;
  5797. md->master_id=sd->bl.id;
  5798. md->special_state.ai=1;
  5799. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5800. clif_specialeffect(&md->bl,344,AREA);
  5801. mob_spawn(md);
  5802. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5803. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5804. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5805. return 0;
  5806. }
  5807. /*==========================================
  5808. * @adjcmdlvl by [MouseJstr]
  5809. *
  5810. * Temp adjust the GM level required to use a GM command
  5811. * Useful during beta testing to allow players to use GM commands for short periods of time
  5812. *------------------------------------------*/
  5813. ACMD_FUNC(adjcmdlvl)
  5814. {
  5815. int newlev, newremotelev;
  5816. char name[100];
  5817. AtCommandInfo* cmd;
  5818. nullpo_retr(-1, sd);
  5819. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5820. {
  5821. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5822. return -1;
  5823. }
  5824. cmd = get_atcommandinfo_byname(name);
  5825. if (cmd == NULL)
  5826. {
  5827. clif_displaymessage(fd, "@command not found.");
  5828. return -1;
  5829. }
  5830. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5831. {
  5832. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5833. return -1;
  5834. }
  5835. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5836. {
  5837. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5838. return -1;
  5839. }
  5840. else
  5841. {
  5842. cmd->level = newlev;
  5843. cmd->level2 = newremotelev;
  5844. clif_displaymessage(fd, "@command level changed.");
  5845. return 0;
  5846. }
  5847. }
  5848. /*==========================================
  5849. * @adjgmlvl by [MouseJstr]
  5850. * Create a temp GM
  5851. * Useful during beta testing to allow players to use GM commands for short periods of time
  5852. *------------------------------------------*/
  5853. ACMD_FUNC(adjgmlvl)
  5854. {
  5855. int newlev;
  5856. char user[NAME_LENGTH];
  5857. struct map_session_data *pl_sd;
  5858. nullpo_retr(-1, sd);
  5859. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5860. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5861. return -1;
  5862. }
  5863. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5864. {
  5865. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5866. return -1;
  5867. }
  5868. pl_sd->gmlevel = newlev;
  5869. return 0;
  5870. }
  5871. /*==========================================
  5872. * @trade by [MouseJstr]
  5873. * Open a trade window with a remote player
  5874. *------------------------------------------*/
  5875. ACMD_FUNC(trade)
  5876. {
  5877. struct map_session_data *pl_sd = NULL;
  5878. nullpo_retr(-1, sd);
  5879. if (!message || !*message) {
  5880. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5881. return -1;
  5882. }
  5883. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5884. {
  5885. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5886. return -1;
  5887. }
  5888. trade_traderequest(sd, pl_sd);
  5889. return 0;
  5890. }
  5891. /*==========================================
  5892. * @setbattleflag by [MouseJstr]
  5893. * set a battle_config flag without having to reboot
  5894. *------------------------------------------*/
  5895. ACMD_FUNC(setbattleflag)
  5896. {
  5897. char flag[128], value[128];
  5898. nullpo_retr(-1, sd);
  5899. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5900. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5901. return -1;
  5902. }
  5903. if (battle_set_value(flag, value) == 0)
  5904. {
  5905. clif_displaymessage(fd, "unknown battle_config flag");
  5906. return -1;
  5907. }
  5908. clif_displaymessage(fd, "battle_config set as requested");
  5909. return 0;
  5910. }
  5911. /*==========================================
  5912. * @unmute [Valaris]
  5913. *------------------------------------------*/
  5914. ACMD_FUNC(unmute)
  5915. {
  5916. struct map_session_data *pl_sd = NULL;
  5917. nullpo_retr(-1, sd);
  5918. if (!message || !*message) {
  5919. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5920. return -1;
  5921. }
  5922. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5923. {
  5924. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5925. return -1;
  5926. }
  5927. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5928. clif_displaymessage(sd->fd,"Player is not muted");
  5929. return -1;
  5930. }
  5931. pl_sd->status.manner = 0;
  5932. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5933. clif_displaymessage(sd->fd,"Player unmuted");
  5934. return 0;
  5935. }
  5936. /*==========================================
  5937. * @uptime by MC Cameri
  5938. *------------------------------------------*/
  5939. ACMD_FUNC(uptime)
  5940. {
  5941. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5942. minute = 60, days = 0, hours = 0, minutes = 0;
  5943. nullpo_retr(-1, sd);
  5944. seconds = get_uptime();
  5945. days = seconds/day;
  5946. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5947. hours = seconds/hour;
  5948. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5949. minutes = seconds/minute;
  5950. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5951. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  5952. clif_displaymessage(fd, atcmd_output);
  5953. return 0;
  5954. }
  5955. /*==========================================
  5956. * @changesex <sex>
  5957. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5958. *------------------------------------------*/
  5959. ACMD_FUNC(changesex)
  5960. {
  5961. nullpo_retr(-1, sd);
  5962. chrif_changesex(sd);
  5963. return 0;
  5964. }
  5965. /*================================================
  5966. * @mute - Mutes a player for a set amount of time
  5967. *------------------------------------------------*/
  5968. ACMD_FUNC(mute)
  5969. {
  5970. struct map_session_data *pl_sd = NULL;
  5971. int manner;
  5972. nullpo_retr(-1, sd);
  5973. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5974. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  5975. return -1;
  5976. }
  5977. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5978. {
  5979. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5980. return -1;
  5981. }
  5982. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5983. {
  5984. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5985. return -1;
  5986. }
  5987. clif_manner_message(sd, 0);
  5988. clif_manner_message(pl_sd, 5);
  5989. if( pl_sd->status.manner < manner ) {
  5990. pl_sd->status.manner -= manner;
  5991. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  5992. } else {
  5993. pl_sd->status.manner = 0;
  5994. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5995. }
  5996. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5997. return 0;
  5998. }
  5999. /*==========================================
  6000. * @refresh (like @jumpto <<yourself>>)
  6001. *------------------------------------------*/
  6002. ACMD_FUNC(refresh)
  6003. {
  6004. nullpo_retr(-1, sd);
  6005. clif_refresh(sd);
  6006. return 0;
  6007. }
  6008. /*==========================================
  6009. * @identify
  6010. * => GM's magnifier.
  6011. *------------------------------------------*/
  6012. ACMD_FUNC(identify)
  6013. {
  6014. int i,num;
  6015. nullpo_retr(-1, sd);
  6016. for(i=num=0;i<MAX_INVENTORY;i++){
  6017. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6018. num++;
  6019. }
  6020. }
  6021. if (num > 0) {
  6022. clif_item_identify_list(sd);
  6023. } else {
  6024. clif_displaymessage(fd,"There are no items to appraise.");
  6025. }
  6026. return 0;
  6027. }
  6028. /*==========================================
  6029. * @gmotd (Global MOTD)
  6030. * by davidsiaw :P
  6031. *------------------------------------------*/
  6032. ACMD_FUNC(gmotd)
  6033. {
  6034. char buf[CHAT_SIZE_MAX];
  6035. size_t len;
  6036. FILE* fp;
  6037. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6038. {
  6039. while( fgets(buf, sizeof(buf), fp) )
  6040. {
  6041. if( buf[0] == '/' && buf[1] == '/' )
  6042. {
  6043. continue;
  6044. }
  6045. len = strlen(buf);
  6046. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6047. {// strip trailing EOL characters
  6048. len--;
  6049. }
  6050. if( len )
  6051. {
  6052. buf[len] = 0;
  6053. intif_broadcast(buf, len+1, 0);
  6054. }
  6055. }
  6056. fclose(fp);
  6057. }
  6058. return 0;
  6059. }
  6060. ACMD_FUNC(misceffect)
  6061. {
  6062. int effect = 0;
  6063. nullpo_retr(-1, sd);
  6064. if (!message || !*message)
  6065. return -1;
  6066. if (sscanf(message, "%d", &effect) < 1)
  6067. return -1;
  6068. clif_misceffect(&sd->bl,effect);
  6069. return 0;
  6070. }
  6071. /*==========================================
  6072. * MAIL SYSTEM
  6073. *------------------------------------------*/
  6074. ACMD_FUNC(mail)
  6075. {
  6076. nullpo_ret(sd);
  6077. #ifndef TXT_ONLY
  6078. mail_openmail(sd);
  6079. #endif
  6080. return 0;
  6081. }
  6082. /*==========================================
  6083. * Show Monster DB Info v 1.0
  6084. * originally by [Lupus] eAthena
  6085. *------------------------------------------*/
  6086. ACMD_FUNC(mobinfo)
  6087. {
  6088. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6089. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6090. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6091. char atcmd_output2[CHAT_SIZE_MAX];
  6092. struct item_data *item_data;
  6093. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6094. int count;
  6095. int i, j, k;
  6096. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6097. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6098. if (!message || !*message) {
  6099. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6100. return -1;
  6101. }
  6102. // If monster identifier/name argument is a name
  6103. if ((i = mobdb_checkid(atoi(message))))
  6104. {
  6105. mob_array[0] = mob_db(i);
  6106. count = 1;
  6107. } else
  6108. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6109. if (!count) {
  6110. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6111. return -1;
  6112. }
  6113. if (count > MAX_SEARCH) {
  6114. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6115. clif_displaymessage(fd, atcmd_output);
  6116. count = MAX_SEARCH;
  6117. }
  6118. for (k = 0; k < count; k++) {
  6119. mob = mob_array[k];
  6120. // stats
  6121. if (mob->mexp)
  6122. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6123. else
  6124. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6125. clif_displaymessage(fd, atcmd_output);
  6126. sprintf(atcmd_output, " Level:%d HP:%d SP:%d Base EXP:%u Job EXP:%u", mob->lv, mob->status.max_hp, mob->status.max_sp, mob->base_exp, mob->job_exp);
  6127. clif_displaymessage(fd, atcmd_output);
  6128. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6129. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6130. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6131. clif_displaymessage(fd, atcmd_output);
  6132. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6133. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6134. mob->range2 , mob->range3, msize[mob->status.size],
  6135. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6136. clif_displaymessage(fd, atcmd_output);
  6137. // drops
  6138. clif_displaymessage(fd, " Drops:");
  6139. strcpy(atcmd_output, " ");
  6140. j = 0;
  6141. for (i = 0; i < MAX_MOB_DROP; i++) {
  6142. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6143. continue;
  6144. if (item_data->slot)
  6145. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  6146. else
  6147. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  6148. strcat(atcmd_output, atcmd_output2);
  6149. if (++j % 3 == 0) {
  6150. clif_displaymessage(fd, atcmd_output);
  6151. strcpy(atcmd_output, " ");
  6152. }
  6153. }
  6154. if (j == 0)
  6155. clif_displaymessage(fd, "This monster has no drops.");
  6156. else if (j % 3 != 0)
  6157. clif_displaymessage(fd, atcmd_output);
  6158. // mvp
  6159. if (mob->mexp) {
  6160. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  6161. clif_displaymessage(fd, atcmd_output);
  6162. strcpy(atcmd_output, " MVP Items:");
  6163. j = 0;
  6164. for (i = 0; i < 3; i++) {
  6165. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6166. continue;
  6167. if (mob->mvpitem[i].p > 0) {
  6168. j++;
  6169. if (j == 1)
  6170. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6171. else
  6172. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6173. strcat(atcmd_output, atcmd_output2);
  6174. }
  6175. }
  6176. if (j == 0)
  6177. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6178. else
  6179. clif_displaymessage(fd, atcmd_output);
  6180. }
  6181. }
  6182. return 0;
  6183. }
  6184. /*=========================================
  6185. * @showmobs by KarLaeda
  6186. * => For 15 sec displays the mobs on minimap
  6187. *------------------------------------------*/
  6188. ACMD_FUNC(showmobs)
  6189. {
  6190. char mob_name[100];
  6191. int mob_id;
  6192. int number = 0;
  6193. struct s_mapiterator* it;
  6194. nullpo_retr(-1, sd);
  6195. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6196. return -1;
  6197. if((mob_id = atoi(mob_name)) == 0)
  6198. mob_id = mobdb_searchname(mob_name);
  6199. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6200. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6201. clif_displaymessage(fd, atcmd_output);
  6202. return 0;
  6203. }
  6204. // Uncomment the following line to show mini-bosses & MVP.
  6205. //#define SHOW_MVP
  6206. #ifndef SHOW_MVP
  6207. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6208. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6209. clif_displaymessage(fd, atcmd_output);
  6210. return 0;
  6211. }
  6212. #endif
  6213. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6214. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6215. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6216. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6217. mob_name, mapindex_id2name(sd->mapindex));
  6218. clif_displaymessage(fd, atcmd_output);
  6219. it = mapit_geteachmob();
  6220. for(;;)
  6221. {
  6222. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6223. if( md == NULL )
  6224. break;// no more mobs
  6225. if( md->bl.m != sd->bl.m )
  6226. continue;
  6227. if( mob_id != -1 && md->class_ != mob_id )
  6228. continue;
  6229. if( md->special_state.ai || md->master_id )
  6230. continue; // hide slaves and player summoned mobs
  6231. if( md->spawn_timer != INVALID_TIMER )
  6232. continue; // hide mobs waiting for respawn
  6233. ++number;
  6234. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6235. }
  6236. mapit_free(it);
  6237. return 0;
  6238. }
  6239. /*==========================================
  6240. * homunculus level up [orn]
  6241. *------------------------------------------*/
  6242. ACMD_FUNC(homlevel)
  6243. {
  6244. TBL_HOM * hd;
  6245. int level = 0, i = 0;
  6246. nullpo_retr(-1, sd);
  6247. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6248. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  6249. return -1;
  6250. }
  6251. if ( !merc_is_hom_active(sd->hd) ) {
  6252. clif_displaymessage(fd, "You do not have a homunculus.");
  6253. return -1;
  6254. }
  6255. hd = sd->hd;
  6256. for (i = 1; i <= level && hd->exp_next; i++){
  6257. hd->homunculus.exp += hd->exp_next;
  6258. merc_hom_levelup(hd);
  6259. }
  6260. status_calc_homunculus(hd,0);
  6261. status_percent_heal(&hd->bl, 100, 100);
  6262. clif_specialeffect(&hd->bl,568,AREA);
  6263. return 0;
  6264. }
  6265. /*==========================================
  6266. * homunculus evolution H [orn]
  6267. *------------------------------------------*/
  6268. ACMD_FUNC(homevolution)
  6269. {
  6270. nullpo_retr(-1, sd);
  6271. if ( !merc_is_hom_active(sd->hd) ) {
  6272. clif_displaymessage(fd, "You do not have a homunculus.");
  6273. return -1;
  6274. }
  6275. if ( !merc_hom_evolution(sd->hd) ) {
  6276. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6277. return -1;
  6278. }
  6279. clif_homskillinfoblock(sd);
  6280. return 0;
  6281. }
  6282. /*==========================================
  6283. * call choosen homunculus [orn]
  6284. *------------------------------------------*/
  6285. ACMD_FUNC(makehomun)
  6286. {
  6287. int homunid;
  6288. nullpo_retr(-1, sd);
  6289. if ( sd->status.hom_id ) {
  6290. clif_displaymessage(fd, msg_txt(450));
  6291. return -1;
  6292. }
  6293. if (!message || !*message) {
  6294. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6295. return -1;
  6296. }
  6297. homunid = atoi(message);
  6298. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6299. {
  6300. clif_displaymessage(fd, "Invalid Homunculus id.");
  6301. return -1;
  6302. }
  6303. merc_create_homunculus_request(sd,homunid);
  6304. return 0;
  6305. }
  6306. /*==========================================
  6307. * modify homunculus intimacy [orn]
  6308. *------------------------------------------*/
  6309. ACMD_FUNC(homfriendly)
  6310. {
  6311. int friendly = 0;
  6312. nullpo_retr(-1, sd);
  6313. if ( !merc_is_hom_active(sd->hd) ) {
  6314. clif_displaymessage(fd, "You do not have a homunculus.");
  6315. return -1;
  6316. }
  6317. if (!message || !*message) {
  6318. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6319. return -1;
  6320. }
  6321. friendly = atoi(message);
  6322. friendly = cap_value(friendly, 0, 1000);
  6323. sd->hd->homunculus.intimacy = friendly * 100 ;
  6324. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6325. return 0;
  6326. }
  6327. /*==========================================
  6328. * modify homunculus hunger [orn]
  6329. *------------------------------------------*/
  6330. ACMD_FUNC(homhungry)
  6331. {
  6332. int hungry = 0;
  6333. nullpo_retr(-1, sd);
  6334. if ( !merc_is_hom_active(sd->hd) ) {
  6335. clif_displaymessage(fd, "You do not have a homunculus.");
  6336. return -1;
  6337. }
  6338. if (!message || !*message) {
  6339. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6340. return -1;
  6341. }
  6342. hungry = atoi(message);
  6343. hungry = cap_value(hungry, 0, 100);
  6344. sd->hd->homunculus.hunger = hungry;
  6345. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6346. return 0;
  6347. }
  6348. /*==========================================
  6349. * make the homunculus speak [orn]
  6350. *------------------------------------------*/
  6351. ACMD_FUNC(homtalk)
  6352. {
  6353. char mes[100],temp[100];
  6354. nullpo_retr(-1, sd);
  6355. if (sd->sc.count && //no "chatting" while muted.
  6356. (sd->sc.data[SC_BERSERK] ||
  6357. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6358. return -1;
  6359. if ( !merc_is_hom_active(sd->hd) ) {
  6360. clif_displaymessage(fd, "You do not have a homunculus.");
  6361. return -1;
  6362. }
  6363. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6364. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6365. return -1;
  6366. }
  6367. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6368. clif_message(&sd->hd->bl, temp);
  6369. return 0;
  6370. }
  6371. /*==========================================
  6372. * Show homunculus stats
  6373. *------------------------------------------*/
  6374. ACMD_FUNC(hominfo)
  6375. {
  6376. struct homun_data *hd;
  6377. struct status_data *status;
  6378. nullpo_retr(-1, sd);
  6379. if ( !merc_is_hom_active(sd->hd) ) {
  6380. clif_displaymessage(fd, "You do not have a homunculus.");
  6381. return -1;
  6382. }
  6383. hd = sd->hd;
  6384. status = status_get_status_data(&hd->bl);
  6385. clif_displaymessage(fd, "Homunculus stats :");
  6386. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6387. status->hp, status->max_hp, status->sp, status->max_sp);
  6388. clif_displaymessage(fd, atcmd_output);
  6389. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6390. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6391. clif_displaymessage(fd, atcmd_output);
  6392. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6393. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6394. clif_displaymessage(fd, atcmd_output);
  6395. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6396. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6397. status->str, status->agi, status->vit,
  6398. status->int_, status->dex, status->luk);
  6399. clif_displaymessage(fd, atcmd_output);
  6400. return 0;
  6401. }
  6402. ACMD_FUNC(homstats)
  6403. {
  6404. struct homun_data *hd;
  6405. struct s_homunculus_db *db;
  6406. struct s_homunculus *hom;
  6407. int lv, min, max, evo;
  6408. nullpo_retr(-1, sd);
  6409. if ( !merc_is_hom_active(sd->hd) ) {
  6410. clif_displaymessage(fd, "You do not have a homunculus.");
  6411. return -1;
  6412. }
  6413. hd = sd->hd;
  6414. hom = &hd->homunculus;
  6415. db = hd->homunculusDB;
  6416. lv = hom->level;
  6417. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6418. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6419. clif_displaymessage(fd, atcmd_output);
  6420. lv--; //Since the first increase is at level 2.
  6421. evo = (hom->class_ == db->evo_class);
  6422. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6423. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6424. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6425. clif_displaymessage(fd, atcmd_output);
  6426. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6427. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6428. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6429. clif_displaymessage(fd, atcmd_output);
  6430. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6431. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6432. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6433. clif_displaymessage(fd, atcmd_output);
  6434. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6435. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6436. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6437. clif_displaymessage(fd, atcmd_output);
  6438. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6439. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6440. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6441. clif_displaymessage(fd, atcmd_output);
  6442. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6443. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6444. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6445. clif_displaymessage(fd, atcmd_output);
  6446. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6447. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6448. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6449. clif_displaymessage(fd, atcmd_output);
  6450. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6451. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6452. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6453. clif_displaymessage(fd, atcmd_output);
  6454. return 0;
  6455. }
  6456. ACMD_FUNC(homshuffle)
  6457. {
  6458. nullpo_retr(-1, sd);
  6459. if(!sd->hd)
  6460. return -1; // nothing to do
  6461. if(!merc_hom_shuffle(sd->hd))
  6462. return -1;
  6463. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6464. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6465. return 0;
  6466. }
  6467. /*==========================================
  6468. * Show Items DB Info v 1.0
  6469. * originally by [Lupus] eAthena
  6470. *------------------------------------------*/
  6471. ACMD_FUNC(iteminfo)
  6472. {
  6473. struct item_data *item_data, *item_array[MAX_SEARCH];
  6474. int i, count = 1;
  6475. if (!message || !*message) {
  6476. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6477. return -1;
  6478. }
  6479. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6480. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6481. if (!count) {
  6482. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6483. return -1;
  6484. }
  6485. if (count > MAX_SEARCH) {
  6486. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6487. clif_displaymessage(fd, atcmd_output);
  6488. count = MAX_SEARCH;
  6489. }
  6490. for (i = 0; i < count; i++) {
  6491. item_data = item_array[i];
  6492. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6493. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6494. itemdb_typename(item_data->type),
  6495. (item_data->script==NULL)? "None" : "With script"
  6496. );
  6497. clif_displaymessage(fd, atcmd_output);
  6498. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6499. clif_displaymessage(fd, atcmd_output);
  6500. if (item_data->maxchance == -1)
  6501. strcpy(atcmd_output, " - Available in the shops only.");
  6502. else if (item_data->maxchance)
  6503. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6504. else
  6505. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6506. clif_displaymessage(fd, atcmd_output);
  6507. }
  6508. return 0;
  6509. }
  6510. /*==========================================
  6511. * Show who drops the item.
  6512. *------------------------------------------*/
  6513. ACMD_FUNC(whodrops)
  6514. {
  6515. struct item_data *item_data, *item_array[MAX_SEARCH];
  6516. int i,j, count = 1;
  6517. if (!message || !*message) {
  6518. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6519. return -1;
  6520. }
  6521. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6522. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6523. if (!count) {
  6524. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6525. return -1;
  6526. }
  6527. if (count > MAX_SEARCH) {
  6528. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6529. clif_displaymessage(fd, atcmd_output);
  6530. count = MAX_SEARCH;
  6531. }
  6532. for (i = 0; i < count; i++) {
  6533. item_data = item_array[i];
  6534. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6535. clif_displaymessage(fd, atcmd_output);
  6536. if (item_data->mob[0].chance == 0) {
  6537. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6538. clif_displaymessage(fd, atcmd_output);
  6539. } else {
  6540. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6541. clif_displaymessage(fd, atcmd_output);
  6542. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6543. {
  6544. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6545. clif_displaymessage(fd, atcmd_output);
  6546. }
  6547. }
  6548. }
  6549. return 0;
  6550. }
  6551. ACMD_FUNC(whereis)
  6552. {
  6553. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6554. int count;
  6555. int i, j, k;
  6556. if (!message || !*message) {
  6557. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6558. return -1;
  6559. }
  6560. // If monster identifier/name argument is a name
  6561. if ((i = mobdb_checkid(atoi(message))))
  6562. {
  6563. mob_array[0] = mob_db(i);
  6564. count = 1;
  6565. } else
  6566. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6567. if (!count) {
  6568. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6569. return -1;
  6570. }
  6571. if (count > MAX_SEARCH) {
  6572. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6573. clif_displaymessage(fd, atcmd_output);
  6574. count = MAX_SEARCH;
  6575. }
  6576. for (k = 0; k < count; k++) {
  6577. mob = mob_array[k];
  6578. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6579. clif_displaymessage(fd, atcmd_output);
  6580. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6581. {
  6582. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6583. if (j < 0) continue;
  6584. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6585. clif_displaymessage(fd, atcmd_output);
  6586. }
  6587. if (i == 0)
  6588. clif_displaymessage(fd, "This monster does not spawn normally.");
  6589. }
  6590. return 0;
  6591. }
  6592. /*==========================================
  6593. * @adopt by [Veider]
  6594. * adopt a novice
  6595. *------------------------------------------*/
  6596. ACMD_FUNC(adopt)
  6597. {
  6598. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6599. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6600. char output[CHAT_SIZE_MAX];
  6601. nullpo_retr(-1, sd);
  6602. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6603. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6604. return -1;
  6605. }
  6606. if (battle_config.etc_log)
  6607. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6608. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6609. sprintf(output, "Cannot find player %s online", player1);
  6610. clif_displaymessage(fd, output);
  6611. return -1;
  6612. }
  6613. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6614. sprintf(output, "Cannot find player %s online", player2);
  6615. clif_displaymessage(fd, output);
  6616. return -1;
  6617. }
  6618. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6619. sprintf(output, "Cannot find player %s online", player3);
  6620. clif_displaymessage(fd, output);
  6621. return -1;
  6622. }
  6623. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6624. return -1;
  6625. }
  6626. clif_displaymessage(fd, "They are family... wish them luck");
  6627. return 0;
  6628. }
  6629. ACMD_FUNC(version)
  6630. {
  6631. const char * revision;
  6632. if ((revision = get_svn_revision()) != 0) {
  6633. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6634. clif_displaymessage(fd,atcmd_output);
  6635. } else
  6636. clif_displaymessage(fd,"Cannot determine SVN revision");
  6637. return 0;
  6638. }
  6639. /*==========================================
  6640. * @mutearea by MouseJstr
  6641. *------------------------------------------*/
  6642. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6643. {
  6644. int time, id;
  6645. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6646. if (pl_sd == NULL)
  6647. return 0;
  6648. id = va_arg(ap, int);
  6649. time = va_arg(ap, int);
  6650. if (id != bl->id && !pc_isGM(pl_sd)) {
  6651. pl_sd->status.manner -= time;
  6652. if (pl_sd->status.manner < 0)
  6653. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6654. else
  6655. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6656. }
  6657. return 0;
  6658. }
  6659. ACMD_FUNC(mutearea)
  6660. {
  6661. int time;
  6662. nullpo_ret(sd);
  6663. if (!message || !*message) {
  6664. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6665. return -1;
  6666. }
  6667. time = atoi(message);
  6668. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6669. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6670. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6671. return 0;
  6672. }
  6673. ACMD_FUNC(rates)
  6674. {
  6675. char buf[CHAT_SIZE_MAX];
  6676. nullpo_ret(sd);
  6677. memset(buf, '\0', sizeof(buf));
  6678. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6679. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6680. clif_displaymessage(fd, buf);
  6681. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6682. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6683. clif_displaymessage(fd, buf);
  6684. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6685. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6686. clif_displaymessage(fd, buf);
  6687. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6688. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6689. clif_displaymessage(fd, buf);
  6690. return 0;
  6691. }
  6692. /*==========================================
  6693. * @me by lordalfa
  6694. * => Displays the OUTPUT string on top of the Visible players Heads.
  6695. *------------------------------------------*/
  6696. ACMD_FUNC(me)
  6697. {
  6698. char tempmes[CHAT_SIZE_MAX];
  6699. nullpo_retr(-1, sd);
  6700. memset(tempmes, '\0', sizeof(tempmes));
  6701. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6702. if (sd->sc.count && //no "chatting" while muted.
  6703. (sd->sc.data[SC_BERSERK] ||
  6704. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6705. return -1;
  6706. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6707. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6708. return -1;
  6709. }
  6710. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6711. clif_disp_overhead(sd, atcmd_output);
  6712. return 0;
  6713. }
  6714. /*==========================================
  6715. * @size
  6716. * => Resize your character sprite. [Valaris]
  6717. *------------------------------------------*/
  6718. ACMD_FUNC(size)
  6719. {
  6720. int size=0;
  6721. nullpo_retr(-1, sd);
  6722. size = atoi(message);
  6723. if(sd->state.size) {
  6724. sd->state.size=0;
  6725. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6726. }
  6727. if(size==1) {
  6728. sd->state.size=1;
  6729. clif_specialeffect(&sd->bl,420,AREA);
  6730. } else if(size==2) {
  6731. sd->state.size=2;
  6732. clif_specialeffect(&sd->bl,422,AREA);
  6733. }
  6734. return 0;
  6735. }
  6736. /*==========================================
  6737. * @monsterignore
  6738. * => Makes monsters ignore you. [Valaris]
  6739. *------------------------------------------*/
  6740. ACMD_FUNC(monsterignore)
  6741. {
  6742. nullpo_retr(-1, sd);
  6743. if (!sd->state.monster_ignore) {
  6744. sd->state.monster_ignore = 1;
  6745. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6746. } else {
  6747. sd->state.monster_ignore = 0;
  6748. clif_displaymessage(sd->fd, "Returned to normal state.");
  6749. }
  6750. return 0;
  6751. }
  6752. /*==========================================
  6753. * @fakename
  6754. * => Gives your character a fake name. [Valaris]
  6755. *------------------------------------------*/
  6756. ACMD_FUNC(fakename)
  6757. {
  6758. nullpo_retr(-1, sd);
  6759. if( !message || !*message )
  6760. {
  6761. if( sd->fakename[0] )
  6762. {
  6763. sd->fakename[0] = '\0';
  6764. clif_charnameack(0, &sd->bl);
  6765. clif_displaymessage(sd->fd, "Returned to real name.");
  6766. return 0;
  6767. }
  6768. clif_displaymessage(sd->fd, "You must enter a name.");
  6769. return -1;
  6770. }
  6771. if( strlen(message) < 2 )
  6772. {
  6773. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6774. return -1;
  6775. }
  6776. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6777. clif_charnameack(0, &sd->bl);
  6778. clif_displaymessage(sd->fd, "Fake name enabled.");
  6779. return 0;
  6780. }
  6781. /*==========================================
  6782. * Ragnarok Resources
  6783. *------------------------------------------*/
  6784. ACMD_FUNC(mapflag) {
  6785. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6786. #define setflag( cmd ) \
  6787. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6788. map[ sd->bl.m ].flag.cmd = flag;\
  6789. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6790. clif_displaymessage(sd->fd,atcmd_output);\
  6791. return 0;\
  6792. }
  6793. unsigned char flag_name[100];
  6794. int flag=9,i;
  6795. nullpo_retr(-1, sd);
  6796. memset(flag_name, '\0', sizeof(flag_name));
  6797. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6798. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6799. clif_displaymessage(sd->fd,"----------------------------------");
  6800. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6801. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6802. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6803. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6804. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6805. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6806. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6807. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6808. checkflag(nogo); checkflag(nobaseexp);
  6809. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6810. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6811. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6812. clif_displaymessage(sd->fd," ");
  6813. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6814. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6815. return 1;
  6816. }
  6817. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6818. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6819. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6820. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6821. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6822. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6823. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6824. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6825. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6826. setflag(nogo); setflag(nobaseexp);
  6827. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6828. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6829. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6830. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6831. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6832. clif_displaymessage(sd->fd,"Available Flags:");
  6833. clif_displaymessage(sd->fd,"----------------------------------");
  6834. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6835. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6836. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6837. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6838. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6839. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6840. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6841. #undef checkflag
  6842. #undef setflag
  6843. return 0;
  6844. }
  6845. /*===================================
  6846. * Remove some messages
  6847. *-----------------------------------*/
  6848. ACMD_FUNC(showexp)
  6849. {
  6850. if (sd->state.showexp) {
  6851. sd->state.showexp = 0;
  6852. clif_displaymessage(fd, "Gained exp will not be shown.");
  6853. return 0;
  6854. }
  6855. sd->state.showexp = 1;
  6856. clif_displaymessage(fd, "Gained exp is now shown");
  6857. return 0;
  6858. }
  6859. ACMD_FUNC(showzeny)
  6860. {
  6861. if (sd->state.showzeny) {
  6862. sd->state.showzeny = 0;
  6863. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6864. return 0;
  6865. }
  6866. sd->state.showzeny = 1;
  6867. clif_displaymessage(fd, "Gained zeny is now shown");
  6868. return 0;
  6869. }
  6870. ACMD_FUNC(showdelay)
  6871. {
  6872. if (sd->state.showdelay) {
  6873. sd->state.showdelay = 0;
  6874. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6875. return 0;
  6876. }
  6877. sd->state.showdelay = 1;
  6878. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6879. return 0;
  6880. }
  6881. /*==========================================
  6882. * Duel organizing functions [LuzZza]
  6883. *
  6884. * @duel [limit|nick] - create a duel
  6885. * @invite <nick> - invite player
  6886. * @accept - accept invitation
  6887. * @reject - reject invitation
  6888. * @leave - leave duel
  6889. *------------------------------------------*/
  6890. ACMD_FUNC(invite)
  6891. {
  6892. unsigned int did = sd->duel_group;
  6893. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6894. if(did <= 0) {
  6895. // "Duel: @invite without @duel."
  6896. clif_displaymessage(fd, msg_txt(350));
  6897. return 0;
  6898. }
  6899. if(duel_list[did].max_players_limit > 0 &&
  6900. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6901. // "Duel: Limit of players is reached."
  6902. clif_displaymessage(fd, msg_txt(351));
  6903. return 0;
  6904. }
  6905. if(target_sd == NULL) {
  6906. // "Duel: Player not found."
  6907. clif_displaymessage(fd, msg_txt(352));
  6908. return 0;
  6909. }
  6910. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6911. // "Duel: Player already in duel."
  6912. clif_displaymessage(fd, msg_txt(353));
  6913. return 0;
  6914. }
  6915. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6916. {
  6917. sprintf(atcmd_output, msg_txt(364), message);
  6918. clif_displaymessage(fd, atcmd_output);
  6919. return 0;
  6920. }
  6921. duel_invite(did, sd, target_sd);
  6922. // "Duel: Invitation has been sent."
  6923. clif_displaymessage(fd, msg_txt(354));
  6924. return 0;
  6925. }
  6926. ACMD_FUNC(duel)
  6927. {
  6928. char output[CHAT_SIZE_MAX];
  6929. unsigned int maxpl=0, newduel;
  6930. struct map_session_data *target_sd;
  6931. if(sd->duel_group > 0) {
  6932. duel_showinfo(sd->duel_group, sd);
  6933. return 0;
  6934. }
  6935. if(sd->duel_invite > 0) {
  6936. // "Duel: @duel without @reject."
  6937. clif_displaymessage(fd, msg_txt(355));
  6938. return 0;
  6939. }
  6940. if(!duel_checktime(sd)) {
  6941. // "Duel: You can take part in duel only one time per %d minutes."
  6942. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6943. clif_displaymessage(fd, output);
  6944. return 0;
  6945. }
  6946. if( message[0] ) {
  6947. if(sscanf(message, "%d", &maxpl) >= 1) {
  6948. if(maxpl < 2 || maxpl > 65535) {
  6949. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  6950. return 0;
  6951. }
  6952. duel_create(sd, maxpl);
  6953. } else {
  6954. target_sd = map_nick2sd((char *)message);
  6955. if(target_sd != NULL) {
  6956. if((newduel = duel_create(sd, 2)) != -1) {
  6957. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6958. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  6959. return 0;
  6960. }
  6961. duel_invite(newduel, sd, target_sd);
  6962. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  6963. }
  6964. } else {
  6965. // "Duel: Player not found."
  6966. clif_displaymessage(fd, msg_txt(352));
  6967. return 0;
  6968. }
  6969. }
  6970. } else
  6971. duel_create(sd, 0);
  6972. return 0;
  6973. }
  6974. ACMD_FUNC(leave)
  6975. {
  6976. if(sd->duel_group <= 0) {
  6977. // "Duel: @leave without @duel."
  6978. clif_displaymessage(fd, msg_txt(358));
  6979. return 0;
  6980. }
  6981. duel_leave(sd->duel_group, sd);
  6982. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  6983. return 0;
  6984. }
  6985. ACMD_FUNC(accept)
  6986. {
  6987. char output[CHAT_SIZE_MAX];
  6988. if(!duel_checktime(sd)) {
  6989. // "Duel: You can take part in duel only one time per %d minutes."
  6990. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6991. clif_displaymessage(fd, output);
  6992. return 0;
  6993. }
  6994. if(sd->duel_invite <= 0) {
  6995. // "Duel: @accept without invititation."
  6996. clif_displaymessage(fd, msg_txt(360));
  6997. return 0;
  6998. }
  6999. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  7000. {
  7001. // "Duel: Limit of players is reached."
  7002. clif_displaymessage(fd, msg_txt(351));
  7003. return 0;
  7004. }
  7005. duel_accept(sd->duel_invite, sd);
  7006. // "Duel: Invitation has been accepted."
  7007. clif_displaymessage(fd, msg_txt(361));
  7008. return 0;
  7009. }
  7010. ACMD_FUNC(reject)
  7011. {
  7012. if(sd->duel_invite <= 0) {
  7013. // "Duel: @reject without invititation."
  7014. clif_displaymessage(fd, msg_txt(362));
  7015. return 0;
  7016. }
  7017. duel_reject(sd->duel_invite, sd);
  7018. // "Duel: Invitation has been rejected."
  7019. clif_displaymessage(fd, msg_txt(363));
  7020. return 0;
  7021. }
  7022. /*===================================
  7023. * Cash Points
  7024. *-----------------------------------*/
  7025. ACMD_FUNC(cash)
  7026. {
  7027. char output[128];
  7028. int value;
  7029. nullpo_retr(-1, sd);
  7030. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7031. clif_displaymessage(fd, "Please, enter an amount.");
  7032. return -1;
  7033. }
  7034. if( !strcmpi(command+1,"cash") )
  7035. {
  7036. if( value > 0 ) {
  7037. pc_getcash(sd, value, 0);
  7038. sprintf(output, msg_txt(505), value, sd->cashPoints);
  7039. clif_disp_onlyself(sd, output, strlen(output));
  7040. } else {
  7041. pc_paycash(sd, -value, 0);
  7042. sprintf(output, msg_txt(410), value, sd->cashPoints);
  7043. clif_disp_onlyself(sd, output, strlen(output));
  7044. }
  7045. }
  7046. else
  7047. { // @points
  7048. if( value > 0 ) {
  7049. pc_getcash(sd, 0, value);
  7050. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  7051. clif_disp_onlyself(sd, output, strlen(output));
  7052. } else {
  7053. pc_paycash(sd, -value, -value);
  7054. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  7055. clif_disp_onlyself(sd, output, strlen(output));
  7056. }
  7057. }
  7058. return 0;
  7059. }
  7060. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7061. ACMD_FUNC(clone)
  7062. {
  7063. int x=0,y=0,flag=0,master=0,i=0;
  7064. struct map_session_data *pl_sd=NULL;
  7065. if (!message || !*message) {
  7066. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7067. return 0;
  7068. }
  7069. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7070. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7071. return 0;
  7072. }
  7073. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7074. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7075. return 0;
  7076. }
  7077. if (strcmpi(command+1, "clone") == 0)
  7078. flag = 1;
  7079. else if (strcmpi(command+1, "slaveclone") == 0) {
  7080. flag = 2;
  7081. master = sd->bl.id;
  7082. if (battle_config.atc_slave_clone_limit
  7083. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7084. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7085. return 0;
  7086. }
  7087. }
  7088. do {
  7089. x = sd->bl.x + (rand() % 10 - 5);
  7090. y = sd->bl.y + (rand() % 10 - 5);
  7091. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7092. if (i >= 10) {
  7093. x = sd->bl.x;
  7094. y = sd->bl.y;
  7095. }
  7096. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7097. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7098. return 0;
  7099. }
  7100. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7101. return 0;
  7102. }
  7103. /*===================================
  7104. * Main chat [LuzZza]
  7105. * Usage: @main <on|off|message>
  7106. *-----------------------------------*/
  7107. ACMD_FUNC(main)
  7108. {
  7109. if( message[0] ) {
  7110. if(strcmpi(message, "on") == 0) {
  7111. if(!sd->state.mainchat) {
  7112. sd->state.mainchat = 1;
  7113. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7114. } else {
  7115. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7116. }
  7117. } else if(strcmpi(message, "off") == 0) {
  7118. if(sd->state.mainchat) {
  7119. sd->state.mainchat = 0;
  7120. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7121. } else {
  7122. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7123. }
  7124. } else {
  7125. if(!sd->state.mainchat) {
  7126. sd->state.mainchat = 1;
  7127. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7128. }
  7129. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  7130. clif_displaymessage(fd, msg_txt(387));
  7131. return -1;
  7132. }
  7133. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7134. // I use 0xFE000000 color for signalizing that this message is
  7135. // main chat message. 0xFE000000 is invalid color, same using
  7136. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7137. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  7138. // Chat logging type 'M' / Main Chat
  7139. log_chat(LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
  7140. }
  7141. } else {
  7142. if(sd->state.mainchat)
  7143. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7144. else
  7145. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7146. }
  7147. return 0;
  7148. }
  7149. /*=====================================
  7150. * Autorejecting Invites/Deals [LuzZza]
  7151. * Usage: @noask
  7152. *-------------------------------------*/
  7153. ACMD_FUNC(noask)
  7154. {
  7155. if(sd->state.noask) {
  7156. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7157. sd->state.noask = 0;
  7158. } else {
  7159. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7160. sd->state.noask = 1;
  7161. }
  7162. return 0;
  7163. }
  7164. /*=====================================
  7165. * Send a @request message to all GMs of lowest_gm_level.
  7166. * Usage: @request <petition>
  7167. *-------------------------------------*/
  7168. ACMD_FUNC(request)
  7169. {
  7170. if (!message || !*message) {
  7171. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  7172. return -1;
  7173. }
  7174. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  7175. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  7176. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7177. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7178. return 0;
  7179. }
  7180. /*==========================================
  7181. * Feel (SG save map) Reset [HiddenDragon]
  7182. *------------------------------------------*/
  7183. ACMD_FUNC(feelreset)
  7184. {
  7185. pc_resetfeel(sd);
  7186. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7187. return 0;
  7188. }
  7189. /*==========================================
  7190. * AUCTION SYSTEM
  7191. *------------------------------------------*/
  7192. ACMD_FUNC(auction)
  7193. {
  7194. nullpo_ret(sd);
  7195. #ifndef TXT_ONLY
  7196. clif_Auction_openwindow(sd);
  7197. #endif
  7198. return 0;
  7199. }
  7200. /*==========================================
  7201. * Kill Steal Protection
  7202. *------------------------------------------*/
  7203. ACMD_FUNC(ksprotection)
  7204. {
  7205. nullpo_retr(-1,sd);
  7206. if( sd->state.noks ) {
  7207. sd->state.noks = 0;
  7208. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7209. }
  7210. else
  7211. {
  7212. if( !message || !*message || !strcmpi(message, "party") )
  7213. { // Default is Party
  7214. sd->state.noks = 2;
  7215. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7216. }
  7217. else if( !strcmpi(message, "self") )
  7218. {
  7219. sd->state.noks = 1;
  7220. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7221. }
  7222. else if( !strcmpi(message, "guild") )
  7223. {
  7224. sd->state.noks = 3;
  7225. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7226. }
  7227. else
  7228. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7229. }
  7230. clif_displaymessage(fd, atcmd_output);
  7231. return 0;
  7232. }
  7233. /*==========================================
  7234. * Map Kill Steal Protection Setting
  7235. *------------------------------------------*/
  7236. ACMD_FUNC(allowks)
  7237. {
  7238. nullpo_retr(-1,sd);
  7239. if( map[sd->bl.m].flag.allowks ) {
  7240. map[sd->bl.m].flag.allowks = 0;
  7241. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7242. } else {
  7243. map[sd->bl.m].flag.allowks = 1;
  7244. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7245. }
  7246. clif_displaymessage(fd, atcmd_output);
  7247. return 0;
  7248. }
  7249. ACMD_FUNC(resetstat)
  7250. {
  7251. nullpo_retr(-1, sd);
  7252. pc_resetstate(sd);
  7253. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7254. clif_displaymessage(fd, atcmd_output);
  7255. return 0;
  7256. }
  7257. ACMD_FUNC(resetskill)
  7258. {
  7259. nullpo_retr(-1,sd);
  7260. pc_resetskill(sd,1);
  7261. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7262. clif_displaymessage(fd, atcmd_output);
  7263. return 0;
  7264. }
  7265. /*==========================================
  7266. * #storagelist: Displays the items list of a player's storage.
  7267. * #cartlist: Displays contents of target's cart.
  7268. * #itemlist: Displays contents of target's inventory.
  7269. *------------------------------------------*/
  7270. ACMD_FUNC(itemlist)
  7271. {
  7272. int i, j, count, counter;
  7273. const char* location;
  7274. const struct item* items;
  7275. int size;
  7276. StringBuf buf;
  7277. nullpo_retr(-1, sd);
  7278. if( strcmp(command+1, "storagelist") == 0 )
  7279. {
  7280. location = "storage";
  7281. items = sd->status.storage.items;
  7282. size = MAX_STORAGE;
  7283. }
  7284. else
  7285. if( strcmp(command+1, "cartlist") == 0 )
  7286. {
  7287. location = "cart";
  7288. items = sd->status.cart;
  7289. size = MAX_CART;
  7290. }
  7291. else
  7292. if( strcmp(command+1, "itemlist") == 0 )
  7293. {
  7294. location = "inventory";
  7295. items = sd->status.inventory;
  7296. size = MAX_INVENTORY;
  7297. }
  7298. else
  7299. return 1;
  7300. StringBuf_Init(&buf);
  7301. count = 0; // total slots occupied
  7302. counter = 0; // total items found
  7303. for( i = 0; i < size; ++i )
  7304. {
  7305. const struct item* it = &items[i];
  7306. struct item_data* itd;
  7307. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7308. continue;
  7309. counter += it->amount;
  7310. count++;
  7311. if( count == 1 )
  7312. {
  7313. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7314. clif_displaymessage(fd, StringBuf_Value(&buf));
  7315. StringBuf_Clear(&buf);
  7316. }
  7317. if( it->refine )
  7318. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7319. else
  7320. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7321. if( it->equip )
  7322. {
  7323. char equipstr[CHAT_SIZE_MAX];
  7324. strcpy(equipstr, " | equipped: ");
  7325. if( it->equip & EQP_GARMENT )
  7326. strcat(equipstr, "garment, ");
  7327. if( it->equip & EQP_ACC_L )
  7328. strcat(equipstr, "left accessory, ");
  7329. if( it->equip & EQP_ARMOR )
  7330. strcat(equipstr, "body/armor, ");
  7331. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7332. strcat(equipstr, "right hand, ");
  7333. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7334. strcat(equipstr, "left hand, ");
  7335. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7336. strcat(equipstr, "both hands, ");
  7337. if( it->equip & EQP_SHOES )
  7338. strcat(equipstr, "feet, ");
  7339. if( it->equip & EQP_ACC_R )
  7340. strcat(equipstr, "right accessory, ");
  7341. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7342. strcat(equipstr, "lower head, ");
  7343. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7344. strcat(equipstr, "top head, ");
  7345. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7346. strcat(equipstr, "lower/top head, ");
  7347. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7348. strcat(equipstr, "mid head, ");
  7349. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7350. strcat(equipstr, "lower/mid head, ");
  7351. if( (it->equip & EQP_HELM) == EQP_HELM )
  7352. strcat(equipstr, "lower/mid/top head, ");
  7353. // remove final ', '
  7354. equipstr[strlen(equipstr) - 2] = '\0';
  7355. StringBuf_AppendStr(&buf, equipstr);
  7356. }
  7357. clif_displaymessage(fd, StringBuf_Value(&buf));
  7358. StringBuf_Clear(&buf);
  7359. if( it->card[0] == CARD0_PET )
  7360. {// pet egg
  7361. if (it->card[3])
  7362. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7363. else
  7364. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7365. }
  7366. else
  7367. if(it->card[0] == CARD0_FORGE)
  7368. {// forged item
  7369. StringBuf_Printf(&buf, " -> (crafted item, creator id: %u, star crumbs %d, element %d)", (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f);
  7370. }
  7371. else
  7372. if(it->card[0] == CARD0_CREATE)
  7373. {// created item
  7374. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7375. }
  7376. else
  7377. {// normal item
  7378. int counter2 = 0;
  7379. for( j = 0; j < itd->slot; ++j )
  7380. {
  7381. struct item_data* card;
  7382. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7383. continue;
  7384. counter2++;
  7385. if( counter2 == 1 )
  7386. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7387. if( counter2 != 1 )
  7388. StringBuf_AppendStr(&buf, ", ");
  7389. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7390. }
  7391. if( counter2 > 0 )
  7392. StringBuf_AppendStr(&buf, ")");
  7393. }
  7394. if( StringBuf_Length(&buf) > 0 )
  7395. clif_displaymessage(fd, StringBuf_Value(&buf));
  7396. StringBuf_Clear(&buf);
  7397. }
  7398. if( count == 0 )
  7399. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7400. else
  7401. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7402. clif_displaymessage(fd, StringBuf_Value(&buf));
  7403. StringBuf_Destroy(&buf);
  7404. return 0;
  7405. }
  7406. ACMD_FUNC(stats)
  7407. {
  7408. char job_jobname[100];
  7409. char output[CHAT_SIZE_MAX];
  7410. int i;
  7411. struct {
  7412. const char* format;
  7413. int value;
  7414. } output_table[] = {
  7415. { "Base Level - %d", 0 },
  7416. { NULL, 0 },
  7417. { "Hp - %d", 0 },
  7418. { "MaxHp - %d", 0 },
  7419. { "Sp - %d", 0 },
  7420. { "MaxSp - %d", 0 },
  7421. { "Str - %3d", 0 },
  7422. { "Agi - %3d", 0 },
  7423. { "Vit - %3d", 0 },
  7424. { "Int - %3d", 0 },
  7425. { "Dex - %3d", 0 },
  7426. { "Luk - %3d", 0 },
  7427. { "Zeny - %d", 0 },
  7428. { "Free SK Points - %d", 0 },
  7429. { "JobChangeLvl - %d", 0 },
  7430. { NULL, 0 }
  7431. };
  7432. memset(job_jobname, '\0', sizeof(job_jobname));
  7433. memset(output, '\0', sizeof(output));
  7434. //direct array initialization with variables is not standard C compliant.
  7435. output_table[0].value = sd->status.base_level;
  7436. output_table[1].format = job_jobname;
  7437. output_table[1].value = sd->status.job_level;
  7438. output_table[2].value = sd->status.hp;
  7439. output_table[3].value = sd->status.max_hp;
  7440. output_table[4].value = sd->status.sp;
  7441. output_table[5].value = sd->status.max_sp;
  7442. output_table[6].value = sd->status.str;
  7443. output_table[7].value = sd->status.agi;
  7444. output_table[8].value = sd->status.vit;
  7445. output_table[9].value = sd->status.int_;
  7446. output_table[10].value = sd->status.dex;
  7447. output_table[11].value = sd->status.luk;
  7448. output_table[12].value = sd->status.zeny;
  7449. output_table[13].value = sd->status.skill_point;
  7450. output_table[14].value = sd->change_level;
  7451. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7452. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7453. clif_displaymessage(fd, output);
  7454. for (i = 0; output_table[i].format != NULL; i++) {
  7455. sprintf(output, output_table[i].format, output_table[i].value);
  7456. clif_displaymessage(fd, output);
  7457. }
  7458. return 0;
  7459. }
  7460. ACMD_FUNC(delitem)
  7461. {
  7462. char item_name[100];
  7463. int nameid, amount = 0, total, idx;
  7464. struct item_data* id;
  7465. nullpo_retr(-1, sd);
  7466. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7467. {
  7468. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7469. return -1;
  7470. }
  7471. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7472. {
  7473. nameid = id->nameid;
  7474. }
  7475. else
  7476. {
  7477. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7478. return -1;
  7479. }
  7480. total = amount;
  7481. // delete items
  7482. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7483. {
  7484. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7485. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7486. {// delete pet
  7487. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7488. }
  7489. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7490. amount-= delamount;
  7491. }
  7492. // notify target
  7493. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7494. clif_displaymessage(sd->fd, atcmd_output);
  7495. // notify source
  7496. if( amount == total )
  7497. {
  7498. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7499. }
  7500. else if( amount )
  7501. {
  7502. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7503. clif_displaymessage(fd, atcmd_output);
  7504. }
  7505. else
  7506. {
  7507. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7508. clif_displaymessage(fd, atcmd_output);
  7509. }
  7510. return 0;
  7511. }
  7512. /*==========================================
  7513. * Custom Fonts
  7514. *------------------------------------------*/
  7515. ACMD_FUNC(font)
  7516. {
  7517. int font_id;
  7518. nullpo_retr(-1,sd);
  7519. font_id = atoi(message);
  7520. if( font_id == 0 )
  7521. {
  7522. if( sd->user_font )
  7523. {
  7524. sd->user_font = 0;
  7525. clif_displaymessage(fd, "Returning to normal font.");
  7526. clif_font(sd);
  7527. }
  7528. else
  7529. {
  7530. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7531. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7532. }
  7533. }
  7534. else if( font_id < 0 || font_id > 9 )
  7535. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7536. else if( font_id != sd->user_font )
  7537. {
  7538. sd->user_font = font_id;
  7539. clif_font(sd);
  7540. clif_displaymessage(fd, "Font changed.");
  7541. }
  7542. else
  7543. clif_displaymessage(fd, "Already using this font.");
  7544. return 0;
  7545. }
  7546. ACMD_FUNC(new_mount) {
  7547. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7548. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7549. clif_displaymessage(sd->fd,"You have mounted.");
  7550. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7551. } else {
  7552. clif_displaymessage(sd->fd,"You have released your mount");
  7553. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7554. }
  7555. return 0;
  7556. }
  7557. /**
  7558. * Fills the reference of available commands in atcommand DBMap
  7559. **/
  7560. void atcommand_basecommands(void) {
  7561. /**
  7562. * Command reference list, place the base of your commands here
  7563. * Dev note: I'd love to get rid of this, if you have a better idea on this please share with the poor mortals
  7564. **/
  7565. AtCommandInfo atcommand_base[] = {
  7566. { "warp", 40,40, atcommand_mapmove }, // + /mm
  7567. { "where", 1,1, atcommand_where },
  7568. { "goto", 20,20, atcommand_jumpto }, // + /shift
  7569. { "jump", 40,40, atcommand_jump },
  7570. { "who", 20,20, atcommand_who },
  7571. { "who2", 20,20, atcommand_who2 },
  7572. { "who3", 20,20, atcommand_who3 },
  7573. { "whomap", 20,20, atcommand_whomap },
  7574. { "whomap2", 20,20, atcommand_whomap2 },
  7575. { "whomap3", 20,20, atcommand_whomap3 },
  7576. { "whogm", 20,20, atcommand_whogm },
  7577. { "save", 40,40, atcommand_save },
  7578. { "load", 40,40, atcommand_load },
  7579. { "speed", 40,40, atcommand_speed },
  7580. { "storage", 1,1, atcommand_storage },
  7581. { "gstorage", 50,50, atcommand_guildstorage },
  7582. { "option", 40,40, atcommand_option },
  7583. { "hide", 40,40, atcommand_hide }, // + /hide
  7584. { "job", 40,40, atcommand_jobchange },
  7585. { "die", 1,1, atcommand_die },
  7586. { "kill", 60,60, atcommand_kill },
  7587. { "alive", 60,60, atcommand_alive },
  7588. { "kami", 40,40, atcommand_kami },
  7589. { "kamib", 40,40, atcommand_kami },
  7590. { "kamic", 40,40, atcommand_kami },
  7591. { "heal", 40,60, atcommand_heal },
  7592. { "item", 60,60, atcommand_item },
  7593. { "item2", 60,60, atcommand_item2 },
  7594. { "itemreset", 40,40, atcommand_itemreset },
  7595. { "blvl", 60,60, atcommand_baselevelup },
  7596. { "jlvl", 60,60, atcommand_joblevelup },
  7597. { "help", 20,20, atcommand_help },
  7598. { "help2", 20,20, atcommand_help2 },
  7599. { "pvpoff", 40,40, atcommand_pvpoff },
  7600. { "pvpon", 40,40, atcommand_pvpon },
  7601. { "gvgoff", 40,40, atcommand_gvgoff },
  7602. { "gvgon", 40,40, atcommand_gvgon },
  7603. { "model", 20,20, atcommand_model },
  7604. { "go", 10,10, atcommand_go },
  7605. { "monster", 50,50, atcommand_monster },
  7606. { "monstersmall", 50,50, atcommand_monstersmall },
  7607. { "monsterbig", 50,50, atcommand_monsterbig },
  7608. { "killmonster", 60,60, atcommand_killmonster },
  7609. { "killmonster2", 40,40, atcommand_killmonster2 },
  7610. { "refine", 60,60, atcommand_refine },
  7611. { "produce", 60,60, atcommand_produce },
  7612. { "memo", 40,40, atcommand_memo },
  7613. { "gat", 99,99, atcommand_gat },
  7614. { "displaystatus", 99,99, atcommand_displaystatus },
  7615. { "stpoint", 60,60, atcommand_statuspoint },
  7616. { "skpoint", 60,60, atcommand_skillpoint },
  7617. { "zeny", 60,60, atcommand_zeny },
  7618. { "str", 60,60, atcommand_param },
  7619. { "agi", 60,60, atcommand_param },
  7620. { "vit", 60,60, atcommand_param },
  7621. { "int", 60,60, atcommand_param },
  7622. { "dex", 60,60, atcommand_param },
  7623. { "luk", 60,60, atcommand_param },
  7624. { "glvl", 60,60, atcommand_guildlevelup },
  7625. { "makeegg", 60,60, atcommand_makeegg },
  7626. { "hatch", 60,60, atcommand_hatch },
  7627. { "petfriendly", 40,40, atcommand_petfriendly },
  7628. { "pethungry", 40,40, atcommand_pethungry },
  7629. { "petrename", 1,1, atcommand_petrename },
  7630. { "recall", 60,60, atcommand_recall }, // + /recall
  7631. { "night", 80,80, atcommand_night },
  7632. { "day", 80,80, atcommand_day },
  7633. { "doom", 80,80, atcommand_doom },
  7634. { "doommap", 80,80, atcommand_doommap },
  7635. { "raise", 80,80, atcommand_raise },
  7636. { "raisemap", 80,80, atcommand_raisemap },
  7637. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7638. { "kickall", 99,99, atcommand_kickall },
  7639. { "allskill", 60,60, atcommand_allskill },
  7640. { "questskill", 40,40, atcommand_questskill },
  7641. { "lostskill", 40,40, atcommand_lostskill },
  7642. { "spiritball", 40,40, atcommand_spiritball },
  7643. { "party", 1,1, atcommand_party },
  7644. { "guild", 50,50, atcommand_guild },
  7645. { "agitstart", 60,60, atcommand_agitstart },
  7646. { "agitend", 60,60, atcommand_agitend },
  7647. { "mapexit", 99,99, atcommand_mapexit },
  7648. { "idsearch", 60,60, atcommand_idsearch },
  7649. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7650. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7651. { "recallall", 80,80, atcommand_recallall },
  7652. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7653. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7654. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7655. { "reloadscript", 99,99, atcommand_reloadscript },
  7656. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7657. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7658. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7659. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7660. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7661. { "mapinfo", 99,99, atcommand_mapinfo },
  7662. { "dye", 40,40, atcommand_dye },
  7663. { "hairstyle", 40,40, atcommand_hair_style },
  7664. { "haircolor", 40,40, atcommand_hair_color },
  7665. { "allstats", 60,60, atcommand_stat_all },
  7666. { "block", 60,60, atcommand_char_block },
  7667. { "ban", 60,60, atcommand_char_ban },
  7668. { "unblock", 60,60, atcommand_char_unblock },
  7669. { "unban", 60,60, atcommand_char_unban },
  7670. { "mount", 20,20, atcommand_mount_peco },
  7671. { "guildspy", 60,60, atcommand_guildspy },
  7672. { "partyspy", 60,60, atcommand_partyspy },
  7673. { "repairall", 60,60, atcommand_repairall },
  7674. { "guildrecall", 60,60, atcommand_guildrecall },
  7675. { "partyrecall", 60,60, atcommand_partyrecall },
  7676. { "nuke", 60,60, atcommand_nuke },
  7677. { "shownpc", 80,80, atcommand_shownpc },
  7678. { "hidenpc", 80,80, atcommand_hidenpc },
  7679. { "loadnpc", 80,80, atcommand_loadnpc },
  7680. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7681. { "time", 1,1, atcommand_servertime },
  7682. { "jail", 60,60, atcommand_jail },
  7683. { "unjail", 60,60, atcommand_unjail },
  7684. { "jailfor", 60,60, atcommand_jailfor },
  7685. { "jailtime", 1,1, atcommand_jailtime },
  7686. { "disguise", 20,20, atcommand_disguise },
  7687. { "undisguise", 20,20, atcommand_undisguise },
  7688. { "email", 1,1, atcommand_email },
  7689. { "effect", 40,40, atcommand_effect },
  7690. { "follow", 20,20, atcommand_follow },
  7691. { "addwarp", 60,60, atcommand_addwarp },
  7692. { "skillon", 80,80, atcommand_skillon },
  7693. { "skilloff", 80,80, atcommand_skilloff },
  7694. { "killer", 60,60, atcommand_killer },
  7695. { "npcmove", 80,80, atcommand_npcmove },
  7696. { "killable", 40,40, atcommand_killable },
  7697. { "dropall", 40,40, atcommand_dropall },
  7698. { "storeall", 40,40, atcommand_storeall },
  7699. { "skillid", 40,40, atcommand_skillid },
  7700. { "useskill", 40,40, atcommand_useskill },
  7701. { "displayskill", 99,99, atcommand_displayskill },
  7702. { "snow", 99,99, atcommand_snow },
  7703. { "sakura", 99,99, atcommand_sakura },
  7704. { "clouds", 99,99, atcommand_clouds },
  7705. { "clouds2", 99,99, atcommand_clouds2 },
  7706. { "fog", 99,99, atcommand_fog },
  7707. { "fireworks", 99,99, atcommand_fireworks },
  7708. { "leaves", 99,99, atcommand_leaves },
  7709. { "summon", 60,60, atcommand_summon },
  7710. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7711. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7712. { "trade", 60,60, atcommand_trade },
  7713. { "send", 99,99, atcommand_send },
  7714. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7715. { "unmute", 80,80, atcommand_unmute },
  7716. { "clearweather", 99,99, atcommand_clearweather },
  7717. { "uptime", 1,1, atcommand_uptime },
  7718. { "changesex", 60,60, atcommand_changesex },
  7719. { "mute", 80,80, atcommand_mute },
  7720. { "refresh", 1,1, atcommand_refresh },
  7721. { "identify", 40,40, atcommand_identify },
  7722. { "gmotd", 20,20, atcommand_gmotd },
  7723. { "misceffect", 50,50, atcommand_misceffect },
  7724. { "mobsearch", 10,10, atcommand_mobsearch },
  7725. { "cleanmap", 40,40, atcommand_cleanmap },
  7726. { "npctalk", 20,20, atcommand_npctalk },
  7727. { "pettalk", 10,10, atcommand_pettalk },
  7728. { "users", 40,40, atcommand_users },
  7729. { "reset", 40,40, atcommand_reset },
  7730. { "skilltree", 40,40, atcommand_skilltree },
  7731. { "marry", 40,40, atcommand_marry },
  7732. { "divorce", 40,40, atcommand_divorce },
  7733. { "sound", 40,40, atcommand_sound },
  7734. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7735. { "disguiseall", 99,99, atcommand_disguiseall },
  7736. { "changelook", 60,60, atcommand_changelook },
  7737. { "autoloot", 10,10, atcommand_autoloot },
  7738. { "alootid", 10,10, atcommand_autolootitem },
  7739. { "monsterinfo", 1,1, atcommand_mobinfo },
  7740. { "exp", 1,1, atcommand_exp },
  7741. { "adopt", 40,40, atcommand_adopt },
  7742. { "version", 1,1, atcommand_version },
  7743. { "mutearea", 99,99, atcommand_mutearea },
  7744. { "rates", 1,1, atcommand_rates },
  7745. { "iteminfo", 1,1, atcommand_iteminfo },
  7746. { "whodrops", 1,1, atcommand_whodrops },
  7747. { "whereis", 10,10, atcommand_whereis },
  7748. { "mapflag", 99,99, atcommand_mapflag },
  7749. { "me", 20,20, atcommand_me },
  7750. { "battleignore", 99,99, atcommand_monsterignore },
  7751. { "fakename", 20,20, atcommand_fakename },
  7752. { "size", 20,20, atcommand_size },
  7753. { "showexp", 10,10, atcommand_showexp},
  7754. { "showzeny", 10,10, atcommand_showzeny},
  7755. { "showdelay", 1,1, atcommand_showdelay},
  7756. { "autotrade", 10,10, atcommand_autotrade },
  7757. { "changegm", 10,10, atcommand_changegm },
  7758. { "changeleader", 10,10, atcommand_changeleader },
  7759. { "partyoption", 10,10, atcommand_partyoption},
  7760. { "invite", 1,1, atcommand_invite },
  7761. { "duel", 1,1, atcommand_duel },
  7762. { "leave", 1,1, atcommand_leave },
  7763. { "accept", 1,1, atcommand_accept },
  7764. { "reject", 1,1, atcommand_reject },
  7765. { "main", 1,1, atcommand_main },
  7766. { "clone", 50,50, atcommand_clone },
  7767. { "slaveclone", 50,50, atcommand_clone },
  7768. { "evilclone", 50,50, atcommand_clone },
  7769. { "tonpc", 40,40, atcommand_tonpc },
  7770. { "commands", 1,1, atcommand_commands },
  7771. { "noask", 1,1, atcommand_noask },
  7772. { "request", 20,20, atcommand_request },
  7773. { "hlvl", 60,60, atcommand_homlevel },
  7774. { "homevolve", 60,60, atcommand_homevolution },
  7775. { "makehomun", 60,60, atcommand_makehomun },
  7776. { "homfriendly", 60,60, atcommand_homfriendly },
  7777. { "homhungry", 60,60, atcommand_homhungry },
  7778. { "homtalk", 10,10, atcommand_homtalk },
  7779. { "hominfo", 1,1, atcommand_hominfo },
  7780. { "homstats", 1,1, atcommand_homstats },
  7781. { "homshuffle", 60,60, atcommand_homshuffle },
  7782. { "showmobs", 10,10, atcommand_showmobs },
  7783. { "feelreset", 10,10, atcommand_feelreset },
  7784. { "auction", 1,1, atcommand_auction },
  7785. { "mail", 1,1, atcommand_mail },
  7786. { "noks", 1,1, atcommand_ksprotection },
  7787. { "allowks", 40,40, atcommand_allowks },
  7788. { "cash", 60,60, atcommand_cash },
  7789. { "points", 60,60, atcommand_cash },
  7790. { "agitstart2", 60,60, atcommand_agitstart2 },
  7791. { "agitend2", 60,60, atcommand_agitend2 },
  7792. { "skreset", 60,60, atcommand_resetskill },
  7793. { "streset", 60,60, atcommand_resetstat },
  7794. { "storagelist", 40,40, atcommand_itemlist },
  7795. { "cartlist", 40,40, atcommand_itemlist },
  7796. { "itemlist", 40,40, atcommand_itemlist },
  7797. { "stats", 40,40, atcommand_stats },
  7798. { "delitem", 60,60, atcommand_delitem },
  7799. { "charcommands", 1,1, atcommand_charcommands },
  7800. { "font", 1,1, atcommand_font },
  7801. /**
  7802. * For Testing Purposes, not going to be here after we're done.
  7803. **/
  7804. { "newmount", 0,99, atcommand_new_mount },
  7805. };
  7806. AtCommandInfo* atcommand;
  7807. int i;
  7808. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7809. CREATE(atcommand, AtCommandInfo, 1);
  7810. safestrncpy(atcommand->command,atcommand_base[i].command,sizeof(atcommand->command));
  7811. atcommand->level = atcommand_base[i].level;
  7812. atcommand->level2 = atcommand_base[i].level2;
  7813. atcommand->func = atcommand_base[i].func;
  7814. strdb_put(atcommand_db, atcommand->command, atcommand);
  7815. }
  7816. return;
  7817. }
  7818. /*==========================================
  7819. * Command lookup functions
  7820. *------------------------------------------*/
  7821. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  7822. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7823. if( strdb_exists(atcommand_db,name) )
  7824. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7825. return NULL;
  7826. }
  7827. /*==========================================
  7828. * Retrieve the command's required gm level
  7829. *------------------------------------------*/
  7830. int get_atcommand_level(const char* name) {
  7831. AtCommandInfo* info = (AtCommandInfo*)strdb_get(atcommand_db, name);
  7832. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7833. }
  7834. /// Executes an at-command.
  7835. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7836. {
  7837. char charname[NAME_LENGTH], params[100];
  7838. char charname2[NAME_LENGTH], params2[100];
  7839. char command[100];
  7840. char output[CHAT_SIZE_MAX];
  7841. int x, y, z;
  7842. int lv = 0;
  7843. //Reconstructed message
  7844. char atcmd_msg[CHAT_SIZE_MAX];
  7845. TBL_PC * ssd = NULL; //sd for target
  7846. AtCommandInfo * info;
  7847. nullpo_retr(false, sd);
  7848. //Shouldn't happen
  7849. if( !message || !*message )
  7850. return false;
  7851. //Block NOCHAT but do not display it as a normal message
  7852. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7853. return true;
  7854. // skip 10/11-langtype's codepage indicator, if detected
  7855. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7856. message += 3;
  7857. //Should display as a normal message
  7858. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7859. return false;
  7860. // type value 0 = server invoked: bypass restrictions
  7861. // 1 = player invoked
  7862. if( type )
  7863. {
  7864. //Commands are disabled on maps flagged as 'nocommand'
  7865. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7866. {
  7867. clif_displaymessage(fd, msg_txt(143));
  7868. return false;
  7869. }
  7870. //Displays as a normal message for Non-GMs
  7871. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7872. return false;
  7873. }
  7874. while (*message == charcommand_symbol)
  7875. {
  7876. //Checks to see if #command has a name or a name + parameters.
  7877. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7878. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7879. //z always has the value of the scan that was successful
  7880. z = ( x > 1 ) ? x : y;
  7881. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) ) {
  7882. if( pc_isGM(sd) ) {
  7883. sprintf(output, "%s failed. Player not found.", command);
  7884. clif_displaymessage(fd, output);
  7885. } else {
  7886. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7887. clif_displaymessage(fd, output);
  7888. }
  7889. return true;
  7890. }
  7891. //#command + name means the sufficient target was used and anything else after
  7892. //can be looked at by the actual command function since most scan to see if the
  7893. //right parameters are used.
  7894. if ( x > 2 ) {
  7895. sprintf(atcmd_msg, "%s %s", command, params);
  7896. break;
  7897. }
  7898. else if ( y > 2 ) {
  7899. sprintf(atcmd_msg, "%s %s", command, params2);
  7900. break;
  7901. }
  7902. //Regardless of what style the #command is used, if it's correct, it will always have
  7903. //this value if there is no parameter. Send it as just the #command
  7904. else if ( z == 2 ) {
  7905. sprintf(atcmd_msg, "%s", command);
  7906. break;
  7907. }
  7908. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7909. clif_displaymessage(fd, output);
  7910. return true;
  7911. }
  7912. if (*message == atcommand_symbol) {
  7913. //atcmd_msg is constructed above differently for charcommands
  7914. //it's copied from message if not a charcommand so it can
  7915. //pass through the rest of the code compatible with both symbols
  7916. sprintf(atcmd_msg, "%s", message);
  7917. }
  7918. //Clearing these to be used once more.
  7919. memset(command, '\0', sizeof(command));
  7920. memset(params, '\0', sizeof(params));
  7921. //check to see if any params exist within this command
  7922. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7923. params[0] = '\0';
  7924. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7925. if( (info = (AtCommandInfo*)strdb_get(atcommand_db, command+1)) == NULL || info->func == NULL || ( type && ((*atcmd_msg == atcommand_symbol && pc_isGM(sd) < info->level) || (*atcmd_msg == charcommand_symbol && pc_isGM(sd) < info->level2)) ) )
  7926. {
  7927. if( pc_isGM(sd) ) {
  7928. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7929. clif_displaymessage(fd, output);
  7930. return true;
  7931. } else
  7932. return false;
  7933. }
  7934. //Log atcommands
  7935. if( *atcmd_msg == atcommand_symbol )
  7936. log_atcommand(sd, info->level, atcmd_msg);
  7937. //Log Charcommands
  7938. else if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  7939. log_atcommand(sd, info->level2, message);
  7940. //Attempt to use the command
  7941. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  7942. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7943. {
  7944. sprintf(output,msg_txt(154), command); // %s failed.
  7945. clif_displaymessage(fd, output);
  7946. }
  7947. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  7948. return true;
  7949. }
  7950. /**
  7951. * Splits and parses command aliases field
  7952. * Note: I'm not good (at all) with string manipulation, if you think you can improve, please do. I beg you.
  7953. **/
  7954. void atcommand_parse_aliases(char aliases[1024],AtCommandInfo* base) {
  7955. char *str[99], *p;
  7956. int i, max = 0;
  7957. p = aliases;
  7958. while( ISSPACE(*p) )//trim
  7959. ++p;
  7960. //I assume nobody is getting over 98 alises in the same command lol
  7961. for( i = 0; i < 99; i++ ) {
  7962. str[i] = p;
  7963. p = strchr(p,',');
  7964. if( p == NULL ) {
  7965. max = i+1;
  7966. break;// comma not found
  7967. }
  7968. *p = '\0';
  7969. ++p;
  7970. }
  7971. if( !str[0] )//no aliases at all
  7972. return;
  7973. for(i = 0; i < max;i++) {
  7974. AtCommandInfo* atcommand = NULL;
  7975. normalize_name(str[i]," ");//trim over
  7976. if( (atcommand = strdb_get(atcommand_db, str[i])) ) {
  7977. atcommand->level = base->level;
  7978. atcommand->level2 = base->level2;
  7979. continue;
  7980. }
  7981. CREATE(atcommand, AtCommandInfo, 1);
  7982. safestrncpy(atcommand->command,str[i],sizeof(atcommand->command));
  7983. atcommand->level = base->level;
  7984. atcommand->level2 = base->level2;
  7985. atcommand->func = base->func;
  7986. strdb_put(atcommand_db, atcommand->command, atcommand);
  7987. }
  7988. return;
  7989. }
  7990. /*==========================================
  7991. *
  7992. *------------------------------------------*/
  7993. int atcommand_config_read(const char* cfgName)
  7994. {
  7995. char line[1024], w1[1024], w2[1024], w3[1024], w4[1024];
  7996. AtCommandInfo* p;
  7997. FILE* fp;
  7998. int i;
  7999. if( (fp = fopen(cfgName, "r")) == NULL ) {
  8000. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  8001. return 1;
  8002. }
  8003. while( fgets(line, sizeof(line), fp) ) {
  8004. if( line[0] == '/' && line[1] == '/' )
  8005. continue;
  8006. if( ( i = sscanf(line,"%1023[^:]:%1023[^,],%1023[^[][%1023[^]]",w1,w2,w3,w4) ) >= 3 ) {
  8007. if( ( p = (AtCommandInfo*)strdb_get(atcommand_db, w1) ) != NULL ) {
  8008. p->level = atoi(w2);//update @level
  8009. p->level2 = atoi(w3);//update #level
  8010. /**
  8011. * Parse the alises
  8012. **/
  8013. if( i == 4 )
  8014. atcommand_parse_aliases(w4,p);
  8015. continue;//we're done move on
  8016. }
  8017. } else if( strcmpi(w1, "import") != 0 && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 ) {
  8018. if( i > 1 )
  8019. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  8020. continue;
  8021. }
  8022. normalize_name(w2," ");//trim
  8023. if( strcmpi(w1, "import") == 0 )
  8024. atcommand_config_read(w2);
  8025. else if( strcmpi(w1, "command_symbol") == 0 &&
  8026. w2[0] > 31 && // control characters
  8027. w2[0] != '/' && // symbol of standard ragnarok GM commands
  8028. w2[0] != '%' && // symbol of party chat speaking
  8029. w2[0] != '$' && // symbol of guild chat speaking
  8030. w2[0] != '#' ) // remote symbol
  8031. atcommand_symbol = w2[0];
  8032. else if( strcmpi(w1, "char_symbol") == 0 &&
  8033. w2[0] > 31 &&
  8034. w2[0] != '/' &&
  8035. w2[0] != '%' &&
  8036. w2[0] != '$' &&
  8037. w2[0] != '@' )
  8038. charcommand_symbol = w2[0];
  8039. }
  8040. fclose(fp);
  8041. return 0;
  8042. }
  8043. static int atcommand_db_free(DBKey key,void *data,va_list va) {
  8044. aFree((AtCommandInfo*)data);
  8045. return 1;
  8046. }
  8047. void atcommand_db_clear() {
  8048. atcommand_db->foreach(atcommand_db,atcommand_db_free);
  8049. db_destroy(atcommand_db);
  8050. return;
  8051. }
  8052. void atcommand_doload() {
  8053. if( atcommand_db != NULL )
  8054. atcommand_db_clear();
  8055. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
  8056. atcommand_basecommands();//fills initial atcommand_db with known commands
  8057. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8058. return;
  8059. }
  8060. void do_init_atcommand() {
  8061. atcommand_doload();
  8062. }
  8063. void do_final_atcommand() {
  8064. atcommand_db_clear();
  8065. return;
  8066. }
  8067. // commands that need to go _after_ the commands table
  8068. /*==========================================
  8069. * type: 1 = commands (@), 2 = charcommands (#)
  8070. *------------------------------------------*/
  8071. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, int type) {
  8072. char line_buff[CHATBOX_SIZE];
  8073. int gm_lvl = pc_isGM(sd), count = 0;
  8074. char* cur = line_buff;
  8075. AtCommandInfo* cmd;
  8076. DBIterator* iter = atcommand_db->iterator(atcommand_db);
  8077. memset(line_buff,' ',CHATBOX_SIZE);
  8078. line_buff[CHATBOX_SIZE-1] = 0;
  8079. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  8080. for( cmd = (AtCommandInfo*)iter->first(iter,NULL); iter->exists(iter); cmd = (AtCommandInfo*)iter->next(iter,NULL) ) {
  8081. unsigned int slen;
  8082. if( type == 1 && gm_lvl < cmd->level )
  8083. continue;
  8084. if( type == 2 && gm_lvl < cmd->level2 )
  8085. continue;
  8086. slen = strlen(cmd->command);
  8087. // flush the text buffer if this command won't fit into it
  8088. if( slen + cur - line_buff >= CHATBOX_SIZE )
  8089. {
  8090. clif_displaymessage(fd,line_buff);
  8091. cur = line_buff;
  8092. memset(line_buff,' ',CHATBOX_SIZE);
  8093. line_buff[CHATBOX_SIZE-1] = 0;
  8094. }
  8095. memcpy(cur,cmd->command,slen);
  8096. cur += slen+(10-slen%10);
  8097. count++;
  8098. }
  8099. iter->destroy(iter);
  8100. clif_displaymessage(fd,line_buff);
  8101. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  8102. clif_displaymessage(fd, atcmd_output);
  8103. return;
  8104. }
  8105. /*==========================================
  8106. * @commands Lists available @ commands to you
  8107. *------------------------------------------*/
  8108. ACMD_FUNC(commands)
  8109. {
  8110. atcommand_commands_sub(sd, fd, 1);
  8111. return 0;
  8112. }
  8113. /*==========================================
  8114. * @charcommands Lists available # commands to you
  8115. *------------------------------------------*/
  8116. ACMD_FUNC(charcommands)
  8117. {
  8118. atcommand_commands_sub(sd, fd, 2);
  8119. return 0;
  8120. }