atcommand.c 277 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487
  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/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "atcommand.h"
  15. #include "battle.h"
  16. #include "chat.h"
  17. #include "clif.h"
  18. #include "chrif.h"
  19. #include "duel.h"
  20. #include "intif.h"
  21. #include "itemdb.h"
  22. #include "log.h"
  23. #include "map.h"
  24. #include "pc.h"
  25. #include "status.h"
  26. #include "skill.h"
  27. #include "mob.h"
  28. #include "npc.h"
  29. #include "pet.h"
  30. #include "homunculus.h"
  31. #include "mail.h"
  32. #include "mercenary.h"
  33. #include "party.h"
  34. #include "guild.h"
  35. #include "script.h"
  36. #include "storage.h"
  37. #include "trade.h"
  38. #include "unit.h"
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include <string.h>
  42. #include <math.h>
  43. // extern variables
  44. char atcommand_symbol = '@'; // first char of the commands
  45. char charcommand_symbol = '#';
  46. char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)
  47. // local declarations
  48. #define ACMD_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. DBMap* atcommand_db = NULL;//name -> AtCommandInfo
  50. #define ATCOMMAND_LENGTH 50
  51. typedef struct AtCommandInfo {
  52. char command[ATCOMMAND_LENGTH];
  53. int level;
  54. int level2;
  55. AtCommandFunc func;
  56. } AtCommandInfo;
  57. static AtCommandInfo* get_atcommandinfo_byname(const char* name);
  58. ACMD_FUNC(commands);
  59. ACMD_FUNC(charcommands);
  60. /*=========================================
  61. * Generic variables
  62. *-----------------------------------------*/
  63. char atcmd_output[CHAT_SIZE_MAX];
  64. char atcmd_player_name[NAME_LENGTH];
  65. char atcmd_temp[100];
  66. // compare function for sorting high to lowest
  67. int hightolow_compare (const void * a, const void * b)
  68. {
  69. return ( *(int*)b - *(int*)a );
  70. }
  71. // compare function for sorting lowest to highest
  72. int lowtohigh_compare (const void * a, const void * b)
  73. {
  74. return ( *(int*)a - *(int*)b );
  75. }
  76. //-----------------------------------------------------------
  77. // Return the message string of the specified number by [Yor]
  78. //-----------------------------------------------------------
  79. const char* msg_txt(int msg_number)
  80. {
  81. if (msg_number >= 0 && msg_number < MAX_MSG &&
  82. msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
  83. return msg_table[msg_number];
  84. return "??";
  85. }
  86. //-----------------------------------------------------------
  87. // Returns Players title (from msg_athena.conf) [Lupus]
  88. //-----------------------------------------------------------
  89. static char* player_title_txt(int level)
  90. {
  91. const char* format;
  92. format = (level >= battle_config.title_lvl8) ? msg_txt(342)
  93. : (level >= battle_config.title_lvl7) ? msg_txt(341)
  94. : (level >= battle_config.title_lvl6) ? msg_txt(340)
  95. : (level >= battle_config.title_lvl5) ? msg_txt(339)
  96. : (level >= battle_config.title_lvl4) ? msg_txt(338)
  97. : (level >= battle_config.title_lvl3) ? msg_txt(337)
  98. : (level >= battle_config.title_lvl2) ? msg_txt(336)
  99. : (level >= battle_config.title_lvl1) ? msg_txt(335)
  100. : "";
  101. sprintf(atcmd_temp, format, level);
  102. return atcmd_temp;
  103. }
  104. /*==========================================
  105. * Read Message Data
  106. *------------------------------------------*/
  107. int msg_config_read(const char* cfgName)
  108. {
  109. int msg_number;
  110. char line[1024], w1[1024], w2[1024];
  111. FILE *fp;
  112. static int called = 1;
  113. if ((fp = fopen(cfgName, "r")) == NULL) {
  114. ShowError("Messages file not found: %s\n", cfgName);
  115. return 1;
  116. }
  117. if ((--called) == 0)
  118. memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
  119. while(fgets(line, sizeof(line), fp))
  120. {
  121. if (line[0] == '/' && line[1] == '/')
  122. continue;
  123. if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
  124. continue;
  125. if (strcmpi(w1, "import") == 0)
  126. msg_config_read(w2);
  127. else
  128. {
  129. msg_number = atoi(w1);
  130. if (msg_number >= 0 && msg_number < MAX_MSG)
  131. {
  132. if (msg_table[msg_number] != NULL)
  133. aFree(msg_table[msg_number]);
  134. msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
  135. strcpy(msg_table[msg_number],w2);
  136. }
  137. }
  138. }
  139. fclose(fp);
  140. return 0;
  141. }
  142. /*==========================================
  143. * Cleanup Message Data
  144. *------------------------------------------*/
  145. void do_final_msg(void)
  146. {
  147. int i;
  148. for (i = 0; i < MAX_MSG; i++)
  149. aFree(msg_table[i]);
  150. }
  151. /*==========================================
  152. * @send (used for testing packet sends from the client)
  153. *------------------------------------------*/
  154. ACMD_FUNC(send)
  155. {
  156. int len=0,off,end,type;
  157. long num;
  158. (void)command; // not used
  159. // read message type as hex number (without the 0x)
  160. if(!message || !*message ||
  161. !((sscanf(message, "len %x", &type)==1 && (len=1))
  162. || sscanf(message, "%x", &type)==1) )
  163. {
  164. clif_displaymessage(fd, "Usage:");
  165. clif_displaymessage(fd, " @send len <packet hex number>");
  166. clif_displaymessage(fd, " @send <packet hex number> {<value>}*");
  167. clif_displaymessage(fd, " Value: <type=B(default),W,L><number> or S<length>\"<string>\"");
  168. return -1;
  169. }
  170. #define PARSE_ERROR(error,p) \
  171. {\
  172. clif_displaymessage(fd, (error));\
  173. sprintf(atcmd_output, ">%s", (p));\
  174. clif_displaymessage(fd, atcmd_output);\
  175. }
  176. //define PARSE_ERROR
  177. #define CHECK_EOS(p) \
  178. if(*(p) == 0){\
  179. clif_displaymessage(fd, "Unexpected end of string");\
  180. return -1;\
  181. }
  182. //define CHECK_EOS
  183. #define SKIP_VALUE(p) \
  184. {\
  185. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  186. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  187. }
  188. //define SKIP_VALUE
  189. #define GET_VALUE(p,num) \
  190. {\
  191. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  192. PARSE_ERROR("Invalid number in:",(p));\
  193. return -1;\
  194. }\
  195. }
  196. //define GET_VALUE
  197. if (type > 0 && type < MAX_PACKET_DB) {
  198. if(len)
  199. {// show packet length
  200. sprintf(atcmd_output, "Packet 0x%x length: %d", type, packet_db[sd->packet_ver][type].len);
  201. clif_displaymessage(fd, atcmd_output);
  202. return 0;
  203. }
  204. len=packet_db[sd->packet_ver][type].len;
  205. off=2;
  206. if(len == 0)
  207. {// unknown packet - ERROR
  208. sprintf(atcmd_output, "Unknown packet: 0x%x", type);
  209. clif_displaymessage(fd, atcmd_output);
  210. return -1;
  211. } else if(len == -1)
  212. {// dynamic packet
  213. len=SHRT_MAX-4; // maximum length
  214. off=4;
  215. }
  216. WFIFOHEAD(fd, len);
  217. WFIFOW(fd,0)=TOW(type);
  218. // parse packet contents
  219. SKIP_VALUE(message);
  220. while(*message != 0 && off < len){
  221. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  222. {// default (byte)
  223. GET_VALUE(message,num);
  224. WFIFOB(fd,off)=TOB(num);
  225. ++off;
  226. } else if(TOUPPER(*message) == 'B')
  227. {// byte
  228. ++message;
  229. GET_VALUE(message,num);
  230. WFIFOB(fd,off)=TOB(num);
  231. ++off;
  232. } else if(TOUPPER(*message) == 'W')
  233. {// word (2 bytes)
  234. ++message;
  235. GET_VALUE(message,num);
  236. WFIFOW(fd,off)=TOW(num);
  237. off+=2;
  238. } else if(TOUPPER(*message) == 'L')
  239. {// long word (4 bytes)
  240. ++message;
  241. GET_VALUE(message,num);
  242. WFIFOL(fd,off)=TOL(num);
  243. off+=4;
  244. } else if(TOUPPER(*message) == 'S')
  245. {// string - escapes are valid
  246. // get string length - num <= 0 means not fixed length (default)
  247. ++message;
  248. if(*message == '"'){
  249. num=0;
  250. } else {
  251. GET_VALUE(message,num);
  252. while(*message != '"')
  253. {// find start of string
  254. if(*message == 0 || ISSPACE(*message)){
  255. PARSE_ERROR("Not a string:",message);
  256. return -1;
  257. }
  258. ++message;
  259. }
  260. }
  261. // parse string
  262. ++message;
  263. CHECK_EOS(message);
  264. end=(num<=0? 0: min(off+((int)num),len));
  265. for(; *message != '"' && (off < end || end == 0); ++off){
  266. if(*message == '\\'){
  267. ++message;
  268. CHECK_EOS(message);
  269. switch(*message){
  270. case 'a': num=0x07; break; // Bell
  271. case 'b': num=0x08; break; // Backspace
  272. case 't': num=0x09; break; // Horizontal tab
  273. case 'n': num=0x0A; break; // Line feed
  274. case 'v': num=0x0B; break; // Vertical tab
  275. case 'f': num=0x0C; break; // Form feed
  276. case 'r': num=0x0D; break; // Carriage return
  277. case 'e': num=0x1B; break; // Escape
  278. default: num=*message; break;
  279. case 'x': // Hexadecimal
  280. {
  281. ++message;
  282. CHECK_EOS(message);
  283. if(!ISXDIGIT(*message)){
  284. PARSE_ERROR("Not a hexadecimal digit:",message);
  285. return -1;
  286. }
  287. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  288. if(ISXDIGIT(*message)){
  289. ++message;
  290. CHECK_EOS(message);
  291. num<<=8;
  292. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  293. }
  294. WFIFOB(fd,off)=TOB(num);
  295. ++message;
  296. CHECK_EOS(message);
  297. continue;
  298. }
  299. case '0':
  300. case '1':
  301. case '2':
  302. case '3':
  303. case '4':
  304. case '5':
  305. case '6':
  306. case '7': // Octal
  307. {
  308. num=*message-'0'; // 1st octal digit
  309. ++message;
  310. CHECK_EOS(message);
  311. if(ISDIGIT(*message) && *message < '8'){
  312. num<<=3;
  313. num+=*message-'0'; // 2nd octal digit
  314. ++message;
  315. CHECK_EOS(message);
  316. if(ISDIGIT(*message) && *message < '8'){
  317. num<<=3;
  318. num+=*message-'0'; // 3rd octal digit
  319. ++message;
  320. CHECK_EOS(message);
  321. }
  322. }
  323. WFIFOB(fd,off)=TOB(num);
  324. continue;
  325. }
  326. }
  327. } else
  328. num=*message;
  329. WFIFOB(fd,off)=TOB(num);
  330. ++message;
  331. CHECK_EOS(message);
  332. }//for
  333. while(*message != '"')
  334. {// ignore extra characters
  335. ++message;
  336. CHECK_EOS(message);
  337. }
  338. // terminate the string
  339. if(off < end)
  340. {// fill the rest with 0's
  341. memset(WFIFOP(fd,off),0,end-off);
  342. off=end;
  343. }
  344. } else
  345. {// unknown
  346. PARSE_ERROR("Unknown type of value in:",message);
  347. return -1;
  348. }
  349. SKIP_VALUE(message);
  350. }
  351. if(packet_db[sd->packet_ver][type].len == -1)
  352. {// send dynamic packet
  353. WFIFOW(fd,2)=TOW(off);
  354. WFIFOSET(fd,off);
  355. } else
  356. {// send static packet
  357. if(off < len)
  358. memset(WFIFOP(fd,off),0,len-off);
  359. WFIFOSET(fd,len);
  360. }
  361. } else {
  362. clif_displaymessage(fd, msg_txt(259)); // Invalid packet
  363. return -1;
  364. }
  365. sprintf (atcmd_output, msg_txt(258), type, type); // Sent packet 0x%x (%d)
  366. clif_displaymessage(fd, atcmd_output);
  367. return 0;
  368. #undef PARSE_ERROR
  369. #undef CHECK_EOS
  370. #undef SKIP_VALUE
  371. #undef GET_VALUE
  372. }
  373. /*==========================================
  374. * @rura, @warp, @mapmove
  375. *------------------------------------------*/
  376. ACMD_FUNC(mapmove)
  377. {
  378. char map_name[MAP_NAME_LENGTH_EXT];
  379. unsigned short mapindex;
  380. short x = 0, y = 0;
  381. int m = -1;
  382. nullpo_retr(-1, sd);
  383. memset(map_name, '\0', sizeof(map_name));
  384. if (!message || !*message ||
  385. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  386. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  387. clif_displaymessage(fd, "Please, enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).");
  388. return -1;
  389. }
  390. mapindex = mapindex_name2id(map_name);
  391. if (mapindex)
  392. m = map_mapindex2mapid(mapindex);
  393. if (!mapindex) { // m < 0 means on different server! [Kevin]
  394. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  395. return -1;
  396. }
  397. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  398. { //This is to prevent the pc_setpos call from printing an error.
  399. clif_displaymessage(fd, msg_txt(2));
  400. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  401. x = y = 0; //Invalid cell, use random spot.
  402. }
  403. if (map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  404. clif_displaymessage(fd, msg_txt(247));
  405. return -1;
  406. }
  407. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  408. clif_displaymessage(fd, msg_txt(248));
  409. return -1;
  410. }
  411. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  412. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  413. return -1;
  414. }
  415. clif_displaymessage(fd, msg_txt(0)); // Warped.
  416. return 0;
  417. }
  418. /*==========================================
  419. * Displays where a character is. Corrected version by Silent. [Skotlex]
  420. *------------------------------------------*/
  421. ACMD_FUNC(where)
  422. {
  423. struct map_session_data* pl_sd;
  424. nullpo_retr(-1, sd);
  425. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  426. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  427. clif_displaymessage(fd, "Please, enter a player name (usage: @where <char name>).");
  428. return -1;
  429. }
  430. pl_sd = map_nick2sd(atcmd_player_name);
  431. if( pl_sd == NULL
  432. || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0
  433. || (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))
  434. ) {
  435. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  436. return -1;
  437. }
  438. 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);
  439. clif_displaymessage(fd, atcmd_output);
  440. return 0;
  441. }
  442. /*==========================================
  443. *
  444. *------------------------------------------*/
  445. ACMD_FUNC(jumpto)
  446. {
  447. struct map_session_data *pl_sd = NULL;
  448. nullpo_retr(-1, sd);
  449. if (!message || !*message) {
  450. clif_displaymessage(fd, "Please, enter a player name (usage: @jumpto/@warpto/@goto <player name/id>).");
  451. return -1;
  452. }
  453. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  454. {
  455. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  456. return -1;
  457. }
  458. if (pl_sd == sd)
  459. {
  460. clif_displaymessage(fd, "But you are already where you are...");
  461. return -1;
  462. }
  463. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  464. {
  465. clif_displaymessage(fd, msg_txt(247)); // You are not authorized to warp to this map.
  466. return -1;
  467. }
  468. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  469. {
  470. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  471. return -1;
  472. }
  473. if( pc_isdead(sd) )
  474. {
  475. clif_displaymessage(fd, "You cannot use this command when dead.");
  476. return -1;
  477. }
  478. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  479. sprintf(atcmd_output, msg_txt(4), pl_sd->status.name); // Jumped to %s
  480. clif_displaymessage(fd, atcmd_output);
  481. return 0;
  482. }
  483. /*==========================================
  484. *
  485. *------------------------------------------*/
  486. ACMD_FUNC(jump)
  487. {
  488. short x = 0, y = 0;
  489. nullpo_retr(-1, sd);
  490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  491. sscanf(message, "%hd %hd", &x, &y);
  492. if (map[sd->bl.m].flag.noteleport && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  493. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  494. return -1;
  495. }
  496. if( pc_isdead(sd) )
  497. {
  498. clif_displaymessage(fd, "You cannot use this command when dead.");
  499. return -1;
  500. }
  501. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  502. { //This is to prevent the pc_setpos call from printing an error.
  503. clif_displaymessage(fd, msg_txt(2));
  504. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  505. x = y = 0; //Invalid cell, use random spot.
  506. }
  507. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  508. sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  509. clif_displaymessage(fd, atcmd_output);
  510. return 0;
  511. }
  512. /*==========================================
  513. * @who3 = Player name, his location
  514. *------------------------------------------*/
  515. ACMD_FUNC(who3)
  516. {
  517. char temp0[100];
  518. struct map_session_data *pl_sd;
  519. struct s_mapiterator* iter;
  520. int j, count;
  521. int pl_GM_level, GM_level;
  522. char match_text[100];
  523. char player_name[NAME_LENGTH];
  524. nullpo_retr(-1, sd);
  525. memset(atcmd_output, '\0', sizeof(atcmd_output));
  526. memset(match_text, '\0', sizeof(match_text));
  527. memset(player_name, '\0', sizeof(player_name));
  528. if (sscanf(message, "%99[^\n]", match_text) < 1)
  529. strcpy(match_text, "");
  530. for (j = 0; match_text[j]; j++)
  531. match_text[j] = TOLOWER(match_text[j]);
  532. count = 0;
  533. GM_level = pc_isGM(sd);
  534. iter = mapit_getallusers();
  535. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  536. {
  537. pl_GM_level = pc_isGM(pl_sd);
  538. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  539. {// you can look only lower or same level
  540. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  541. for (j = 0; player_name[j]; j++)
  542. player_name[j] = TOLOWER(player_name[j]);
  543. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  544. if (battle_config.who_display_aid > 0 && pc_isGM(sd) >= battle_config.who_display_aid) {
  545. sprintf(atcmd_output, "(CID:%d/AID:%d) ", pl_sd->status.char_id, pl_sd->status.account_id);
  546. } else {
  547. atcmd_output[0]=0;
  548. }
  549. //Player name
  550. sprintf(temp0, msg_txt(343), pl_sd->status.name);
  551. strcat(atcmd_output,temp0);
  552. //Player title, if exists
  553. if (pl_GM_level > 0) {
  554. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  555. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  556. strcat(atcmd_output,temp0);
  557. }
  558. //Players Location: map x y
  559. sprintf(temp0, msg_txt(348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  560. strcat(atcmd_output,temp0);
  561. clif_displaymessage(fd, atcmd_output);
  562. count++;
  563. }
  564. }
  565. }
  566. mapit_free(iter);
  567. if (count == 0)
  568. clif_displaymessage(fd, msg_txt(28)); // No player found.
  569. else if (count == 1)
  570. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  571. else {
  572. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  573. clif_displaymessage(fd, atcmd_output);
  574. }
  575. return 0;
  576. }
  577. /*==========================================
  578. * Player name, BLevel, Job,
  579. *------------------------------------------*/
  580. ACMD_FUNC(who2)
  581. {
  582. char temp0[100];
  583. struct map_session_data *pl_sd;
  584. struct s_mapiterator* iter;
  585. int j, count;
  586. int pl_GM_level, GM_level;
  587. char match_text[100];
  588. char player_name[NAME_LENGTH];
  589. nullpo_retr(-1, sd);
  590. memset(atcmd_output, '\0', sizeof(atcmd_output));
  591. memset(match_text, '\0', sizeof(match_text));
  592. memset(player_name, '\0', sizeof(player_name));
  593. if (sscanf(message, "%99[^\n]", match_text) < 1)
  594. strcpy(match_text, "");
  595. for (j = 0; match_text[j]; j++)
  596. match_text[j] = TOLOWER(match_text[j]);
  597. count = 0;
  598. GM_level = pc_isGM(sd);
  599. iter = mapit_getallusers();
  600. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  601. {
  602. pl_GM_level = pc_isGM(pl_sd);
  603. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) ))
  604. {// you can look only lower or same level
  605. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  606. for (j = 0; player_name[j]; j++)
  607. player_name[j] = TOLOWER(player_name[j]);
  608. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  609. //Players Name
  610. //sprintf(atcmd_output, "Name: %s ", pl_sd->status.name);
  611. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  612. //Player title, if exists
  613. if (pl_GM_level > 0) {
  614. //sprintf(temp0, "(%s) ", player_title_txt(pl_GM_level) );
  615. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  616. strcat(atcmd_output,temp0);
  617. }
  618. //Players Base Level / Job name
  619. //sprintf(temp0, "| L:%d/%d | Job: %s", pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  620. sprintf(temp0, msg_txt(347), pl_sd->status.base_level, pl_sd->status.job_level, job_name(pl_sd->status.class_) );
  621. strcat(atcmd_output,temp0);
  622. clif_displaymessage(fd, atcmd_output);
  623. count++;
  624. }
  625. }
  626. }
  627. mapit_free(iter);
  628. if (count == 0)
  629. clif_displaymessage(fd, msg_txt(28)); // No player found.
  630. else if (count == 1)
  631. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  632. else {
  633. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  634. clif_displaymessage(fd, atcmd_output);
  635. }
  636. return 0;
  637. }
  638. /*==========================================
  639. * Player name, Playrs Party / Guild name
  640. *------------------------------------------*/
  641. ACMD_FUNC(who)
  642. {
  643. char temp0[100];
  644. struct map_session_data *pl_sd;
  645. struct s_mapiterator* iter;
  646. int j, count;
  647. int pl_GM_level, GM_level;
  648. char match_text[100];
  649. char player_name[NAME_LENGTH];
  650. struct guild *g;
  651. struct party_data *p;
  652. nullpo_retr(-1, sd);
  653. memset(temp0, '\0', sizeof(temp0));
  654. memset(atcmd_output, '\0', sizeof(atcmd_output));
  655. memset(match_text, '\0', sizeof(match_text));
  656. memset(player_name, '\0', sizeof(player_name));
  657. if (sscanf(message, "%99[^\n]", match_text) < 1)
  658. strcpy(match_text, "");
  659. for (j = 0; match_text[j]; j++)
  660. match_text[j] = TOLOWER(match_text[j]);
  661. count = 0;
  662. GM_level = pc_isGM(sd);
  663. iter = mapit_getallusers();
  664. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  665. {
  666. pl_GM_level = pc_isGM(pl_sd);
  667. if(!( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && pl_GM_level > GM_level ))
  668. {// you can look only lower or same level
  669. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  670. for (j = 0; player_name[j]; j++)
  671. player_name[j] = TOLOWER(player_name[j]);
  672. if (strstr(player_name, match_text) != NULL) { // search with no case sensitive
  673. g = guild_search(pl_sd->status.guild_id);
  674. p = party_search(pl_sd->status.party_id);
  675. //Players Name
  676. sprintf(atcmd_output, msg_txt(343), pl_sd->status.name);
  677. //Player title, if exists
  678. if (pl_GM_level > 0) {
  679. sprintf(temp0, msg_txt(344), player_title_txt(pl_GM_level) );
  680. strcat(atcmd_output,temp0);
  681. }
  682. //Players Party if exists
  683. if (p != NULL) {
  684. //sprintf(temp0," | Party: '%s'", p->name);
  685. sprintf(temp0, msg_txt(345), p->party.name);
  686. strcat(atcmd_output,temp0);
  687. }
  688. //Players Guild if exists
  689. if (g != NULL) {
  690. //sprintf(temp0," | Guild: '%s'", g->name);
  691. sprintf(temp0, msg_txt(346), g->name);
  692. strcat(atcmd_output,temp0);
  693. }
  694. clif_displaymessage(fd, atcmd_output);
  695. count++;
  696. }
  697. }
  698. }
  699. mapit_free(iter);
  700. if (count == 0)
  701. clif_displaymessage(fd, msg_txt(28)); // No player found.
  702. else if (count == 1)
  703. clif_displaymessage(fd, msg_txt(29)); // 1 player found.
  704. else {
  705. sprintf(atcmd_output, msg_txt(30), count); // %d players found.
  706. clif_displaymessage(fd, atcmd_output);
  707. }
  708. return 0;
  709. }
  710. /*==========================================
  711. *
  712. *------------------------------------------*/
  713. ACMD_FUNC(whomap3)
  714. {
  715. struct map_session_data *pl_sd;
  716. struct s_mapiterator* iter;
  717. int count;
  718. int pl_GM_level, GM_level;
  719. int map_id;
  720. char map_name[MAP_NAME_LENGTH_EXT];
  721. memset(atcmd_output, '\0', sizeof(atcmd_output));
  722. memset(map_name, '\0', sizeof(map_name));
  723. if (!message || !*message)
  724. map_id = sd->bl.m;
  725. else {
  726. sscanf(message, "%15s", map_name);
  727. if ((map_id = map_mapname2mapid(map_name)) < 0)
  728. map_id = sd->bl.m;
  729. }
  730. count = 0;
  731. GM_level = pc_isGM(sd);
  732. iter = mapit_getallusers();
  733. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  734. {
  735. pl_GM_level = pc_isGM(pl_sd);
  736. if( pl_sd->bl.m != map_id )
  737. continue;
  738. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  739. continue;
  740. if (pl_GM_level > 0)
  741. 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);
  742. else
  743. 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);
  744. clif_displaymessage(fd, atcmd_output);
  745. count++;
  746. }
  747. mapit_free(iter);
  748. if (count == 0)
  749. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  750. else if (count == 1)
  751. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  752. else {
  753. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  754. }
  755. clif_displaymessage(fd, atcmd_output);
  756. return 0;
  757. }
  758. /*==========================================
  759. *
  760. *------------------------------------------*/
  761. ACMD_FUNC(whomap2)
  762. {
  763. struct map_session_data *pl_sd;
  764. struct s_mapiterator* iter;
  765. int count;
  766. int pl_GM_level, GM_level;
  767. int map_id = 0;
  768. char map_name[MAP_NAME_LENGTH_EXT];
  769. nullpo_retr(-1, sd);
  770. memset(atcmd_output, '\0', sizeof(atcmd_output));
  771. memset(map_name, '\0', sizeof(map_name));
  772. if (!message || !*message)
  773. map_id = sd->bl.m;
  774. else {
  775. sscanf(message, "%15s", map_name);
  776. if ((map_id = map_mapname2mapid(map_name)) < 0)
  777. map_id = sd->bl.m;
  778. }
  779. count = 0;
  780. GM_level = pc_isGM(sd);
  781. iter = mapit_getallusers();
  782. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  783. {
  784. pl_GM_level = pc_isGM(pl_sd);
  785. if( pl_sd->bl.m != map_id )
  786. continue;
  787. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  788. continue;
  789. if (pl_GM_level > 0)
  790. 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);
  791. else
  792. 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);
  793. clif_displaymessage(fd, atcmd_output);
  794. count++;
  795. }
  796. mapit_free(iter);
  797. if (count == 0)
  798. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  799. else if (count == 1)
  800. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  801. else {
  802. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  803. }
  804. clif_displaymessage(fd, atcmd_output);
  805. return 0;
  806. }
  807. /*==========================================
  808. *
  809. *------------------------------------------*/
  810. ACMD_FUNC(whomap)
  811. {
  812. char temp0[100];
  813. char temp1[100];
  814. struct map_session_data *pl_sd;
  815. struct s_mapiterator* iter;
  816. int count;
  817. int pl_GM_level, GM_level;
  818. int map_id = 0;
  819. char map_name[MAP_NAME_LENGTH_EXT];
  820. struct guild *g;
  821. struct party_data *p;
  822. nullpo_retr(-1, sd);
  823. memset(temp0, '\0', sizeof(temp0));
  824. memset(temp1, '\0', sizeof(temp1));
  825. memset(atcmd_output, '\0', sizeof(atcmd_output));
  826. memset(map_name, '\0', sizeof(map_name));
  827. if (!message || !*message)
  828. map_id = sd->bl.m;
  829. else {
  830. sscanf(message, "%15s", map_name);
  831. if ((map_id = map_mapname2mapid(map_name)) < 0)
  832. map_id = sd->bl.m;
  833. }
  834. count = 0;
  835. GM_level = pc_isGM(sd);
  836. iter = mapit_getallusers();
  837. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  838. {
  839. pl_GM_level = pc_isGM(pl_sd);
  840. if( pl_sd->bl.m != map_id )
  841. continue;
  842. if( (battle_config.hide_GM_session || (pl_sd->sc.option & OPTION_INVISIBLE)) && (pl_GM_level > GM_level) )
  843. continue;
  844. g = guild_search(pl_sd->status.guild_id);
  845. if (g == NULL)
  846. sprintf(temp1, "None");
  847. else
  848. sprintf(temp1, "%s", g->name);
  849. p = party_search(pl_sd->status.party_id);
  850. if (p == NULL)
  851. sprintf(temp0, "None");
  852. else
  853. sprintf(temp0, "%s", p->party.name);
  854. if (pl_GM_level > 0)
  855. sprintf(atcmd_output, "Name: %s (GM:%d) | Party: '%s' | Guild: '%s'", pl_sd->status.name, pl_GM_level, temp0, temp1);
  856. else
  857. sprintf(atcmd_output, "Name: %s | Party: '%s' | Guild: '%s'", pl_sd->status.name, temp0, temp1);
  858. clif_displaymessage(fd, atcmd_output);
  859. count++;
  860. }
  861. mapit_free(iter);
  862. if (count == 0)
  863. sprintf(atcmd_output, msg_txt(54), map[map_id].name); // No player found in map '%s'.
  864. else if (count == 1)
  865. sprintf(atcmd_output, msg_txt(55), map[map_id].name); // 1 player found in map '%s'.
  866. else {
  867. sprintf(atcmd_output, msg_txt(56), count, map[map_id].name); // %d players found in map '%s'.
  868. }
  869. clif_displaymessage(fd, atcmd_output);
  870. return 0;
  871. }
  872. /*==========================================
  873. *
  874. *------------------------------------------*/
  875. ACMD_FUNC(whogm)
  876. {
  877. struct map_session_data* pl_sd;
  878. struct s_mapiterator* iter;
  879. int j, count;
  880. int pl_GM_level, GM_level;
  881. char match_text[CHAT_SIZE_MAX];
  882. char player_name[NAME_LENGTH];
  883. struct guild *g;
  884. struct party_data *p;
  885. nullpo_retr(-1, sd);
  886. memset(atcmd_output, '\0', sizeof(atcmd_output));
  887. memset(match_text, '\0', sizeof(match_text));
  888. memset(player_name, '\0', sizeof(player_name));
  889. if (sscanf(message, "%199[^\n]", match_text) < 1)
  890. strcpy(match_text, "");
  891. for (j = 0; match_text[j]; j++)
  892. match_text[j] = TOLOWER(match_text[j]);
  893. count = 0;
  894. GM_level = pc_isGM(sd);
  895. iter = mapit_getallusers();
  896. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  897. {
  898. pl_GM_level = pc_isGM(pl_sd);
  899. if (!pl_GM_level)
  900. continue;
  901. if (match_text[0])
  902. {
  903. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  904. for (j = 0; player_name[j]; j++)
  905. player_name[j] = TOLOWER(player_name[j]);
  906. // search with no case sensitive
  907. if (strstr(player_name, match_text) == NULL)
  908. continue;
  909. }
  910. if (pl_GM_level > GM_level) {
  911. if (pl_sd->sc.option & OPTION_INVISIBLE)
  912. continue;
  913. sprintf(atcmd_output, "Name: %s (GM)", pl_sd->status.name);
  914. clif_displaymessage(fd, atcmd_output);
  915. count++;
  916. continue;
  917. }
  918. sprintf(atcmd_output, "Name: %s (GM:%d) | Location: %s %d %d",
  919. pl_sd->status.name, pl_GM_level,
  920. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  921. clif_displaymessage(fd, atcmd_output);
  922. sprintf(atcmd_output, " BLvl: %d | Job: %s (Lvl: %d)",
  923. pl_sd->status.base_level,
  924. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  925. clif_displaymessage(fd, atcmd_output);
  926. p = party_search(pl_sd->status.party_id);
  927. g = guild_search(pl_sd->status.guild_id);
  928. sprintf(atcmd_output," Party: '%s' | Guild: '%s'",
  929. p?p->party.name:"None", g?g->name:"None");
  930. clif_displaymessage(fd, atcmd_output);
  931. count++;
  932. }
  933. mapit_free(iter);
  934. if (count == 0)
  935. clif_displaymessage(fd, msg_txt(150)); // No GM found.
  936. else if (count == 1)
  937. clif_displaymessage(fd, msg_txt(151)); // 1 GM found.
  938. else {
  939. sprintf(atcmd_output, msg_txt(152), count); // %d GMs found.
  940. clif_displaymessage(fd, atcmd_output);
  941. }
  942. return 0;
  943. }
  944. /*==========================================
  945. *
  946. *------------------------------------------*/
  947. ACMD_FUNC(save)
  948. {
  949. nullpo_retr(-1, sd);
  950. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  951. if (sd->status.pet_id > 0 && sd->pd)
  952. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  953. chrif_save(sd,0);
  954. clif_displaymessage(fd, msg_txt(6)); // Your save point has been changed.
  955. return 0;
  956. }
  957. /*==========================================
  958. *
  959. *------------------------------------------*/
  960. ACMD_FUNC(load)
  961. {
  962. int m;
  963. nullpo_retr(-1, sd);
  964. m = map_mapindex2mapid(sd->status.save_point.map);
  965. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  966. clif_displaymessage(fd, msg_txt(249)); // You are not authorized to warp to your save map.
  967. return -1;
  968. }
  969. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  970. clif_displaymessage(fd, msg_txt(248)); // You are not authorized to warp from your current map.
  971. return -1;
  972. }
  973. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  974. clif_displaymessage(fd, msg_txt(7)); // Warping to save point..
  975. return 0;
  976. }
  977. /*==========================================
  978. *
  979. *------------------------------------------*/
  980. ACMD_FUNC(speed)
  981. {
  982. int speed;
  983. nullpo_retr(-1, sd);
  984. memset(atcmd_output, '\0', sizeof(atcmd_output));
  985. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  986. sprintf(atcmd_output, "Please, enter a speed value (usage: @speed <%d-%d>).", MIN_WALK_SPEED, MAX_WALK_SPEED);
  987. clif_displaymessage(fd, atcmd_output);
  988. return -1;
  989. }
  990. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  991. status_calc_bl(&sd->bl, SCB_SPEED);
  992. clif_displaymessage(fd, msg_txt(8)); // Speed changed.
  993. return 0;
  994. }
  995. /*==========================================
  996. *
  997. *------------------------------------------*/
  998. ACMD_FUNC(storage)
  999. {
  1000. nullpo_retr(-1, sd);
  1001. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  1002. return -1;
  1003. if (storage_storageopen(sd) == 1)
  1004. { //Already open.
  1005. clif_displaymessage(fd, msg_txt(250));
  1006. return -1;
  1007. }
  1008. clif_displaymessage(fd, "Storage opened.");
  1009. return 0;
  1010. }
  1011. /*==========================================
  1012. *
  1013. *------------------------------------------*/
  1014. ACMD_FUNC(guildstorage)
  1015. {
  1016. nullpo_retr(-1, sd);
  1017. if (!sd->status.guild_id) {
  1018. clif_displaymessage(fd, msg_txt(252));
  1019. return -1;
  1020. }
  1021. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  1022. return -1;
  1023. if (sd->state.storage_flag == 1) {
  1024. clif_displaymessage(fd, msg_txt(250));
  1025. return -1;
  1026. }
  1027. if (sd->state.storage_flag == 2) {
  1028. clif_displaymessage(fd, msg_txt(251));
  1029. return -1;
  1030. }
  1031. storage_guild_storageopen(sd);
  1032. clif_displaymessage(fd, "Guild storage opened.");
  1033. return 0;
  1034. }
  1035. /*==========================================
  1036. *
  1037. *------------------------------------------*/
  1038. ACMD_FUNC(option)
  1039. {
  1040. int param1 = 0, param2 = 0, param3 = 0;
  1041. nullpo_retr(-1, sd);
  1042. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {
  1043. clif_displaymessage(fd, "Please, enter at least a option (usage: @option <param1:0+> <param2:0+> <param3:0+>).");
  1044. return -1;
  1045. }
  1046. sd->sc.opt1 = param1;
  1047. sd->sc.opt2 = param2;
  1048. pc_setoption(sd, param3);
  1049. clif_displaymessage(fd, msg_txt(9)); // Options changed.
  1050. return 0;
  1051. }
  1052. /*==========================================
  1053. *
  1054. *------------------------------------------*/
  1055. ACMD_FUNC(hide)
  1056. {
  1057. nullpo_retr(-1, sd);
  1058. if (sd->sc.option & OPTION_INVISIBLE) {
  1059. sd->sc.option &= ~OPTION_INVISIBLE;
  1060. if (sd->disguise)
  1061. status_set_viewdata(&sd->bl, sd->disguise);
  1062. else
  1063. status_set_viewdata(&sd->bl, sd->status.class_);
  1064. clif_displaymessage(fd, msg_txt(10)); // Invisible: Off
  1065. if( map[sd->bl.m].flag.pvp )
  1066. {// increment the number of pvp players on the map
  1067. map[sd->bl.m].users_pvp++;
  1068. if( !map[sd->bl.m].flag.pvp_nocalcrank )
  1069. {// register the player for ranking calculations
  1070. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  1071. }
  1072. }
  1073. //bugreport:2266
  1074. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  1075. } else {
  1076. sd->sc.option |= OPTION_INVISIBLE;
  1077. sd->vd.class_ = INVISIBLE_CLASS;
  1078. clif_displaymessage(fd, msg_txt(11)); // Invisible: On
  1079. if( map[sd->bl.m].flag.pvp )
  1080. {// decrement the number of pvp players on the map
  1081. map[sd->bl.m].users_pvp--;
  1082. if( !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  1083. {// unregister the player for ranking
  1084. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  1085. sd->pvp_timer = INVALID_TIMER;
  1086. }
  1087. }
  1088. }
  1089. clif_changeoption(&sd->bl);
  1090. return 0;
  1091. }
  1092. /*==========================================
  1093. * Changes a character's class
  1094. *------------------------------------------*/
  1095. ACMD_FUNC(jobchange)
  1096. {
  1097. //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage]
  1098. int job = 0, upper = 0;
  1099. nullpo_retr(-1, sd);
  1100. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1)
  1101. {
  1102. int i, found = 0;
  1103. const struct { char name[24]; int id; } jobs[] = {
  1104. { "novice", 0 },
  1105. { "swordsman", 1 },
  1106. { "mage", 2 },
  1107. { "archer", 3 },
  1108. { "acolyte", 4 },
  1109. { "merchant", 5 },
  1110. { "thief", 6 },
  1111. { "knight", 7 },
  1112. { "priest", 8 },
  1113. { "priestess", 8 },
  1114. { "wizard", 9 },
  1115. { "blacksmith", 10 },
  1116. { "hunter", 11 },
  1117. { "assassin", 12 },
  1118. { "crusader", 14 },
  1119. { "monk", 15 },
  1120. { "sage", 16 },
  1121. { "rogue", 17 },
  1122. { "alchemist", 18 },
  1123. { "bard", 19 },
  1124. { "dancer", 20 },
  1125. { "super novice", 23 },
  1126. { "supernovice", 23 },
  1127. { "gunslinger", 24 },
  1128. { "gunner", 24 },
  1129. { "ninja", 25 },
  1130. { "high novice", 4001 },
  1131. { "swordsman high", 4002 },
  1132. { "mage high", 4003 },
  1133. { "archer high", 4004 },
  1134. { "acolyte high", 4005 },
  1135. { "merchant high", 4006 },
  1136. { "thief high", 4007 },
  1137. { "lord knight", 4008 },
  1138. { "high priest", 4009 },
  1139. { "high priestess", 4009 },
  1140. { "high wizard", 4010 },
  1141. { "whitesmith", 4011 },
  1142. { "sniper", 4012 },
  1143. { "assassin cross", 4013 },
  1144. { "paladin", 4015 },
  1145. { "champion", 4016 },
  1146. { "professor", 4017 },
  1147. { "stalker", 4018 },
  1148. { "creator", 4019 },
  1149. { "clown", 4020 },
  1150. { "gypsy", 4021 },
  1151. { "baby novice", 4023 },
  1152. { "baby swordsman", 4024 },
  1153. { "baby mage", 4025 },
  1154. { "baby archer", 4026 },
  1155. { "baby acolyte", 4027 },
  1156. { "baby merchant", 4028 },
  1157. { "baby thief", 4029 },
  1158. { "baby knight", 4030 },
  1159. { "baby priest", 4031 },
  1160. { "baby priestess", 4031 },
  1161. { "baby wizard", 4032 },
  1162. { "baby blacksmith",4033 },
  1163. { "baby hunter", 4034 },
  1164. { "baby assassin", 4035 },
  1165. { "baby crusader", 4037 },
  1166. { "baby monk", 4038 },
  1167. { "baby sage", 4039 },
  1168. { "baby rogue", 4040 },
  1169. { "baby alchemist", 4041 },
  1170. { "baby bard", 4042 },
  1171. { "baby dancer", 4043 },
  1172. { "super baby", 4045 },
  1173. { "taekwon", 4046 },
  1174. { "taekwon boy", 4046 },
  1175. { "taekwon girl", 4046 },
  1176. { "star gladiator", 4047 },
  1177. { "soul linker", 4049 },
  1178. { "rune knight", 4054 },
  1179. { "warlock", 4055 },
  1180. { "ranger", 4056 },
  1181. { "arch bishop", 4057 },
  1182. { "mechanic", 4058 },
  1183. { "guillotine", 4059 },
  1184. { "rune knight (Trans)", 4060 },
  1185. { "warlock (Trans)", 4061 },
  1186. { "ranger (Trans)", 4062 },
  1187. { "arch bishop (Trans)", 4063 },
  1188. { "mechanic (Trans)", 4064 },
  1189. { "guillotine (Trans)", 4065 },
  1190. { "royal guard", 4066 },
  1191. { "sorcerer", 4067 },
  1192. { "minstrel", 4068 },
  1193. { "wanderer", 4069 },
  1194. { "sura", 4070 },
  1195. { "genetic", 4071 },
  1196. { "shadow chaser", 4072 },
  1197. { "royal guard (Trans)", 4073 },
  1198. { "sorcerer (Trans)", 4074 },
  1199. { "minstrel (Trans)", 4075 },
  1200. { "wanderer (Trans)", 4076 },
  1201. { "sura (Trans)", 4077 },
  1202. { "genetic (Trans)", 4078 },
  1203. { "shadow chaser (Trans)", 4079 },
  1204. };
  1205. for (i=0; i < ARRAYLENGTH(jobs); i++) {
  1206. if (strncmpi(message, jobs[i].name, 16) == 0) {
  1207. job = jobs[i].id;
  1208. upper = 0;
  1209. found = 1;
  1210. break;
  1211. }
  1212. }
  1213. if (!found) {
  1214. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1215. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1216. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1217. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1218. clif_displaymessage(fd, "----- 2nd Class -----");
  1219. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1220. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1221. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1222. clif_displaymessage(fd, " 20 Dancer");
  1223. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1224. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1225. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1226. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1227. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1228. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1229. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1230. clif_displaymessage(fd, "4021 Gypsy");
  1231. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1232. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1233. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1234. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1235. clif_displaymessage(fd, "4072 Shadow Chaser");
  1236. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1237. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1238. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1239. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1240. clif_displaymessage(fd, "4079 Shadow Chaser");
  1241. clif_displaymessage(fd, "----- Expanded Class -----");
  1242. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1243. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1244. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1245. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1246. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1247. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1248. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1249. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1250. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1251. clif_displaymessage(fd, "4045 Super Baby");
  1252. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1253. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1254. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1255. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1256. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1257. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1258. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1259. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1260. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1261. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1262. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1263. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1264. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1265. return -1;
  1266. }
  1267. }
  1268. if (job == 13 || job == 21 || job == 22 || job == 26 || job == 27
  1269. || job == 4014 || job == 4022 || job == 4036 || job == 4044 || job == 4048
  1270. ) // Deny direct transformation into dummy jobs
  1271. return 0;
  1272. if (pcdb_checkid(job))
  1273. {
  1274. if (pc_jobchange(sd, job, upper) == 0)
  1275. clif_displaymessage(fd, msg_txt(12)); // Your job has been changed.
  1276. else {
  1277. clif_displaymessage(fd, msg_txt(155)); // You are unable to change your job.
  1278. return -1;
  1279. }
  1280. } else {
  1281. clif_displaymessage(fd, "Please, enter job ID (usage: @job/@jobchange <job name/ID>).");
  1282. clif_displaymessage(fd, "----- Novice / 1st Class -----");
  1283. clif_displaymessage(fd, " 0 Novice 1 Swordman 2 Mage 3 Archer");
  1284. clif_displaymessage(fd, " 4 Acolyte 5 Merchant 6 Thief");
  1285. clif_displaymessage(fd, "----- 2nd Class -----");
  1286. clif_displaymessage(fd, " 7 Knight 8 Priest 9 Wizard 10 Blacksmith");
  1287. clif_displaymessage(fd, " 11 Hunter 12 Assassin 14 Crusader 15 Monk");
  1288. clif_displaymessage(fd, " 16 Sage 17 Rogue 18 Alchemist 19 Bard");
  1289. clif_displaymessage(fd, " 20 Dancer");
  1290. clif_displaymessage(fd, "----- High Novice / High 1st Class -----");
  1291. clif_displaymessage(fd, "4001 Novice High 4002 Swordman High 4003 Mage High 4004 Archer High");
  1292. clif_displaymessage(fd, "4005 Acolyte High 4006 Merchant High 4007 Thief High");
  1293. clif_displaymessage(fd, "----- Transcendent 2nd Class -----");
  1294. clif_displaymessage(fd, "4008 Lord Knight 4009 High Priest 4010 High Wizard 4011 Whitesmith");
  1295. clif_displaymessage(fd, "4012 Sniper 4013 Assassin Cross 4015 Paladin 4016 Champion");
  1296. clif_displaymessage(fd, "4017 Professor 4018 Stalker 4019 Creator 4020 Clown");
  1297. clif_displaymessage(fd, "4021 Gypsy");
  1298. clif_displaymessage(fd, "----- 3rd Class (Regular to 3rd) -----");
  1299. clif_displaymessage(fd, "4054 Rune Knight 4055 Warlock 4056 Ranger 4057 Arch Bishop");
  1300. clif_displaymessage(fd, "4058 Mechanic 4059 Guillotine Cross 4066 Royal Guard 4067 Sorcerer");
  1301. clif_displaymessage(fd, "4068 Minstrel 4069 Wanderer 4070 Sura 4071 Genetic");
  1302. clif_displaymessage(fd, "4072 Shadow Chaser");
  1303. clif_displaymessage(fd, "----- 3rd Class (Transcendent to 3rd) -----");
  1304. clif_displaymessage(fd, "4060 Rune Knight 4061 Warlock 4062 Ranger 4063 Arch Bishop");
  1305. clif_displaymessage(fd, "4064 Mechanic 4065 Guillotine Cross 4073 Royal Guard 4074 Sorcerer");
  1306. clif_displaymessage(fd, "4075 Minstrel 4076 Wanderer 4077 Sura 4078 Genetic");
  1307. clif_displaymessage(fd, "4079 Shadow Chaser");
  1308. clif_displaymessage(fd, "----- Expanded Class -----");
  1309. clif_displaymessage(fd, " 23 Super Novice 24 Gunslinger 25 Ninja 26 Xmas");
  1310. clif_displaymessage(fd, " 27 Summer 4046 Taekwon 4047 Star Gladiator 4049 Soul Linker");
  1311. //clif_displaymessage(fd, "4050 Gangsi 4051 Death Knight 4052 Dark Collector");
  1312. clif_displaymessage(fd, "---- 1st And 2nd Baby Class ----");
  1313. clif_displaymessage(fd, "4023 Baby Novice 4024 Baby Swordsman 4025 Baby Mage 4026 Baby Archer");
  1314. clif_displaymessage(fd, "4027 Baby Acolyte 4028 Baby Merchant 4029 Baby Thief 4030 Baby Knight");
  1315. clif_displaymessage(fd, "4031 Baby Priest 4032 Baby Wizard 4033 Baby Blacksmith 4034 Baby Hunter");
  1316. clif_displaymessage(fd, "4035 Baby Assassin 4037 Baby Crusader 4038 Baby Monk 4039 Baby Sage");
  1317. clif_displaymessage(fd, "4040 Baby Rogue 4041 Baby Alchemist 4042 Baby Bard 4043 Baby Dancer");
  1318. clif_displaymessage(fd, "4045 Super Baby");
  1319. //clif_displaymessage(fd, "---- 3rd Baby Class ----");
  1320. //clif_displaymessage(fd, "4096 Baby Rune Knight 4097 Baby Warlock 4098 Baby Ranger");
  1321. //clif_displaymessage(fd, "4099 Baby Arch Bishop 4100 Baby Mechanic 4101 Baby Guillotine Cross");
  1322. //clif_displaymessage(fd, "4102 Baby Royal Guard 4103 Baby Sorcerer 4104 Baby Minstrel");
  1323. //clif_displaymessage(fd, "4105 Baby Wanderer 4106 Baby Sura 4107 Baby Genetic");
  1324. //clif_displaymessage(fd, "4108 Baby Shadow Chaser");
  1325. //clif_displaymessage(fd, "---- Mounts, Modes, And Others ----");
  1326. //clif_displaymessage(fd, " 13 Knight (Peco) 21 Crusader (Peco) 22 Wedding 26 Christmas");
  1327. //clif_displaymessage(fd, " 27 Summer 4014 Lord Knight (Peco) 4022 Paladin (Peco) 4036 Baby Knight (Peco)");
  1328. //clif_displaymessage(fd, "4044 Baby Crusader (Peco) 4048 Star Gladiator (Union) 4080 Rune Knight (Dragon)");
  1329. //clif_displaymessage(fd, "4081 Rune Knight Trans (Dragon) 4082 Royal Guard (Gryphon)");
  1330. //clif_displaymessage(fd, "4083 Royal Guard Trans (Gryphon) 4084 Ranger (Warg) 4085 Ranger Trans (Warg)");
  1331. //clif_displaymessage(fd, "4086 Mechanic (Mado) 4087 Mechanic Trans (Mado)");
  1332. return -1;
  1333. }
  1334. return 0;
  1335. }
  1336. /*==========================================
  1337. *
  1338. *------------------------------------------*/
  1339. ACMD_FUNC(die)
  1340. {
  1341. nullpo_retr(-1, sd);
  1342. clif_specialeffect(&sd->bl,450,SELF);
  1343. status_kill(&sd->bl);
  1344. clif_displaymessage(fd, msg_txt(13)); // A pity! You've died.
  1345. return 0;
  1346. }
  1347. /*==========================================
  1348. *
  1349. *------------------------------------------*/
  1350. ACMD_FUNC(kill)
  1351. {
  1352. struct map_session_data *pl_sd;
  1353. nullpo_retr(-1, sd);
  1354. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  1355. if (!message || !*message) {
  1356. clif_displaymessage(fd, "Please, enter a player name (usage: @kill <player name/id>).");
  1357. return -1;
  1358. }
  1359. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  1360. {
  1361. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  1362. return -1;
  1363. }
  1364. if (pc_isGM(sd) < pc_isGM(pl_sd))
  1365. { // you can kill only lower or same level
  1366. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  1367. return -1;
  1368. }
  1369. status_kill(&pl_sd->bl);
  1370. clif_displaymessage(pl_sd->fd, msg_txt(13)); // A pity! You've died.
  1371. if (fd != pl_sd->fd)
  1372. clif_displaymessage(fd, msg_txt(14)); // Character killed.
  1373. return 0;
  1374. }
  1375. /*==========================================
  1376. *
  1377. *------------------------------------------*/
  1378. ACMD_FUNC(alive)
  1379. {
  1380. nullpo_retr(-1, sd);
  1381. if (!status_revive(&sd->bl, 100, 100))
  1382. {
  1383. clif_displaymessage(fd, "You're not dead.");
  1384. return -1;
  1385. }
  1386. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  1387. clif_displaymessage(fd, msg_txt(16)); // You've been revived! It's a miracle!
  1388. return 0;
  1389. }
  1390. /*==========================================
  1391. * +kamic [LuzZza]
  1392. *------------------------------------------*/
  1393. ACMD_FUNC(kami)
  1394. {
  1395. unsigned long color=0;
  1396. nullpo_retr(-1, sd);
  1397. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1398. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1399. if (!message || !*message) {
  1400. clif_displaymessage(fd, "Please, enter a message (usage: @kami <message>).");
  1401. return -1;
  1402. }
  1403. sscanf(message, "%199[^\n]", atcmd_output);
  1404. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  1405. } else {
  1406. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  1407. clif_displaymessage(fd, "Please, enter color and message (usage: @kamic <color> <message>).");
  1408. return -1;
  1409. }
  1410. if(color > 0xFFFFFF) {
  1411. clif_displaymessage(fd, "Invalid color.");
  1412. return -1;
  1413. }
  1414. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1415. }
  1416. return 0;
  1417. }
  1418. /*==========================================
  1419. *
  1420. *------------------------------------------*/
  1421. ACMD_FUNC(heal)
  1422. {
  1423. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1424. nullpo_retr(-1, sd);
  1425. sscanf(message, "%d %d", &hp, &sp);
  1426. // some overflow checks
  1427. if( hp == INT_MIN ) hp++;
  1428. if( sp == INT_MIN ) sp++;
  1429. if ( hp == 0 && sp == 0 ) {
  1430. if (!status_percent_heal(&sd->bl, 100, 100))
  1431. clif_displaymessage(fd, msg_txt(157)); // HP and SP have already been recovered.
  1432. else
  1433. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1434. return 0;
  1435. }
  1436. if ( hp > 0 && sp >= 0 ) {
  1437. if(!status_heal(&sd->bl, hp, sp, 0))
  1438. clif_displaymessage(fd, msg_txt(157)); // HP and SP are already with the good value.
  1439. else
  1440. clif_displaymessage(fd, msg_txt(17)); // HP, SP recovered.
  1441. return 0;
  1442. }
  1443. if ( hp < 0 && sp <= 0 ) {
  1444. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1445. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1446. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1447. return 0;
  1448. }
  1449. //Opposing signs.
  1450. if ( hp ) {
  1451. if (hp > 0)
  1452. status_heal(&sd->bl, hp, 0, 0);
  1453. else {
  1454. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1455. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  1456. }
  1457. }
  1458. if ( sp ) {
  1459. if (sp > 0)
  1460. status_heal(&sd->bl, 0, sp, 0);
  1461. else
  1462. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1463. }
  1464. clif_displaymessage(fd, msg_txt(156)); // HP or/and SP modified.
  1465. return 0;
  1466. }
  1467. /*==========================================
  1468. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  1469. *------------------------------------------*/
  1470. ACMD_FUNC(item)
  1471. {
  1472. char item_name[100];
  1473. int number = 0, item_id, flag;
  1474. struct item item_tmp;
  1475. struct item_data *item_data;
  1476. int get_count, i;
  1477. nullpo_retr(-1, sd);
  1478. memset(item_name, '\0', sizeof(item_name));
  1479. if (!message || !*message || (
  1480. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1481. sscanf(message, "%99s %d", item_name, &number) < 1
  1482. )) {
  1483. clif_displaymessage(fd, "Please, enter an item name/id (usage: @item <item name or ID> [quantity]).");
  1484. return -1;
  1485. }
  1486. if (number <= 0)
  1487. number = 1;
  1488. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  1489. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  1490. {
  1491. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1492. return -1;
  1493. }
  1494. item_id = item_data->nameid;
  1495. get_count = number;
  1496. //Check if it's stackable.
  1497. if (!itemdb_isstackable2(item_data))
  1498. get_count = 1;
  1499. for (i = 0; i < number; i += get_count) {
  1500. // if not pet egg
  1501. if (!pet_create_egg(sd, item_id)) {
  1502. memset(&item_tmp, 0, sizeof(item_tmp));
  1503. item_tmp.nameid = item_id;
  1504. item_tmp.identify = 1;
  1505. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1506. clif_additem(sd, 0, 0, flag);
  1507. }
  1508. }
  1509. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1510. return 0;
  1511. }
  1512. /*==========================================
  1513. *
  1514. *------------------------------------------*/
  1515. ACMD_FUNC(item2)
  1516. {
  1517. struct item item_tmp;
  1518. struct item_data *item_data;
  1519. char item_name[100];
  1520. int item_id, number = 0;
  1521. int identify = 0, refine = 0, attr = 0;
  1522. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1523. int flag;
  1524. int loop, get_count, i;
  1525. nullpo_retr(-1, sd);
  1526. memset(item_name, '\0', sizeof(item_name));
  1527. if (!message || !*message || (
  1528. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1529. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1530. )) {
  1531. clif_displaymessage(fd, "Please, enter all informations (usage: @item2 <item name or ID> <quantity>");
  1532. clif_displaymessage(fd, " <Identify_flag> <refine> <attribut> <Card1> <Card2> <Card3> <Card4>).");
  1533. return -1;
  1534. }
  1535. if (number <= 0)
  1536. number = 1;
  1537. item_id = 0;
  1538. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1539. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1540. item_id = item_data->nameid;
  1541. if (item_id > 500) {
  1542. loop = 1;
  1543. get_count = number;
  1544. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1545. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1546. loop = number;
  1547. get_count = 1;
  1548. if (item_data->type == IT_PETEGG) {
  1549. identify = 1;
  1550. refine = 0;
  1551. }
  1552. if (item_data->type == IT_PETARMOR)
  1553. refine = 0;
  1554. if (refine > MAX_REFINE)
  1555. refine = MAX_REFINE;
  1556. } else {
  1557. identify = 1;
  1558. refine = attr = 0;
  1559. }
  1560. for (i = 0; i < loop; i++) {
  1561. memset(&item_tmp, 0, sizeof(item_tmp));
  1562. item_tmp.nameid = item_id;
  1563. item_tmp.identify = identify;
  1564. item_tmp.refine = refine;
  1565. item_tmp.attribute = attr;
  1566. item_tmp.card[0] = c1;
  1567. item_tmp.card[1] = c2;
  1568. item_tmp.card[2] = c3;
  1569. item_tmp.card[3] = c4;
  1570. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1571. clif_additem(sd, 0, 0, flag);
  1572. }
  1573. clif_displaymessage(fd, msg_txt(18)); // Item created.
  1574. } else {
  1575. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  1576. return -1;
  1577. }
  1578. return 0;
  1579. }
  1580. /*==========================================
  1581. *
  1582. *------------------------------------------*/
  1583. ACMD_FUNC(itemreset)
  1584. {
  1585. int i;
  1586. nullpo_retr(-1, sd);
  1587. for (i = 0; i < MAX_INVENTORY; i++) {
  1588. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1589. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1590. }
  1591. }
  1592. clif_displaymessage(fd, msg_txt(20)); // All of your items have been removed.
  1593. return 0;
  1594. }
  1595. /*==========================================
  1596. * Atcommand @lvlup
  1597. *------------------------------------------*/
  1598. ACMD_FUNC(baselevelup)
  1599. {
  1600. int level=0, i=0, status_point=0;
  1601. nullpo_retr(-1, sd);
  1602. level = atoi(message);
  1603. if (!message || !*message || !level) {
  1604. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).");
  1605. return -1;
  1606. }
  1607. if (level > 0) {
  1608. if (sd->status.base_level == pc_maxbaselv(sd)) { // check for max level by Valaris
  1609. clif_displaymessage(fd, msg_txt(47)); // Base level can't go any higher.
  1610. return -1;
  1611. } // End Addition
  1612. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1613. level = pc_maxbaselv(sd) - sd->status.base_level;
  1614. for (i = 0; i < level; i++)
  1615. status_point += pc_gets_status_point(sd->status.base_level + i);
  1616. sd->status.status_point += status_point;
  1617. sd->status.base_level += (unsigned int)level;
  1618. status_percent_heal(&sd->bl, 100, 100);
  1619. clif_misceffect(&sd->bl, 0);
  1620. clif_displaymessage(fd, msg_txt(21)); // Base level raised.
  1621. } else {
  1622. if (sd->status.base_level == 1) {
  1623. clif_displaymessage(fd, msg_txt(158)); // Base level can't go any lower.
  1624. return -1;
  1625. }
  1626. level*=-1;
  1627. if ((unsigned int)level >= sd->status.base_level)
  1628. level = sd->status.base_level-1;
  1629. for (i = 0; i > -level; i--)
  1630. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1631. if (sd->status.status_point < status_point)
  1632. pc_resetstate(sd);
  1633. if (sd->status.status_point < status_point)
  1634. sd->status.status_point = 0;
  1635. else
  1636. sd->status.status_point -= status_point;
  1637. sd->status.base_level -= (unsigned int)level;
  1638. clif_displaymessage(fd, msg_txt(22)); // Base level lowered.
  1639. }
  1640. sd->status.base_exp = 0;
  1641. clif_updatestatus(sd, SP_STATUSPOINT);
  1642. clif_updatestatus(sd, SP_BASELEVEL);
  1643. clif_updatestatus(sd, SP_BASEEXP);
  1644. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1645. status_calc_pc(sd, 0);
  1646. if(sd->status.party_id)
  1647. party_send_levelup(sd);
  1648. return 0;
  1649. }
  1650. /*==========================================
  1651. *
  1652. *------------------------------------------*/
  1653. ACMD_FUNC(joblevelup)
  1654. {
  1655. int level=0;
  1656. nullpo_retr(-1, sd);
  1657. level = atoi(message);
  1658. if (!message || !*message || !level) {
  1659. clif_displaymessage(fd, "Please, enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).");
  1660. return -1;
  1661. }
  1662. if (level > 0) {
  1663. if (sd->status.job_level == pc_maxjoblv(sd)) {
  1664. clif_displaymessage(fd, msg_txt(23)); // Job level can't go any higher.
  1665. return -1;
  1666. }
  1667. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1668. level = pc_maxjoblv(sd) - sd->status.job_level;
  1669. sd->status.job_level += (unsigned int)level;
  1670. sd->status.skill_point += level;
  1671. clif_misceffect(&sd->bl, 1);
  1672. clif_displaymessage(fd, msg_txt(24)); // Job level raised.
  1673. } else {
  1674. if (sd->status.job_level == 1) {
  1675. clif_displaymessage(fd, msg_txt(159)); // Job level can't go any lower.
  1676. return -1;
  1677. }
  1678. level *=-1;
  1679. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1680. level = sd->status.job_level-1;
  1681. sd->status.job_level -= (unsigned int)level;
  1682. if (sd->status.skill_point < level)
  1683. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1684. if (sd->status.skill_point < level)
  1685. sd->status.skill_point = 0;
  1686. else
  1687. sd->status.skill_point -= level;
  1688. clif_displaymessage(fd, msg_txt(25)); // Job level lowered.
  1689. }
  1690. sd->status.job_exp = 0;
  1691. clif_updatestatus(sd, SP_JOBLEVEL);
  1692. clif_updatestatus(sd, SP_JOBEXP);
  1693. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1694. clif_updatestatus(sd, SP_SKILLPOINT);
  1695. status_calc_pc(sd, 0);
  1696. return 0;
  1697. }
  1698. /*==========================================
  1699. * @help
  1700. *------------------------------------------*/
  1701. ACMD_FUNC(help)
  1702. {
  1703. char buf[2048], w1[2048], w2[2048];
  1704. int i, gm_level;
  1705. FILE* fp;
  1706. nullpo_retr(-1, sd);
  1707. memset(buf, '\0', sizeof(buf));
  1708. if ((fp = fopen(help_txt, "r")) != NULL) {
  1709. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1710. gm_level = pc_isGM(sd);
  1711. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1712. if (buf[0] == '/' && buf[1] == '/')
  1713. continue;
  1714. for (i = 0; buf[i] != '\0'; i++) {
  1715. if (buf[i] == '\r' || buf[i] == '\n') {
  1716. buf[i] = '\0';
  1717. break;
  1718. }
  1719. }
  1720. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1721. clif_displaymessage(fd, buf);
  1722. else if (gm_level >= atoi(w1))
  1723. clif_displaymessage(fd, w2);
  1724. }
  1725. fclose(fp);
  1726. } else {
  1727. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1728. return -1;
  1729. }
  1730. return 0;
  1731. }
  1732. /*==========================================
  1733. * @help2 - Char commands [Kayla]
  1734. *------------------------------------------*/
  1735. ACMD_FUNC(help2)
  1736. {
  1737. char buf[2048], w1[2048], w2[2048];
  1738. int i, gm_level;
  1739. FILE* fp;
  1740. nullpo_retr(-1, sd);
  1741. memset(buf, '\0', sizeof(buf));
  1742. if ((fp = fopen(help2_txt, "r")) != NULL) {
  1743. clif_displaymessage(fd, msg_txt(26)); // Help commands:
  1744. gm_level = pc_isGM(sd);
  1745. while(fgets(buf, sizeof(buf), fp) != NULL) {
  1746. if (buf[0] == '/' && buf[1] == '/')
  1747. continue;
  1748. for (i = 0; buf[i] != '\0'; i++) {
  1749. if (buf[i] == '\r' || buf[i] == '\n') {
  1750. buf[i] = '\0';
  1751. break;
  1752. }
  1753. }
  1754. if (sscanf(buf, "%2047[^:]:%2047[^\n]", w1, w2) < 2)
  1755. clif_displaymessage(fd, buf);
  1756. else if (gm_level >= atoi(w1))
  1757. clif_displaymessage(fd, w2);
  1758. }
  1759. fclose(fp);
  1760. } else {
  1761. clif_displaymessage(fd, msg_txt(27)); // File help.txt not found.
  1762. return -1;
  1763. }
  1764. return 0;
  1765. }
  1766. // helper function, used in foreach calls to stop auto-attack timers
  1767. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1768. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1769. {
  1770. struct unit_data *ud = unit_bl2ud(bl);
  1771. int id = va_arg(ap, int);
  1772. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1773. {
  1774. unit_stop_attack(bl);
  1775. return 1;
  1776. }
  1777. return 0;
  1778. }
  1779. /*==========================================
  1780. *
  1781. *------------------------------------------*/
  1782. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1783. {
  1784. TBL_PC* sd = (TBL_PC*)bl;
  1785. clif_pvpset(sd, 0, 0, 2);
  1786. if (sd->pvp_timer != INVALID_TIMER) {
  1787. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1788. sd->pvp_timer = INVALID_TIMER;
  1789. }
  1790. return 0;
  1791. }
  1792. ACMD_FUNC(pvpoff)
  1793. {
  1794. nullpo_retr(-1, sd);
  1795. if (!map[sd->bl.m].flag.pvp) {
  1796. clif_displaymessage(fd, msg_txt(160)); // PvP is already Off.
  1797. return -1;
  1798. }
  1799. map[sd->bl.m].flag.pvp = 0;
  1800. if (!battle_config.pk_mode)
  1801. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1802. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1803. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1804. clif_displaymessage(fd, msg_txt(31)); // PvP: Off.
  1805. return 0;
  1806. }
  1807. /*==========================================
  1808. *
  1809. *------------------------------------------*/
  1810. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1811. {
  1812. TBL_PC* sd = (TBL_PC*)bl;
  1813. if (sd->pvp_timer == INVALID_TIMER) {
  1814. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1815. sd->pvp_rank = 0;
  1816. sd->pvp_lastusers = 0;
  1817. sd->pvp_point = 5;
  1818. sd->pvp_won = 0;
  1819. sd->pvp_lost = 0;
  1820. }
  1821. return 0;
  1822. }
  1823. ACMD_FUNC(pvpon)
  1824. {
  1825. nullpo_retr(-1, sd);
  1826. if (map[sd->bl.m].flag.pvp) {
  1827. clif_displaymessage(fd, msg_txt(161)); // PvP is already On.
  1828. return -1;
  1829. }
  1830. map[sd->bl.m].flag.pvp = 1;
  1831. if (!battle_config.pk_mode)
  1832. {// display pvp circle and rank
  1833. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1834. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1835. }
  1836. clif_displaymessage(fd, msg_txt(32)); // PvP: On.
  1837. return 0;
  1838. }
  1839. /*==========================================
  1840. *
  1841. *------------------------------------------*/
  1842. ACMD_FUNC(gvgoff)
  1843. {
  1844. nullpo_retr(-1, sd);
  1845. if (!map[sd->bl.m].flag.gvg) {
  1846. clif_displaymessage(fd, msg_txt(162)); // GvG is already Off.
  1847. return -1;
  1848. }
  1849. map[sd->bl.m].flag.gvg = 0;
  1850. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1851. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1852. clif_displaymessage(fd, msg_txt(33)); // GvG: Off.
  1853. return 0;
  1854. }
  1855. /*==========================================
  1856. *
  1857. *------------------------------------------*/
  1858. ACMD_FUNC(gvgon)
  1859. {
  1860. nullpo_retr(-1, sd);
  1861. if (map[sd->bl.m].flag.gvg) {
  1862. clif_displaymessage(fd, msg_txt(163)); // GvG is already On.
  1863. return -1;
  1864. }
  1865. map[sd->bl.m].flag.gvg = 1;
  1866. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1867. clif_displaymessage(fd, msg_txt(34)); // GvG: On.
  1868. return 0;
  1869. }
  1870. /*==========================================
  1871. *
  1872. *------------------------------------------*/
  1873. ACMD_FUNC(model)
  1874. {
  1875. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1876. nullpo_retr(-1, sd);
  1877. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1878. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1879. sprintf(atcmd_output, "Please, enter at least a value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).",
  1880. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1881. clif_displaymessage(fd, atcmd_output);
  1882. return -1;
  1883. }
  1884. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1885. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1886. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1887. pc_changelook(sd, LOOK_HAIR, hair_style);
  1888. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1889. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1890. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1891. } else {
  1892. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1893. return -1;
  1894. }
  1895. return 0;
  1896. }
  1897. /*==========================================
  1898. * @dye && @ccolor
  1899. *------------------------------------------*/
  1900. ACMD_FUNC(dye)
  1901. {
  1902. int cloth_color = 0;
  1903. nullpo_retr(-1, sd);
  1904. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1905. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1906. sprintf(atcmd_output, "Please, enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).", MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1907. clif_displaymessage(fd, atcmd_output);
  1908. return -1;
  1909. }
  1910. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1911. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1912. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1913. } else {
  1914. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1915. return -1;
  1916. }
  1917. return 0;
  1918. }
  1919. /*==========================================
  1920. * @hairstyle && @hstyle
  1921. *------------------------------------------*/
  1922. ACMD_FUNC(hair_style)
  1923. {
  1924. int hair_style = 0;
  1925. nullpo_retr(-1, sd);
  1926. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1927. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1928. sprintf(atcmd_output, "Please, enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).", MIN_HAIR_STYLE, MAX_HAIR_STYLE);
  1929. clif_displaymessage(fd, atcmd_output);
  1930. return -1;
  1931. }
  1932. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1933. pc_changelook(sd, LOOK_HAIR, hair_style);
  1934. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1935. } else {
  1936. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1937. return -1;
  1938. }
  1939. return 0;
  1940. }
  1941. /*==========================================
  1942. * @haircolor && @hcolor
  1943. *------------------------------------------*/
  1944. ACMD_FUNC(hair_color)
  1945. {
  1946. int hair_color = 0;
  1947. nullpo_retr(-1, sd);
  1948. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1949. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1950. sprintf(atcmd_output, "Please, enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).", MIN_HAIR_COLOR, MAX_HAIR_COLOR);
  1951. clif_displaymessage(fd, atcmd_output);
  1952. return -1;
  1953. }
  1954. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1955. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1956. clif_displaymessage(fd, msg_txt(36)); // Appearence changed.
  1957. } else {
  1958. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  1959. return -1;
  1960. }
  1961. return 0;
  1962. }
  1963. /*==========================================
  1964. * @go [city_number or city_name] - Updated by Harbin
  1965. *------------------------------------------*/
  1966. ACMD_FUNC(go)
  1967. {
  1968. int i;
  1969. int town;
  1970. char map_name[MAP_NAME_LENGTH];
  1971. int m;
  1972. const struct {
  1973. char map[MAP_NAME_LENGTH];
  1974. int x, y;
  1975. } data[] = {
  1976. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1977. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1978. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1979. { MAP_PAYON, 162, 233 }, // 3=Payon
  1980. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1981. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1982. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1983. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1984. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1985. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1986. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1987. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1988. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1989. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1990. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1991. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1992. { MAP_JAIL, 23, 61 }, // 16=Prison
  1993. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1994. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1995. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1996. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1997. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1998. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1999. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  2000. { MAP_VEINS, 216, 123 }, // 24=Veins
  2001. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  2002. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  2003. { MAP_MANUK, 282, 138 }, // 27=Manuk
  2004. { MAP_SPLENDIDE, 197, 176 }, // 28=Splendide
  2005. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  2006. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  2007. { MAP_MORA, 44, 151 }, // 31=Mora
  2008. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  2009. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  2010. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  2011. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  2012. };
  2013. nullpo_retr(-1, sd);
  2014. if( map[sd->bl.m].flag.nogo && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) {
  2015. clif_displaymessage(sd->fd,"You can not use @go on this map.");
  2016. return 0;
  2017. }
  2018. memset(map_name, '\0', sizeof(map_name));
  2019. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2020. // get the number
  2021. town = atoi(message);
  2022. // if no value, display all value
  2023. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data)) {
  2024. clif_displaymessage(fd, msg_txt(38)); // Invalid location number, or name.
  2025. clif_displaymessage(fd, msg_txt(82)); // Please provide a name or number from the list provided:
  2026. clif_displaymessage(fd, " 0=Prontera 1=Morroc 2=Geffen");
  2027. clif_displaymessage(fd, " 3=Payon 4=Alberta 5=Izlude");
  2028. clif_displaymessage(fd, " 6=Al De Baran 7=Lutie 8=Comodo");
  2029. clif_displaymessage(fd, " 9=Yuno 10=Amatsu 11=Gonryun");
  2030. clif_displaymessage(fd, " 12=Umbala 13=Niflheim 14=Louyang");
  2031. clif_displaymessage(fd, " 15=Novice Grounds 16=Prison 17=Jawaii");
  2032. clif_displaymessage(fd, " 18=Ayothaya 19=Einbroch 20=Lighthalzen");
  2033. clif_displaymessage(fd, " 21=Einbech 22=Hugel 23=Rachel");
  2034. clif_displaymessage(fd, " 24=Veins 25=Moscovia 26=Midgard Camp");
  2035. clif_displaymessage(fd, " 27=Manuk 28=Splendide 29=Brasilis");
  2036. clif_displaymessage(fd, " 30=El Dicastes 31=Mora 32=Dewata");
  2037. clif_displaymessage(fd, " 33=Malangdo Island 34=Malaya Port 35=Eclage");
  2038. return -1;
  2039. }
  2040. // get possible name of the city
  2041. map_name[MAP_NAME_LENGTH-1] = '\0';
  2042. for (i = 0; map_name[i]; i++)
  2043. map_name[i] = TOLOWER(map_name[i]);
  2044. // try to identify the map name
  2045. if (strncmp(map_name, "prontera", 3) == 0) {
  2046. town = 0;
  2047. } else if (strncmp(map_name, "morocc", 3) == 0) {
  2048. town = 1;
  2049. } else if (strncmp(map_name, "geffen", 3) == 0) {
  2050. town = 2;
  2051. } else if (strncmp(map_name, "payon", 3) == 0 ||
  2052. strncmp(map_name, "paion", 3) == 0) {
  2053. town = 3;
  2054. } else if (strncmp(map_name, "alberta", 3) == 0) {
  2055. town = 4;
  2056. } else if (strncmp(map_name, "izlude", 3) == 0 ||
  2057. strncmp(map_name, "islude", 3) == 0) {
  2058. town = 5;
  2059. } else if (strncmp(map_name, "aldebaran", 3) == 0 ||
  2060. strcmp(map_name, "al") == 0) {
  2061. town = 6;
  2062. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  2063. strcmp(map_name, "christmas") == 0 ||
  2064. strncmp(map_name, "xmas", 3) == 0 ||
  2065. strncmp(map_name, "x-mas", 3) == 0) {
  2066. town = 7;
  2067. } else if (strncmp(map_name, "comodo", 3) == 0) {
  2068. town = 8;
  2069. } else if (strncmp(map_name, "yuno", 3) == 0) {
  2070. town = 9;
  2071. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  2072. town = 10;
  2073. } else if (strncmp(map_name, "gonryun", 3) == 0) {
  2074. town = 11;
  2075. } else if (strncmp(map_name, "umbala", 3) == 0) {
  2076. town = 12;
  2077. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  2078. town = 13;
  2079. } else if (strncmp(map_name, "louyang", 3) == 0) {
  2080. town = 14;
  2081. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  2082. strncmp(map_name, "startpoint", 3) == 0 ||
  2083. strncmp(map_name, "begining", 3) == 0) {
  2084. town = 15;
  2085. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  2086. strncmp(map_name, "prison", 3) == 0 ||
  2087. strncmp(map_name, "jails", 3) == 0) {
  2088. town = 16;
  2089. } else if (strncmp(map_name, "jawaii", 3) == 0 ||
  2090. strncmp(map_name, "jawai", 3) == 0) {
  2091. town = 17;
  2092. } else if (strncmp(map_name, "ayothaya", 3) == 0 ||
  2093. strncmp(map_name, "ayotaya", 3) == 0) {
  2094. town = 18;
  2095. } else if (strncmp(map_name, "einbroch", 5) == 0 ||
  2096. strncmp(map_name, "ainbroch", 5) == 0) {
  2097. town = 19;
  2098. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  2099. town = 20;
  2100. } else if (strncmp(map_name, "einbech", 3) == 0) {
  2101. town = 21;
  2102. } else if (strncmp(map_name, "hugel", 3) == 0) {
  2103. town = 22;
  2104. } else if (strncmp(map_name, "rachel", 3) == 0) {
  2105. town = 23;
  2106. } else if (strncmp(map_name, "veins", 3) == 0) {
  2107. town = 24;
  2108. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  2109. town = 25;
  2110. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  2111. town = 26;
  2112. } else if (strncmp(map_name, "manuk", 3) == 0) {
  2113. town = 27;
  2114. } else if (strncmp(map_name, "splendide", 3) == 0) {
  2115. town = 28;
  2116. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  2117. town = 29;
  2118. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  2119. town = 30;
  2120. } else if (strncmp(map_name, "mora", 3) == 0) {
  2121. town = 31;
  2122. } else if (strncmp(map_name, "dewata", 3) == 0) {
  2123. town = 32;
  2124. } else if (strncmp(map_name, "malangdo", 3) == 0) {
  2125. town = 33;
  2126. } else if (strncmp(map_name, "malaya", 3) == 0) {
  2127. town = 34;
  2128. } else if (strncmp(map_name, "eclage", 3) == 0) {
  2129. town = 35;
  2130. }
  2131. if (town >= 0 && town < ARRAYLENGTH(data))
  2132. {
  2133. m = map_mapname2mapid(data[town].map);
  2134. if (m >= 0 && map[m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2135. clif_displaymessage(fd, msg_txt(247));
  2136. return -1;
  2137. }
  2138. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  2139. clif_displaymessage(fd, msg_txt(248));
  2140. return -1;
  2141. }
  2142. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  2143. clif_displaymessage(fd, msg_txt(0)); // Warped.
  2144. } else {
  2145. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  2146. return -1;
  2147. }
  2148. } else { // if you arrive here, you have an error in town variable when reading of names
  2149. clif_displaymessage(fd, msg_txt(38)); // Invalid location number or name.
  2150. return -1;
  2151. }
  2152. return 0;
  2153. }
  2154. /*==========================================
  2155. *
  2156. *------------------------------------------*/
  2157. ACMD_FUNC(monster)
  2158. {
  2159. char name[NAME_LENGTH];
  2160. char monster[NAME_LENGTH];
  2161. int mob_id;
  2162. int number = 0;
  2163. int count;
  2164. int i, k, range;
  2165. short mx, my;
  2166. nullpo_retr(-1, sd);
  2167. memset(name, '\0', sizeof(name));
  2168. memset(monster, '\0', sizeof(monster));
  2169. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2170. if (!message || !*message) {
  2171. clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please.
  2172. return -1;
  2173. }
  2174. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  2175. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  2176. //All data can be left as it is.
  2177. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  2178. //Here, it is possible name was not given and we are using monster for it.
  2179. if (count < 3) //Blank mob's name.
  2180. name[0] = '\0';
  2181. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  2182. //All data can be left as it is.
  2183. } else if (sscanf(message, "%23s", monster) > 0) {
  2184. //As before, name may be already filled.
  2185. name[0] = '\0';
  2186. } else {
  2187. clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please.
  2188. return -1;
  2189. }
  2190. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2191. mob_id = mobdb_checkid(atoi(monster));
  2192. if (mob_id == 0) {
  2193. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2194. return -1;
  2195. }
  2196. if (mob_id == MOBID_EMPERIUM) {
  2197. clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
  2198. return -1;
  2199. }
  2200. if (number <= 0)
  2201. number = 1;
  2202. if( !name[0] )
  2203. strcpy(name, "--ja--");
  2204. // 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
  2205. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  2206. number = battle_config.atc_spawn_quantity_limit;
  2207. if (battle_config.etc_log)
  2208. 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);
  2209. count = 0;
  2210. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  2211. for (i = 0; i < number; i++) {
  2212. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  2213. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "");
  2214. count += (k != 0) ? 1 : 0;
  2215. }
  2216. if (count != 0)
  2217. if (number == count)
  2218. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  2219. else {
  2220. sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned!
  2221. clif_displaymessage(fd, atcmd_output);
  2222. }
  2223. else {
  2224. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  2225. return -1;
  2226. }
  2227. return 0;
  2228. }
  2229. // small monster spawning [Valaris]
  2230. ACMD_FUNC(monstersmall)
  2231. {
  2232. char name[NAME_LENGTH] = "";
  2233. char monster[NAME_LENGTH] = "";
  2234. int mob_id = 0;
  2235. int number = 0;
  2236. int x = 0;
  2237. int y = 0;
  2238. int count;
  2239. int i;
  2240. nullpo_retr(-1, sd);
  2241. if (!message || !*message) {
  2242. clif_displaymessage(fd, "Give a monster name/id please.");
  2243. return -1;
  2244. }
  2245. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2246. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2247. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2248. clif_displaymessage(fd, "Give a monster name/id please.");
  2249. return -1;
  2250. }
  2251. // If monster identifier/name argument is a name
  2252. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2253. mob_id = atoi(monster);
  2254. if (mob_id == 0) {
  2255. clif_displaymessage(fd, msg_txt(40));
  2256. return -1;
  2257. }
  2258. if (mob_id == MOBID_EMPERIUM) {
  2259. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2260. return -1;
  2261. }
  2262. if (mobdb_checkid(mob_id) == 0) {
  2263. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2264. return -1;
  2265. }
  2266. if (number <= 0)
  2267. number = 1;
  2268. if( !name[0] )
  2269. strcpy(name, "--ja--");
  2270. // 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
  2271. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2272. number = battle_config.atc_spawn_quantity_limit;
  2273. count = 0;
  2274. for (i = 0; i < number; i++) {
  2275. int mx, my;
  2276. if (x <= 0)
  2277. mx = sd->bl.x + (rnd() % 11 - 5);
  2278. else
  2279. mx = x;
  2280. if (y <= 0)
  2281. my = sd->bl.y + (rnd() % 11 - 5);
  2282. else
  2283. my = y;
  2284. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0;
  2285. }
  2286. if (count != 0)
  2287. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2288. else
  2289. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2290. return 0;
  2291. }
  2292. // big monster spawning [Valaris]
  2293. ACMD_FUNC(monsterbig)
  2294. {
  2295. char name[NAME_LENGTH] = "";
  2296. char monster[NAME_LENGTH] = "";
  2297. int mob_id = 0;
  2298. int number = 0;
  2299. int x = 0;
  2300. int y = 0;
  2301. int count;
  2302. int i;
  2303. nullpo_retr(-1, sd);
  2304. if (!message || !*message) {
  2305. clif_displaymessage(fd, "Give a monster name/id please.");
  2306. return -1;
  2307. }
  2308. if (sscanf(message, "\"%23[^\"]\" %23s %d %d %d", name, monster, &number, &x, &y) < 2 &&
  2309. sscanf(message, "%23s \"%23[^\"]\" %d %d %d", monster, name, &number, &x, &y) < 2 &&
  2310. sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) {
  2311. clif_displaymessage(fd, "Give a monster name/id please.");
  2312. return -1;
  2313. }
  2314. // If monster identifier/name argument is a name
  2315. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  2316. mob_id = atoi(monster);
  2317. if (mob_id == 0) {
  2318. clif_displaymessage(fd, msg_txt(40));
  2319. return -1;
  2320. }
  2321. if (mob_id == MOBID_EMPERIUM) {
  2322. clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium
  2323. return -1;
  2324. }
  2325. if (mobdb_checkid(mob_id) == 0) {
  2326. clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID.
  2327. return -1;
  2328. }
  2329. if (number <= 0)
  2330. number = 1;
  2331. if( !name[0] )
  2332. strcpy(name, "--ja--");
  2333. // 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
  2334. if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit)
  2335. number = battle_config.atc_spawn_quantity_limit;
  2336. count = 0;
  2337. for (i = 0; i < number; i++) {
  2338. int mx, my;
  2339. if (x <= 0)
  2340. mx = sd->bl.x + (rnd() % 11 - 5);
  2341. else
  2342. mx = x;
  2343. if (y <= 0)
  2344. my = sd->bl.y + (rnd() % 11 - 5);
  2345. else
  2346. my = y;
  2347. count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0;
  2348. }
  2349. if (count != 0)
  2350. clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!!
  2351. else
  2352. clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID.
  2353. return 0;
  2354. }
  2355. /*==========================================
  2356. *
  2357. *------------------------------------------*/
  2358. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  2359. {
  2360. struct mob_data *md;
  2361. int flag;
  2362. nullpo_ret(md=(struct mob_data *)bl);
  2363. flag = va_arg(ap, int);
  2364. if (md->guardian_data)
  2365. return 0; //Do not touch WoE mobs!
  2366. if (flag)
  2367. status_zap(bl,md->status.hp, 0);
  2368. else
  2369. status_kill(bl);
  2370. return 1;
  2371. }
  2372. void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
  2373. {
  2374. int map_id;
  2375. char map_name[MAP_NAME_LENGTH_EXT];
  2376. if (!sd) return;
  2377. memset(map_name, '\0', sizeof(map_name));
  2378. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2379. map_id = sd->bl.m;
  2380. else {
  2381. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2382. map_id = sd->bl.m;
  2383. }
  2384. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, drop);
  2385. clif_displaymessage(fd, msg_txt(165)); // All monsters killed!
  2386. return;
  2387. }
  2388. ACMD_FUNC(killmonster)
  2389. {
  2390. atcommand_killmonster_sub(fd, sd, message, 1);
  2391. return 0;
  2392. }
  2393. /*==========================================
  2394. *
  2395. *------------------------------------------*/
  2396. ACMD_FUNC(killmonster2)
  2397. {
  2398. atcommand_killmonster_sub(fd, sd, message, 0);
  2399. return 0;
  2400. }
  2401. /*==========================================
  2402. *
  2403. *------------------------------------------*/
  2404. ACMD_FUNC(refine)
  2405. {
  2406. int i,j, position = 0, refine = 0, current_position, final_refine;
  2407. int count;
  2408. nullpo_retr(-1, sd);
  2409. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2410. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  2411. clif_displaymessage(fd, "Please, enter a position and an amount (usage: @refine <equip position> <+/- amount>).");
  2412. sprintf(atcmd_output, "%d: Lower Headgear", EQP_HEAD_LOW);
  2413. clif_displaymessage(fd, atcmd_output);
  2414. sprintf(atcmd_output, "%d: Right Hand", EQP_HAND_R);
  2415. clif_displaymessage(fd, atcmd_output);
  2416. sprintf(atcmd_output, "%d: Garment", EQP_GARMENT);
  2417. clif_displaymessage(fd, atcmd_output);
  2418. sprintf(atcmd_output, "%d: Left Accessory", EQP_ACC_L);
  2419. clif_displaymessage(fd, atcmd_output);
  2420. sprintf(atcmd_output, "%d: Body Armor", EQP_ARMOR);
  2421. clif_displaymessage(fd, atcmd_output);
  2422. sprintf(atcmd_output, "%d: Left Hand", EQP_HAND_L);
  2423. clif_displaymessage(fd, atcmd_output);
  2424. sprintf(atcmd_output, "%d: Shoes", EQP_SHOES);
  2425. clif_displaymessage(fd, atcmd_output);
  2426. sprintf(atcmd_output, "%d: Right Accessory", EQP_ACC_R);
  2427. clif_displaymessage(fd, atcmd_output);
  2428. sprintf(atcmd_output, "%d: Top Headgear", EQP_HEAD_TOP);
  2429. clif_displaymessage(fd, atcmd_output);
  2430. sprintf(atcmd_output, "%d: Mid Headgear", EQP_HEAD_MID);
  2431. clif_displaymessage(fd, atcmd_output);
  2432. return -1;
  2433. }
  2434. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2435. count = 0;
  2436. for (j = 0; j < EQI_MAX-1; j++) {
  2437. if ((i = sd->equip_index[j]) < 0)
  2438. continue;
  2439. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  2440. continue;
  2441. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  2442. continue;
  2443. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  2444. continue;
  2445. if(position && !(sd->status.inventory[i].equip & position))
  2446. continue;
  2447. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  2448. if (sd->status.inventory[i].refine != final_refine) {
  2449. sd->status.inventory[i].refine = final_refine;
  2450. current_position = sd->status.inventory[i].equip;
  2451. pc_unequipitem(sd, i, 3);
  2452. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  2453. clif_delitem(sd, i, 1, 3);
  2454. clif_additem(sd, i, 1, 0);
  2455. pc_equipitem(sd, i, current_position);
  2456. clif_misceffect(&sd->bl, 3);
  2457. count++;
  2458. }
  2459. }
  2460. if (count == 0)
  2461. clif_displaymessage(fd, msg_txt(166)); // No item has been refined.
  2462. else if (count == 1)
  2463. clif_displaymessage(fd, msg_txt(167)); // 1 item has been refined.
  2464. else {
  2465. sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined.
  2466. clif_displaymessage(fd, atcmd_output);
  2467. }
  2468. return 0;
  2469. }
  2470. /*==========================================
  2471. *
  2472. *------------------------------------------*/
  2473. ACMD_FUNC(produce)
  2474. {
  2475. char item_name[100];
  2476. int item_id, attribute = 0, star = 0;
  2477. int flag = 0;
  2478. struct item_data *item_data;
  2479. struct item tmp_item;
  2480. nullpo_retr(-1, sd);
  2481. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2482. memset(item_name, '\0', sizeof(item_name));
  2483. if (!message || !*message || (
  2484. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  2485. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  2486. )) {
  2487. clif_displaymessage(fd, "Please, enter at least an item name/id (usage: @produce <equip name or equip ID> <element> <# of very's>).");
  2488. return -1;
  2489. }
  2490. item_id = 0;
  2491. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  2492. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  2493. {
  2494. clif_displaymessage(fd, msg_txt(170)); //This item is not an equipment.
  2495. return -1;
  2496. }
  2497. item_id = item_data->nameid;
  2498. if (itemdb_isequip2(item_data)) {
  2499. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2500. attribute = ATTRIBUTE_NORMAL;
  2501. if (star < MIN_STAR || star > MAX_STAR)
  2502. star = 0;
  2503. memset(&tmp_item, 0, sizeof tmp_item);
  2504. tmp_item.nameid = item_id;
  2505. tmp_item.amount = 1;
  2506. tmp_item.identify = 1;
  2507. tmp_item.card[0] = CARD0_FORGE;
  2508. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2509. ((star*5) << 8) + attribute:0;
  2510. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2511. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2512. clif_produceeffect(sd, 0, item_id);
  2513. clif_misceffect(&sd->bl, 3);
  2514. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2515. clif_additem(sd, 0, 0, flag);
  2516. } else {
  2517. sprintf(atcmd_output, msg_txt(169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  2518. clif_displaymessage(fd, atcmd_output);
  2519. return -1;
  2520. }
  2521. return 0;
  2522. }
  2523. /*==========================================
  2524. *
  2525. *------------------------------------------*/
  2526. ACMD_FUNC(memo)
  2527. {
  2528. int position = 0;
  2529. nullpo_retr(-1, sd);
  2530. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2531. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  2532. {
  2533. int i;
  2534. clif_displaymessage(sd->fd, "Your actual memo positions are:");
  2535. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2536. {
  2537. if( sd->status.memo_point[i].map )
  2538. 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);
  2539. else
  2540. sprintf(atcmd_output, msg_txt(171), i); // %d - void
  2541. clif_displaymessage(sd->fd, atcmd_output);
  2542. }
  2543. return 0;
  2544. }
  2545. if( position < 0 || position >= MAX_MEMOPOINTS )
  2546. {
  2547. sprintf(atcmd_output, "Please, enter a valid position (usage: @memo <memo_position:%d-%d>).", 0, MAX_MEMOPOINTS-1);
  2548. clif_displaymessage(fd, atcmd_output);
  2549. return -1;
  2550. }
  2551. pc_memo(sd, position);
  2552. return 0;
  2553. }
  2554. /*==========================================
  2555. *
  2556. *------------------------------------------*/
  2557. ACMD_FUNC(gat)
  2558. {
  2559. int y;
  2560. nullpo_retr(-1, sd);
  2561. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2562. for (y = 2; y >= -2; y--) {
  2563. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2564. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2565. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2566. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2567. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2568. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2569. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2570. clif_displaymessage(fd, atcmd_output);
  2571. }
  2572. return 0;
  2573. }
  2574. /*==========================================
  2575. *
  2576. *------------------------------------------*/
  2577. ACMD_FUNC(displaystatus)
  2578. {
  2579. int i, type, flag, tick;
  2580. nullpo_retr(-1, sd);
  2581. if (!message || !*message || (i = sscanf(message, "%d %d %d", &type, &flag, &tick)) < 1) {
  2582. clif_displaymessage(fd, "Please, enter a status type/flag (usage: @displaystatus <status type> <flag> <tick>).");
  2583. return -1;
  2584. }
  2585. if (i < 2) flag = 1;
  2586. if (i < 3) tick = 0;
  2587. clif_status_change(&sd->bl, type, flag, tick, 0, 0, 0);
  2588. return 0;
  2589. }
  2590. /*==========================================
  2591. * @stpoint (Rewritten by [Yor])
  2592. *------------------------------------------*/
  2593. ACMD_FUNC(statuspoint)
  2594. {
  2595. int point;
  2596. unsigned int new_status_point;
  2597. if (!message || !*message || (point = atoi(message)) == 0) {
  2598. clif_displaymessage(fd, "Please, enter a number (usage: @stpoint <number of points>).");
  2599. return -1;
  2600. }
  2601. if(point < 0)
  2602. {
  2603. if(sd->status.status_point < (unsigned int)(-point))
  2604. {
  2605. new_status_point = 0;
  2606. }
  2607. else
  2608. {
  2609. new_status_point = sd->status.status_point + point;
  2610. }
  2611. }
  2612. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2613. {
  2614. new_status_point = UINT_MAX;
  2615. }
  2616. else
  2617. {
  2618. new_status_point = sd->status.status_point + point;
  2619. }
  2620. if (new_status_point != sd->status.status_point) {
  2621. sd->status.status_point = new_status_point;
  2622. clif_updatestatus(sd, SP_STATUSPOINT);
  2623. clif_displaymessage(fd, msg_txt(174)); // Number of status points changed.
  2624. } else {
  2625. if (point < 0)
  2626. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2627. else
  2628. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2629. return -1;
  2630. }
  2631. return 0;
  2632. }
  2633. /*==========================================
  2634. * @skpoint (Rewritten by [Yor])
  2635. *------------------------------------------*/
  2636. ACMD_FUNC(skillpoint)
  2637. {
  2638. int point;
  2639. unsigned int new_skill_point;
  2640. nullpo_retr(-1, sd);
  2641. if (!message || !*message || (point = atoi(message)) == 0) {
  2642. clif_displaymessage(fd, "Please, enter a number (usage: @skpoint <number of points>).");
  2643. return -1;
  2644. }
  2645. if(point < 0)
  2646. {
  2647. if(sd->status.skill_point < (unsigned int)(-point))
  2648. {
  2649. new_skill_point = 0;
  2650. }
  2651. else
  2652. {
  2653. new_skill_point = sd->status.skill_point + point;
  2654. }
  2655. }
  2656. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2657. {
  2658. new_skill_point = UINT_MAX;
  2659. }
  2660. else
  2661. {
  2662. new_skill_point = sd->status.skill_point + point;
  2663. }
  2664. if (new_skill_point != sd->status.skill_point) {
  2665. sd->status.skill_point = new_skill_point;
  2666. clif_updatestatus(sd, SP_SKILLPOINT);
  2667. clif_displaymessage(fd, msg_txt(175)); // Number of skill points changed.
  2668. } else {
  2669. if (point < 0)
  2670. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2671. else
  2672. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2673. return -1;
  2674. }
  2675. return 0;
  2676. }
  2677. /*==========================================
  2678. * @zeny (Rewritten by [Yor])
  2679. *------------------------------------------*/
  2680. ACMD_FUNC(zeny)
  2681. {
  2682. int zeny, new_zeny;
  2683. nullpo_retr(-1, sd);
  2684. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2685. clif_displaymessage(fd, "Please, enter an amount (usage: @zeny <amount>).");
  2686. return -1;
  2687. }
  2688. new_zeny = sd->status.zeny + zeny;
  2689. if (zeny > 0 && (zeny > MAX_ZENY || new_zeny > MAX_ZENY)) // fix positiv overflow
  2690. new_zeny = MAX_ZENY;
  2691. else if (zeny < 0 && (zeny < -MAX_ZENY || new_zeny < 0)) // fix negativ overflow
  2692. new_zeny = 0;
  2693. if (new_zeny != sd->status.zeny) {
  2694. sd->status.zeny = new_zeny;
  2695. clif_updatestatus(sd, SP_ZENY);
  2696. clif_displaymessage(fd, msg_txt(176)); // Current amount of zeny changed.
  2697. } else {
  2698. if (zeny < 0)
  2699. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2700. else
  2701. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2702. return -1;
  2703. }
  2704. return 0;
  2705. }
  2706. /*==========================================
  2707. *
  2708. *------------------------------------------*/
  2709. ACMD_FUNC(param)
  2710. {
  2711. int i, value = 0, new_value, max;
  2712. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2713. short* status[6];
  2714. //we don't use direct initialization because it isn't part of the c standard.
  2715. nullpo_retr(-1, sd);
  2716. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2717. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2718. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2719. clif_displaymessage(fd, atcmd_output);
  2720. return -1;
  2721. }
  2722. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2723. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2724. sprintf(atcmd_output, "Please, enter a valid value (usage: @str,@agi,@vit,@int,@dex,@luk <+/-adjustment>).");
  2725. clif_displaymessage(fd, atcmd_output);
  2726. return -1;
  2727. }
  2728. status[0] = &sd->status.str;
  2729. status[1] = &sd->status.agi;
  2730. status[2] = &sd->status.vit;
  2731. status[3] = &sd->status.int_;
  2732. status[4] = &sd->status.dex;
  2733. status[5] = &sd->status.luk;
  2734. if( battle_config.atcommand_max_stat_bypass )
  2735. max = SHRT_MAX;
  2736. else
  2737. max = pc_maxparameter(sd);
  2738. if(value < 0 && *status[i] <= -value) {
  2739. new_value = 1;
  2740. } else if(max - *status[i] < value) {
  2741. new_value = max;
  2742. } else {
  2743. new_value = *status[i] + value;
  2744. }
  2745. if (new_value != *status[i]) {
  2746. *status[i] = new_value;
  2747. clif_updatestatus(sd, SP_STR + i);
  2748. clif_updatestatus(sd, SP_USTR + i);
  2749. status_calc_pc(sd, 0);
  2750. clif_displaymessage(fd, msg_txt(42)); // Stat changed.
  2751. } else {
  2752. if (value < 0)
  2753. clif_displaymessage(fd, msg_txt(41)); // Unable to decrease the number/value.
  2754. else
  2755. clif_displaymessage(fd, msg_txt(149)); // Unable to increase the number/value.
  2756. return -1;
  2757. }
  2758. return 0;
  2759. }
  2760. /*==========================================
  2761. * Stat all by fritz (rewritten by [Yor])
  2762. *------------------------------------------*/
  2763. ACMD_FUNC(stat_all)
  2764. {
  2765. int index, count, value, max, new_value;
  2766. short* status[6];
  2767. //we don't use direct initialization because it isn't part of the c standard.
  2768. nullpo_retr(-1, sd);
  2769. status[0] = &sd->status.str;
  2770. status[1] = &sd->status.agi;
  2771. status[2] = &sd->status.vit;
  2772. status[3] = &sd->status.int_;
  2773. status[4] = &sd->status.dex;
  2774. status[5] = &sd->status.luk;
  2775. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2776. value = pc_maxparameter(sd);
  2777. max = pc_maxparameter(sd);
  2778. } else {
  2779. if( battle_config.atcommand_max_stat_bypass )
  2780. max = SHRT_MAX;
  2781. else
  2782. max = pc_maxparameter(sd);
  2783. }
  2784. count = 0;
  2785. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2786. if (value > 0 && *status[index] > max - value)
  2787. new_value = max;
  2788. else if (value < 0 && *status[index] <= -value)
  2789. new_value = 1;
  2790. else
  2791. new_value = *status[index] +value;
  2792. if (new_value != (int)*status[index]) {
  2793. *status[index] = new_value;
  2794. clif_updatestatus(sd, SP_STR + index);
  2795. clif_updatestatus(sd, SP_USTR + index);
  2796. count++;
  2797. }
  2798. }
  2799. if (count > 0) { // if at least 1 stat modified
  2800. status_calc_pc(sd, 0);
  2801. clif_displaymessage(fd, msg_txt(84)); // All stats changed!
  2802. } else {
  2803. if (value < 0)
  2804. clif_displaymessage(fd, msg_txt(177)); // You cannot decrease that stat anymore.
  2805. else
  2806. clif_displaymessage(fd, msg_txt(178)); // You cannot increase that stat anymore.
  2807. return -1;
  2808. }
  2809. return 0;
  2810. }
  2811. /*==========================================
  2812. *
  2813. *------------------------------------------*/
  2814. ACMD_FUNC(guildlevelup)
  2815. {
  2816. int level = 0;
  2817. short added_level;
  2818. struct guild *guild_info;
  2819. nullpo_retr(-1, sd);
  2820. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2821. clif_displaymessage(fd, "Please, enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).");
  2822. return -1;
  2823. }
  2824. if (sd->status.guild_id <= 0 || (guild_info = guild_search(sd->status.guild_id)) == NULL) {
  2825. clif_displaymessage(fd, msg_txt(43)); // You're not in a guild.
  2826. return -1;
  2827. }
  2828. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2829. // clif_displaymessage(fd, msg_txt(44)); // You're not the master of your guild.
  2830. // return -1;
  2831. //}
  2832. added_level = (short)level;
  2833. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2834. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2835. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2836. added_level = 1 - guild_info->guild_lv;
  2837. if (added_level != 0) {
  2838. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2839. clif_displaymessage(fd, msg_txt(179)); // Guild level changed.
  2840. } else {
  2841. clif_displaymessage(fd, msg_txt(45)); // Guild level change failed.
  2842. return -1;
  2843. }
  2844. return 0;
  2845. }
  2846. /*==========================================
  2847. *
  2848. *------------------------------------------*/
  2849. ACMD_FUNC(makeegg)
  2850. {
  2851. struct item_data *item_data;
  2852. int id, pet_id;
  2853. nullpo_retr(-1, sd);
  2854. if (!message || !*message) {
  2855. clif_displaymessage(fd, "Please, enter a monster/egg name/id (usage: @makeegg <pet>).");
  2856. return -1;
  2857. }
  2858. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2859. id = item_data->nameid;
  2860. else
  2861. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2862. ;
  2863. else
  2864. id = atoi(message);
  2865. pet_id = search_petDB_index(id, PET_CLASS);
  2866. if (pet_id < 0)
  2867. pet_id = search_petDB_index(id, PET_EGG);
  2868. if (pet_id >= 0) {
  2869. sd->catch_target_class = pet_db[pet_id].class_;
  2870. intif_create_pet(
  2871. sd->status.account_id, sd->status.char_id,
  2872. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2873. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2874. 100, 0, 1, pet_db[pet_id].jname);
  2875. } else {
  2876. clif_displaymessage(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
  2877. return -1;
  2878. }
  2879. return 0;
  2880. }
  2881. /*==========================================
  2882. *
  2883. *------------------------------------------*/
  2884. ACMD_FUNC(hatch)
  2885. {
  2886. nullpo_retr(-1, sd);
  2887. if (sd->status.pet_id <= 0)
  2888. clif_sendegg(sd);
  2889. else {
  2890. clif_displaymessage(fd, msg_txt(181)); // You already have a pet.
  2891. return -1;
  2892. }
  2893. return 0;
  2894. }
  2895. /*==========================================
  2896. *
  2897. *------------------------------------------*/
  2898. ACMD_FUNC(petfriendly)
  2899. {
  2900. int friendly;
  2901. struct pet_data *pd;
  2902. nullpo_retr(-1, sd);
  2903. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2904. clif_displaymessage(fd, "Please, enter a valid value (usage: @petfriendly <0-1000>).");
  2905. return -1;
  2906. }
  2907. pd = sd->pd;
  2908. if (!pd) {
  2909. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2910. return -1;
  2911. }
  2912. if (friendly < 0 || friendly > 1000)
  2913. {
  2914. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2915. return -1;
  2916. }
  2917. if (friendly == pd->pet.intimate) {
  2918. clif_displaymessage(fd, msg_txt(183)); // Pet intimacy is already at maximum.
  2919. return -1;
  2920. }
  2921. pet_set_intimate(pd, friendly);
  2922. clif_send_petstatus(sd);
  2923. clif_displaymessage(fd, msg_txt(182)); // Pet intimacy changed.
  2924. return 0;
  2925. }
  2926. /*==========================================
  2927. *
  2928. *------------------------------------------*/
  2929. ACMD_FUNC(pethungry)
  2930. {
  2931. int hungry;
  2932. struct pet_data *pd;
  2933. nullpo_retr(-1, sd);
  2934. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2935. clif_displaymessage(fd, "Please, enter a valid number (usage: @pethungry <0-100>).");
  2936. return -1;
  2937. }
  2938. pd = sd->pd;
  2939. if (!sd->status.pet_id || !pd) {
  2940. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2941. return -1;
  2942. }
  2943. if (hungry < 0 || hungry > 100) {
  2944. clif_displaymessage(fd, msg_txt(37)); // An invalid number was specified.
  2945. return -1;
  2946. }
  2947. if (hungry == pd->pet.hungry) {
  2948. clif_displaymessage(fd, msg_txt(186)); // Pet hunger is already at maximum.
  2949. return -1;
  2950. }
  2951. pd->pet.hungry = hungry;
  2952. clif_send_petstatus(sd);
  2953. clif_displaymessage(fd, msg_txt(185)); // Pet hunger changed.
  2954. return 0;
  2955. }
  2956. /*==========================================
  2957. *
  2958. *------------------------------------------*/
  2959. ACMD_FUNC(petrename)
  2960. {
  2961. struct pet_data *pd;
  2962. nullpo_retr(-1, sd);
  2963. if (!sd->status.pet_id || !sd->pd) {
  2964. clif_displaymessage(fd, msg_txt(184)); // Sorry, but you have no pet.
  2965. return -1;
  2966. }
  2967. pd = sd->pd;
  2968. if (!pd->pet.rename_flag) {
  2969. clif_displaymessage(fd, msg_txt(188)); // You can already rename your pet.
  2970. return -1;
  2971. }
  2972. pd->pet.rename_flag = 0;
  2973. intif_save_petdata(sd->status.account_id, &pd->pet);
  2974. clif_send_petstatus(sd);
  2975. clif_displaymessage(fd, msg_txt(187)); // You can now rename your pet.
  2976. return 0;
  2977. }
  2978. /*==========================================
  2979. *
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(recall)
  2982. {
  2983. struct map_session_data *pl_sd = NULL;
  2984. nullpo_retr(-1, sd);
  2985. if (!message || !*message) {
  2986. clif_displaymessage(fd, "Please, enter a player name (usage: @recall <player name/id>).");
  2987. return -1;
  2988. }
  2989. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2990. {
  2991. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  2992. return -1;
  2993. }
  2994. if (pl_sd == sd)
  2995. {
  2996. clif_displaymessage(fd, "You are already where you are...");
  2997. return -1;
  2998. }
  2999. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3000. {
  3001. clif_displaymessage(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  3002. return -1;
  3003. }
  3004. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3005. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3006. return -1;
  3007. }
  3008. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3009. clif_displaymessage(fd, "You are not authorized to warp this player from its actual map.");
  3010. return -1;
  3011. }
  3012. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3013. sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled!
  3014. clif_displaymessage(fd, atcmd_output);
  3015. return 0;
  3016. }
  3017. /*==========================================
  3018. * charblock command (usage: charblock <player_name>)
  3019. * This command do a definitiv ban on a player
  3020. *------------------------------------------*/
  3021. ACMD_FUNC(char_block)
  3022. {
  3023. nullpo_retr(-1, sd);
  3024. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3025. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3026. clif_displaymessage(fd, "Please, enter a player name (usage: @charblock/@block <name>).");
  3027. return -1;
  3028. }
  3029. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  3030. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3031. return 0;
  3032. }
  3033. /*==========================================
  3034. * charban command (usage: charban <time> <player_name>)
  3035. * This command do a limited ban on a player
  3036. * Time is done as follows:
  3037. * Adjustment value (-1, 1, +1, etc...)
  3038. * Modified element:
  3039. * a or y: year
  3040. * m: month
  3041. * j or d: day
  3042. * h: hour
  3043. * mn: minute
  3044. * s: second
  3045. * <example> @ban +1m-2mn1s-6y test_player
  3046. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  3047. *------------------------------------------*/
  3048. ACMD_FUNC(char_ban)
  3049. {
  3050. char * modif_p;
  3051. int year, month, day, hour, minute, second, value;
  3052. nullpo_retr(-1, sd);
  3053. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3054. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3055. if (!message || !*message || sscanf(message, "%s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  3056. clif_displaymessage(fd, "Please, enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <name>).");
  3057. return -1;
  3058. }
  3059. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3060. modif_p = atcmd_output;
  3061. year = month = day = hour = minute = second = 0;
  3062. while (modif_p[0] != '\0') {
  3063. value = atoi(modif_p);
  3064. if (value == 0)
  3065. modif_p++;
  3066. else {
  3067. if (modif_p[0] == '-' || modif_p[0] == '+')
  3068. modif_p++;
  3069. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3070. modif_p++;
  3071. if (modif_p[0] == 's') {
  3072. second = value;
  3073. modif_p++;
  3074. } else if (modif_p[0] == 'n') {
  3075. minute = value;
  3076. modif_p++;
  3077. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3078. minute = value;
  3079. modif_p = modif_p + 2;
  3080. } else if (modif_p[0] == 'h') {
  3081. hour = value;
  3082. modif_p++;
  3083. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3084. day = value;
  3085. modif_p++;
  3086. } else if (modif_p[0] == 'm') {
  3087. month = value;
  3088. modif_p++;
  3089. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3090. year = value;
  3091. modif_p++;
  3092. } else if (modif_p[0] != '\0') {
  3093. modif_p++;
  3094. }
  3095. }
  3096. }
  3097. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  3098. clif_displaymessage(fd, msg_txt(85)); // Invalid time for ban command.
  3099. return -1;
  3100. }
  3101. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  3102. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3103. return 0;
  3104. }
  3105. /*==========================================
  3106. * charunblock command (usage: charunblock <player_name>)
  3107. *------------------------------------------*/
  3108. ACMD_FUNC(char_unblock)
  3109. {
  3110. nullpo_retr(-1, sd);
  3111. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3112. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3113. clif_displaymessage(fd, "Please, enter a player name (usage: @charunblock <player_name>).");
  3114. return -1;
  3115. }
  3116. // send answer to login server via char-server
  3117. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  3118. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3119. return 0;
  3120. }
  3121. /*==========================================
  3122. * charunban command (usage: charunban <player_name>)
  3123. *------------------------------------------*/
  3124. ACMD_FUNC(char_unban)
  3125. {
  3126. nullpo_retr(-1, sd);
  3127. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3128. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3129. clif_displaymessage(fd, "Please, enter a player name (usage: @charunban <player_name>).");
  3130. return -1;
  3131. }
  3132. // send answer to login server via char-server
  3133. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  3134. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
  3135. return 0;
  3136. }
  3137. /*==========================================
  3138. *
  3139. *------------------------------------------*/
  3140. ACMD_FUNC(night)
  3141. {
  3142. nullpo_retr(-1, sd);
  3143. if (night_flag != 1) {
  3144. map_night_timer(night_timer_tid, 0, 0, 1);
  3145. } else {
  3146. clif_displaymessage(fd, msg_txt(89)); // Night mode is already enabled.
  3147. return -1;
  3148. }
  3149. return 0;
  3150. }
  3151. /*==========================================
  3152. *
  3153. *------------------------------------------*/
  3154. ACMD_FUNC(day)
  3155. {
  3156. nullpo_retr(-1, sd);
  3157. if (night_flag != 0) {
  3158. map_day_timer(day_timer_tid, 0, 0, 1);
  3159. } else {
  3160. clif_displaymessage(fd, msg_txt(90)); // Day mode is already enabled.
  3161. return -1;
  3162. }
  3163. return 0;
  3164. }
  3165. /*==========================================
  3166. *
  3167. *------------------------------------------*/
  3168. ACMD_FUNC(doom)
  3169. {
  3170. struct map_session_data* pl_sd;
  3171. struct s_mapiterator* iter;
  3172. nullpo_retr(-1, sd);
  3173. iter = mapit_getallusers();
  3174. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3175. {
  3176. if (pl_sd->fd != fd && pc_isGM(sd) >= pc_isGM(pl_sd))
  3177. {
  3178. status_kill(&pl_sd->bl);
  3179. clif_specialeffect(&pl_sd->bl,450,AREA);
  3180. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3181. }
  3182. }
  3183. mapit_free(iter);
  3184. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3185. return 0;
  3186. }
  3187. /*==========================================
  3188. *
  3189. *------------------------------------------*/
  3190. ACMD_FUNC(doommap)
  3191. {
  3192. struct map_session_data* pl_sd;
  3193. struct s_mapiterator* iter;
  3194. nullpo_retr(-1, sd);
  3195. iter = mapit_getallusers();
  3196. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3197. {
  3198. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_isGM(sd) >= pc_isGM(pl_sd))
  3199. {
  3200. status_kill(&pl_sd->bl);
  3201. clif_specialeffect(&pl_sd->bl,450,AREA);
  3202. clif_displaymessage(pl_sd->fd, msg_txt(61)); // The holy messenger has given judgement.
  3203. }
  3204. }
  3205. mapit_free(iter);
  3206. clif_displaymessage(fd, msg_txt(62)); // Judgement was made.
  3207. return 0;
  3208. }
  3209. /*==========================================
  3210. *
  3211. *------------------------------------------*/
  3212. static void atcommand_raise_sub(struct map_session_data* sd)
  3213. {
  3214. if (!status_isdead(&sd->bl))
  3215. return;
  3216. if(!status_revive(&sd->bl, 100, 100))
  3217. return;
  3218. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  3219. clif_displaymessage(sd->fd, msg_txt(63)); // Mercy has been shown.
  3220. }
  3221. /*==========================================
  3222. *
  3223. *------------------------------------------*/
  3224. ACMD_FUNC(raise)
  3225. {
  3226. struct map_session_data* pl_sd;
  3227. struct s_mapiterator* iter;
  3228. nullpo_retr(-1, sd);
  3229. iter = mapit_getallusers();
  3230. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3231. atcommand_raise_sub(pl_sd);
  3232. mapit_free(iter);
  3233. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3234. return 0;
  3235. }
  3236. /*==========================================
  3237. *
  3238. *------------------------------------------*/
  3239. ACMD_FUNC(raisemap)
  3240. {
  3241. struct map_session_data* pl_sd;
  3242. struct s_mapiterator* iter;
  3243. nullpo_retr(-1, sd);
  3244. iter = mapit_getallusers();
  3245. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3246. if (sd->bl.m == pl_sd->bl.m)
  3247. atcommand_raise_sub(pl_sd);
  3248. mapit_free(iter);
  3249. clif_displaymessage(fd, msg_txt(64)); // Mercy has been granted.
  3250. return 0;
  3251. }
  3252. /*==========================================
  3253. *
  3254. *------------------------------------------*/
  3255. ACMD_FUNC(kick)
  3256. {
  3257. struct map_session_data *pl_sd;
  3258. nullpo_retr(-1, sd);
  3259. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3260. if (!message || !*message) {
  3261. clif_displaymessage(fd, "Please, enter a player name (usage: @kick <player name/id>).");
  3262. return -1;
  3263. }
  3264. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  3265. {
  3266. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  3267. return -1;
  3268. }
  3269. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  3270. {
  3271. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  3272. return -1;
  3273. }
  3274. clif_GM_kick(sd, pl_sd);
  3275. return 0;
  3276. }
  3277. /*==========================================
  3278. *
  3279. *------------------------------------------*/
  3280. ACMD_FUNC(kickall)
  3281. {
  3282. struct map_session_data* pl_sd;
  3283. struct s_mapiterator* iter;
  3284. nullpo_retr(-1, sd);
  3285. iter = mapit_getallusers();
  3286. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3287. {
  3288. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kick only lower or same gm level
  3289. if (sd->status.account_id != pl_sd->status.account_id)
  3290. clif_GM_kick(NULL, pl_sd);
  3291. }
  3292. }
  3293. mapit_free(iter);
  3294. clif_displaymessage(fd, msg_txt(195)); // All players have been kicked!
  3295. return 0;
  3296. }
  3297. /*==========================================
  3298. *
  3299. *------------------------------------------*/
  3300. ACMD_FUNC(allskill)
  3301. {
  3302. nullpo_retr(-1, sd);
  3303. pc_allskillup(sd); // all skills
  3304. sd->status.skill_point = 0; // 0 skill points
  3305. clif_updatestatus(sd, SP_SKILLPOINT); // update
  3306. clif_displaymessage(fd, msg_txt(76)); // All skills have been added to your skill tree.
  3307. return 0;
  3308. }
  3309. /*==========================================
  3310. *
  3311. *------------------------------------------*/
  3312. ACMD_FUNC(questskill)
  3313. {
  3314. int skill_id;
  3315. nullpo_retr(-1, sd);
  3316. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3317. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
  3318. return -1;
  3319. }
  3320. if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
  3321. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3322. return -1;
  3323. }
  3324. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3325. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3326. return -1;
  3327. }
  3328. if (pc_checkskill(sd, skill_id) > 0) {
  3329. clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill.
  3330. return -1;
  3331. }
  3332. pc_skill(sd, skill_id, 1, 0);
  3333. clif_displaymessage(fd, msg_txt(70)); // You have learned the skill.
  3334. return 0;
  3335. }
  3336. /*==========================================
  3337. *
  3338. *------------------------------------------*/
  3339. ACMD_FUNC(lostskill)
  3340. {
  3341. int skill_id;
  3342. nullpo_retr(-1, sd);
  3343. if (!message || !*message || (skill_id = atoi(message)) < 0) {
  3344. clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
  3345. return -1;
  3346. }
  3347. if (skill_id < 0 && skill_id >= MAX_SKILL) {
  3348. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
  3349. return -1;
  3350. }
  3351. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  3352. clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill.
  3353. return -1;
  3354. }
  3355. if (pc_checkskill(sd, skill_id) == 0) {
  3356. clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill.
  3357. return -1;
  3358. }
  3359. sd->status.skill[skill_id].lv = 0;
  3360. sd->status.skill[skill_id].flag = 0;
  3361. clif_deleteskill(sd,skill_id);
  3362. clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill.
  3363. return 0;
  3364. }
  3365. /*==========================================
  3366. *
  3367. *------------------------------------------*/
  3368. ACMD_FUNC(spiritball)
  3369. {
  3370. int max_spiritballs;
  3371. int number;
  3372. nullpo_retr(-1, sd);
  3373. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  3374. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  3375. {
  3376. char msg[CHAT_SIZE_MAX];
  3377. safesnprintf(msg, sizeof(msg), "Usage: @spiritball <number: 0-%d>", max_spiritballs);
  3378. clif_displaymessage(fd, msg);
  3379. return -1;
  3380. }
  3381. if( sd->spiritball > 0 )
  3382. pc_delspiritball(sd, sd->spiritball, 1);
  3383. sd->spiritball = number;
  3384. clif_spiritball(sd);
  3385. // no message, player can look the difference
  3386. return 0;
  3387. }
  3388. /*==========================================
  3389. *
  3390. *------------------------------------------*/
  3391. ACMD_FUNC(party)
  3392. {
  3393. char party[NAME_LENGTH];
  3394. nullpo_retr(-1, sd);
  3395. memset(party, '\0', sizeof(party));
  3396. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3397. clif_displaymessage(fd, "Please, enter a party name (usage: @party <party_name>).");
  3398. return -1;
  3399. }
  3400. party_create(sd, party, 0, 0);
  3401. return 0;
  3402. }
  3403. /*==========================================
  3404. *
  3405. *------------------------------------------*/
  3406. ACMD_FUNC(guild)
  3407. {
  3408. char guild[NAME_LENGTH];
  3409. int prev;
  3410. nullpo_retr(-1, sd);
  3411. memset(guild, '\0', sizeof(guild));
  3412. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3413. clif_displaymessage(fd, "Please, enter a guild name (usage: @guild <guild_name>).");
  3414. return -1;
  3415. }
  3416. prev = battle_config.guild_emperium_check;
  3417. battle_config.guild_emperium_check = 0;
  3418. guild_create(sd, guild);
  3419. battle_config.guild_emperium_check = prev;
  3420. return 0;
  3421. }
  3422. /*==========================================
  3423. *
  3424. *------------------------------------------*/
  3425. ACMD_FUNC(agitstart)
  3426. {
  3427. nullpo_retr(-1, sd);
  3428. if (agit_flag == 1) {
  3429. clif_displaymessage(fd, msg_txt(73)); // War of Emperium is currently in progress.
  3430. return -1;
  3431. }
  3432. agit_flag = 1;
  3433. guild_agit_start();
  3434. clif_displaymessage(fd, msg_txt(72)); // War of Emperium has been initiated.
  3435. return 0;
  3436. }
  3437. /*==========================================
  3438. *
  3439. *------------------------------------------*/
  3440. ACMD_FUNC(agitstart2)
  3441. {
  3442. nullpo_retr(-1, sd);
  3443. if (agit2_flag == 1) {
  3444. clif_displaymessage(fd, msg_txt(404)); // "War of Emperium SE is currently in progress."
  3445. return -1;
  3446. }
  3447. agit2_flag = 1;
  3448. guild_agit2_start();
  3449. clif_displaymessage(fd, msg_txt(403)); // "War of Emperium SE has been initiated."
  3450. return 0;
  3451. }
  3452. /*==========================================
  3453. *
  3454. *------------------------------------------*/
  3455. ACMD_FUNC(agitend)
  3456. {
  3457. nullpo_retr(-1, sd);
  3458. if (agit_flag == 0) {
  3459. clif_displaymessage(fd, msg_txt(75)); // War of Emperium is currently not in progress.
  3460. return -1;
  3461. }
  3462. agit_flag = 0;
  3463. guild_agit_end();
  3464. clif_displaymessage(fd, msg_txt(74)); // War of Emperium has been ended.
  3465. return 0;
  3466. }
  3467. /*==========================================
  3468. *
  3469. *------------------------------------------*/
  3470. ACMD_FUNC(agitend2)
  3471. {
  3472. nullpo_retr(-1, sd);
  3473. if (agit2_flag == 0) {
  3474. clif_displaymessage(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress."
  3475. return -1;
  3476. }
  3477. agit2_flag = 0;
  3478. guild_agit2_end();
  3479. clif_displaymessage(fd, msg_txt(405)); // "War of Emperium SE has been ended."
  3480. return 0;
  3481. }
  3482. /*==========================================
  3483. * @mapexit - shuts down the map server
  3484. *------------------------------------------*/
  3485. ACMD_FUNC(mapexit)
  3486. {
  3487. nullpo_retr(-1, sd);
  3488. do_shutdown();
  3489. return 0;
  3490. }
  3491. /*==========================================
  3492. * idsearch <part_of_name>: revrited by [Yor]
  3493. *------------------------------------------*/
  3494. ACMD_FUNC(idsearch)
  3495. {
  3496. char item_name[100];
  3497. unsigned int i, match;
  3498. struct item_data *item_array[MAX_SEARCH];
  3499. nullpo_retr(-1, sd);
  3500. memset(item_name, '\0', sizeof(item_name));
  3501. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3502. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3503. clif_displaymessage(fd, "Please, enter a part of item name (usage: @idsearch <part_of_item_name>).");
  3504. return -1;
  3505. }
  3506. sprintf(atcmd_output, msg_txt(77), item_name); // The reference result of '%s' (name: id):
  3507. clif_displaymessage(fd, atcmd_output);
  3508. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3509. if (match > MAX_SEARCH) {
  3510. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, match);
  3511. clif_displaymessage(fd, atcmd_output);
  3512. match = MAX_SEARCH;
  3513. }
  3514. for(i = 0; i < match; i++) {
  3515. sprintf(atcmd_output, msg_txt(78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3516. clif_displaymessage(fd, atcmd_output);
  3517. }
  3518. sprintf(atcmd_output, msg_txt(79), match); // It is %d affair above.
  3519. clif_displaymessage(fd, atcmd_output);
  3520. return 0;
  3521. }
  3522. /*==========================================
  3523. * Recall All Characters Online To Your Location
  3524. *------------------------------------------*/
  3525. ACMD_FUNC(recallall)
  3526. {
  3527. struct map_session_data* pl_sd;
  3528. struct s_mapiterator* iter;
  3529. int count;
  3530. nullpo_retr(-1, sd);
  3531. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3532. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3533. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3534. return -1;
  3535. }
  3536. count = 0;
  3537. iter = mapit_getallusers();
  3538. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3539. {
  3540. if (sd->status.account_id != pl_sd->status.account_id && pc_isGM(sd) >= pc_isGM(pl_sd))
  3541. {
  3542. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3543. count++;
  3544. else {
  3545. if (pc_isdead(pl_sd)) { //Wake them up
  3546. pc_setstand(pl_sd);
  3547. pc_setrestartvalue(pl_sd,1);
  3548. }
  3549. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3550. }
  3551. }
  3552. }
  3553. mapit_free(iter);
  3554. clif_displaymessage(fd, msg_txt(92)); // All characters recalled!
  3555. if (count) {
  3556. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3557. clif_displaymessage(fd, atcmd_output);
  3558. }
  3559. return 0;
  3560. }
  3561. /*==========================================
  3562. * Recall online characters of a guild to your location
  3563. *------------------------------------------*/
  3564. ACMD_FUNC(guildrecall)
  3565. {
  3566. struct map_session_data* pl_sd;
  3567. struct s_mapiterator* iter;
  3568. int count;
  3569. char guild_name[NAME_LENGTH];
  3570. struct guild *g;
  3571. nullpo_retr(-1, sd);
  3572. memset(guild_name, '\0', sizeof(guild_name));
  3573. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3574. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3575. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildrecall <guild_name/id>).");
  3576. return -1;
  3577. }
  3578. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3579. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3580. return -1;
  3581. }
  3582. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3583. (g = guild_search(atoi(message))) == NULL)
  3584. {
  3585. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online.
  3586. return -1;
  3587. }
  3588. count = 0;
  3589. iter = mapit_getallusers();
  3590. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3591. {
  3592. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3593. {
  3594. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3595. continue; //Skip GMs greater than you.
  3596. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3597. count++;
  3598. else
  3599. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3600. }
  3601. }
  3602. mapit_free(iter);
  3603. sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position.
  3604. clif_displaymessage(fd, atcmd_output);
  3605. if (count) {
  3606. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3607. clif_displaymessage(fd, atcmd_output);
  3608. }
  3609. return 0;
  3610. }
  3611. /*==========================================
  3612. * Recall online characters of a party to your location
  3613. *------------------------------------------*/
  3614. ACMD_FUNC(partyrecall)
  3615. {
  3616. struct map_session_data* pl_sd;
  3617. struct s_mapiterator* iter;
  3618. char party_name[NAME_LENGTH];
  3619. struct party_data *p;
  3620. int count;
  3621. nullpo_retr(-1, sd);
  3622. memset(party_name, '\0', sizeof(party_name));
  3623. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3624. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3625. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyrecall <party_name/id>).");
  3626. return -1;
  3627. }
  3628. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd)) {
  3629. clif_displaymessage(fd, "You are not authorised to warp somenone to your actual map.");
  3630. return -1;
  3631. }
  3632. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3633. (p = party_search(atoi(message))) == NULL)
  3634. {
  3635. clif_displaymessage(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online.
  3636. return -1;
  3637. }
  3638. count = 0;
  3639. iter = mapit_getallusers();
  3640. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3641. {
  3642. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3643. {
  3644. if (pc_isGM(pl_sd) > pc_isGM(sd))
  3645. continue; //Skip GMs greater than you.
  3646. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd))
  3647. count++;
  3648. else
  3649. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3650. }
  3651. }
  3652. mapit_free(iter);
  3653. sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3654. clif_displaymessage(fd, atcmd_output);
  3655. if (count) {
  3656. sprintf(atcmd_output, "Because you are not authorised to warp from some maps, %d player(s) have not been recalled.", count);
  3657. clif_displaymessage(fd, atcmd_output);
  3658. }
  3659. return 0;
  3660. }
  3661. /*==========================================
  3662. *
  3663. *------------------------------------------*/
  3664. ACMD_FUNC(reloaditemdb)
  3665. {
  3666. nullpo_retr(-1, sd);
  3667. itemdb_reload();
  3668. clif_displaymessage(fd, msg_txt(97)); // Item database has been reloaded.
  3669. return 0;
  3670. }
  3671. /*==========================================
  3672. *
  3673. *------------------------------------------*/
  3674. ACMD_FUNC(reloadmobdb)
  3675. {
  3676. nullpo_retr(-1, sd);
  3677. mob_reload();
  3678. read_petdb();
  3679. merc_reload();
  3680. read_mercenarydb();
  3681. clif_displaymessage(fd, msg_txt(98)); // Monster database has been reloaded.
  3682. return 0;
  3683. }
  3684. /*==========================================
  3685. *
  3686. *------------------------------------------*/
  3687. ACMD_FUNC(reloadskilldb)
  3688. {
  3689. nullpo_retr(-1, sd);
  3690. skill_reload();
  3691. merc_skill_reload();
  3692. read_mercenary_skilldb();
  3693. clif_displaymessage(fd, msg_txt(99)); // Skill database has been reloaded.
  3694. return 0;
  3695. }
  3696. /*==========================================
  3697. * @reloadatcommand - reloads atcommand_athena.conf
  3698. *------------------------------------------*/
  3699. void atcommand_doload();
  3700. ACMD_FUNC(reloadatcommand) {
  3701. atcommand_doload();
  3702. clif_displaymessage(fd, msg_txt(254));
  3703. return 0;
  3704. }
  3705. /*==========================================
  3706. * @reloadbattleconf - reloads battle_athena.conf
  3707. *------------------------------------------*/
  3708. ACMD_FUNC(reloadbattleconf)
  3709. {
  3710. struct Battle_Config prev_config;
  3711. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3712. battle_config_read(BATTLE_CONF_FILENAME);
  3713. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3714. || prev_config.item_rate_common != battle_config.item_rate_common
  3715. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3716. || prev_config.item_rate_card != battle_config.item_rate_card
  3717. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3718. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3719. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3720. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3721. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3722. || prev_config.item_rate_use != battle_config.item_rate_use
  3723. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3724. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3725. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3726. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3727. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3728. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3729. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3730. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3731. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3732. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3733. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3734. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3735. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3736. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3737. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3738. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3739. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3740. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3741. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3742. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3743. )
  3744. { // Exp or Drop rates changed.
  3745. mob_reload(); //Needed as well so rate changes take effect.
  3746. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3747. }
  3748. clif_displaymessage(fd, msg_txt(255));
  3749. return 0;
  3750. }
  3751. /*==========================================
  3752. * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt
  3753. *------------------------------------------*/
  3754. ACMD_FUNC(reloadstatusdb)
  3755. {
  3756. status_readdb();
  3757. clif_displaymessage(fd, msg_txt(256));
  3758. return 0;
  3759. }
  3760. /*==========================================
  3761. * @reloadpcdb - reloads exp.txt skill_tree.txt attr_fix.txt statpoint.txt
  3762. *------------------------------------------*/
  3763. ACMD_FUNC(reloadpcdb)
  3764. {
  3765. pc_readdb();
  3766. clif_displaymessage(fd, msg_txt(257));
  3767. return 0;
  3768. }
  3769. /*==========================================
  3770. * @reloadmotd - reloads motd.txt
  3771. *------------------------------------------*/
  3772. ACMD_FUNC(reloadmotd)
  3773. {
  3774. pc_read_motd();
  3775. clif_displaymessage(fd, msg_txt(268));
  3776. return 0;
  3777. }
  3778. /*==========================================
  3779. * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
  3780. *------------------------------------------*/
  3781. ACMD_FUNC(reloadscript)
  3782. {
  3783. nullpo_retr(-1, sd);
  3784. //atcommand_broadcast( fd, sd, "@broadcast", "eAthena Server is Rehashing..." );
  3785. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3786. //atcommand_broadcast( fd, sd, "@broadcast", "Reloading NPCs..." );
  3787. flush_fifos();
  3788. script_reload();
  3789. npc_reload();
  3790. clif_displaymessage(fd, msg_txt(100)); // Scripts have been reloaded.
  3791. return 0;
  3792. }
  3793. /*==========================================
  3794. * @mapinfo [0-3] <map name> by MC_Cameri
  3795. * => Shows information about the map [map name]
  3796. * 0 = no additional information
  3797. * 1 = Show users in that map and their location
  3798. * 2 = Shows NPCs in that map
  3799. * 3 = Shows the shops/chats in that map (not implemented)
  3800. *------------------------------------------*/
  3801. ACMD_FUNC(mapinfo)
  3802. {
  3803. struct map_session_data* pl_sd;
  3804. struct s_mapiterator* iter;
  3805. struct npc_data *nd = NULL;
  3806. struct chat_data *cd = NULL;
  3807. char direction[12];
  3808. int i, m_id, chat_num, list = 0;
  3809. unsigned short m_index;
  3810. char mapname[24];
  3811. nullpo_retr(-1, sd);
  3812. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3813. memset(mapname, '\0', sizeof(mapname));
  3814. memset(direction, '\0', sizeof(direction));
  3815. sscanf(message, "%d %23[^\n]", &list, mapname);
  3816. if (list < 0 || list > 3) {
  3817. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  3818. return -1;
  3819. }
  3820. if (mapname[0] == '\0') {
  3821. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3822. m_id = map_mapindex2mapid(sd->mapindex);
  3823. } else {
  3824. m_id = map_mapname2mapid(mapname);
  3825. }
  3826. if (m_id < 0) {
  3827. clif_displaymessage(fd, msg_txt(1)); // Map not found.
  3828. return -1;
  3829. }
  3830. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3831. clif_displaymessage(fd, "------ Map Info ------");
  3832. // count chats (for initial message)
  3833. chat_num = 0;
  3834. iter = mapit_getallusers();
  3835. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3836. if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd )
  3837. chat_num++;
  3838. mapit_free(iter);
  3839. 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);
  3840. clif_displaymessage(fd, atcmd_output);
  3841. clif_displaymessage(fd, "------ Map Flags ------");
  3842. if (map[m_id].flag.town)
  3843. clif_displaymessage(fd, "Town Map");
  3844. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3845. clif_displaymessage(fd, "Autotrade Enabled");
  3846. else
  3847. clif_displaymessage(fd, "Autotrade Disabled");
  3848. if (map[m_id].flag.battleground)
  3849. clif_displaymessage(fd, "Battlegrounds ON");
  3850. strcpy(atcmd_output,"PvP Flags: ");
  3851. if (map[m_id].flag.pvp)
  3852. strcat(atcmd_output, "Pvp ON | ");
  3853. if (map[m_id].flag.pvp_noguild)
  3854. strcat(atcmd_output, "NoGuild | ");
  3855. if (map[m_id].flag.pvp_noparty)
  3856. strcat(atcmd_output, "NoParty | ");
  3857. if (map[m_id].flag.pvp_nightmaredrop)
  3858. strcat(atcmd_output, "NightmareDrop | ");
  3859. if (map[m_id].flag.pvp_nocalcrank)
  3860. strcat(atcmd_output, "NoCalcRank | ");
  3861. clif_displaymessage(fd, atcmd_output);
  3862. strcpy(atcmd_output,"GvG Flags: ");
  3863. if (map[m_id].flag.gvg)
  3864. strcat(atcmd_output, "GvG ON | ");
  3865. if (map[m_id].flag.gvg_dungeon)
  3866. strcat(atcmd_output, "GvG Dungeon | ");
  3867. if (map[m_id].flag.gvg_castle)
  3868. strcat(atcmd_output, "GvG Castle | ");
  3869. if (map[m_id].flag.gvg_noparty)
  3870. strcat(atcmd_output, "NoParty | ");
  3871. clif_displaymessage(fd, atcmd_output);
  3872. strcpy(atcmd_output,"Teleport Flags: ");
  3873. if (map[m_id].flag.noteleport)
  3874. strcat(atcmd_output, "NoTeleport | ");
  3875. if (map[m_id].flag.monster_noteleport)
  3876. strcat(atcmd_output, "Monster NoTeleport | ");
  3877. if (map[m_id].flag.nowarp)
  3878. strcat(atcmd_output, "NoWarp | ");
  3879. if (map[m_id].flag.nowarpto)
  3880. strcat(atcmd_output, "NoWarpTo | ");
  3881. if (map[m_id].flag.noreturn)
  3882. strcat(atcmd_output, "NoReturn | ");
  3883. if (map[m_id].flag.nogo)
  3884. strcat(atcmd_output, "NoGo | ");
  3885. if (map[m_id].flag.nomemo)
  3886. strcat(atcmd_output, "NoMemo | ");
  3887. clif_displaymessage(fd, atcmd_output);
  3888. 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");
  3889. clif_displaymessage(fd, atcmd_output);
  3890. if (map[m_id].flag.nosave) {
  3891. if (!map[m_id].save.map)
  3892. sprintf(atcmd_output, "No Save (Return to last Save Point)");
  3893. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 )
  3894. sprintf(atcmd_output, "No Save, Save Point: %s,Random",mapindex_id2name(map[m_id].save.map));
  3895. else
  3896. sprintf(atcmd_output, "No Save, Save Point: %s,%d,%d",
  3897. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3898. clif_displaymessage(fd, atcmd_output);
  3899. }
  3900. strcpy(atcmd_output,"Weather Flags: ");
  3901. if (map[m_id].flag.snow)
  3902. strcat(atcmd_output, "Snow | ");
  3903. if (map[m_id].flag.fog)
  3904. strcat(atcmd_output, "Fog | ");
  3905. if (map[m_id].flag.sakura)
  3906. strcat(atcmd_output, "Sakura | ");
  3907. if (map[m_id].flag.clouds)
  3908. strcat(atcmd_output, "Clouds | ");
  3909. if (map[m_id].flag.clouds2)
  3910. strcat(atcmd_output, "Clouds2 | ");
  3911. if (map[m_id].flag.fireworks)
  3912. strcat(atcmd_output, "Fireworks | ");
  3913. if (map[m_id].flag.leaves)
  3914. strcat(atcmd_output, "Leaves | ");
  3915. /**
  3916. * No longer available, keeping here just in case it's back someday. [Ind]
  3917. **/
  3918. //if (map[m_id].flag.rain)
  3919. // strcat(atcmd_output, "Rain | ");
  3920. if (map[m_id].flag.nightenabled)
  3921. strcat(atcmd_output, "Displays Night | ");
  3922. clif_displaymessage(fd, atcmd_output);
  3923. strcpy(atcmd_output,"Other Flags: ");
  3924. if (map[m_id].flag.nobranch)
  3925. strcat(atcmd_output, "NoBranch | ");
  3926. if (map[m_id].flag.notrade)
  3927. strcat(atcmd_output, "NoTrade | ");
  3928. if (map[m_id].flag.novending)
  3929. strcat(atcmd_output, "NoVending | ");
  3930. if (map[m_id].flag.nodrop)
  3931. strcat(atcmd_output, "NoDrop | ");
  3932. if (map[m_id].flag.noskill)
  3933. strcat(atcmd_output, "NoSkill | ");
  3934. if (map[m_id].flag.noicewall)
  3935. strcat(atcmd_output, "NoIcewall | ");
  3936. if (map[m_id].flag.allowks)
  3937. strcat(atcmd_output, "AllowKS | ");
  3938. if (map[m_id].flag.reset)
  3939. strcat(atcmd_output, "Reset | ");
  3940. clif_displaymessage(fd, atcmd_output);
  3941. strcpy(atcmd_output,"Other Flags: ");
  3942. if (map[m_id].nocommand)
  3943. strcat(atcmd_output, "NoCommand | ");
  3944. if (map[m_id].flag.nobaseexp)
  3945. strcat(atcmd_output, "NoBaseEXP | ");
  3946. if (map[m_id].flag.nojobexp)
  3947. strcat(atcmd_output, "NoJobEXP | ");
  3948. if (map[m_id].flag.nomobloot)
  3949. strcat(atcmd_output, "NoMobLoot | ");
  3950. if (map[m_id].flag.nomvploot)
  3951. strcat(atcmd_output, "NoMVPLoot | ");
  3952. if (map[m_id].flag.partylock)
  3953. strcat(atcmd_output, "PartyLock | ");
  3954. if (map[m_id].flag.guildlock)
  3955. strcat(atcmd_output, "GuildLock | ");
  3956. clif_displaymessage(fd, atcmd_output);
  3957. switch (list) {
  3958. case 0:
  3959. // Do nothing. It's list 0, no additional display.
  3960. break;
  3961. case 1:
  3962. clif_displaymessage(fd, "----- Players in Map -----");
  3963. iter = mapit_getallusers();
  3964. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3965. {
  3966. if (pl_sd->mapindex == m_index) {
  3967. sprintf(atcmd_output, "Player '%s' (session #%d) | Location: %d,%d",
  3968. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3969. clif_displaymessage(fd, atcmd_output);
  3970. }
  3971. }
  3972. mapit_free(iter);
  3973. break;
  3974. case 2:
  3975. clif_displaymessage(fd, "----- NPCs in Map -----");
  3976. for (i = 0; i < map[m_id].npc_num;)
  3977. {
  3978. nd = map[m_id].npc[i];
  3979. switch(nd->ud.dir) {
  3980. case 0: strcpy(direction, "North"); break;
  3981. case 1: strcpy(direction, "North West"); break;
  3982. case 2: strcpy(direction, "West"); break;
  3983. case 3: strcpy(direction, "South West"); break;
  3984. case 4: strcpy(direction, "South"); break;
  3985. case 5: strcpy(direction, "South East"); break;
  3986. case 6: strcpy(direction, "East"); break;
  3987. case 7: strcpy(direction, "North East"); break;
  3988. case 9: strcpy(direction, "North"); break;
  3989. default: strcpy(direction, "Unknown"); break;
  3990. }
  3991. sprintf(atcmd_output, "NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d",
  3992. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3993. clif_displaymessage(fd, atcmd_output);
  3994. }
  3995. break;
  3996. case 3:
  3997. clif_displaymessage(fd, "----- Chats in Map -----");
  3998. iter = mapit_getallusers();
  3999. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4000. {
  4001. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  4002. pl_sd->mapindex == m_index &&
  4003. cd->usersd[0] == pl_sd)
  4004. {
  4005. sprintf(atcmd_output, "Chat: %s | Player: %s | Location: %d %d",
  4006. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4007. clif_displaymessage(fd, atcmd_output);
  4008. sprintf(atcmd_output, " Users: %d/%d | Password: %s | Public: %s",
  4009. cd->users, cd->limit, cd->pass, (cd->pub) ? "Yes" : "No");
  4010. clif_displaymessage(fd, atcmd_output);
  4011. }
  4012. }
  4013. mapit_free(iter);
  4014. break;
  4015. default: // normally impossible to arrive here
  4016. clif_displaymessage(fd, "Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
  4017. return -1;
  4018. break;
  4019. }
  4020. return 0;
  4021. }
  4022. /*==========================================
  4023. *
  4024. *------------------------------------------*/
  4025. ACMD_FUNC(mount_peco)
  4026. {
  4027. nullpo_retr(-1, sd);
  4028. if( pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4029. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  4030. clif_displaymessage(sd->fd,"You have mounted your Dragon");
  4031. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  4032. } else {
  4033. clif_displaymessage(sd->fd,"You have released your Dragon");
  4034. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  4035. }
  4036. return 0;
  4037. }
  4038. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4039. if( !(sd->sc.option&OPTION_MADOGEAR) ) {
  4040. clif_displaymessage(sd->fd,"You have mounted your Mado Gear");
  4041. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  4042. } else {
  4043. clif_displaymessage(sd->fd,"You have released your Mado Gear");
  4044. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  4045. }
  4046. return 0;
  4047. }
  4048. if (!pc_isriding(sd)) { // if actually no peco
  4049. if (!pc_checkskill(sd, KN_RIDING))
  4050. {
  4051. clif_displaymessage(fd, msg_txt(213)); // You can not mount a Peco Peco with your current job.
  4052. return -1;
  4053. }
  4054. if (sd->disguise)
  4055. {
  4056. clif_displaymessage(fd, msg_txt(212)); // Cannot mount a Peco Peco while in disguise.
  4057. return -1;
  4058. }
  4059. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4060. clif_displaymessage(fd, msg_txt(102)); // You have mounted a Peco Peco.
  4061. } else { //Dismount
  4062. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4063. clif_displaymessage(fd, msg_txt(214)); // You have released your Peco Peco.
  4064. }
  4065. return 0;
  4066. }
  4067. /*==========================================
  4068. *Spy Commands by Syrus22
  4069. *------------------------------------------*/
  4070. ACMD_FUNC(guildspy)
  4071. {
  4072. char guild_name[NAME_LENGTH];
  4073. struct guild *g;
  4074. nullpo_retr(-1, sd);
  4075. memset(guild_name, '\0', sizeof(guild_name));
  4076. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4077. if (!enable_spy)
  4078. {
  4079. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4080. return -1;
  4081. }
  4082. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4083. clif_displaymessage(fd, "Please, enter a guild name/id (usage: @guildspy <guild_name/id>).");
  4084. return -1;
  4085. }
  4086. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  4087. (g = guild_search(atoi(message))) != NULL) {
  4088. if (sd->guildspy == g->guild_id) {
  4089. sd->guildspy = 0;
  4090. sprintf(atcmd_output, msg_txt(103), g->name); // No longer spying on the %s guild.
  4091. clif_displaymessage(fd, atcmd_output);
  4092. } else {
  4093. sd->guildspy = g->guild_id;
  4094. sprintf(atcmd_output, msg_txt(104), g->name); // Spying on the %s guild.
  4095. clif_displaymessage(fd, atcmd_output);
  4096. }
  4097. } else {
  4098. clif_displaymessage(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online.
  4099. return -1;
  4100. }
  4101. return 0;
  4102. }
  4103. /*==========================================
  4104. *
  4105. *------------------------------------------*/
  4106. ACMD_FUNC(partyspy)
  4107. {
  4108. char party_name[NAME_LENGTH];
  4109. struct party_data *p;
  4110. nullpo_retr(-1, sd);
  4111. memset(party_name, '\0', sizeof(party_name));
  4112. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4113. if (!enable_spy)
  4114. {
  4115. clif_displaymessage(fd, "The mapserver has spy command support disabled.");
  4116. return -1;
  4117. }
  4118. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4119. clif_displaymessage(fd, "Please, enter a party name/id (usage: @partyspy <party_name/id>).");
  4120. return -1;
  4121. }
  4122. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  4123. (p = party_search(atoi(message))) != NULL) {
  4124. if (sd->partyspy == p->party.party_id) {
  4125. sd->partyspy = 0;
  4126. sprintf(atcmd_output, msg_txt(105), p->party.name); // No longer spying on the %s party.
  4127. clif_displaymessage(fd, atcmd_output);
  4128. } else {
  4129. sd->partyspy = p->party.party_id;
  4130. sprintf(atcmd_output, msg_txt(106), p->party.name); // Spying on the %s party.
  4131. clif_displaymessage(fd, atcmd_output);
  4132. }
  4133. } else {
  4134. clif_displaymessage(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online.
  4135. return -1;
  4136. }
  4137. return 0;
  4138. }
  4139. /*==========================================
  4140. * @repairall [Valaris]
  4141. *------------------------------------------*/
  4142. ACMD_FUNC(repairall)
  4143. {
  4144. int count, i;
  4145. nullpo_retr(-1, sd);
  4146. count = 0;
  4147. for (i = 0; i < MAX_INVENTORY; i++) {
  4148. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  4149. sd->status.inventory[i].attribute = 0;
  4150. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  4151. count++;
  4152. }
  4153. }
  4154. if (count > 0) {
  4155. clif_misceffect(&sd->bl, 3);
  4156. clif_equiplist(sd);
  4157. clif_displaymessage(fd, msg_txt(107)); // All items have been repaired.
  4158. } else {
  4159. clif_displaymessage(fd, msg_txt(108)); // No item need to be repaired.
  4160. return -1;
  4161. }
  4162. return 0;
  4163. }
  4164. /*==========================================
  4165. * @nuke [Valaris]
  4166. *------------------------------------------*/
  4167. ACMD_FUNC(nuke)
  4168. {
  4169. struct map_session_data *pl_sd;
  4170. nullpo_retr(-1, sd);
  4171. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4172. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4173. clif_displaymessage(fd, "Please, enter a player name (usage: @nuke <char name>).");
  4174. return -1;
  4175. }
  4176. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  4177. if (pc_isGM(sd) >= pc_isGM(pl_sd)) { // you can kill only lower or same GM level
  4178. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4179. clif_displaymessage(fd, msg_txt(109)); // Player has been nuked!
  4180. } else {
  4181. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4182. return -1;
  4183. }
  4184. } else {
  4185. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4186. return -1;
  4187. }
  4188. return 0;
  4189. }
  4190. /*==========================================
  4191. * @tonpc
  4192. *------------------------------------------*/
  4193. ACMD_FUNC(tonpc)
  4194. {
  4195. char npcname[NAME_LENGTH+1];
  4196. struct npc_data *nd;
  4197. nullpo_retr(-1, sd);
  4198. memset(npcname, 0, sizeof(npcname));
  4199. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  4200. clif_displaymessage(fd, "Please, enter a NPC name (usage: @tonpc <NPC_name>).");
  4201. return -1;
  4202. }
  4203. if ((nd = npc_name2id(npcname)) != NULL) {
  4204. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  4205. clif_displaymessage(fd, msg_txt(0)); // Warped.
  4206. else
  4207. return -1;
  4208. } else {
  4209. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4210. return -1;
  4211. }
  4212. return 0;
  4213. }
  4214. /*==========================================
  4215. *
  4216. *------------------------------------------*/
  4217. ACMD_FUNC(shownpc)
  4218. {
  4219. char NPCname[NAME_LENGTH+1];
  4220. nullpo_retr(-1, sd);
  4221. memset(NPCname, '\0', sizeof(NPCname));
  4222. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4223. clif_displaymessage(fd, "Please, enter a NPC name (usage: @enablenpc <NPC_name>).");
  4224. return -1;
  4225. }
  4226. if (npc_name2id(NPCname) != NULL) {
  4227. npc_enable(NPCname, 1);
  4228. clif_displaymessage(fd, msg_txt(110)); // Npc Enabled.
  4229. } else {
  4230. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4231. return -1;
  4232. }
  4233. return 0;
  4234. }
  4235. /*==========================================
  4236. *
  4237. *------------------------------------------*/
  4238. ACMD_FUNC(hidenpc)
  4239. {
  4240. char NPCname[NAME_LENGTH+1];
  4241. nullpo_retr(-1, sd);
  4242. memset(NPCname, '\0', sizeof(NPCname));
  4243. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  4244. clif_displaymessage(fd, "Please, enter a NPC name (usage: @hidenpc <NPC_name>).");
  4245. return -1;
  4246. }
  4247. if (npc_name2id(NPCname) == NULL) {
  4248. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4249. return -1;
  4250. }
  4251. npc_enable(NPCname, 0);
  4252. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4253. return 0;
  4254. }
  4255. ACMD_FUNC(loadnpc)
  4256. {
  4257. FILE *fp;
  4258. if (!message || !*message) {
  4259. clif_displaymessage(fd, "Please, enter a script file name (usage: @loadnpc <file name>).");
  4260. return -1;
  4261. }
  4262. // check if script file exists
  4263. if ((fp = fopen(message, "r")) == NULL) {
  4264. clif_displaymessage(fd, msg_txt(261));
  4265. return -1;
  4266. }
  4267. fclose(fp);
  4268. // add to list of script sources and run it
  4269. npc_addsrcfile(message);
  4270. npc_parsesrcfile(message);
  4271. npc_read_event_script();
  4272. clif_displaymessage(fd, msg_txt(262));
  4273. return 0;
  4274. }
  4275. ACMD_FUNC(unloadnpc)
  4276. {
  4277. struct npc_data *nd;
  4278. char NPCname[NAME_LENGTH+1];
  4279. nullpo_retr(-1, sd);
  4280. memset(NPCname, '\0', sizeof(NPCname));
  4281. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  4282. clif_displaymessage(fd, "Please, enter a NPC name (usage: @npcoff <NPC_name>).");
  4283. return -1;
  4284. }
  4285. if ((nd = npc_name2id(NPCname)) == NULL) {
  4286. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4287. return -1;
  4288. }
  4289. npc_unload_duplicates(nd);
  4290. npc_unload(nd);
  4291. npc_read_event_script();
  4292. clif_displaymessage(fd, msg_txt(112)); // Npc Disabled.
  4293. return 0;
  4294. }
  4295. /*==========================================
  4296. * time in txt for time command (by [Yor])
  4297. *------------------------------------------*/
  4298. char* txt_time(unsigned int duration)
  4299. {
  4300. int days, hours, minutes, seconds;
  4301. char temp[CHAT_SIZE_MAX];
  4302. static char temp1[CHAT_SIZE_MAX];
  4303. memset(temp, '\0', sizeof(temp));
  4304. memset(temp1, '\0', sizeof(temp1));
  4305. days = duration / (60 * 60 * 24);
  4306. duration = duration - (60 * 60 * 24 * days);
  4307. hours = duration / (60 * 60);
  4308. duration = duration - (60 * 60 * hours);
  4309. minutes = duration / 60;
  4310. seconds = duration - (60 * minutes);
  4311. if (days < 2)
  4312. sprintf(temp, msg_txt(219), days); // %d day
  4313. else
  4314. sprintf(temp, msg_txt(220), days); // %d days
  4315. if (hours < 2)
  4316. sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
  4317. else
  4318. sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
  4319. if (minutes < 2)
  4320. sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
  4321. else
  4322. sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
  4323. if (seconds < 2)
  4324. sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
  4325. else
  4326. sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
  4327. return temp1;
  4328. }
  4329. /*==========================================
  4330. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4331. * Calculation management of GM modification (@day/@night GM commands) is done
  4332. *------------------------------------------*/
  4333. ACMD_FUNC(servertime)
  4334. {
  4335. const struct TimerData * timer_data;
  4336. const struct TimerData * timer_data2;
  4337. time_t time_server; // variable for number of seconds (used with time() function)
  4338. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4339. char temp[CHAT_SIZE_MAX];
  4340. nullpo_retr(-1, sd);
  4341. memset(temp, '\0', sizeof(temp));
  4342. time(&time_server); // get time in seconds since 1/1/1970
  4343. datetime = localtime(&time_server); // convert seconds in structure
  4344. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4345. strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4346. clif_displaymessage(fd, temp);
  4347. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4348. if (night_flag == 0)
  4349. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4350. else
  4351. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4352. } else if (battle_config.night_duration == 0)
  4353. if (night_flag == 1) { // we start with night
  4354. timer_data = get_timer(day_timer_tid);
  4355. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  4356. clif_displaymessage(fd, temp);
  4357. clif_displaymessage(fd, msg_txt(234)); // Game time: After, the game will be in permanent daylight.
  4358. } else
  4359. clif_displaymessage(fd, msg_txt(231)); // Game time: The game is in permanent daylight.
  4360. else if (battle_config.day_duration == 0)
  4361. if (night_flag == 0) { // we start with day
  4362. timer_data = get_timer(night_timer_tid);
  4363. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4364. clif_displaymessage(fd, temp);
  4365. clif_displaymessage(fd, msg_txt(236)); // Game time: After, the game will be in permanent night.
  4366. } else
  4367. clif_displaymessage(fd, msg_txt(232)); // Game time: The game is in permanent night.
  4368. else {
  4369. if (night_flag == 0) {
  4370. timer_data = get_timer(night_timer_tid);
  4371. timer_data2 = get_timer(day_timer_tid);
  4372. sprintf(temp, msg_txt(235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  4373. clif_displaymessage(fd, temp);
  4374. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4375. 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.
  4376. else
  4377. 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.
  4378. clif_displaymessage(fd, temp);
  4379. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4380. clif_displaymessage(fd, temp);
  4381. } else {
  4382. timer_data = get_timer(day_timer_tid);
  4383. timer_data2 = get_timer(night_timer_tid);
  4384. sprintf(temp, msg_txt(233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  4385. clif_displaymessage(fd, temp);
  4386. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4387. 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.
  4388. else
  4389. 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.
  4390. clif_displaymessage(fd, temp);
  4391. sprintf(temp, msg_txt(238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4392. clif_displaymessage(fd, temp);
  4393. }
  4394. }
  4395. return 0;
  4396. }
  4397. //Added by Coltaro
  4398. //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...).
  4399. //Well, using time_t could still work but for some reason that looks like more coding x_x
  4400. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  4401. {
  4402. const int factor_year = 518400; //12*30*24*60 = 518400
  4403. const int factor_month = 43200; //30*24*60 = 43200
  4404. const int factor_day = 1440; //24*60 = 1440
  4405. const int factor_hour = 60;
  4406. *year = jailtime/factor_year;
  4407. jailtime -= *year*factor_year;
  4408. *month = jailtime/factor_month;
  4409. jailtime -= *month*factor_month;
  4410. *day = jailtime/factor_day;
  4411. jailtime -= *day*factor_day;
  4412. *hour = jailtime/factor_hour;
  4413. jailtime -= *hour*factor_hour;
  4414. *minute = jailtime;
  4415. *year = *year > 0? *year : 0;
  4416. *month = *month > 0? *month : 0;
  4417. *day = *day > 0? *day : 0;
  4418. *hour = *hour > 0? *hour : 0;
  4419. *minute = *minute > 0? *minute : 0;
  4420. return;
  4421. }
  4422. /*==========================================
  4423. * @jail <char_name> by [Yor]
  4424. * Special warp! No check with nowarp and nowarpto flag
  4425. *------------------------------------------*/
  4426. ACMD_FUNC(jail)
  4427. {
  4428. struct map_session_data *pl_sd;
  4429. int x, y;
  4430. unsigned short m_index;
  4431. nullpo_retr(-1, sd);
  4432. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4433. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4434. clif_displaymessage(fd, "Please, enter a player name (usage: @jail <char_name>).");
  4435. return -1;
  4436. }
  4437. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4438. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4439. return -1;
  4440. }
  4441. if (pc_isGM(sd) < pc_isGM(pl_sd))
  4442. { // you can jail only lower or same GM
  4443. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4444. return -1;
  4445. }
  4446. if (pl_sd->sc.data[SC_JAILED])
  4447. {
  4448. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4449. return -1;
  4450. }
  4451. switch(rnd() % 2) { //Jail Locations
  4452. case 0:
  4453. m_index = mapindex_name2id(MAP_JAIL);
  4454. x = 24;
  4455. y = 75;
  4456. break;
  4457. default:
  4458. m_index = mapindex_name2id(MAP_JAIL);
  4459. x = 49;
  4460. y = 75;
  4461. break;
  4462. }
  4463. //Duration of INT_MAX to specify infinity.
  4464. sc_start4(&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4465. clif_displaymessage(pl_sd->fd, msg_txt(117)); // GM has send you in jails.
  4466. clif_displaymessage(fd, msg_txt(118)); // Player warped in jails.
  4467. return 0;
  4468. }
  4469. /*==========================================
  4470. * @unjail/@discharge <char_name> by [Yor]
  4471. * Special warp! No check with nowarp and nowarpto flag
  4472. *------------------------------------------*/
  4473. ACMD_FUNC(unjail)
  4474. {
  4475. struct map_session_data *pl_sd;
  4476. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4477. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4478. clif_displaymessage(fd, "Please, enter a player name (usage: @unjail/@discharge <char_name>).");
  4479. return -1;
  4480. }
  4481. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4482. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4483. return -1;
  4484. }
  4485. if (pc_isGM(sd) < pc_isGM(pl_sd)) { // you can jail only lower or same GM
  4486. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4487. return -1;
  4488. }
  4489. if (!pl_sd->sc.data[SC_JAILED])
  4490. {
  4491. clif_displaymessage(fd, msg_txt(119)); // This player is not in jails.
  4492. return -1;
  4493. }
  4494. //Reset jail time to 1 sec.
  4495. sc_start(&pl_sd->bl,SC_JAILED,100,1,1000);
  4496. clif_displaymessage(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail.
  4497. clif_displaymessage(fd, msg_txt(121)); // Player unjailed.
  4498. return 0;
  4499. }
  4500. ACMD_FUNC(jailfor)
  4501. {
  4502. struct map_session_data *pl_sd = NULL;
  4503. int year, month, day, hour, minute, value;
  4504. char * modif_p;
  4505. int jailtime = 0,x,y;
  4506. short m_index = 0;
  4507. nullpo_retr(-1, sd);
  4508. if (!message || !*message || sscanf(message, "%s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4509. clif_displaymessage(fd, msg_txt(400)); //Usage: @jailfor <time> <character name>
  4510. return -1;
  4511. }
  4512. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4513. modif_p = atcmd_output;
  4514. year = month = day = hour = minute = 0;
  4515. while (modif_p[0] != '\0') {
  4516. value = atoi(modif_p);
  4517. if (value == 0)
  4518. modif_p++;
  4519. else {
  4520. if (modif_p[0] == '-' || modif_p[0] == '+')
  4521. modif_p++;
  4522. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  4523. modif_p++;
  4524. if (modif_p[0] == 'n') {
  4525. minute = value;
  4526. modif_p++;
  4527. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  4528. minute = value;
  4529. modif_p = modif_p + 2;
  4530. } else if (modif_p[0] == 'h') {
  4531. hour = value;
  4532. modif_p++;
  4533. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  4534. day = value;
  4535. modif_p++;
  4536. } else if (modif_p[0] == 'm') {
  4537. month = value;
  4538. modif_p++;
  4539. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  4540. year = value;
  4541. modif_p++;
  4542. } else if (modif_p[0] != '\0') {
  4543. modif_p++;
  4544. }
  4545. }
  4546. }
  4547. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  4548. clif_displaymessage(fd, "Invalid time for jail command.");
  4549. return -1;
  4550. }
  4551. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4552. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4553. return -1;
  4554. }
  4555. if (pc_isGM(pl_sd) > pc_isGM(sd)) {
  4556. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  4557. return -1;
  4558. }
  4559. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  4560. if(jailtime==0) {
  4561. clif_displaymessage(fd, "Invalid time for jail command.");
  4562. return -1;
  4563. }
  4564. //Added by Coltaro
  4565. if(pl_sd->sc.data[SC_JAILED] &&
  4566. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  4567. { //Update the player's jail time
  4568. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4569. if (jailtime <= 0) {
  4570. jailtime = 0;
  4571. clif_displaymessage(pl_sd->fd, msg_txt(120)); // GM has discharge you.
  4572. clif_displaymessage(fd, msg_txt(121)); // Player unjailed
  4573. } else {
  4574. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  4575. 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
  4576. clif_displaymessage(pl_sd->fd, atcmd_output);
  4577. 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
  4578. clif_displaymessage(fd, atcmd_output);
  4579. }
  4580. } else if (jailtime < 0) {
  4581. clif_displaymessage(fd, "Invalid time for jail command.");
  4582. return -1;
  4583. }
  4584. //Jail locations, add more as you wish.
  4585. switch(rnd()%2)
  4586. {
  4587. case 1: //Jail #1
  4588. m_index = mapindex_name2id(MAP_JAIL);
  4589. x = 49; y = 75;
  4590. break;
  4591. default: //Default Jail
  4592. m_index = mapindex_name2id(MAP_JAIL);
  4593. x = 24; y = 75;
  4594. break;
  4595. }
  4596. 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).
  4597. return 0;
  4598. }
  4599. //By Coltaro
  4600. ACMD_FUNC(jailtime)
  4601. {
  4602. int year, month, day, hour, minute;
  4603. nullpo_retr(-1, sd);
  4604. if (!sd->sc.data[SC_JAILED]) {
  4605. clif_displaymessage(fd, "You are not in jail."); // You are not in jail.
  4606. return -1;
  4607. }
  4608. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4609. clif_displaymessage(fd, "You have been jailed indefinitely.");
  4610. return 0;
  4611. }
  4612. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4613. clif_displaymessage(fd, "You have been jailed for an unknown amount of time.");
  4614. return -1;
  4615. }
  4616. //Get remaining jail time
  4617. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4618. 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
  4619. clif_displaymessage(fd, atcmd_output);
  4620. return 0;
  4621. }
  4622. /*==========================================
  4623. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4624. *------------------------------------------*/
  4625. ACMD_FUNC(disguise)
  4626. {
  4627. int id = 0;
  4628. nullpo_retr(-1, sd);
  4629. if (!message || !*message) {
  4630. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguise <monster_name_or_monster_ID>).");
  4631. return -1;
  4632. }
  4633. if ((id = atoi(message)) > 0)
  4634. { //Acquired an ID
  4635. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4636. id = 0; //Invalid id for either mobs or npcs.
  4637. } else { //Acquired a Name
  4638. if ((id = mobdb_searchname(message)) == 0)
  4639. {
  4640. struct npc_data* nd = npc_name2id(message);
  4641. if (nd != NULL)
  4642. id = nd->class_;
  4643. }
  4644. }
  4645. if (id == 0)
  4646. {
  4647. clif_displaymessage(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified.
  4648. return -1;
  4649. }
  4650. if(pc_isriding(sd))
  4651. {
  4652. //FIXME: wrong message [ultramage]
  4653. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
  4654. return -1;
  4655. }
  4656. pc_disguise(sd, id);
  4657. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4658. return 0;
  4659. }
  4660. /*==========================================
  4661. * DisguiseAll
  4662. *------------------------------------------*/
  4663. ACMD_FUNC(disguiseall)
  4664. {
  4665. int mob_id=0;
  4666. struct map_session_data *pl_sd;
  4667. struct s_mapiterator* iter;
  4668. nullpo_retr(-1, sd);
  4669. if (!message || !*message) {
  4670. clif_displaymessage(fd, "Please, enter a Monster/NPC name/id (usage: @disguiseall <monster name or monster ID>).");
  4671. return -1;
  4672. }
  4673. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4674. mob_id = atoi(message);
  4675. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4676. clif_displaymessage(fd, msg_txt(123)); // Monster/NPC name/id not found.
  4677. return -1;
  4678. }
  4679. iter = mapit_getallusers();
  4680. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4681. pc_disguise(pl_sd, mob_id);
  4682. mapit_free(iter);
  4683. clif_displaymessage(fd, msg_txt(122)); // Disguise applied.
  4684. return 0;
  4685. }
  4686. /*==========================================
  4687. * @undisguise by [Yor]
  4688. *------------------------------------------*/
  4689. ACMD_FUNC(undisguise)
  4690. {
  4691. nullpo_retr(-1, sd);
  4692. if (sd->disguise) {
  4693. pc_disguise(sd, 0);
  4694. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4695. } else {
  4696. clif_displaymessage(fd, msg_txt(125)); // You're not disguised.
  4697. return -1;
  4698. }
  4699. return 0;
  4700. }
  4701. /*==========================================
  4702. * UndisguiseAll
  4703. *------------------------------------------*/
  4704. ACMD_FUNC(undisguiseall)
  4705. {
  4706. struct map_session_data *pl_sd;
  4707. struct s_mapiterator* iter;
  4708. nullpo_retr(-1, sd);
  4709. iter = mapit_getallusers();
  4710. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4711. if( pl_sd->disguise )
  4712. pc_disguise(pl_sd, 0);
  4713. mapit_free(iter);
  4714. clif_displaymessage(fd, msg_txt(124)); // Undisguise applied.
  4715. return 0;
  4716. }
  4717. /*==========================================
  4718. * @exp by [Skotlex]
  4719. *------------------------------------------*/
  4720. ACMD_FUNC(exp)
  4721. {
  4722. char output[CHAT_SIZE_MAX];
  4723. double nextb, nextj;
  4724. nullpo_retr(-1, sd);
  4725. memset(output, '\0', sizeof(output));
  4726. nextb = pc_nextbaseexp(sd);
  4727. if (nextb)
  4728. nextb = sd->status.base_exp*100.0/nextb;
  4729. nextj = pc_nextjobexp(sd);
  4730. if (nextj)
  4731. nextj = sd->status.job_exp*100.0/nextj;
  4732. sprintf(output, "Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)", sd->status.base_level, nextb, sd->status.job_level, nextj);
  4733. clif_displaymessage(fd, output);
  4734. return 0;
  4735. }
  4736. /*==========================================
  4737. * @broadcast by [Valaris]
  4738. *------------------------------------------*/
  4739. ACMD_FUNC(broadcast)
  4740. {
  4741. nullpo_retr(-1, sd);
  4742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4743. if (!message || !*message) {
  4744. clif_displaymessage(fd, "Please, enter a message (usage: @broadcast <message>).");
  4745. return -1;
  4746. }
  4747. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4748. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4749. return 0;
  4750. }
  4751. /*==========================================
  4752. * @localbroadcast by [Valaris]
  4753. *------------------------------------------*/
  4754. ACMD_FUNC(localbroadcast)
  4755. {
  4756. nullpo_retr(-1, sd);
  4757. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4758. if (!message || !*message) {
  4759. clif_displaymessage(fd, "Please, enter a message (usage: @localbroadcast <message>).");
  4760. return -1;
  4761. }
  4762. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4763. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4764. return 0;
  4765. }
  4766. /*==========================================
  4767. * @email <actual@email> <new@email> by [Yor]
  4768. *------------------------------------------*/
  4769. ACMD_FUNC(email)
  4770. {
  4771. char actual_email[100];
  4772. char new_email[100];
  4773. nullpo_retr(-1, sd);
  4774. memset(actual_email, '\0', sizeof(actual_email));
  4775. memset(new_email, '\0', sizeof(new_email));
  4776. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4777. clif_displaymessage(fd, "Please enter 2 emails (usage: @email <actual@email> <new@email>).");
  4778. return -1;
  4779. }
  4780. if (e_mail_check(actual_email) == 0) {
  4781. clif_displaymessage(fd, msg_txt(144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4782. return -1;
  4783. } else if (e_mail_check(new_email) == 0) {
  4784. clif_displaymessage(fd, msg_txt(145)); // Invalid new email. Please enter a real e-mail.
  4785. return -1;
  4786. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4787. clif_displaymessage(fd, msg_txt(146)); // New email must be a real e-mail.
  4788. return -1;
  4789. } else if (strcmpi(actual_email, new_email) == 0) {
  4790. clif_displaymessage(fd, msg_txt(147)); // New email must be different of the actual e-mail.
  4791. return -1;
  4792. }
  4793. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4794. clif_displaymessage(fd, msg_txt(148)); // Information sended to login-server via char-server.
  4795. return 0;
  4796. }
  4797. /*==========================================
  4798. *@effect
  4799. *------------------------------------------*/
  4800. ACMD_FUNC(effect)
  4801. {
  4802. int type = 0, flag = 0;
  4803. nullpo_retr(-1, sd);
  4804. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4805. clif_displaymessage(fd, "Please, enter an effect number (usage: @effect <effect number>).");
  4806. return -1;
  4807. }
  4808. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4809. clif_displaymessage(fd, msg_txt(229)); // Your effect has changed.
  4810. return 0;
  4811. }
  4812. /*==========================================
  4813. * @killer by MouseJstr
  4814. * enable killing players even when not in pvp
  4815. *------------------------------------------*/
  4816. ACMD_FUNC(killer)
  4817. {
  4818. nullpo_retr(-1, sd);
  4819. sd->state.killer = !sd->state.killer;
  4820. if(sd->state.killer)
  4821. clif_displaymessage(fd, msg_txt(241));
  4822. else {
  4823. clif_displaymessage(fd, msg_txt(287));
  4824. pc_stop_attack(sd);
  4825. }
  4826. return 0;
  4827. }
  4828. /*==========================================
  4829. * @killable by MouseJstr
  4830. * enable other people killing you
  4831. *------------------------------------------*/
  4832. ACMD_FUNC(killable)
  4833. {
  4834. nullpo_retr(-1, sd);
  4835. sd->state.killable = !sd->state.killable;
  4836. if(sd->state.killable)
  4837. clif_displaymessage(fd, msg_txt(242));
  4838. else {
  4839. clif_displaymessage(fd, msg_txt(288));
  4840. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4841. }
  4842. return 0;
  4843. }
  4844. /*==========================================
  4845. * @skillon by MouseJstr
  4846. * turn skills on for the map
  4847. *------------------------------------------*/
  4848. ACMD_FUNC(skillon)
  4849. {
  4850. nullpo_retr(-1, sd);
  4851. map[sd->bl.m].flag.noskill = 0;
  4852. clif_displaymessage(fd, msg_txt(244));
  4853. return 0;
  4854. }
  4855. /*==========================================
  4856. * @skilloff by MouseJstr
  4857. * Turn skills off on the map
  4858. *------------------------------------------*/
  4859. ACMD_FUNC(skilloff)
  4860. {
  4861. nullpo_retr(-1, sd);
  4862. map[sd->bl.m].flag.noskill = 1;
  4863. clif_displaymessage(fd, msg_txt(243));
  4864. return 0;
  4865. }
  4866. /*==========================================
  4867. * @npcmove by MouseJstr
  4868. * move a npc
  4869. *------------------------------------------*/
  4870. ACMD_FUNC(npcmove)
  4871. {
  4872. int x = 0, y = 0, m;
  4873. struct npc_data *nd = 0;
  4874. nullpo_retr(-1, sd);
  4875. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4876. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4877. clif_displaymessage(fd, "Usage: @npcmove <X> <Y> <npc_name>");
  4878. return -1;
  4879. }
  4880. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4881. {
  4882. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist.
  4883. return -1;
  4884. }
  4885. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4886. {
  4887. clif_displaymessage(fd, "NPC is not on this map.");
  4888. return -1; //Not on a map.
  4889. }
  4890. x = cap_value(x, 0, map[m].xs-1);
  4891. y = cap_value(y, 0, map[m].ys-1);
  4892. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4893. map_moveblock(&nd->bl, x, y, gettick());
  4894. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4895. clif_displaymessage(fd, "NPC moved.");
  4896. return 0;
  4897. }
  4898. /*==========================================
  4899. * @addwarp by MouseJstr
  4900. * Create a new static warp point.
  4901. *------------------------------------------*/
  4902. ACMD_FUNC(addwarp)
  4903. {
  4904. char mapname[32];
  4905. int x,y;
  4906. unsigned short m;
  4907. struct npc_data* nd;
  4908. nullpo_retr(-1, sd);
  4909. if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
  4910. clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>.");
  4911. return -1;
  4912. }
  4913. m = mapindex_name2id(mapname);
  4914. if( m == 0 )
  4915. {
  4916. sprintf(atcmd_output, "Unknown map '%s'.", mapname);
  4917. clif_displaymessage(fd, atcmd_output);
  4918. return -1;
  4919. }
  4920. nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4921. if( nd == NULL )
  4922. return -1;
  4923. sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname);
  4924. clif_displaymessage(fd, atcmd_output);
  4925. return 0;
  4926. }
  4927. /*==========================================
  4928. * @follow by [MouseJstr]
  4929. * Follow a player .. staying no more then 5 spaces away
  4930. *------------------------------------------*/
  4931. ACMD_FUNC(follow)
  4932. {
  4933. struct map_session_data *pl_sd = NULL;
  4934. nullpo_retr(-1, sd);
  4935. if (!message || !*message) {
  4936. if (sd->followtarget == -1)
  4937. return -1;
  4938. pc_stop_following (sd);
  4939. clif_displaymessage(fd, "Follow mode OFF.");
  4940. return 0;
  4941. }
  4942. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4943. {
  4944. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  4945. return -1;
  4946. }
  4947. if (sd->followtarget == pl_sd->bl.id) {
  4948. pc_stop_following (sd);
  4949. clif_displaymessage(fd, "Follow mode OFF.");
  4950. } else {
  4951. pc_follow(sd, pl_sd->bl.id);
  4952. clif_displaymessage(fd, "Follow mode ON.");
  4953. }
  4954. return 0;
  4955. }
  4956. /*==========================================
  4957. * @dropall by [MouseJstr]
  4958. * Drop all your possession on the ground
  4959. *------------------------------------------*/
  4960. ACMD_FUNC(dropall)
  4961. {
  4962. int i;
  4963. nullpo_retr(-1, sd);
  4964. for (i = 0; i < MAX_INVENTORY; i++) {
  4965. if (sd->status.inventory[i].amount) {
  4966. if(sd->status.inventory[i].equip != 0)
  4967. pc_unequipitem(sd, i, 3);
  4968. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4969. }
  4970. }
  4971. return 0;
  4972. }
  4973. /*==========================================
  4974. * @storeall by [MouseJstr]
  4975. * Put everything into storage
  4976. *------------------------------------------*/
  4977. ACMD_FUNC(storeall)
  4978. {
  4979. int i;
  4980. nullpo_retr(-1, sd);
  4981. if (sd->state.storage_flag != 1)
  4982. { //Open storage.
  4983. if( storage_storageopen(sd) == 1 ) {
  4984. clif_displaymessage(fd, "You can't open the storage currently.");
  4985. return -1;
  4986. }
  4987. }
  4988. for (i = 0; i < MAX_INVENTORY; i++) {
  4989. if (sd->status.inventory[i].amount) {
  4990. if(sd->status.inventory[i].equip != 0)
  4991. pc_unequipitem(sd, i, 3);
  4992. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4993. }
  4994. }
  4995. storage_storageclose(sd);
  4996. clif_displaymessage(fd, "It is done");
  4997. return 0;
  4998. }
  4999. /*==========================================
  5000. * @skillid by [MouseJstr]
  5001. * lookup a skill by name
  5002. *------------------------------------------*/
  5003. ACMD_FUNC(skillid)
  5004. {
  5005. int skillen, idx;
  5006. nullpo_retr(-1, sd);
  5007. if (!message || !*message)
  5008. {
  5009. clif_displaymessage(fd, "Please enter a skill name to look up (usage: @skillid <skill name>).");
  5010. return -1;
  5011. }
  5012. skillen = strlen(message);
  5013. for (idx = 0; idx < MAX_SKILL_DB; idx++) {
  5014. if (strnicmp(skill_db[idx].name, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0)
  5015. {
  5016. sprintf(atcmd_output, "skill %d: %s", idx, skill_db[idx].desc);
  5017. clif_displaymessage(fd, atcmd_output);
  5018. }
  5019. }
  5020. return 0;
  5021. }
  5022. /*==========================================
  5023. * @useskill by [MouseJstr]
  5024. * A way of using skills without having to find them in the skills menu
  5025. *------------------------------------------*/
  5026. ACMD_FUNC(useskill)
  5027. {
  5028. struct map_session_data *pl_sd = NULL;
  5029. struct block_list *bl;
  5030. int skillnum;
  5031. int skilllv;
  5032. char target[100];
  5033. nullpo_retr(-1, sd);
  5034. if(!message || !*message || sscanf(message, "%d %d %23[^\n]", &skillnum, &skilllv, target) != 3) {
  5035. clif_displaymessage(fd, "Usage: @useskill <skillnum> <skillv> <target>");
  5036. return -1;
  5037. }
  5038. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5039. {
  5040. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5041. return -1;
  5042. }
  5043. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  5044. {
  5045. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  5046. return -1;
  5047. }
  5048. if (skillnum >= HM_SKILLBASE && skillnum < HM_SKILLBASE+MAX_HOMUNSKILL
  5049. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5050. bl = &sd->hd->bl;
  5051. else
  5052. bl = &sd->bl;
  5053. if (skill_get_inf(skillnum)&INF_GROUND_SKILL)
  5054. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skillnum, skilllv);
  5055. else
  5056. unit_skilluse_id(bl, pl_sd->bl.id, skillnum, skilllv);
  5057. return 0;
  5058. }
  5059. /*==========================================
  5060. * @displayskill by [Skotlex]
  5061. * Debug command to locate new skill IDs. It sends the
  5062. * three possible skill-effect packets to the area.
  5063. *------------------------------------------*/
  5064. ACMD_FUNC(displayskill)
  5065. {
  5066. struct status_data * status;
  5067. unsigned int tick;
  5068. int skillnum;
  5069. int skilllv = 1;
  5070. nullpo_retr(-1, sd);
  5071. if (!message || !*message || sscanf(message, "%d %d", &skillnum, &skilllv) < 1)
  5072. {
  5073. clif_displaymessage(fd, "Usage: @displayskill <skillnum> {<skillv>}>");
  5074. return -1;
  5075. }
  5076. status = status_get_status_data(&sd->bl);
  5077. tick = gettick();
  5078. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skillnum, skilllv, 5);
  5079. clif_skill_nodamage(&sd->bl, &sd->bl, skillnum, skilllv, 1);
  5080. clif_skill_poseffect(&sd->bl, skillnum, skilllv, sd->bl.x, sd->bl.y, tick);
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. * @skilltree by [MouseJstr]
  5085. * prints the skill tree for a player required to get to a skill
  5086. *------------------------------------------*/
  5087. ACMD_FUNC(skilltree)
  5088. {
  5089. struct map_session_data *pl_sd = NULL;
  5090. int skillnum;
  5091. int meets, j, c=0;
  5092. char target[NAME_LENGTH];
  5093. struct skill_tree_entry *ent;
  5094. nullpo_retr(-1, sd);
  5095. if(!message || !*message || sscanf(message, "%d %23[^\r\n]", &skillnum, target) != 2) {
  5096. clif_displaymessage(fd, "Usage: @skilltree <skillnum> <target>");
  5097. return -1;
  5098. }
  5099. if ( (pl_sd = map_nick2sd(target)) == NULL )
  5100. {
  5101. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5102. return -1;
  5103. }
  5104. c = pc_calc_skilltree_normalize_job(pl_sd);
  5105. c = pc_mapid2jobid(c, pl_sd->status.sex);
  5106. sprintf(atcmd_output, "Player is using %s skill tree (%d basic points)", job_name(c), pc_checkskill(pl_sd, 1));
  5107. clif_displaymessage(fd, atcmd_output);
  5108. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skillnum );
  5109. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  5110. {
  5111. sprintf(atcmd_output, "I do not believe the player can use that skill");
  5112. clif_displaymessage(fd, atcmd_output);
  5113. return 0;
  5114. }
  5115. ent = &skill_tree[c][j];
  5116. meets = 1;
  5117. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  5118. {
  5119. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  5120. {
  5121. sprintf(atcmd_output, "player requires level %d of skill %s", ent->need[j].lv, skill_db[ent->need[j].id].desc);
  5122. clif_displaymessage(fd, atcmd_output);
  5123. meets = 0;
  5124. }
  5125. }
  5126. if (meets == 1) {
  5127. sprintf(atcmd_output, "I believe the player meets all the requirements for that skill");
  5128. clif_displaymessage(fd, atcmd_output);
  5129. }
  5130. return 0;
  5131. }
  5132. // Hand a ring with partners name on it to this char
  5133. void getring (struct map_session_data* sd)
  5134. {
  5135. int flag, item_id;
  5136. struct item item_tmp;
  5137. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5138. memset(&item_tmp, 0, sizeof(item_tmp));
  5139. item_tmp.nameid = item_id;
  5140. item_tmp.identify = 1;
  5141. item_tmp.card[0] = 255;
  5142. item_tmp.card[2] = sd->status.partner_id;
  5143. item_tmp.card[3] = sd->status.partner_id >> 16;
  5144. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5145. clif_additem(sd,0,0,flag);
  5146. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
  5147. }
  5148. }
  5149. /*==========================================
  5150. * @marry by [MouseJstr], fixed by Lupus
  5151. * Marry two players
  5152. *------------------------------------------*/
  5153. ACMD_FUNC(marry)
  5154. {
  5155. struct map_session_data *pl_sd1 = NULL;
  5156. struct map_session_data *pl_sd2 = NULL;
  5157. char player1[128], player2[128]; //Length used for return error msgs
  5158. nullpo_retr(-1, sd);
  5159. if (!message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", player1, player2) != 2) {
  5160. clif_displaymessage(fd, "Usage: @marry <player1>,<player2>");
  5161. return -1;
  5162. }
  5163. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  5164. sprintf(player2, "Cannot find player '%s' online", player1);
  5165. clif_displaymessage(fd, player2);
  5166. return -1;
  5167. }
  5168. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  5169. sprintf(player1, "Cannot find player '%s' online", player2);
  5170. clif_displaymessage(fd, player1);
  5171. return -1;
  5172. }
  5173. if (pc_marriage(pl_sd1, pl_sd2) == 0) {
  5174. clif_displaymessage(fd, "They are married.. wish them well");
  5175. clif_wedding_effect(&sd->bl); //wedding effect and music [Lupus]
  5176. // Auto-give named rings (Aru)
  5177. getring (pl_sd1);
  5178. getring (pl_sd2);
  5179. return 0;
  5180. }
  5181. clif_displaymessage(fd, "The two cannot wed because one of them is either a baby or is already married.");
  5182. return -1;
  5183. }
  5184. /*==========================================
  5185. * @divorce by [MouseJstr], fixed by [Lupus]
  5186. * divorce two players
  5187. *------------------------------------------*/
  5188. ACMD_FUNC(divorce)
  5189. {
  5190. struct map_session_data *pl_sd = NULL;
  5191. nullpo_retr(-1, sd);
  5192. if (!message || !*message || sscanf(message, "%23[^\r\n]", atcmd_player_name) != 1) {
  5193. clif_displaymessage(fd, "Usage: @divorce <player>.");
  5194. return -1;
  5195. }
  5196. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5197. {
  5198. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5199. return -1;
  5200. }
  5201. if (pc_divorce(pl_sd) != 0) {
  5202. sprintf(atcmd_output, "The divorce has failed.. Cannot find player '%s' or his(her) partner online.", atcmd_player_name);
  5203. clif_displaymessage(fd, atcmd_output);
  5204. return -1;
  5205. }
  5206. sprintf(atcmd_output, "'%s' and his(her) partner are now divorced.", atcmd_player_name);
  5207. clif_displaymessage(fd, atcmd_output);
  5208. return 0;
  5209. }
  5210. /*==========================================
  5211. * @changelook by [Celest]
  5212. *------------------------------------------*/
  5213. ACMD_FUNC(changelook)
  5214. {
  5215. int i, j = 0, k = 0;
  5216. int pos[6] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES };
  5217. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  5218. clif_displaymessage(fd, "Usage: @changelook [<position>] <view id> -- [] = optional");
  5219. clif_displaymessage(fd, "Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield");
  5220. return -1;
  5221. } else if (i == 2) {
  5222. if (j < 1) j = 1;
  5223. else if (j > 6) j = 6; // 6 = Shoes - for beta clients only perhaps
  5224. j = pos[j - 1];
  5225. } else if (i == 1) { // position not defined, use HEAD_TOP as default
  5226. k = j; // swap
  5227. j = LOOK_HEAD_TOP;
  5228. }
  5229. clif_changelook(&sd->bl,j,k);
  5230. return 0;
  5231. }
  5232. /*==========================================
  5233. * @autotrade by durf [Lupus] [Paradox924X]
  5234. * Turns on/off Autotrade for a specific player
  5235. *------------------------------------------*/
  5236. ACMD_FUNC(autotrade)
  5237. {
  5238. nullpo_retr(-1, sd);
  5239. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5240. clif_displaymessage(fd, "Autotrade is not allowed on this map.");
  5241. return -1;
  5242. }
  5243. if( pc_isdead(sd) ) {
  5244. clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
  5245. return -1;
  5246. }
  5247. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5248. clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
  5249. return -1;
  5250. }
  5251. sd->state.autotrade = 1;
  5252. if( battle_config.at_timeout )
  5253. {
  5254. int timeout = atoi(message);
  5255. 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);
  5256. }
  5257. clif_authfail_fd(fd, 15);
  5258. return 0;
  5259. }
  5260. /*==========================================
  5261. * @changegm by durf (changed by Lupus)
  5262. * Changes Master of your Guild to a specified guild member
  5263. *------------------------------------------*/
  5264. ACMD_FUNC(changegm)
  5265. {
  5266. struct guild *g;
  5267. struct map_session_data *pl_sd;
  5268. nullpo_retr(-1, sd);
  5269. if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL || strcmp(g->master,sd->status.name))
  5270. {
  5271. clif_displaymessage(fd, "You need to be a Guild Master to use this command.");
  5272. return -1;
  5273. }
  5274. if( map[sd->bl.m].flag.guildlock )
  5275. {
  5276. clif_displaymessage(fd, "You cannot change guild leaders on this map.");
  5277. return -1;
  5278. }
  5279. if( !message[0] )
  5280. {
  5281. clif_displaymessage(fd, "Command usage: @changegm <guildmember name>");
  5282. return -1;
  5283. }
  5284. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5285. clif_displaymessage(fd, "Target character must be online and be a guildmate.");
  5286. return -1;
  5287. }
  5288. guild_gm_change(sd->status.guild_id, pl_sd);
  5289. return 0;
  5290. }
  5291. /*==========================================
  5292. * @changeleader by Skotlex
  5293. * Changes the leader of a party.
  5294. *------------------------------------------*/
  5295. ACMD_FUNC(changeleader)
  5296. {
  5297. nullpo_retr(-1, sd);
  5298. if( !message[0] )
  5299. {
  5300. clif_displaymessage(fd, "Command usage: @changeleader <party member name>");
  5301. return -1;
  5302. }
  5303. if (party_changeleader(sd, map_nick2sd((char *) message)))
  5304. return 0;
  5305. return -1;
  5306. }
  5307. /*==========================================
  5308. * @partyoption by Skotlex
  5309. * Used to change the item share setting of a party.
  5310. *------------------------------------------*/
  5311. ACMD_FUNC(partyoption)
  5312. {
  5313. struct party_data *p;
  5314. int mi, option;
  5315. char w1[16], w2[16];
  5316. nullpo_retr(-1, sd);
  5317. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5318. {
  5319. clif_displaymessage(fd, msg_txt(282));
  5320. return -1;
  5321. }
  5322. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5323. if (mi == MAX_PARTY)
  5324. return -1; //Shouldn't happen
  5325. if (!p->party.member[mi].leader)
  5326. {
  5327. clif_displaymessage(fd, msg_txt(282));
  5328. return -1;
  5329. }
  5330. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5331. {
  5332. clif_displaymessage(fd, "Command usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>");
  5333. return -1;
  5334. }
  5335. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5336. //Change item share type.
  5337. if (option != p->party.item)
  5338. party_changeoption(sd, p->party.exp, option);
  5339. else
  5340. clif_displaymessage(fd, msg_txt(286));
  5341. return 0;
  5342. }
  5343. /*==========================================
  5344. * @autoloot by Upa-Kun
  5345. * Turns on/off AutoLoot for a specific player
  5346. *------------------------------------------*/
  5347. ACMD_FUNC(autoloot)
  5348. {
  5349. int rate;
  5350. double drate;
  5351. nullpo_retr(-1, sd);
  5352. // autoloot command without value
  5353. if(!message || !*message)
  5354. {
  5355. if (sd->state.autoloot)
  5356. rate = 0;
  5357. else
  5358. rate = 10000;
  5359. } else {
  5360. drate = atof(message);
  5361. rate = (int)(drate*100);
  5362. }
  5363. if (rate < 0) rate = 0;
  5364. if (rate > 10000) rate = 10000;
  5365. sd->state.autoloot = rate;
  5366. if (sd->state.autoloot) {
  5367. snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.",((double)sd->state.autoloot)/100.);
  5368. clif_displaymessage(fd, atcmd_output);
  5369. }else
  5370. clif_displaymessage(fd, "Autoloot is now off.");
  5371. return 0;
  5372. }
  5373. /*==========================================
  5374. * @alootid
  5375. *------------------------------------------*/
  5376. ACMD_FUNC(autolootitem)
  5377. {
  5378. struct item_data *item_data = NULL;
  5379. int i;
  5380. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5381. if (message && *message) {
  5382. if (message[0] == '+') {
  5383. message++;
  5384. action = 1;
  5385. }
  5386. else if (message[0] == '-') {
  5387. message++;
  5388. action = 2;
  5389. }
  5390. else if (!strcmp(message,"reset"))
  5391. action = 4;
  5392. }
  5393. if (action < 3) // add or remove
  5394. {
  5395. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5396. item_data = itemdb_searchname(message);
  5397. if (!item_data) {
  5398. // No items founds in the DB with Id or Name
  5399. clif_displaymessage(fd, "Item not found.");
  5400. return -1;
  5401. }
  5402. }
  5403. switch(action) {
  5404. case 1:
  5405. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5406. if (i != AUTOLOOTITEM_SIZE) {
  5407. clif_displaymessage(fd, "You're already autolooting this item.");
  5408. return -1;
  5409. }
  5410. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5411. if (i == AUTOLOOTITEM_SIZE) {
  5412. clif_displaymessage(fd, "Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.");
  5413. return -1;
  5414. }
  5415. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5416. sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5417. clif_displaymessage(fd, atcmd_output);
  5418. break;
  5419. case 2:
  5420. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5421. if (i == AUTOLOOTITEM_SIZE) {
  5422. clif_displaymessage(fd, "You're currently not autolooting this item.");
  5423. return -1;
  5424. }
  5425. sd->state.autolootid[i] = 0;
  5426. sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
  5427. clif_displaymessage(fd, atcmd_output);
  5428. break;
  5429. case 3:
  5430. sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
  5431. clif_displaymessage(fd, atcmd_output);
  5432. clif_displaymessage(fd, "To add item to the list, use \"@alootid +<item name or ID>\". To remove item use \"@alootid -<item name or ID>\".");
  5433. clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
  5434. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5435. if (i == AUTOLOOTITEM_SIZE) {
  5436. clif_displaymessage(fd, "Your autolootitem list is empty.");
  5437. } else {
  5438. clif_displaymessage(fd, "Items on your autolootitem list:");
  5439. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5440. {
  5441. if (sd->state.autolootid[i] == 0)
  5442. continue;
  5443. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5444. ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
  5445. continue;
  5446. }
  5447. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5448. clif_displaymessage(fd, atcmd_output);
  5449. }
  5450. }
  5451. break;
  5452. case 4:
  5453. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5454. clif_displaymessage(fd, "Your autolootitem list has been reset.");
  5455. break;
  5456. }
  5457. return 0;
  5458. }
  5459. /**
  5460. * No longer available, keeping here just in case it's back someday. [Ind]
  5461. **/
  5462. /*==========================================
  5463. * It is made to rain.
  5464. *------------------------------------------*/
  5465. //ACMD_FUNC(rain)
  5466. //{
  5467. // nullpo_retr(-1, sd);
  5468. // if (map[sd->bl.m].flag.rain) {
  5469. // map[sd->bl.m].flag.rain=0;
  5470. // clif_weather(sd->bl.m);
  5471. // clif_displaymessage(fd, "The rain has stopped.");
  5472. // } else {
  5473. // map[sd->bl.m].flag.rain=1;
  5474. // clif_weather(sd->bl.m);
  5475. // clif_displaymessage(fd, "It is made to rain.");
  5476. // }
  5477. // return 0;
  5478. //}
  5479. /*==========================================
  5480. * It is made to snow.
  5481. *------------------------------------------*/
  5482. ACMD_FUNC(snow)
  5483. {
  5484. nullpo_retr(-1, sd);
  5485. if (map[sd->bl.m].flag.snow) {
  5486. map[sd->bl.m].flag.snow=0;
  5487. clif_weather(sd->bl.m);
  5488. clif_displaymessage(fd, "Snow has stopped falling.");
  5489. } else {
  5490. map[sd->bl.m].flag.snow=1;
  5491. clif_weather(sd->bl.m);
  5492. clif_displaymessage(fd, "It is made to snow.");
  5493. }
  5494. return 0;
  5495. }
  5496. /*==========================================
  5497. * Cherry tree snowstorm is made to fall. (Sakura)
  5498. *------------------------------------------*/
  5499. ACMD_FUNC(sakura)
  5500. {
  5501. nullpo_retr(-1, sd);
  5502. if (map[sd->bl.m].flag.sakura) {
  5503. map[sd->bl.m].flag.sakura=0;
  5504. clif_weather(sd->bl.m);
  5505. clif_displaymessage(fd, "Cherry tree leaves no longer fall.");
  5506. } else {
  5507. map[sd->bl.m].flag.sakura=1;
  5508. clif_weather(sd->bl.m);
  5509. clif_displaymessage(fd, "Cherry tree leaves is made to fall.");
  5510. }
  5511. return 0;
  5512. }
  5513. /*==========================================
  5514. * Clouds appear.
  5515. *------------------------------------------*/
  5516. ACMD_FUNC(clouds)
  5517. {
  5518. nullpo_retr(-1, sd);
  5519. if (map[sd->bl.m].flag.clouds) {
  5520. map[sd->bl.m].flag.clouds=0;
  5521. clif_weather(sd->bl.m);
  5522. clif_displaymessage(fd, "The clouds has disappear.");
  5523. } else {
  5524. map[sd->bl.m].flag.clouds=1;
  5525. clif_weather(sd->bl.m);
  5526. clif_displaymessage(fd, "Clouds appear.");
  5527. }
  5528. return 0;
  5529. }
  5530. /*==========================================
  5531. * Different type of clouds using effect 516
  5532. *------------------------------------------*/
  5533. ACMD_FUNC(clouds2)
  5534. {
  5535. nullpo_retr(-1, sd);
  5536. if (map[sd->bl.m].flag.clouds2) {
  5537. map[sd->bl.m].flag.clouds2=0;
  5538. clif_weather(sd->bl.m);
  5539. clif_displaymessage(fd, "The alternative clouds disappear.");
  5540. } else {
  5541. map[sd->bl.m].flag.clouds2=1;
  5542. clif_weather(sd->bl.m);
  5543. clif_displaymessage(fd, "Alternative clouds appear.");
  5544. }
  5545. return 0;
  5546. }
  5547. /*==========================================
  5548. * Fog hangs over.
  5549. *------------------------------------------*/
  5550. ACMD_FUNC(fog)
  5551. {
  5552. nullpo_retr(-1, sd);
  5553. if (map[sd->bl.m].flag.fog) {
  5554. map[sd->bl.m].flag.fog=0;
  5555. clif_weather(sd->bl.m);
  5556. clif_displaymessage(fd, "The fog has gone.");
  5557. } else {
  5558. map[sd->bl.m].flag.fog=1;
  5559. clif_weather(sd->bl.m);
  5560. clif_displaymessage(fd, "Fog hangs over.");
  5561. }
  5562. return 0;
  5563. }
  5564. /*==========================================
  5565. * Fallen leaves fall.
  5566. *------------------------------------------*/
  5567. ACMD_FUNC(leaves)
  5568. {
  5569. nullpo_retr(-1, sd);
  5570. if (map[sd->bl.m].flag.leaves) {
  5571. map[sd->bl.m].flag.leaves=0;
  5572. clif_weather(sd->bl.m);
  5573. clif_displaymessage(fd, "Leaves no longer fall.");
  5574. } else {
  5575. map[sd->bl.m].flag.leaves=1;
  5576. clif_weather(sd->bl.m);
  5577. clif_displaymessage(fd, "Fallen leaves fall.");
  5578. }
  5579. return 0;
  5580. }
  5581. /*==========================================
  5582. * Fireworks appear.
  5583. *------------------------------------------*/
  5584. ACMD_FUNC(fireworks)
  5585. {
  5586. nullpo_retr(-1, sd);
  5587. if (map[sd->bl.m].flag.fireworks) {
  5588. map[sd->bl.m].flag.fireworks=0;
  5589. clif_weather(sd->bl.m);
  5590. clif_displaymessage(fd, "Fireworks are ended.");
  5591. } else {
  5592. map[sd->bl.m].flag.fireworks=1;
  5593. clif_weather(sd->bl.m);
  5594. clif_displaymessage(fd, "Fireworks are launched.");
  5595. }
  5596. return 0;
  5597. }
  5598. /*==========================================
  5599. * Clearing Weather Effects by Dexity
  5600. *------------------------------------------*/
  5601. ACMD_FUNC(clearweather)
  5602. {
  5603. nullpo_retr(-1, sd);
  5604. /**
  5605. * No longer available, keeping here just in case it's back someday. [Ind]
  5606. **/
  5607. //map[sd->bl.m].flag.rain=0;
  5608. map[sd->bl.m].flag.snow=0;
  5609. map[sd->bl.m].flag.sakura=0;
  5610. map[sd->bl.m].flag.clouds=0;
  5611. map[sd->bl.m].flag.clouds2=0;
  5612. map[sd->bl.m].flag.fog=0;
  5613. map[sd->bl.m].flag.fireworks=0;
  5614. map[sd->bl.m].flag.leaves=0;
  5615. clif_weather(sd->bl.m);
  5616. clif_displaymessage(fd, msg_txt(291));
  5617. return 0;
  5618. }
  5619. /*===============================================================
  5620. * Sound Command - plays a sound for everyone around! [Codemaster]
  5621. *---------------------------------------------------------------*/
  5622. ACMD_FUNC(sound)
  5623. {
  5624. char sound_file[100];
  5625. memset(sound_file, '\0', sizeof(sound_file));
  5626. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5627. clif_displaymessage(fd, "Please, enter a sound filename. (usage: @sound <filename>)");
  5628. return -1;
  5629. }
  5630. if(strstr(sound_file, ".wav") == NULL)
  5631. strcat(sound_file, ".wav");
  5632. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5633. return 0;
  5634. }
  5635. /*==========================================
  5636. * MOB Search
  5637. *------------------------------------------*/
  5638. ACMD_FUNC(mobsearch)
  5639. {
  5640. char mob_name[100];
  5641. int mob_id;
  5642. int number = 0;
  5643. struct s_mapiterator* it;
  5644. nullpo_retr(-1, sd);
  5645. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5646. clif_displaymessage(fd, "Please, enter a monster name (usage: @mobsearch <monster name>).");
  5647. return -1;
  5648. }
  5649. if ((mob_id = atoi(mob_name)) == 0)
  5650. mob_id = mobdb_searchname(mob_name);
  5651. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5652. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  5653. clif_displaymessage(fd, atcmd_output);
  5654. return -1;
  5655. }
  5656. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5657. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5658. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5659. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s", mob_name, mapindex_id2name(sd->mapindex));
  5660. clif_displaymessage(fd, atcmd_output);
  5661. it = mapit_geteachmob();
  5662. for(;;)
  5663. {
  5664. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5665. if( md == NULL )
  5666. break;// no more mobs
  5667. if( md->bl.m != sd->bl.m )
  5668. continue;
  5669. if( mob_id != -1 && md->class_ != mob_id )
  5670. continue;
  5671. ++number;
  5672. if( md->spawn_timer == INVALID_TIMER )
  5673. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5674. else
  5675. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5676. clif_displaymessage(fd, atcmd_output);
  5677. }
  5678. mapit_free(it);
  5679. return 0;
  5680. }
  5681. /*==========================================
  5682. * @cleanmap - cleans items on the ground
  5683. *------------------------------------------*/
  5684. static int atcommand_cleanmap_sub(struct block_list *bl, va_list ap)
  5685. {
  5686. nullpo_ret(bl);
  5687. map_clearflooritem(bl->id);
  5688. return 0;
  5689. }
  5690. ACMD_FUNC(cleanmap)
  5691. {
  5692. map_foreachinarea(atcommand_cleanmap_sub, sd->bl.m,
  5693. sd->bl.x-AREA_SIZE*2, sd->bl.y-AREA_SIZE*2,
  5694. sd->bl.x+AREA_SIZE*2, sd->bl.y+AREA_SIZE*2,
  5695. BL_ITEM);
  5696. clif_displaymessage(fd, "All dropped items have been cleaned up.");
  5697. return 0;
  5698. }
  5699. /*==========================================
  5700. * make a NPC/PET talk
  5701. * @npctalkc [SnakeDrak]
  5702. *------------------------------------------*/
  5703. ACMD_FUNC(npctalk)
  5704. {
  5705. char name[NAME_LENGTH],mes[100],temp[100];
  5706. struct npc_data *nd;
  5707. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5708. unsigned long color=0;
  5709. if (sd->sc.count && //no "chatting" while muted.
  5710. (sd->sc.data[SC_BERSERK] ||
  5711. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5712. return -1;
  5713. if(!ifcolor) {
  5714. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5715. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalk <npc name>, <message>).");
  5716. return -1;
  5717. }
  5718. }
  5719. else {
  5720. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5721. clif_displaymessage(fd, "Please, enter the correct info (usage: @npctalkc <color> <npc name>, <message>).");
  5722. return -1;
  5723. }
  5724. }
  5725. if (!(nd = npc_name2id(name))) {
  5726. clif_displaymessage(fd, msg_txt(111)); // This NPC doesn't exist
  5727. return -1;
  5728. }
  5729. strtok(name, "#"); // discard extra name identifier if present
  5730. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5731. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5732. else clif_message(&nd->bl, temp);
  5733. return 0;
  5734. }
  5735. ACMD_FUNC(pettalk)
  5736. {
  5737. char mes[100],temp[100];
  5738. struct pet_data *pd;
  5739. nullpo_retr(-1, sd);
  5740. if(!sd->status.pet_id || !(pd=sd->pd))
  5741. {
  5742. clif_displaymessage(fd, msg_txt(184));
  5743. return -1;
  5744. }
  5745. if (sd->sc.count && //no "chatting" while muted.
  5746. (sd->sc.data[SC_BERSERK] ||
  5747. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5748. return -1;
  5749. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5750. clif_displaymessage(fd, "Please, enter a message (usage: @pettalk <message>");
  5751. return -1;
  5752. }
  5753. if (message[0] == '/')
  5754. {// pet emotion processing
  5755. const char* emo[] = {
  5756. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5757. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5758. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5759. "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh",
  5760. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa",
  5761. "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice"
  5762. };
  5763. int i;
  5764. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5765. if( i < ARRAYLENGTH(emo) )
  5766. {
  5767. clif_emotion(&pd->bl, i);
  5768. return 0;
  5769. }
  5770. }
  5771. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5772. clif_message(&pd->bl, temp);
  5773. return 0;
  5774. }
  5775. /// @users - displays the number of players present on each map (and percentage)
  5776. /// #users displays on the target user instead of self
  5777. ACMD_FUNC(users)
  5778. {
  5779. char buf[CHAT_SIZE_MAX];
  5780. int i;
  5781. int users[MAX_MAPINDEX];
  5782. int users_all;
  5783. struct s_mapiterator* iter;
  5784. memset(users, 0, sizeof(users));
  5785. users_all = 0;
  5786. // count users on each map
  5787. iter = mapit_getallusers();
  5788. for(;;)
  5789. {
  5790. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5791. if( sd2 == NULL )
  5792. break;// no more users
  5793. if( sd2->mapindex >= MAX_MAPINDEX )
  5794. continue;// invalid mapindex
  5795. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5796. if( users_all < INT_MAX ) ++users_all;
  5797. }
  5798. mapit_free(iter);
  5799. // display results for each map
  5800. for( i = 0; i < MAX_MAPINDEX; ++i )
  5801. {
  5802. if( users[i] == 0 )
  5803. continue;// empty
  5804. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5805. clif_displaymessage(sd->fd, buf);
  5806. }
  5807. // display overall count
  5808. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5809. clif_displaymessage(sd->fd, buf);
  5810. return 0;
  5811. }
  5812. /*==========================================
  5813. *
  5814. *------------------------------------------*/
  5815. ACMD_FUNC(reset)
  5816. {
  5817. pc_resetstate(sd);
  5818. pc_resetskill(sd,1);
  5819. sprintf(atcmd_output, msg_txt(208), sd->status.name); // '%s' skill and stats points reseted!
  5820. clif_displaymessage(fd, atcmd_output);
  5821. return 0;
  5822. }
  5823. /*==========================================
  5824. *
  5825. *------------------------------------------*/
  5826. ACMD_FUNC(summon)
  5827. {
  5828. char name[NAME_LENGTH];
  5829. int mob_id = 0;
  5830. int duration = 0;
  5831. struct mob_data *md;
  5832. unsigned int tick=gettick();
  5833. nullpo_retr(-1, sd);
  5834. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5835. {
  5836. clif_displaymessage(fd, "Please, enter a monster name (usage: @summon <monster name> [duration]");
  5837. return -1;
  5838. }
  5839. if (duration < 1)
  5840. duration =1;
  5841. else if (duration > 60)
  5842. duration =60;
  5843. if ((mob_id = atoi(name)) == 0)
  5844. mob_id = mobdb_searchname(name);
  5845. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5846. {
  5847. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  5848. return -1;
  5849. }
  5850. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "");
  5851. if(!md)
  5852. return -1;
  5853. md->master_id=sd->bl.id;
  5854. md->special_state.ai=1;
  5855. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5856. clif_specialeffect(&md->bl,344,AREA);
  5857. mob_spawn(md);
  5858. sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5859. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5860. clif_displaymessage(fd, msg_txt(39)); // All monster summoned!
  5861. return 0;
  5862. }
  5863. /*==========================================
  5864. * @adjcmdlvl by [MouseJstr]
  5865. *
  5866. * Temp adjust the GM level required to use a GM command
  5867. * Useful during beta testing to allow players to use GM commands for short periods of time
  5868. *------------------------------------------*/
  5869. ACMD_FUNC(adjcmdlvl)
  5870. {
  5871. int newlev, newremotelev;
  5872. char name[100];
  5873. AtCommandInfo* cmd;
  5874. nullpo_retr(-1, sd);
  5875. if (!message || !*message || sscanf(message, "%d %d %99s", &newlev, &newremotelev, name) != 3)
  5876. {
  5877. clif_displaymessage(fd, "Usage: @adjcmdlvl <lvl> <remote lvl> <command>.");
  5878. return -1;
  5879. }
  5880. cmd = get_atcommandinfo_byname(name);
  5881. if (cmd == NULL)
  5882. {
  5883. clif_displaymessage(fd, "@command not found.");
  5884. return -1;
  5885. }
  5886. else if (newlev > pc_isGM(sd) || newremotelev > pc_isGM(sd) )
  5887. {
  5888. clif_displaymessage(fd, "You can't make a command require higher GM level than your own.");
  5889. return -1;
  5890. }
  5891. else if (cmd->level > pc_isGM(sd) || cmd->level2 > pc_isGM(sd) )
  5892. {
  5893. clif_displaymessage(fd, "You can't adjust the level of a command which's level is above your own.");
  5894. return -1;
  5895. }
  5896. else
  5897. {
  5898. cmd->level = newlev;
  5899. cmd->level2 = newremotelev;
  5900. clif_displaymessage(fd, "@command level changed.");
  5901. return 0;
  5902. }
  5903. }
  5904. /*==========================================
  5905. * @adjgmlvl by [MouseJstr]
  5906. * Create a temp GM
  5907. * Useful during beta testing to allow players to use GM commands for short periods of time
  5908. *------------------------------------------*/
  5909. ACMD_FUNC(adjgmlvl)
  5910. {
  5911. int newlev;
  5912. char user[NAME_LENGTH];
  5913. struct map_session_data *pl_sd;
  5914. nullpo_retr(-1, sd);
  5915. if (!message || !*message || sscanf(message, "%d %23[^\r\n]", &newlev, user) != 2) {
  5916. clif_displaymessage(fd, "Usage: @adjgmlvl <lvl> <user>.");
  5917. return -1;
  5918. }
  5919. if ( (pl_sd = map_nick2sd(user)) == NULL )
  5920. {
  5921. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5922. return -1;
  5923. }
  5924. pl_sd->gmlevel = newlev;
  5925. return 0;
  5926. }
  5927. /*==========================================
  5928. * @trade by [MouseJstr]
  5929. * Open a trade window with a remote player
  5930. *------------------------------------------*/
  5931. ACMD_FUNC(trade)
  5932. {
  5933. struct map_session_data *pl_sd = NULL;
  5934. nullpo_retr(-1, sd);
  5935. if (!message || !*message) {
  5936. clif_displaymessage(fd, "Please, enter a player name (usage: @trade <player>).");
  5937. return -1;
  5938. }
  5939. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5940. {
  5941. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5942. return -1;
  5943. }
  5944. trade_traderequest(sd, pl_sd);
  5945. return 0;
  5946. }
  5947. /*==========================================
  5948. * @setbattleflag by [MouseJstr]
  5949. * set a battle_config flag without having to reboot
  5950. *------------------------------------------*/
  5951. ACMD_FUNC(setbattleflag)
  5952. {
  5953. char flag[128], value[128];
  5954. nullpo_retr(-1, sd);
  5955. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5956. clif_displaymessage(fd, "Usage: @setbattleflag <flag> <value>.");
  5957. return -1;
  5958. }
  5959. if (battle_set_value(flag, value) == 0)
  5960. {
  5961. clif_displaymessage(fd, "unknown battle_config flag");
  5962. return -1;
  5963. }
  5964. clif_displaymessage(fd, "battle_config set as requested");
  5965. return 0;
  5966. }
  5967. /*==========================================
  5968. * @unmute [Valaris]
  5969. *------------------------------------------*/
  5970. ACMD_FUNC(unmute)
  5971. {
  5972. struct map_session_data *pl_sd = NULL;
  5973. nullpo_retr(-1, sd);
  5974. if (!message || !*message) {
  5975. clif_displaymessage(fd, "Please, enter a player name (usage: @unmute <player>).");
  5976. return -1;
  5977. }
  5978. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5979. {
  5980. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  5981. return -1;
  5982. }
  5983. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5984. clif_displaymessage(sd->fd,"Player is not muted");
  5985. return -1;
  5986. }
  5987. pl_sd->status.manner = 0;
  5988. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5989. clif_displaymessage(sd->fd,"Player unmuted");
  5990. return 0;
  5991. }
  5992. /*==========================================
  5993. * @uptime by MC Cameri
  5994. *------------------------------------------*/
  5995. ACMD_FUNC(uptime)
  5996. {
  5997. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5998. minute = 60, days = 0, hours = 0, minutes = 0;
  5999. nullpo_retr(-1, sd);
  6000. seconds = get_uptime();
  6001. days = seconds/day;
  6002. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6003. hours = seconds/hour;
  6004. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6005. minutes = seconds/minute;
  6006. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6007. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds);
  6008. clif_displaymessage(fd, atcmd_output);
  6009. return 0;
  6010. }
  6011. /*==========================================
  6012. * @changesex <sex>
  6013. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  6014. *------------------------------------------*/
  6015. ACMD_FUNC(changesex)
  6016. {
  6017. nullpo_retr(-1, sd);
  6018. chrif_changesex(sd);
  6019. return 0;
  6020. }
  6021. /*================================================
  6022. * @mute - Mutes a player for a set amount of time
  6023. *------------------------------------------------*/
  6024. ACMD_FUNC(mute)
  6025. {
  6026. struct map_session_data *pl_sd = NULL;
  6027. int manner;
  6028. nullpo_retr(-1, sd);
  6029. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6030. clif_displaymessage(fd, "Usage: @mute <time> <character name>.");
  6031. return -1;
  6032. }
  6033. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  6034. {
  6035. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  6036. return -1;
  6037. }
  6038. if ( pc_isGM(sd) < pc_isGM(pl_sd) )
  6039. {
  6040. clif_displaymessage(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player.
  6041. return -1;
  6042. }
  6043. clif_manner_message(sd, 0);
  6044. clif_manner_message(pl_sd, 5);
  6045. if( pl_sd->status.manner < manner ) {
  6046. pl_sd->status.manner -= manner;
  6047. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6048. } else {
  6049. pl_sd->status.manner = 0;
  6050. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6051. }
  6052. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6053. return 0;
  6054. }
  6055. /*==========================================
  6056. * @refresh (like @jumpto <<yourself>>)
  6057. *------------------------------------------*/
  6058. ACMD_FUNC(refresh)
  6059. {
  6060. nullpo_retr(-1, sd);
  6061. clif_refresh(sd);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * @identify
  6066. * => GM's magnifier.
  6067. *------------------------------------------*/
  6068. ACMD_FUNC(identify)
  6069. {
  6070. int i,num;
  6071. nullpo_retr(-1, sd);
  6072. for(i=num=0;i<MAX_INVENTORY;i++){
  6073. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  6074. num++;
  6075. }
  6076. }
  6077. if (num > 0) {
  6078. clif_item_identify_list(sd);
  6079. } else {
  6080. clif_displaymessage(fd,"There are no items to appraise.");
  6081. }
  6082. return 0;
  6083. }
  6084. /*==========================================
  6085. * @gmotd (Global MOTD)
  6086. * by davidsiaw :P
  6087. *------------------------------------------*/
  6088. ACMD_FUNC(gmotd)
  6089. {
  6090. char buf[CHAT_SIZE_MAX];
  6091. size_t len;
  6092. FILE* fp;
  6093. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6094. {
  6095. while( fgets(buf, sizeof(buf), fp) )
  6096. {
  6097. if( buf[0] == '/' && buf[1] == '/' )
  6098. {
  6099. continue;
  6100. }
  6101. len = strlen(buf);
  6102. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6103. {// strip trailing EOL characters
  6104. len--;
  6105. }
  6106. if( len )
  6107. {
  6108. buf[len] = 0;
  6109. intif_broadcast(buf, len+1, 0);
  6110. }
  6111. }
  6112. fclose(fp);
  6113. }
  6114. return 0;
  6115. }
  6116. ACMD_FUNC(misceffect)
  6117. {
  6118. int effect = 0;
  6119. nullpo_retr(-1, sd);
  6120. if (!message || !*message)
  6121. return -1;
  6122. if (sscanf(message, "%d", &effect) < 1)
  6123. return -1;
  6124. clif_misceffect(&sd->bl,effect);
  6125. return 0;
  6126. }
  6127. /*==========================================
  6128. * MAIL SYSTEM
  6129. *------------------------------------------*/
  6130. ACMD_FUNC(mail)
  6131. {
  6132. nullpo_ret(sd);
  6133. mail_openmail(sd);
  6134. return 0;
  6135. }
  6136. /*==========================================
  6137. * Show Monster DB Info v 1.0
  6138. * originally by [Lupus] eAthena
  6139. *------------------------------------------*/
  6140. ACMD_FUNC(mobinfo)
  6141. {
  6142. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  6143. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  6144. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  6145. char atcmd_output2[CHAT_SIZE_MAX];
  6146. struct item_data *item_data;
  6147. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6148. int count;
  6149. int i, j, k;
  6150. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6151. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6152. if (!message || !*message) {
  6153. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @mobinfo <monster_name_or_monster_ID>).");
  6154. return -1;
  6155. }
  6156. // If monster identifier/name argument is a name
  6157. if ((i = mobdb_checkid(atoi(message))))
  6158. {
  6159. mob_array[0] = mob_db(i);
  6160. count = 1;
  6161. } else
  6162. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6163. if (!count) {
  6164. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6165. return -1;
  6166. }
  6167. if (count > MAX_SEARCH) {
  6168. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6169. clif_displaymessage(fd, atcmd_output);
  6170. count = MAX_SEARCH;
  6171. }
  6172. for (k = 0; k < count; k++) {
  6173. mob = mob_array[k];
  6174. // stats
  6175. if (mob->mexp)
  6176. sprintf(atcmd_output, "MVP Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6177. else
  6178. sprintf(atcmd_output, "Monster: '%s'/'%s'/'%s' (%d)", mob->name, mob->jname, mob->sprite, mob->vd.class_);
  6179. clif_displaymessage(fd, atcmd_output);
  6180. 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);
  6181. clif_displaymessage(fd, atcmd_output);
  6182. sprintf(atcmd_output, " DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d",
  6183. mob->status.def, mob->status.mdef, mob->status.str, mob->status.agi,
  6184. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6185. clif_displaymessage(fd, atcmd_output);
  6186. sprintf(atcmd_output, " ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)",
  6187. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6188. mob->range2 , mob->range3, msize[mob->status.size],
  6189. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6190. clif_displaymessage(fd, atcmd_output);
  6191. // drops
  6192. clif_displaymessage(fd, " Drops:");
  6193. strcpy(atcmd_output, " ");
  6194. j = 0;
  6195. for (i = 0; i < MAX_MOB_DROP; i++) {
  6196. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6197. continue;
  6198. if (item_data->slot)
  6199. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->dropitem[i].p / 100);
  6200. else
  6201. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->dropitem[i].p / 100);
  6202. strcat(atcmd_output, atcmd_output2);
  6203. if (++j % 3 == 0) {
  6204. clif_displaymessage(fd, atcmd_output);
  6205. strcpy(atcmd_output, " ");
  6206. }
  6207. }
  6208. if (j == 0)
  6209. clif_displaymessage(fd, "This monster has no drops.");
  6210. else if (j % 3 != 0)
  6211. clif_displaymessage(fd, atcmd_output);
  6212. // mvp
  6213. if (mob->mexp) {
  6214. sprintf(atcmd_output, " MVP Bonus EXP:%u %02.02f%%", mob->mexp, (float)mob->mexpper / 100);
  6215. clif_displaymessage(fd, atcmd_output);
  6216. strcpy(atcmd_output, " MVP Items:");
  6217. j = 0;
  6218. for (i = 0; i < 3; i++) {
  6219. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6220. continue;
  6221. if (mob->mvpitem[i].p > 0) {
  6222. j++;
  6223. if (j == 1)
  6224. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6225. else
  6226. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  6227. strcat(atcmd_output, atcmd_output2);
  6228. }
  6229. }
  6230. if (j == 0)
  6231. clif_displaymessage(fd, "This monster has no MVP prizes.");
  6232. else
  6233. clif_displaymessage(fd, atcmd_output);
  6234. }
  6235. }
  6236. return 0;
  6237. }
  6238. /*=========================================
  6239. * @showmobs by KarLaeda
  6240. * => For 15 sec displays the mobs on minimap
  6241. *------------------------------------------*/
  6242. ACMD_FUNC(showmobs)
  6243. {
  6244. char mob_name[100];
  6245. int mob_id;
  6246. int number = 0;
  6247. struct s_mapiterator* it;
  6248. nullpo_retr(-1, sd);
  6249. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6250. return -1;
  6251. if((mob_id = atoi(mob_name)) == 0)
  6252. mob_id = mobdb_searchname(mob_name);
  6253. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6254. snprintf(atcmd_output, sizeof atcmd_output, "Invalid mob id %s!",mob_name);
  6255. clif_displaymessage(fd, atcmd_output);
  6256. return 0;
  6257. }
  6258. // Uncomment the following line to show mini-bosses & MVP.
  6259. //#define SHOW_MVP
  6260. #ifndef SHOW_MVP
  6261. if(mob_db(mob_id)->status.mode&MD_BOSS){
  6262. snprintf(atcmd_output, sizeof atcmd_output, "Can't show Boss mobs!");
  6263. clif_displaymessage(fd, atcmd_output);
  6264. return 0;
  6265. }
  6266. #endif
  6267. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6268. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6269. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6270. snprintf(atcmd_output, sizeof atcmd_output, "Mob Search... %s %s",
  6271. mob_name, mapindex_id2name(sd->mapindex));
  6272. clif_displaymessage(fd, atcmd_output);
  6273. it = mapit_geteachmob();
  6274. for(;;)
  6275. {
  6276. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6277. if( md == NULL )
  6278. break;// no more mobs
  6279. if( md->bl.m != sd->bl.m )
  6280. continue;
  6281. if( mob_id != -1 && md->class_ != mob_id )
  6282. continue;
  6283. if( md->special_state.ai || md->master_id )
  6284. continue; // hide slaves and player summoned mobs
  6285. if( md->spawn_timer != INVALID_TIMER )
  6286. continue; // hide mobs waiting for respawn
  6287. ++number;
  6288. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6289. }
  6290. mapit_free(it);
  6291. return 0;
  6292. }
  6293. /*==========================================
  6294. * homunculus level up [orn]
  6295. *------------------------------------------*/
  6296. ACMD_FUNC(homlevel)
  6297. {
  6298. TBL_HOM * hd;
  6299. int level = 0, i = 0;
  6300. nullpo_retr(-1, sd);
  6301. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6302. clif_displaymessage(fd, "Please, enter a level adjustment: (usage: @homlevel <# of levels to level up>.");
  6303. return -1;
  6304. }
  6305. if ( !merc_is_hom_active(sd->hd) ) {
  6306. clif_displaymessage(fd, "You do not have a homunculus.");
  6307. return -1;
  6308. }
  6309. hd = sd->hd;
  6310. for (i = 1; i <= level && hd->exp_next; i++){
  6311. hd->homunculus.exp += hd->exp_next;
  6312. merc_hom_levelup(hd);
  6313. }
  6314. status_calc_homunculus(hd,0);
  6315. status_percent_heal(&hd->bl, 100, 100);
  6316. clif_specialeffect(&hd->bl,568,AREA);
  6317. return 0;
  6318. }
  6319. /*==========================================
  6320. * homunculus evolution H [orn]
  6321. *------------------------------------------*/
  6322. ACMD_FUNC(homevolution)
  6323. {
  6324. nullpo_retr(-1, sd);
  6325. if ( !merc_is_hom_active(sd->hd) ) {
  6326. clif_displaymessage(fd, "You do not have a homunculus.");
  6327. return -1;
  6328. }
  6329. if ( !merc_hom_evolution(sd->hd) ) {
  6330. clif_displaymessage(fd, "Your homunculus doesn't evolve.");
  6331. return -1;
  6332. }
  6333. clif_homskillinfoblock(sd);
  6334. return 0;
  6335. }
  6336. /*==========================================
  6337. * call choosen homunculus [orn]
  6338. *------------------------------------------*/
  6339. ACMD_FUNC(makehomun)
  6340. {
  6341. int homunid;
  6342. nullpo_retr(-1, sd);
  6343. if ( sd->status.hom_id ) {
  6344. clif_displaymessage(fd, msg_txt(450));
  6345. return -1;
  6346. }
  6347. if (!message || !*message) {
  6348. clif_displaymessage(fd, "Please, enter a homunculus id: (usage: @makehomun <homunculus id>.");
  6349. return -1;
  6350. }
  6351. homunid = atoi(message);
  6352. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6353. {
  6354. clif_displaymessage(fd, "Invalid Homunculus id.");
  6355. return -1;
  6356. }
  6357. merc_create_homunculus_request(sd,homunid);
  6358. return 0;
  6359. }
  6360. /*==========================================
  6361. * modify homunculus intimacy [orn]
  6362. *------------------------------------------*/
  6363. ACMD_FUNC(homfriendly)
  6364. {
  6365. int friendly = 0;
  6366. nullpo_retr(-1, sd);
  6367. if ( !merc_is_hom_active(sd->hd) ) {
  6368. clif_displaymessage(fd, "You do not have a homunculus.");
  6369. return -1;
  6370. }
  6371. if (!message || !*message) {
  6372. clif_displaymessage(fd, "Please, enter a friendly value: (usage: @homfriendly <friendly value[0-1000]>.");
  6373. return -1;
  6374. }
  6375. friendly = atoi(message);
  6376. friendly = cap_value(friendly, 0, 1000);
  6377. sd->hd->homunculus.intimacy = friendly * 100 ;
  6378. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6379. return 0;
  6380. }
  6381. /*==========================================
  6382. * modify homunculus hunger [orn]
  6383. *------------------------------------------*/
  6384. ACMD_FUNC(homhungry)
  6385. {
  6386. int hungry = 0;
  6387. nullpo_retr(-1, sd);
  6388. if ( !merc_is_hom_active(sd->hd) ) {
  6389. clif_displaymessage(fd, "You do not have a homunculus.");
  6390. return -1;
  6391. }
  6392. if (!message || !*message) {
  6393. clif_displaymessage(fd, "Please, enter a hunger value: (usage: @homhungry <hunger value[0-100]>.");
  6394. return -1;
  6395. }
  6396. hungry = atoi(message);
  6397. hungry = cap_value(hungry, 0, 100);
  6398. sd->hd->homunculus.hunger = hungry;
  6399. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6400. return 0;
  6401. }
  6402. /*==========================================
  6403. * make the homunculus speak [orn]
  6404. *------------------------------------------*/
  6405. ACMD_FUNC(homtalk)
  6406. {
  6407. char mes[100],temp[100];
  6408. nullpo_retr(-1, sd);
  6409. if (sd->sc.count && //no "chatting" while muted.
  6410. (sd->sc.data[SC_BERSERK] ||
  6411. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6412. return -1;
  6413. if ( !merc_is_hom_active(sd->hd) ) {
  6414. clif_displaymessage(fd, "You do not have a homunculus.");
  6415. return -1;
  6416. }
  6417. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6418. clif_displaymessage(fd, "Please, enter a message (usage: @homtalk <message>");
  6419. return -1;
  6420. }
  6421. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6422. clif_message(&sd->hd->bl, temp);
  6423. return 0;
  6424. }
  6425. /*==========================================
  6426. * Show homunculus stats
  6427. *------------------------------------------*/
  6428. ACMD_FUNC(hominfo)
  6429. {
  6430. struct homun_data *hd;
  6431. struct status_data *status;
  6432. nullpo_retr(-1, sd);
  6433. if ( !merc_is_hom_active(sd->hd) ) {
  6434. clif_displaymessage(fd, "You do not have a homunculus.");
  6435. return -1;
  6436. }
  6437. hd = sd->hd;
  6438. status = status_get_status_data(&hd->bl);
  6439. clif_displaymessage(fd, "Homunculus stats :");
  6440. snprintf(atcmd_output, sizeof(atcmd_output) ,"HP : %d/%d - SP : %d/%d",
  6441. status->hp, status->max_hp, status->sp, status->max_sp);
  6442. clif_displaymessage(fd, atcmd_output);
  6443. snprintf(atcmd_output, sizeof(atcmd_output) ,"ATK : %d - MATK : %d~%d",
  6444. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6445. clif_displaymessage(fd, atcmd_output);
  6446. snprintf(atcmd_output, sizeof(atcmd_output) ,"Hungry : %d - Intimacy : %u",
  6447. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6448. clif_displaymessage(fd, atcmd_output);
  6449. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6450. "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d",
  6451. status->str, status->agi, status->vit,
  6452. status->int_, status->dex, status->luk);
  6453. clif_displaymessage(fd, atcmd_output);
  6454. return 0;
  6455. }
  6456. ACMD_FUNC(homstats)
  6457. {
  6458. struct homun_data *hd;
  6459. struct s_homunculus_db *db;
  6460. struct s_homunculus *hom;
  6461. int lv, min, max, evo;
  6462. nullpo_retr(-1, sd);
  6463. if ( !merc_is_hom_active(sd->hd) ) {
  6464. clif_displaymessage(fd, "You do not have a homunculus.");
  6465. return -1;
  6466. }
  6467. hd = sd->hd;
  6468. hom = &hd->homunculus;
  6469. db = hd->homunculusDB;
  6470. lv = hom->level;
  6471. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6472. "Homunculus growth stats (Lv %d %s):", lv, db->name);
  6473. clif_displaymessage(fd, atcmd_output);
  6474. lv--; //Since the first increase is at level 2.
  6475. evo = (hom->class_ == db->evo_class);
  6476. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6477. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6478. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max HP: %d (%d~%d)", hom->max_hp, min, max);
  6479. clif_displaymessage(fd, atcmd_output);
  6480. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6481. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6482. snprintf(atcmd_output, sizeof(atcmd_output) ,"Max SP: %d (%d~%d)", hom->max_sp, min, max);
  6483. clif_displaymessage(fd, atcmd_output);
  6484. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6485. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6486. snprintf(atcmd_output, sizeof(atcmd_output) ,"Str: %d (%d~%d)", hom->str/10, min, max);
  6487. clif_displaymessage(fd, atcmd_output);
  6488. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6489. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6490. snprintf(atcmd_output, sizeof(atcmd_output) ,"Agi: %d (%d~%d)", hom->agi/10, min, max);
  6491. clif_displaymessage(fd, atcmd_output);
  6492. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6493. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6494. snprintf(atcmd_output, sizeof(atcmd_output) ,"Vit: %d (%d~%d)", hom->vit/10, min, max);
  6495. clif_displaymessage(fd, atcmd_output);
  6496. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6497. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6498. snprintf(atcmd_output, sizeof(atcmd_output) ,"Int: %d (%d~%d)", hom->int_/10, min, max);
  6499. clif_displaymessage(fd, atcmd_output);
  6500. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6501. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6502. snprintf(atcmd_output, sizeof(atcmd_output) ,"Dex: %d (%d~%d)", hom->dex/10, min, max);
  6503. clif_displaymessage(fd, atcmd_output);
  6504. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6505. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6506. snprintf(atcmd_output, sizeof(atcmd_output) ,"Luk: %d (%d~%d)", hom->luk/10, min, max);
  6507. clif_displaymessage(fd, atcmd_output);
  6508. return 0;
  6509. }
  6510. ACMD_FUNC(homshuffle)
  6511. {
  6512. nullpo_retr(-1, sd);
  6513. if(!sd->hd)
  6514. return -1; // nothing to do
  6515. if(!merc_hom_shuffle(sd->hd))
  6516. return -1;
  6517. clif_displaymessage(sd->fd, "[Homunculus Stats Altered]");
  6518. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6519. return 0;
  6520. }
  6521. /*==========================================
  6522. * Show Items DB Info v 1.0
  6523. * originally by [Lupus] eAthena
  6524. *------------------------------------------*/
  6525. ACMD_FUNC(iteminfo)
  6526. {
  6527. struct item_data *item_data, *item_array[MAX_SEARCH];
  6528. int i, count = 1;
  6529. if (!message || !*message) {
  6530. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @ii/@iteminfo <item name or ID>).");
  6531. return -1;
  6532. }
  6533. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6534. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6535. if (!count) {
  6536. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6537. return -1;
  6538. }
  6539. if (count > MAX_SEARCH) {
  6540. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6541. clif_displaymessage(fd, atcmd_output);
  6542. count = MAX_SEARCH;
  6543. }
  6544. for (i = 0; i < count; i++) {
  6545. item_data = item_array[i];
  6546. sprintf(atcmd_output, "Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s",
  6547. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6548. itemdb_typename(item_data->type),
  6549. (item_data->script==NULL)? "None" : "With script"
  6550. );
  6551. clif_displaymessage(fd, atcmd_output);
  6552. sprintf(atcmd_output, "NPC Buy:%dz, Sell:%dz | Weight: %.1f ", item_data->value_buy, item_data->value_sell, item_data->weight/10. );
  6553. clif_displaymessage(fd, atcmd_output);
  6554. if (item_data->maxchance == -1)
  6555. strcpy(atcmd_output, " - Available in the shops only.");
  6556. else if (item_data->maxchance)
  6557. sprintf(atcmd_output, " - Maximal monsters drop chance: %02.02f%%", (float)item_data->maxchance / 100 );
  6558. else
  6559. strcpy(atcmd_output, " - Monsters don't drop this item.");
  6560. clif_displaymessage(fd, atcmd_output);
  6561. }
  6562. return 0;
  6563. }
  6564. /*==========================================
  6565. * Show who drops the item.
  6566. *------------------------------------------*/
  6567. ACMD_FUNC(whodrops)
  6568. {
  6569. struct item_data *item_data, *item_array[MAX_SEARCH];
  6570. int i,j, count = 1;
  6571. if (!message || !*message) {
  6572. clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @whodrops <item name or ID>).");
  6573. return -1;
  6574. }
  6575. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6576. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6577. if (!count) {
  6578. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  6579. return -1;
  6580. }
  6581. if (count > MAX_SEARCH) {
  6582. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6583. clif_displaymessage(fd, atcmd_output);
  6584. count = MAX_SEARCH;
  6585. }
  6586. for (i = 0; i < count; i++) {
  6587. item_data = item_array[i];
  6588. sprintf(atcmd_output, "Item: '%s'[%d]", item_data->jname,item_data->slot);
  6589. clif_displaymessage(fd, atcmd_output);
  6590. if (item_data->mob[0].chance == 0) {
  6591. strcpy(atcmd_output, " - Item is not dropped by mobs.");
  6592. clif_displaymessage(fd, atcmd_output);
  6593. } else {
  6594. sprintf(atcmd_output, "- Common mobs with highest drop chance (only max %d are listed):", MAX_SEARCH);
  6595. clif_displaymessage(fd, atcmd_output);
  6596. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6597. {
  6598. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
  6599. clif_displaymessage(fd, atcmd_output);
  6600. }
  6601. }
  6602. }
  6603. return 0;
  6604. }
  6605. ACMD_FUNC(whereis)
  6606. {
  6607. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6608. int count;
  6609. int i, j, k;
  6610. if (!message || !*message) {
  6611. clif_displaymessage(fd, "Please, enter a Monster/ID (usage: @whereis<monster_name_or_monster_ID>).");
  6612. return -1;
  6613. }
  6614. // If monster identifier/name argument is a name
  6615. if ((i = mobdb_checkid(atoi(message))))
  6616. {
  6617. mob_array[0] = mob_db(i);
  6618. count = 1;
  6619. } else
  6620. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6621. if (!count) {
  6622. clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name.
  6623. return -1;
  6624. }
  6625. if (count > MAX_SEARCH) {
  6626. sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count);
  6627. clif_displaymessage(fd, atcmd_output);
  6628. count = MAX_SEARCH;
  6629. }
  6630. for (k = 0; k < count; k++) {
  6631. mob = mob_array[k];
  6632. snprintf(atcmd_output, sizeof atcmd_output, "%s spawns in:", mob->jname);
  6633. clif_displaymessage(fd, atcmd_output);
  6634. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6635. {
  6636. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6637. if (j < 0) continue;
  6638. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6639. clif_displaymessage(fd, atcmd_output);
  6640. }
  6641. if (i == 0)
  6642. clif_displaymessage(fd, "This monster does not spawn normally.");
  6643. }
  6644. return 0;
  6645. }
  6646. /*==========================================
  6647. * @adopt by [Veider]
  6648. * adopt a novice
  6649. *------------------------------------------*/
  6650. ACMD_FUNC(adopt)
  6651. {
  6652. struct map_session_data *pl_sd1, *pl_sd2, *pl_sd3;
  6653. char player1[NAME_LENGTH], player2[NAME_LENGTH], player3[NAME_LENGTH];
  6654. char output[CHAT_SIZE_MAX];
  6655. nullpo_retr(-1, sd);
  6656. if (!message || !*message || sscanf(message, "%23[^,],%23[^,],%23[^\r\n]", player1, player2, player3) < 3) {
  6657. clif_displaymessage(fd, "usage: @adopt <father>,<mother>,<child>.");
  6658. return -1;
  6659. }
  6660. if (battle_config.etc_log)
  6661. ShowInfo("Adopting: --%s--%s--%s--\n",player1,player2,player3);
  6662. if((pl_sd1=map_nick2sd((char *) player1)) == NULL) {
  6663. sprintf(output, "Cannot find player %s online", player1);
  6664. clif_displaymessage(fd, output);
  6665. return -1;
  6666. }
  6667. if((pl_sd2=map_nick2sd((char *) player2)) == NULL) {
  6668. sprintf(output, "Cannot find player %s online", player2);
  6669. clif_displaymessage(fd, output);
  6670. return -1;
  6671. }
  6672. if((pl_sd3=map_nick2sd((char *) player3)) == NULL) {
  6673. sprintf(output, "Cannot find player %s online", player3);
  6674. clif_displaymessage(fd, output);
  6675. return -1;
  6676. }
  6677. if( !pc_adoption(pl_sd1, pl_sd2, pl_sd3) ) {
  6678. return -1;
  6679. }
  6680. clif_displaymessage(fd, "They are family... wish them luck");
  6681. return 0;
  6682. }
  6683. ACMD_FUNC(version)
  6684. {
  6685. const char * revision;
  6686. if ((revision = get_svn_revision()) != 0) {
  6687. sprintf(atcmd_output,"eAthena Version SVN r%s",revision);
  6688. clif_displaymessage(fd,atcmd_output);
  6689. } else
  6690. clif_displaymessage(fd,"Cannot determine SVN revision");
  6691. return 0;
  6692. }
  6693. /*==========================================
  6694. * @mutearea by MouseJstr
  6695. *------------------------------------------*/
  6696. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6697. {
  6698. int time, id;
  6699. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6700. if (pl_sd == NULL)
  6701. return 0;
  6702. id = va_arg(ap, int);
  6703. time = va_arg(ap, int);
  6704. if (id != bl->id && !pc_isGM(pl_sd)) {
  6705. pl_sd->status.manner -= time;
  6706. if (pl_sd->status.manner < 0)
  6707. sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0);
  6708. else
  6709. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6710. }
  6711. return 0;
  6712. }
  6713. ACMD_FUNC(mutearea)
  6714. {
  6715. int time;
  6716. nullpo_ret(sd);
  6717. if (!message || !*message) {
  6718. clif_displaymessage(fd, "Please, enter a time in minutes (usage: @mutearea/@stfu <time in minutes>.");
  6719. return -1;
  6720. }
  6721. time = atoi(message);
  6722. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6723. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6724. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6725. return 0;
  6726. }
  6727. ACMD_FUNC(rates)
  6728. {
  6729. char buf[CHAT_SIZE_MAX];
  6730. nullpo_ret(sd);
  6731. memset(buf, '\0', sizeof(buf));
  6732. snprintf(buf, CHAT_SIZE_MAX, "Experience rates: Base %.2fx / Job %.2fx",
  6733. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6734. clif_displaymessage(fd, buf);
  6735. snprintf(buf, CHAT_SIZE_MAX, "Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6736. 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.);
  6737. clif_displaymessage(fd, buf);
  6738. snprintf(buf, CHAT_SIZE_MAX, "Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx",
  6739. 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.);
  6740. clif_displaymessage(fd, buf);
  6741. snprintf(buf, CHAT_SIZE_MAX, "Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx",
  6742. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6743. clif_displaymessage(fd, buf);
  6744. return 0;
  6745. }
  6746. /*==========================================
  6747. * @me by lordalfa
  6748. * => Displays the OUTPUT string on top of the Visible players Heads.
  6749. *------------------------------------------*/
  6750. ACMD_FUNC(me)
  6751. {
  6752. char tempmes[CHAT_SIZE_MAX];
  6753. nullpo_retr(-1, sd);
  6754. memset(tempmes, '\0', sizeof(tempmes));
  6755. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6756. if (sd->sc.count && //no "chatting" while muted.
  6757. (sd->sc.data[SC_BERSERK] ||
  6758. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6759. return -1;
  6760. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6761. clif_displaymessage(fd, "Please, enter a message (usage: @me <message>).");
  6762. return -1;
  6763. }
  6764. sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s*
  6765. clif_disp_overhead(sd, atcmd_output);
  6766. return 0;
  6767. }
  6768. /*==========================================
  6769. * @size
  6770. * => Resize your character sprite. [Valaris]
  6771. *------------------------------------------*/
  6772. ACMD_FUNC(size)
  6773. {
  6774. int size=0;
  6775. nullpo_retr(-1, sd);
  6776. size = atoi(message);
  6777. if(sd->state.size) {
  6778. sd->state.size=0;
  6779. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6780. }
  6781. if(size==1) {
  6782. sd->state.size=1;
  6783. clif_specialeffect(&sd->bl,420,AREA);
  6784. } else if(size==2) {
  6785. sd->state.size=2;
  6786. clif_specialeffect(&sd->bl,422,AREA);
  6787. }
  6788. return 0;
  6789. }
  6790. /*==========================================
  6791. * @monsterignore
  6792. * => Makes monsters ignore you. [Valaris]
  6793. *------------------------------------------*/
  6794. ACMD_FUNC(monsterignore)
  6795. {
  6796. nullpo_retr(-1, sd);
  6797. if (!sd->state.monster_ignore) {
  6798. sd->state.monster_ignore = 1;
  6799. clif_displaymessage(sd->fd, "You are now immune to attacks.");
  6800. } else {
  6801. sd->state.monster_ignore = 0;
  6802. clif_displaymessage(sd->fd, "Returned to normal state.");
  6803. }
  6804. return 0;
  6805. }
  6806. /*==========================================
  6807. * @fakename
  6808. * => Gives your character a fake name. [Valaris]
  6809. *------------------------------------------*/
  6810. ACMD_FUNC(fakename)
  6811. {
  6812. nullpo_retr(-1, sd);
  6813. if( !message || !*message )
  6814. {
  6815. if( sd->fakename[0] )
  6816. {
  6817. sd->fakename[0] = '\0';
  6818. clif_charnameack(0, &sd->bl);
  6819. clif_displaymessage(sd->fd, "Returned to real name.");
  6820. return 0;
  6821. }
  6822. clif_displaymessage(sd->fd, "You must enter a name.");
  6823. return -1;
  6824. }
  6825. if( strlen(message) < 2 )
  6826. {
  6827. clif_displaymessage(sd->fd, "Fake name must be at least two characters.");
  6828. return -1;
  6829. }
  6830. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6831. clif_charnameack(0, &sd->bl);
  6832. clif_displaymessage(sd->fd, "Fake name enabled.");
  6833. return 0;
  6834. }
  6835. /*==========================================
  6836. * Ragnarok Resources
  6837. *------------------------------------------*/
  6838. ACMD_FUNC(mapflag) {
  6839. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6840. #define setflag( cmd ) \
  6841. if ( strcmp( flag_name , #cmd ) == 0 && ( flag == 0 || flag == 1 ) ){\
  6842. map[ sd->bl.m ].flag.cmd = flag;\
  6843. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s",#cmd,flag?"On":"Off");\
  6844. clif_displaymessage(sd->fd,atcmd_output);\
  6845. return 0;\
  6846. }
  6847. unsigned char flag_name[100];
  6848. int flag=9,i;
  6849. nullpo_retr(-1, sd);
  6850. memset(flag_name, '\0', sizeof(flag_name));
  6851. if (!message || !*message || (sscanf(message, "%99s %d", flag_name, &flag) < 1)) {
  6852. clif_displaymessage(sd->fd,"Enabled Mapflags in this map:");
  6853. clif_displaymessage(sd->fd,"----------------------------------");
  6854. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6855. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6856. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6857. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6858. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6859. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6860. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6861. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6862. checkflag(nogo); checkflag(nobaseexp);
  6863. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6864. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6865. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6866. clif_displaymessage(sd->fd," ");
  6867. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off 1=On)");
  6868. clif_displaymessage(sd->fd,"Use: \"@mapflag available\" to list the available mapflags");
  6869. return 1;
  6870. }
  6871. for (i = 0; flag_name[i]; i++) flag_name[i] = tolower(flag_name[i]); //lowercase
  6872. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6873. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6874. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6875. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6876. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6877. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6878. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6879. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6880. setflag(nogo); setflag(nobaseexp);
  6881. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6882. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6883. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6884. clif_displaymessage(sd->fd,"Invalid flag name or flag");
  6885. clif_displaymessage(sd->fd,"Usage: \"@mapflag monster_teleport 1\" (0=Off | 1=On)");
  6886. clif_displaymessage(sd->fd,"Available Flags:");
  6887. clif_displaymessage(sd->fd,"----------------------------------");
  6888. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6889. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6890. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6891. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6892. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6893. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6894. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6895. #undef checkflag
  6896. #undef setflag
  6897. return 0;
  6898. }
  6899. /*===================================
  6900. * Remove some messages
  6901. *-----------------------------------*/
  6902. ACMD_FUNC(showexp)
  6903. {
  6904. if (sd->state.showexp) {
  6905. sd->state.showexp = 0;
  6906. clif_displaymessage(fd, "Gained exp will not be shown.");
  6907. return 0;
  6908. }
  6909. sd->state.showexp = 1;
  6910. clif_displaymessage(fd, "Gained exp is now shown");
  6911. return 0;
  6912. }
  6913. ACMD_FUNC(showzeny)
  6914. {
  6915. if (sd->state.showzeny) {
  6916. sd->state.showzeny = 0;
  6917. clif_displaymessage(fd, "Gained zeny will not be shown.");
  6918. return 0;
  6919. }
  6920. sd->state.showzeny = 1;
  6921. clif_displaymessage(fd, "Gained zeny is now shown");
  6922. return 0;
  6923. }
  6924. ACMD_FUNC(showdelay)
  6925. {
  6926. if (sd->state.showdelay) {
  6927. sd->state.showdelay = 0;
  6928. clif_displaymessage(fd, "Skill delay failures won't be shown.");
  6929. return 0;
  6930. }
  6931. sd->state.showdelay = 1;
  6932. clif_displaymessage(fd, "Skill delay failures are shown now.");
  6933. return 0;
  6934. }
  6935. /*==========================================
  6936. * Duel organizing functions [LuzZza]
  6937. *
  6938. * @duel [limit|nick] - create a duel
  6939. * @invite <nick> - invite player
  6940. * @accept - accept invitation
  6941. * @reject - reject invitation
  6942. * @leave - leave duel
  6943. *------------------------------------------*/
  6944. ACMD_FUNC(invite)
  6945. {
  6946. unsigned int did = sd->duel_group;
  6947. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6948. if(did <= 0) {
  6949. // "Duel: @invite without @duel."
  6950. clif_displaymessage(fd, msg_txt(350));
  6951. return 0;
  6952. }
  6953. if(duel_list[did].max_players_limit > 0 &&
  6954. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6955. // "Duel: Limit of players is reached."
  6956. clif_displaymessage(fd, msg_txt(351));
  6957. return 0;
  6958. }
  6959. if(target_sd == NULL) {
  6960. // "Duel: Player not found."
  6961. clif_displaymessage(fd, msg_txt(352));
  6962. return 0;
  6963. }
  6964. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6965. // "Duel: Player already in duel."
  6966. clif_displaymessage(fd, msg_txt(353));
  6967. return 0;
  6968. }
  6969. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6970. {
  6971. sprintf(atcmd_output, msg_txt(364), message);
  6972. clif_displaymessage(fd, atcmd_output);
  6973. return 0;
  6974. }
  6975. duel_invite(did, sd, target_sd);
  6976. // "Duel: Invitation has been sent."
  6977. clif_displaymessage(fd, msg_txt(354));
  6978. return 0;
  6979. }
  6980. ACMD_FUNC(duel)
  6981. {
  6982. char output[CHAT_SIZE_MAX];
  6983. unsigned int maxpl=0, newduel;
  6984. struct map_session_data *target_sd;
  6985. if(sd->duel_group > 0) {
  6986. duel_showinfo(sd->duel_group, sd);
  6987. return 0;
  6988. }
  6989. if(sd->duel_invite > 0) {
  6990. // "Duel: @duel without @reject."
  6991. clif_displaymessage(fd, msg_txt(355));
  6992. return 0;
  6993. }
  6994. if(!duel_checktime(sd)) {
  6995. // "Duel: You can take part in duel only one time per %d minutes."
  6996. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  6997. clif_displaymessage(fd, output);
  6998. return 0;
  6999. }
  7000. if( message[0] ) {
  7001. if(sscanf(message, "%d", &maxpl) >= 1) {
  7002. if(maxpl < 2 || maxpl > 65535) {
  7003. clif_displaymessage(fd, msg_txt(357)); // "Duel: Invalid value."
  7004. return 0;
  7005. }
  7006. duel_create(sd, maxpl);
  7007. } else {
  7008. target_sd = map_nick2sd((char *)message);
  7009. if(target_sd != NULL) {
  7010. if((newduel = duel_create(sd, 2)) != -1) {
  7011. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7012. clif_displaymessage(fd, msg_txt(353)); // "Duel: Player already in duel."
  7013. return 0;
  7014. }
  7015. duel_invite(newduel, sd, target_sd);
  7016. clif_displaymessage(fd, msg_txt(354)); // "Duel: Invitation has been sent."
  7017. }
  7018. } else {
  7019. // "Duel: Player not found."
  7020. clif_displaymessage(fd, msg_txt(352));
  7021. return 0;
  7022. }
  7023. }
  7024. } else
  7025. duel_create(sd, 0);
  7026. return 0;
  7027. }
  7028. ACMD_FUNC(leave)
  7029. {
  7030. if(sd->duel_group <= 0) {
  7031. // "Duel: @leave without @duel."
  7032. clif_displaymessage(fd, msg_txt(358));
  7033. return 0;
  7034. }
  7035. duel_leave(sd->duel_group, sd);
  7036. clif_displaymessage(fd, msg_txt(359)); // "Duel: You left the duel."
  7037. return 0;
  7038. }
  7039. ACMD_FUNC(accept)
  7040. {
  7041. char output[CHAT_SIZE_MAX];
  7042. if(!duel_checktime(sd)) {
  7043. // "Duel: You can take part in duel only one time per %d minutes."
  7044. sprintf(output, msg_txt(356), battle_config.duel_time_interval);
  7045. clif_displaymessage(fd, output);
  7046. return 0;
  7047. }
  7048. if(sd->duel_invite <= 0) {
  7049. // "Duel: @accept without invititation."
  7050. clif_displaymessage(fd, msg_txt(360));
  7051. return 0;
  7052. }
  7053. 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 )
  7054. {
  7055. // "Duel: Limit of players is reached."
  7056. clif_displaymessage(fd, msg_txt(351));
  7057. return 0;
  7058. }
  7059. duel_accept(sd->duel_invite, sd);
  7060. // "Duel: Invitation has been accepted."
  7061. clif_displaymessage(fd, msg_txt(361));
  7062. return 0;
  7063. }
  7064. ACMD_FUNC(reject)
  7065. {
  7066. if(sd->duel_invite <= 0) {
  7067. // "Duel: @reject without invititation."
  7068. clif_displaymessage(fd, msg_txt(362));
  7069. return 0;
  7070. }
  7071. duel_reject(sd->duel_invite, sd);
  7072. // "Duel: Invitation has been rejected."
  7073. clif_displaymessage(fd, msg_txt(363));
  7074. return 0;
  7075. }
  7076. /*===================================
  7077. * Cash Points
  7078. *-----------------------------------*/
  7079. ACMD_FUNC(cash)
  7080. {
  7081. char output[128];
  7082. int value;
  7083. nullpo_retr(-1, sd);
  7084. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7085. clif_displaymessage(fd, "Please, enter an amount.");
  7086. return -1;
  7087. }
  7088. if( !strcmpi(command+1,"cash") )
  7089. {
  7090. if( value > 0 ) {
  7091. pc_getcash(sd, value, 0);
  7092. sprintf(output, msg_txt(505), value, sd->cashPoints);
  7093. clif_disp_onlyself(sd, output, strlen(output));
  7094. } else {
  7095. pc_paycash(sd, -value, 0);
  7096. sprintf(output, msg_txt(410), value, sd->cashPoints);
  7097. clif_disp_onlyself(sd, output, strlen(output));
  7098. }
  7099. }
  7100. else
  7101. { // @points
  7102. if( value > 0 ) {
  7103. pc_getcash(sd, 0, value);
  7104. sprintf(output, msg_txt(506), value, sd->kafraPoints);
  7105. clif_disp_onlyself(sd, output, strlen(output));
  7106. } else {
  7107. pc_paycash(sd, -value, -value);
  7108. sprintf(output, msg_txt(411), -value, sd->kafraPoints);
  7109. clif_disp_onlyself(sd, output, strlen(output));
  7110. }
  7111. }
  7112. return 0;
  7113. }
  7114. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7115. ACMD_FUNC(clone)
  7116. {
  7117. int x=0,y=0,flag=0,master=0,i=0;
  7118. struct map_session_data *pl_sd=NULL;
  7119. if (!message || !*message) {
  7120. clif_displaymessage(sd->fd,"You must enter a name or character ID.");
  7121. return 0;
  7122. }
  7123. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7124. clif_displaymessage(fd, msg_txt(3)); // Character not found.
  7125. return 0;
  7126. }
  7127. if(pc_isGM(pl_sd) > pc_isGM(sd)) {
  7128. clif_displaymessage(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself.
  7129. return 0;
  7130. }
  7131. if (strcmpi(command+1, "clone") == 0)
  7132. flag = 1;
  7133. else if (strcmpi(command+1, "slaveclone") == 0) {
  7134. flag = 2;
  7135. master = sd->bl.id;
  7136. if (battle_config.atc_slave_clone_limit
  7137. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7138. clif_displaymessage(fd, msg_txt(127)); // You've reached your slave clones limit.
  7139. return 0;
  7140. }
  7141. }
  7142. do {
  7143. x = sd->bl.x + (rnd() % 10 - 5);
  7144. y = sd->bl.y + (rnd() % 10 - 5);
  7145. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7146. if (i >= 10) {
  7147. x = sd->bl.x;
  7148. y = sd->bl.y;
  7149. }
  7150. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7151. clif_displaymessage(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7152. return 0;
  7153. }
  7154. clif_displaymessage(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7155. return 0;
  7156. }
  7157. /*===================================
  7158. * Main chat [LuzZza]
  7159. * Usage: @main <on|off|message>
  7160. *-----------------------------------*/
  7161. ACMD_FUNC(main)
  7162. {
  7163. if( message[0] ) {
  7164. if(strcmpi(message, "on") == 0) {
  7165. if(!sd->state.mainchat) {
  7166. sd->state.mainchat = 1;
  7167. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7168. } else {
  7169. clif_displaymessage(fd, msg_txt(381)); // Main chat already activated.
  7170. }
  7171. } else if(strcmpi(message, "off") == 0) {
  7172. if(sd->state.mainchat) {
  7173. sd->state.mainchat = 0;
  7174. clif_displaymessage(fd, msg_txt(382)); // Main chat has been disabled.
  7175. } else {
  7176. clif_displaymessage(fd, msg_txt(383)); // Main chat already disabled.
  7177. }
  7178. } else {
  7179. if(!sd->state.mainchat) {
  7180. sd->state.mainchat = 1;
  7181. clif_displaymessage(fd, msg_txt(380)); // Main chat has been activated.
  7182. }
  7183. if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) {
  7184. clif_displaymessage(fd, msg_txt(387));
  7185. return -1;
  7186. }
  7187. sprintf(atcmd_output, msg_txt(386), sd->status.name, message);
  7188. // I use 0xFE000000 color for signalizing that this message is
  7189. // main chat message. 0xFE000000 is invalid color, same using
  7190. // 0xFF000000 for simple (not colored) GM messages. [LuzZza]
  7191. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, 0xFE000000, 0, 0, 0, 0);
  7192. // Chat logging type 'M' / Main Chat
  7193. 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);
  7194. }
  7195. } else {
  7196. if(sd->state.mainchat)
  7197. clif_displaymessage(fd, msg_txt(384)); // Main chat currently enabled. Usage: @main <on|off>, @main <message>.
  7198. else
  7199. clif_displaymessage(fd, msg_txt(385)); // Main chat currently disabled. Usage: @main <on|off>, @main <message>.
  7200. }
  7201. return 0;
  7202. }
  7203. /*=====================================
  7204. * Autorejecting Invites/Deals [LuzZza]
  7205. * Usage: @noask
  7206. *-------------------------------------*/
  7207. ACMD_FUNC(noask)
  7208. {
  7209. if(sd->state.noask) {
  7210. clif_displaymessage(fd, msg_txt(391)); // Autorejecting is deactivated.
  7211. sd->state.noask = 0;
  7212. } else {
  7213. clif_displaymessage(fd, msg_txt(390)); // Autorejecting is activated.
  7214. sd->state.noask = 1;
  7215. }
  7216. return 0;
  7217. }
  7218. /*=====================================
  7219. * Send a @request message to all GMs of lowest_gm_level.
  7220. * Usage: @request <petition>
  7221. *-------------------------------------*/
  7222. ACMD_FUNC(request)
  7223. {
  7224. if (!message || !*message) {
  7225. clif_displaymessage(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>.
  7226. return -1;
  7227. }
  7228. sprintf(atcmd_output, msg_txt(278), message); // (@request): %s
  7229. intif_wis_message_to_gm(sd->status.name, battle_config.lowest_gm_level, atcmd_output);
  7230. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7231. clif_displaymessage(sd->fd,msg_txt(279)); // @request sent.
  7232. return 0;
  7233. }
  7234. /*==========================================
  7235. * Feel (SG save map) Reset [HiddenDragon]
  7236. *------------------------------------------*/
  7237. ACMD_FUNC(feelreset)
  7238. {
  7239. pc_resetfeel(sd);
  7240. clif_displaymessage(fd, "Reset 'Feeling' maps.");
  7241. return 0;
  7242. }
  7243. /*==========================================
  7244. * AUCTION SYSTEM
  7245. *------------------------------------------*/
  7246. ACMD_FUNC(auction)
  7247. {
  7248. nullpo_ret(sd);
  7249. clif_Auction_openwindow(sd);
  7250. return 0;
  7251. }
  7252. /*==========================================
  7253. * Kill Steal Protection
  7254. *------------------------------------------*/
  7255. ACMD_FUNC(ksprotection)
  7256. {
  7257. nullpo_retr(-1,sd);
  7258. if( sd->state.noks ) {
  7259. sd->state.noks = 0;
  7260. sprintf(atcmd_output, "[ K.S Protection Inactive ]");
  7261. }
  7262. else
  7263. {
  7264. if( !message || !*message || !strcmpi(message, "party") )
  7265. { // Default is Party
  7266. sd->state.noks = 2;
  7267. sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
  7268. }
  7269. else if( !strcmpi(message, "self") )
  7270. {
  7271. sd->state.noks = 1;
  7272. sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
  7273. }
  7274. else if( !strcmpi(message, "guild") )
  7275. {
  7276. sd->state.noks = 3;
  7277. sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
  7278. }
  7279. else
  7280. sprintf(atcmd_output, "Usage: @noks <self|party|guild>");
  7281. }
  7282. clif_displaymessage(fd, atcmd_output);
  7283. return 0;
  7284. }
  7285. /*==========================================
  7286. * Map Kill Steal Protection Setting
  7287. *------------------------------------------*/
  7288. ACMD_FUNC(allowks)
  7289. {
  7290. nullpo_retr(-1,sd);
  7291. if( map[sd->bl.m].flag.allowks ) {
  7292. map[sd->bl.m].flag.allowks = 0;
  7293. sprintf(atcmd_output, "[ Map K.S Protection Active ]");
  7294. } else {
  7295. map[sd->bl.m].flag.allowks = 1;
  7296. sprintf(atcmd_output, "[ Map K.S Protection Inactive ]");
  7297. }
  7298. clif_displaymessage(fd, atcmd_output);
  7299. return 0;
  7300. }
  7301. ACMD_FUNC(resetstat)
  7302. {
  7303. nullpo_retr(-1, sd);
  7304. pc_resetstate(sd);
  7305. sprintf(atcmd_output, msg_txt(207), sd->status.name);
  7306. clif_displaymessage(fd, atcmd_output);
  7307. return 0;
  7308. }
  7309. ACMD_FUNC(resetskill)
  7310. {
  7311. nullpo_retr(-1,sd);
  7312. pc_resetskill(sd,1);
  7313. sprintf(atcmd_output, msg_txt(206), sd->status.name);
  7314. clif_displaymessage(fd, atcmd_output);
  7315. return 0;
  7316. }
  7317. /*==========================================
  7318. * #storagelist: Displays the items list of a player's storage.
  7319. * #cartlist: Displays contents of target's cart.
  7320. * #itemlist: Displays contents of target's inventory.
  7321. *------------------------------------------*/
  7322. ACMD_FUNC(itemlist)
  7323. {
  7324. int i, j, count, counter;
  7325. const char* location;
  7326. const struct item* items;
  7327. int size;
  7328. StringBuf buf;
  7329. nullpo_retr(-1, sd);
  7330. if( strcmp(command+1, "storagelist") == 0 )
  7331. {
  7332. location = "storage";
  7333. items = sd->status.storage.items;
  7334. size = MAX_STORAGE;
  7335. }
  7336. else
  7337. if( strcmp(command+1, "cartlist") == 0 )
  7338. {
  7339. location = "cart";
  7340. items = sd->status.cart;
  7341. size = MAX_CART;
  7342. }
  7343. else
  7344. if( strcmp(command+1, "itemlist") == 0 )
  7345. {
  7346. location = "inventory";
  7347. items = sd->status.inventory;
  7348. size = MAX_INVENTORY;
  7349. }
  7350. else
  7351. return 1;
  7352. StringBuf_Init(&buf);
  7353. count = 0; // total slots occupied
  7354. counter = 0; // total items found
  7355. for( i = 0; i < size; ++i )
  7356. {
  7357. const struct item* it = &items[i];
  7358. struct item_data* itd;
  7359. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7360. continue;
  7361. counter += it->amount;
  7362. count++;
  7363. if( count == 1 )
  7364. {
  7365. StringBuf_Printf(&buf, "------ %s items list of '%s' ------", location, sd->status.name);
  7366. clif_displaymessage(fd, StringBuf_Value(&buf));
  7367. StringBuf_Clear(&buf);
  7368. }
  7369. if( it->refine )
  7370. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7371. else
  7372. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7373. if( it->equip )
  7374. {
  7375. char equipstr[CHAT_SIZE_MAX];
  7376. strcpy(equipstr, " | equipped: ");
  7377. if( it->equip & EQP_GARMENT )
  7378. strcat(equipstr, "garment, ");
  7379. if( it->equip & EQP_ACC_L )
  7380. strcat(equipstr, "left accessory, ");
  7381. if( it->equip & EQP_ARMOR )
  7382. strcat(equipstr, "body/armor, ");
  7383. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7384. strcat(equipstr, "right hand, ");
  7385. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7386. strcat(equipstr, "left hand, ");
  7387. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7388. strcat(equipstr, "both hands, ");
  7389. if( it->equip & EQP_SHOES )
  7390. strcat(equipstr, "feet, ");
  7391. if( it->equip & EQP_ACC_R )
  7392. strcat(equipstr, "right accessory, ");
  7393. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7394. strcat(equipstr, "lower head, ");
  7395. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7396. strcat(equipstr, "top head, ");
  7397. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7398. strcat(equipstr, "lower/top head, ");
  7399. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7400. strcat(equipstr, "mid head, ");
  7401. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7402. strcat(equipstr, "lower/mid head, ");
  7403. if( (it->equip & EQP_HELM) == EQP_HELM )
  7404. strcat(equipstr, "lower/mid/top head, ");
  7405. // remove final ', '
  7406. equipstr[strlen(equipstr) - 2] = '\0';
  7407. StringBuf_AppendStr(&buf, equipstr);
  7408. }
  7409. clif_displaymessage(fd, StringBuf_Value(&buf));
  7410. StringBuf_Clear(&buf);
  7411. if( it->card[0] == CARD0_PET )
  7412. {// pet egg
  7413. if (it->card[3])
  7414. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, named)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7415. else
  7416. StringBuf_Printf(&buf, " -> (pet egg, pet id: %u, unnamed)", (unsigned int)MakeDWord(it->card[1], it->card[2]));
  7417. }
  7418. else
  7419. if(it->card[0] == CARD0_FORGE)
  7420. {// forged item
  7421. 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);
  7422. }
  7423. else
  7424. if(it->card[0] == CARD0_CREATE)
  7425. {// created item
  7426. StringBuf_Printf(&buf, " -> (produced item, creator id: %u)", (unsigned int)MakeDWord(it->card[2], it->card[3]));
  7427. }
  7428. else
  7429. {// normal item
  7430. int counter2 = 0;
  7431. for( j = 0; j < itd->slot; ++j )
  7432. {
  7433. struct item_data* card;
  7434. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7435. continue;
  7436. counter2++;
  7437. if( counter2 == 1 )
  7438. StringBuf_AppendStr(&buf, " -> (card(s): ");
  7439. if( counter2 != 1 )
  7440. StringBuf_AppendStr(&buf, ", ");
  7441. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7442. }
  7443. if( counter2 > 0 )
  7444. StringBuf_AppendStr(&buf, ")");
  7445. }
  7446. if( StringBuf_Length(&buf) > 0 )
  7447. clif_displaymessage(fd, StringBuf_Value(&buf));
  7448. StringBuf_Clear(&buf);
  7449. }
  7450. if( count == 0 )
  7451. StringBuf_Printf(&buf, "No item found in this player's %s.", location);
  7452. else
  7453. StringBuf_Printf(&buf, "%d item(s) found in %d %s slots.", counter, count, location);
  7454. clif_displaymessage(fd, StringBuf_Value(&buf));
  7455. StringBuf_Destroy(&buf);
  7456. return 0;
  7457. }
  7458. ACMD_FUNC(stats)
  7459. {
  7460. char job_jobname[100];
  7461. char output[CHAT_SIZE_MAX];
  7462. int i;
  7463. struct {
  7464. const char* format;
  7465. int value;
  7466. } output_table[] = {
  7467. { "Base Level - %d", 0 },
  7468. { NULL, 0 },
  7469. { "Hp - %d", 0 },
  7470. { "MaxHp - %d", 0 },
  7471. { "Sp - %d", 0 },
  7472. { "MaxSp - %d", 0 },
  7473. { "Str - %3d", 0 },
  7474. { "Agi - %3d", 0 },
  7475. { "Vit - %3d", 0 },
  7476. { "Int - %3d", 0 },
  7477. { "Dex - %3d", 0 },
  7478. { "Luk - %3d", 0 },
  7479. { "Zeny - %d", 0 },
  7480. { "Free SK Points - %d", 0 },
  7481. { "JobChangeLvl - %d", 0 },
  7482. { NULL, 0 }
  7483. };
  7484. memset(job_jobname, '\0', sizeof(job_jobname));
  7485. memset(output, '\0', sizeof(output));
  7486. //direct array initialization with variables is not standard C compliant.
  7487. output_table[0].value = sd->status.base_level;
  7488. output_table[1].format = job_jobname;
  7489. output_table[1].value = sd->status.job_level;
  7490. output_table[2].value = sd->status.hp;
  7491. output_table[3].value = sd->status.max_hp;
  7492. output_table[4].value = sd->status.sp;
  7493. output_table[5].value = sd->status.max_sp;
  7494. output_table[6].value = sd->status.str;
  7495. output_table[7].value = sd->status.agi;
  7496. output_table[8].value = sd->status.vit;
  7497. output_table[9].value = sd->status.int_;
  7498. output_table[10].value = sd->status.dex;
  7499. output_table[11].value = sd->status.luk;
  7500. output_table[12].value = sd->status.zeny;
  7501. output_table[13].value = sd->status.skill_point;
  7502. output_table[14].value = sd->change_level;
  7503. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7504. sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
  7505. clif_displaymessage(fd, output);
  7506. for (i = 0; output_table[i].format != NULL; i++) {
  7507. sprintf(output, output_table[i].format, output_table[i].value);
  7508. clif_displaymessage(fd, output);
  7509. }
  7510. return 0;
  7511. }
  7512. ACMD_FUNC(delitem)
  7513. {
  7514. char item_name[100];
  7515. int nameid, amount = 0, total, idx;
  7516. struct item_data* id;
  7517. nullpo_retr(-1, sd);
  7518. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7519. {
  7520. clif_displaymessage(fd, "Please, enter an item name/id, a quantity and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).");
  7521. return -1;
  7522. }
  7523. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7524. {
  7525. nameid = id->nameid;
  7526. }
  7527. else
  7528. {
  7529. clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  7530. return -1;
  7531. }
  7532. total = amount;
  7533. // delete items
  7534. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7535. {
  7536. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7537. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7538. {// delete pet
  7539. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7540. }
  7541. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7542. amount-= delamount;
  7543. }
  7544. // notify target
  7545. sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM.
  7546. clif_displaymessage(sd->fd, atcmd_output);
  7547. // notify source
  7548. if( amount == total )
  7549. {
  7550. clif_displaymessage(fd, msg_txt(116)); // Character does not have the item.
  7551. }
  7552. else if( amount )
  7553. {
  7554. sprintf(atcmd_output, msg_txt(115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7555. clif_displaymessage(fd, atcmd_output);
  7556. }
  7557. else
  7558. {
  7559. sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player.
  7560. clif_displaymessage(fd, atcmd_output);
  7561. }
  7562. return 0;
  7563. }
  7564. /*==========================================
  7565. * Custom Fonts
  7566. *------------------------------------------*/
  7567. ACMD_FUNC(font)
  7568. {
  7569. int font_id;
  7570. nullpo_retr(-1,sd);
  7571. font_id = atoi(message);
  7572. if( font_id == 0 )
  7573. {
  7574. if( sd->user_font )
  7575. {
  7576. sd->user_font = 0;
  7577. clif_displaymessage(fd, "Returning to normal font.");
  7578. clif_font(sd);
  7579. }
  7580. else
  7581. {
  7582. clif_displaymessage(fd, "Use @font <1..9> to change your messages font.");
  7583. clif_displaymessage(fd, "Use 0 or no parameter to back to normal font.");
  7584. }
  7585. }
  7586. else if( font_id < 0 || font_id > 9 )
  7587. clif_displaymessage(fd, "Invalid font. Use a Value from 0 to 9.");
  7588. else if( font_id != sd->user_font )
  7589. {
  7590. sd->user_font = font_id;
  7591. clif_font(sd);
  7592. clif_displaymessage(fd, "Font changed.");
  7593. }
  7594. else
  7595. clif_displaymessage(fd, "Already using this font.");
  7596. return 0;
  7597. }
  7598. ACMD_FUNC(new_mount) {
  7599. clif_displaymessage(sd->fd,"NOTICE: If you crash with mount your LUA is outdated");
  7600. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7601. clif_displaymessage(sd->fd,"You have mounted.");
  7602. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7603. } else {
  7604. clif_displaymessage(sd->fd,"You have released your mount");
  7605. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7606. }
  7607. return 0;
  7608. }
  7609. /**
  7610. * Fills the reference of available commands in atcommand DBMap
  7611. **/
  7612. void atcommand_basecommands(void) {
  7613. /**
  7614. * Command reference list, place the base of your commands here
  7615. * Dev note: I'd love to get rid of this, if you have a better idea on this please share with the poor mortals
  7616. **/
  7617. AtCommandInfo atcommand_base[] = {
  7618. { "warp", 40,40, atcommand_mapmove }, // + /mm
  7619. { "where", 1,1, atcommand_where },
  7620. { "goto", 20,20, atcommand_jumpto }, // + /shift
  7621. { "jump", 40,40, atcommand_jump },
  7622. { "who", 20,20, atcommand_who },
  7623. { "who2", 20,20, atcommand_who2 },
  7624. { "who3", 20,20, atcommand_who3 },
  7625. { "whomap", 20,20, atcommand_whomap },
  7626. { "whomap2", 20,20, atcommand_whomap2 },
  7627. { "whomap3", 20,20, atcommand_whomap3 },
  7628. { "whogm", 20,20, atcommand_whogm },
  7629. { "save", 40,40, atcommand_save },
  7630. { "load", 40,40, atcommand_load },
  7631. { "speed", 40,40, atcommand_speed },
  7632. { "storage", 1,1, atcommand_storage },
  7633. { "gstorage", 50,50, atcommand_guildstorage },
  7634. { "option", 40,40, atcommand_option },
  7635. { "hide", 40,40, atcommand_hide }, // + /hide
  7636. { "job", 40,40, atcommand_jobchange },
  7637. { "die", 1,1, atcommand_die },
  7638. { "kill", 60,60, atcommand_kill },
  7639. { "alive", 60,60, atcommand_alive },
  7640. { "kami", 40,40, atcommand_kami },
  7641. { "kamib", 40,40, atcommand_kami },
  7642. { "kamic", 40,40, atcommand_kami },
  7643. { "heal", 40,60, atcommand_heal },
  7644. { "item", 60,60, atcommand_item },
  7645. { "item2", 60,60, atcommand_item2 },
  7646. { "itemreset", 40,40, atcommand_itemreset },
  7647. { "blvl", 60,60, atcommand_baselevelup },
  7648. { "jlvl", 60,60, atcommand_joblevelup },
  7649. { "help", 20,20, atcommand_help },
  7650. { "help2", 20,20, atcommand_help2 },
  7651. { "pvpoff", 40,40, atcommand_pvpoff },
  7652. { "pvpon", 40,40, atcommand_pvpon },
  7653. { "gvgoff", 40,40, atcommand_gvgoff },
  7654. { "gvgon", 40,40, atcommand_gvgon },
  7655. { "model", 20,20, atcommand_model },
  7656. { "go", 10,10, atcommand_go },
  7657. { "monster", 50,50, atcommand_monster },
  7658. { "monstersmall", 50,50, atcommand_monstersmall },
  7659. { "monsterbig", 50,50, atcommand_monsterbig },
  7660. { "killmonster", 60,60, atcommand_killmonster },
  7661. { "killmonster2", 40,40, atcommand_killmonster2 },
  7662. { "refine", 60,60, atcommand_refine },
  7663. { "produce", 60,60, atcommand_produce },
  7664. { "memo", 40,40, atcommand_memo },
  7665. { "gat", 99,99, atcommand_gat },
  7666. { "displaystatus", 99,99, atcommand_displaystatus },
  7667. { "stpoint", 60,60, atcommand_statuspoint },
  7668. { "skpoint", 60,60, atcommand_skillpoint },
  7669. { "zeny", 60,60, atcommand_zeny },
  7670. { "str", 60,60, atcommand_param },
  7671. { "agi", 60,60, atcommand_param },
  7672. { "vit", 60,60, atcommand_param },
  7673. { "int", 60,60, atcommand_param },
  7674. { "dex", 60,60, atcommand_param },
  7675. { "luk", 60,60, atcommand_param },
  7676. { "glvl", 60,60, atcommand_guildlevelup },
  7677. { "makeegg", 60,60, atcommand_makeegg },
  7678. { "hatch", 60,60, atcommand_hatch },
  7679. { "petfriendly", 40,40, atcommand_petfriendly },
  7680. { "pethungry", 40,40, atcommand_pethungry },
  7681. { "petrename", 1,1, atcommand_petrename },
  7682. { "recall", 60,60, atcommand_recall }, // + /recall
  7683. { "night", 80,80, atcommand_night },
  7684. { "day", 80,80, atcommand_day },
  7685. { "doom", 80,80, atcommand_doom },
  7686. { "doommap", 80,80, atcommand_doommap },
  7687. { "raise", 80,80, atcommand_raise },
  7688. { "raisemap", 80,80, atcommand_raisemap },
  7689. { "kick", 20,20, atcommand_kick }, // + right click menu for GM "(name) force to quit"
  7690. { "kickall", 99,99, atcommand_kickall },
  7691. { "allskill", 60,60, atcommand_allskill },
  7692. { "questskill", 40,40, atcommand_questskill },
  7693. { "lostskill", 40,40, atcommand_lostskill },
  7694. { "spiritball", 40,40, atcommand_spiritball },
  7695. { "party", 1,1, atcommand_party },
  7696. { "guild", 50,50, atcommand_guild },
  7697. { "agitstart", 60,60, atcommand_agitstart },
  7698. { "agitend", 60,60, atcommand_agitend },
  7699. { "mapexit", 99,99, atcommand_mapexit },
  7700. { "idsearch", 60,60, atcommand_idsearch },
  7701. { "broadcast", 40,40, atcommand_broadcast }, // + /b and /nb
  7702. { "localbroadcast", 40,40, atcommand_localbroadcast }, // + /lb and /nlb
  7703. { "recallall", 80,80, atcommand_recallall },
  7704. { "reloaditemdb", 99,99, atcommand_reloaditemdb },
  7705. { "reloadmobdb", 99,99, atcommand_reloadmobdb },
  7706. { "reloadskilldb", 99,99, atcommand_reloadskilldb },
  7707. { "reloadscript", 99,99, atcommand_reloadscript },
  7708. { "reloadatcommand", 99,99, atcommand_reloadatcommand },
  7709. { "reloadbattleconf", 99,99, atcommand_reloadbattleconf },
  7710. { "reloadstatusdb", 99,99, atcommand_reloadstatusdb },
  7711. { "reloadpcdb", 99,99, atcommand_reloadpcdb },
  7712. { "reloadmotd", 99,99, atcommand_reloadmotd },
  7713. { "mapinfo", 99,99, atcommand_mapinfo },
  7714. { "dye", 40,40, atcommand_dye },
  7715. { "hairstyle", 40,40, atcommand_hair_style },
  7716. { "haircolor", 40,40, atcommand_hair_color },
  7717. { "allstats", 60,60, atcommand_stat_all },
  7718. { "block", 60,60, atcommand_char_block },
  7719. { "ban", 60,60, atcommand_char_ban },
  7720. { "unblock", 60,60, atcommand_char_unblock },
  7721. { "unban", 60,60, atcommand_char_unban },
  7722. { "mount", 20,20, atcommand_mount_peco },
  7723. { "guildspy", 60,60, atcommand_guildspy },
  7724. { "partyspy", 60,60, atcommand_partyspy },
  7725. { "repairall", 60,60, atcommand_repairall },
  7726. { "guildrecall", 60,60, atcommand_guildrecall },
  7727. { "partyrecall", 60,60, atcommand_partyrecall },
  7728. { "nuke", 60,60, atcommand_nuke },
  7729. { "shownpc", 80,80, atcommand_shownpc },
  7730. { "hidenpc", 80,80, atcommand_hidenpc },
  7731. { "loadnpc", 80,80, atcommand_loadnpc },
  7732. { "unloadnpc", 80,80, atcommand_unloadnpc },
  7733. { "time", 1,1, atcommand_servertime },
  7734. { "jail", 60,60, atcommand_jail },
  7735. { "unjail", 60,60, atcommand_unjail },
  7736. { "jailfor", 60,60, atcommand_jailfor },
  7737. { "jailtime", 1,1, atcommand_jailtime },
  7738. { "disguise", 20,20, atcommand_disguise },
  7739. { "undisguise", 20,20, atcommand_undisguise },
  7740. { "email", 1,1, atcommand_email },
  7741. { "effect", 40,40, atcommand_effect },
  7742. { "follow", 20,20, atcommand_follow },
  7743. { "addwarp", 60,60, atcommand_addwarp },
  7744. { "skillon", 80,80, atcommand_skillon },
  7745. { "skilloff", 80,80, atcommand_skilloff },
  7746. { "killer", 60,60, atcommand_killer },
  7747. { "npcmove", 80,80, atcommand_npcmove },
  7748. { "killable", 40,40, atcommand_killable },
  7749. { "dropall", 40,40, atcommand_dropall },
  7750. { "storeall", 40,40, atcommand_storeall },
  7751. { "skillid", 40,40, atcommand_skillid },
  7752. { "useskill", 40,40, atcommand_useskill },
  7753. { "displayskill", 99,99, atcommand_displayskill },
  7754. { "snow", 99,99, atcommand_snow },
  7755. { "sakura", 99,99, atcommand_sakura },
  7756. { "clouds", 99,99, atcommand_clouds },
  7757. { "clouds2", 99,99, atcommand_clouds2 },
  7758. { "fog", 99,99, atcommand_fog },
  7759. { "fireworks", 99,99, atcommand_fireworks },
  7760. { "leaves", 99,99, atcommand_leaves },
  7761. { "summon", 60,60, atcommand_summon },
  7762. { "adjgmlvl", 99,99, atcommand_adjgmlvl },
  7763. { "adjcmdlvl", 99,99, atcommand_adjcmdlvl },
  7764. { "trade", 60,60, atcommand_trade },
  7765. { "send", 99,99, atcommand_send },
  7766. { "setbattleflag", 99,99, atcommand_setbattleflag },
  7767. { "unmute", 80,80, atcommand_unmute },
  7768. { "clearweather", 99,99, atcommand_clearweather },
  7769. { "uptime", 1,1, atcommand_uptime },
  7770. { "changesex", 60,60, atcommand_changesex },
  7771. { "mute", 80,80, atcommand_mute },
  7772. { "refresh", 1,1, atcommand_refresh },
  7773. { "identify", 40,40, atcommand_identify },
  7774. { "gmotd", 20,20, atcommand_gmotd },
  7775. { "misceffect", 50,50, atcommand_misceffect },
  7776. { "mobsearch", 10,10, atcommand_mobsearch },
  7777. { "cleanmap", 40,40, atcommand_cleanmap },
  7778. { "npctalk", 20,20, atcommand_npctalk },
  7779. { "pettalk", 10,10, atcommand_pettalk },
  7780. { "users", 40,40, atcommand_users },
  7781. { "reset", 40,40, atcommand_reset },
  7782. { "skilltree", 40,40, atcommand_skilltree },
  7783. { "marry", 40,40, atcommand_marry },
  7784. { "divorce", 40,40, atcommand_divorce },
  7785. { "sound", 40,40, atcommand_sound },
  7786. { "undisguiseall", 99,99, atcommand_undisguiseall },
  7787. { "disguiseall", 99,99, atcommand_disguiseall },
  7788. { "changelook", 60,60, atcommand_changelook },
  7789. { "autoloot", 10,10, atcommand_autoloot },
  7790. { "alootid", 10,10, atcommand_autolootitem },
  7791. { "monsterinfo", 1,1, atcommand_mobinfo },
  7792. { "exp", 1,1, atcommand_exp },
  7793. { "adopt", 40,40, atcommand_adopt },
  7794. { "version", 1,1, atcommand_version },
  7795. { "mutearea", 99,99, atcommand_mutearea },
  7796. { "rates", 1,1, atcommand_rates },
  7797. { "iteminfo", 1,1, atcommand_iteminfo },
  7798. { "whodrops", 1,1, atcommand_whodrops },
  7799. { "whereis", 10,10, atcommand_whereis },
  7800. { "mapflag", 99,99, atcommand_mapflag },
  7801. { "me", 20,20, atcommand_me },
  7802. { "battleignore", 99,99, atcommand_monsterignore },
  7803. { "fakename", 20,20, atcommand_fakename },
  7804. { "size", 20,20, atcommand_size },
  7805. { "showexp", 10,10, atcommand_showexp},
  7806. { "showzeny", 10,10, atcommand_showzeny},
  7807. { "showdelay", 1,1, atcommand_showdelay},
  7808. { "autotrade", 10,10, atcommand_autotrade },
  7809. { "changegm", 10,10, atcommand_changegm },
  7810. { "changeleader", 10,10, atcommand_changeleader },
  7811. { "partyoption", 10,10, atcommand_partyoption},
  7812. { "invite", 1,1, atcommand_invite },
  7813. { "duel", 1,1, atcommand_duel },
  7814. { "leave", 1,1, atcommand_leave },
  7815. { "accept", 1,1, atcommand_accept },
  7816. { "reject", 1,1, atcommand_reject },
  7817. { "main", 1,1, atcommand_main },
  7818. { "clone", 50,50, atcommand_clone },
  7819. { "slaveclone", 50,50, atcommand_clone },
  7820. { "evilclone", 50,50, atcommand_clone },
  7821. { "tonpc", 40,40, atcommand_tonpc },
  7822. { "commands", 1,1, atcommand_commands },
  7823. { "noask", 1,1, atcommand_noask },
  7824. { "request", 20,20, atcommand_request },
  7825. { "hlvl", 60,60, atcommand_homlevel },
  7826. { "homevolve", 60,60, atcommand_homevolution },
  7827. { "makehomun", 60,60, atcommand_makehomun },
  7828. { "homfriendly", 60,60, atcommand_homfriendly },
  7829. { "homhungry", 60,60, atcommand_homhungry },
  7830. { "homtalk", 10,10, atcommand_homtalk },
  7831. { "hominfo", 1,1, atcommand_hominfo },
  7832. { "homstats", 1,1, atcommand_homstats },
  7833. { "homshuffle", 60,60, atcommand_homshuffle },
  7834. { "showmobs", 10,10, atcommand_showmobs },
  7835. { "feelreset", 10,10, atcommand_feelreset },
  7836. { "auction", 1,1, atcommand_auction },
  7837. { "mail", 1,1, atcommand_mail },
  7838. { "noks", 1,1, atcommand_ksprotection },
  7839. { "allowks", 40,40, atcommand_allowks },
  7840. { "cash", 60,60, atcommand_cash },
  7841. { "points", 60,60, atcommand_cash },
  7842. { "agitstart2", 60,60, atcommand_agitstart2 },
  7843. { "agitend2", 60,60, atcommand_agitend2 },
  7844. { "skreset", 60,60, atcommand_resetskill },
  7845. { "streset", 60,60, atcommand_resetstat },
  7846. { "storagelist", 40,40, atcommand_itemlist },
  7847. { "cartlist", 40,40, atcommand_itemlist },
  7848. { "itemlist", 40,40, atcommand_itemlist },
  7849. { "stats", 40,40, atcommand_stats },
  7850. { "delitem", 60,60, atcommand_delitem },
  7851. { "charcommands", 1,1, atcommand_charcommands },
  7852. { "font", 1,1, atcommand_font },
  7853. /**
  7854. * For Testing Purposes, not going to be here after we're done.
  7855. **/
  7856. { "newmount", 0,99, atcommand_new_mount },
  7857. };
  7858. AtCommandInfo* atcommand;
  7859. int i;
  7860. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7861. CREATE(atcommand, AtCommandInfo, 1);
  7862. safestrncpy(atcommand->command,atcommand_base[i].command,sizeof(atcommand->command));
  7863. atcommand->level = atcommand_base[i].level;
  7864. atcommand->level2 = atcommand_base[i].level2;
  7865. atcommand->func = atcommand_base[i].func;
  7866. strdb_put(atcommand_db, atcommand->command, atcommand);
  7867. }
  7868. return;
  7869. }
  7870. /*==========================================
  7871. * Command lookup functions
  7872. *------------------------------------------*/
  7873. static AtCommandInfo* get_atcommandinfo_byname(const char* name) {
  7874. if( *name == atcommand_symbol || *name == charcommand_symbol ) name++; // for backwards compatibility
  7875. if( strdb_exists(atcommand_db,name) )
  7876. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7877. return NULL;
  7878. }
  7879. /*==========================================
  7880. * Retrieve the command's required gm level
  7881. *------------------------------------------*/
  7882. int get_atcommand_level(const char* name) {
  7883. AtCommandInfo* info = (AtCommandInfo*)strdb_get(atcommand_db, name);
  7884. return ( info != NULL ) ? info->level : 100; // 100: command can not be used
  7885. }
  7886. /// Executes an at-command.
  7887. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  7888. {
  7889. char charname[NAME_LENGTH], params[100];
  7890. char charname2[NAME_LENGTH], params2[100];
  7891. char command[100];
  7892. char output[CHAT_SIZE_MAX];
  7893. int x, y, z;
  7894. int lv = 0;
  7895. //Reconstructed message
  7896. char atcmd_msg[CHAT_SIZE_MAX];
  7897. TBL_PC * ssd = NULL; //sd for target
  7898. AtCommandInfo * info;
  7899. nullpo_retr(false, sd);
  7900. //Shouldn't happen
  7901. if( !message || !*message )
  7902. return false;
  7903. //Block NOCHAT but do not display it as a normal message
  7904. if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  7905. return true;
  7906. // skip 10/11-langtype's codepage indicator, if detected
  7907. if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  7908. message += 3;
  7909. //Should display as a normal message
  7910. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  7911. return false;
  7912. // type value 0 = server invoked: bypass restrictions
  7913. // 1 = player invoked
  7914. if( type )
  7915. {
  7916. //Commands are disabled on maps flagged as 'nocommand'
  7917. if( map[sd->bl.m].nocommand && pc_isGM(sd) < map[sd->bl.m].nocommand )
  7918. {
  7919. clif_displaymessage(fd, msg_txt(143));
  7920. return false;
  7921. }
  7922. //Displays as a normal message for Non-GMs
  7923. if( battle_config.atc_gmonly != 0 && pc_isGM(sd) == 0 )
  7924. return false;
  7925. }
  7926. while (*message == charcommand_symbol)
  7927. {
  7928. //Checks to see if #command has a name or a name + parameters.
  7929. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  7930. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  7931. //z always has the value of the scan that was successful
  7932. z = ( x > 1 ) ? x : y;
  7933. if ( (ssd = map_nick2sd(charname)) == NULL && ( (ssd = map_nick2sd(charname2)) == NULL ) ) {
  7934. if( pc_isGM(sd) ) {
  7935. sprintf(output, "%s failed. Player not found.", command);
  7936. clif_displaymessage(fd, output);
  7937. } else {
  7938. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7939. clif_displaymessage(fd, output);
  7940. }
  7941. return true;
  7942. }
  7943. //#command + name means the sufficient target was used and anything else after
  7944. //can be looked at by the actual command function since most scan to see if the
  7945. //right parameters are used.
  7946. if ( x > 2 ) {
  7947. sprintf(atcmd_msg, "%s %s", command, params);
  7948. break;
  7949. }
  7950. else if ( y > 2 ) {
  7951. sprintf(atcmd_msg, "%s %s", command, params2);
  7952. break;
  7953. }
  7954. //Regardless of what style the #command is used, if it's correct, it will always have
  7955. //this value if there is no parameter. Send it as just the #command
  7956. else if ( z == 2 ) {
  7957. sprintf(atcmd_msg, "%s", command);
  7958. break;
  7959. }
  7960. sprintf(output, "Charcommand failed. Usage: #<command> <char name> <params>.");
  7961. clif_displaymessage(fd, output);
  7962. return true;
  7963. }
  7964. if (*message == atcommand_symbol) {
  7965. //atcmd_msg is constructed above differently for charcommands
  7966. //it's copied from message if not a charcommand so it can
  7967. //pass through the rest of the code compatible with both symbols
  7968. sprintf(atcmd_msg, "%s", message);
  7969. }
  7970. //Clearing these to be used once more.
  7971. memset(command, '\0', sizeof(command));
  7972. memset(params, '\0', sizeof(params));
  7973. //check to see if any params exist within this command
  7974. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  7975. params[0] = '\0';
  7976. //Grab the command information and check for the proper GM level required to use it or if the command exists
  7977. 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)) ) )
  7978. {
  7979. if( pc_isGM(sd) ) {
  7980. sprintf(output, msg_txt(153), command); // "%s is Unknown Command."
  7981. clif_displaymessage(fd, output);
  7982. return true;
  7983. } else
  7984. return false;
  7985. }
  7986. //Log atcommands
  7987. if( *atcmd_msg == atcommand_symbol )
  7988. log_atcommand(sd, info->level, atcmd_msg);
  7989. //Log Charcommands
  7990. else if( *atcmd_msg == charcommand_symbol && ssd != NULL )
  7991. log_atcommand(sd, info->level2, message);
  7992. //Attempt to use the command
  7993. if( strcmpi("adjgmlvl",command+1) && ssd ) { lv = ssd->gmlevel; ssd->gmlevel = sd->gmlevel; }
  7994. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  7995. {
  7996. sprintf(output,msg_txt(154), command); // %s failed.
  7997. clif_displaymessage(fd, output);
  7998. }
  7999. if( strcmpi("adjgmlvl",command+1) && ssd ) ssd->gmlevel = lv;
  8000. return true;
  8001. }
  8002. /**
  8003. * Splits and parses command aliases field
  8004. * Note: I'm not good (at all) with string manipulation, if you think you can improve, please do. I beg you.
  8005. **/
  8006. void atcommand_parse_aliases(char aliases[1024],AtCommandInfo* base) {
  8007. char *str[99], *p;
  8008. int i, max = 0;
  8009. p = aliases;
  8010. while( ISSPACE(*p) )//trim
  8011. ++p;
  8012. //I assume nobody is getting over 98 alises in the same command lol
  8013. for( i = 0; i < 99; i++ ) {
  8014. str[i] = p;
  8015. p = strchr(p,',');
  8016. if( p == NULL ) {
  8017. max = i+1;
  8018. break;// comma not found
  8019. }
  8020. *p = '\0';
  8021. ++p;
  8022. }
  8023. if( !str[0] )//no aliases at all
  8024. return;
  8025. for(i = 0; i < max;i++) {
  8026. AtCommandInfo* atcommand = NULL;
  8027. normalize_name(str[i]," ");//trim over
  8028. if( (atcommand = strdb_get(atcommand_db, str[i])) ) {
  8029. atcommand->level = base->level;
  8030. atcommand->level2 = base->level2;
  8031. continue;
  8032. }
  8033. CREATE(atcommand, AtCommandInfo, 1);
  8034. safestrncpy(atcommand->command,str[i],sizeof(atcommand->command));
  8035. atcommand->level = base->level;
  8036. atcommand->level2 = base->level2;
  8037. atcommand->func = base->func;
  8038. strdb_put(atcommand_db, atcommand->command, atcommand);
  8039. }
  8040. return;
  8041. }
  8042. /*==========================================
  8043. *
  8044. *------------------------------------------*/
  8045. int atcommand_config_read(const char* cfgName)
  8046. {
  8047. char line[1024], w1[1024], w2[1024], w3[1024], w4[1024];
  8048. AtCommandInfo* p;
  8049. FILE* fp;
  8050. int i;
  8051. if( (fp = fopen(cfgName, "r")) == NULL ) {
  8052. ShowError("AtCommand configuration file not found: %s\n", cfgName);
  8053. return 1;
  8054. }
  8055. while( fgets(line, sizeof(line), fp) ) {
  8056. if( line[0] == '/' && line[1] == '/' )
  8057. continue;
  8058. if( ( i = sscanf(line,"%1023[^:]:%1023[^,],%1023[^[][%1023[^]]",w1,w2,w3,w4) ) >= 3 ) {
  8059. if( ( p = (AtCommandInfo*)strdb_get(atcommand_db, w1) ) != NULL ) {
  8060. p->level = atoi(w2);//update @level
  8061. p->level2 = atoi(w3);//update #level
  8062. /**
  8063. * Parse the alises
  8064. **/
  8065. if( i == 4 )
  8066. atcommand_parse_aliases(w4,p);
  8067. continue;//we're done move on
  8068. }
  8069. } else if( strcmpi(w1, "import") != 0 && strcmpi(w1, "command_symbol") != 0 && strcmpi(w1, "char_symbol") != 0 ) {
  8070. if( i > 1 )
  8071. ShowWarning("Unknown setting '%s' in file %s\n", w1, cfgName);
  8072. continue;
  8073. }
  8074. normalize_name(w2," ");//trim
  8075. if( strcmpi(w1, "import") == 0 )
  8076. atcommand_config_read(w2);
  8077. else if( strcmpi(w1, "command_symbol") == 0 &&
  8078. w2[0] > 31 && // control characters
  8079. w2[0] != '/' && // symbol of standard ragnarok GM commands
  8080. w2[0] != '%' && // symbol of party chat speaking
  8081. w2[0] != '$' && // symbol of guild chat speaking
  8082. w2[0] != '#' ) // remote symbol
  8083. atcommand_symbol = w2[0];
  8084. else if( strcmpi(w1, "char_symbol") == 0 &&
  8085. w2[0] > 31 &&
  8086. w2[0] != '/' &&
  8087. w2[0] != '%' &&
  8088. w2[0] != '$' &&
  8089. w2[0] != '@' )
  8090. charcommand_symbol = w2[0];
  8091. }
  8092. fclose(fp);
  8093. return 0;
  8094. }
  8095. static int atcommand_db_free(DBKey key,void *data,va_list va) {
  8096. aFree((AtCommandInfo*)data);
  8097. return 1;
  8098. }
  8099. void atcommand_db_clear() {
  8100. atcommand_db->foreach(atcommand_db,atcommand_db_free);
  8101. db_destroy(atcommand_db);
  8102. return;
  8103. }
  8104. void atcommand_doload() {
  8105. if( atcommand_db != NULL )
  8106. atcommand_db_clear();
  8107. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
  8108. atcommand_basecommands();//fills initial atcommand_db with known commands
  8109. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8110. return;
  8111. }
  8112. void do_init_atcommand() {
  8113. atcommand_doload();
  8114. }
  8115. void do_final_atcommand() {
  8116. atcommand_db_clear();
  8117. return;
  8118. }
  8119. // commands that need to go _after_ the commands table
  8120. /*==========================================
  8121. * type: 1 = commands (@), 2 = charcommands (#)
  8122. *------------------------------------------*/
  8123. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, int type) {
  8124. char line_buff[CHATBOX_SIZE];
  8125. int gm_lvl = pc_isGM(sd), count = 0;
  8126. char* cur = line_buff;
  8127. AtCommandInfo* cmd;
  8128. DBIterator* iter = atcommand_db->iterator(atcommand_db);
  8129. memset(line_buff,' ',CHATBOX_SIZE);
  8130. line_buff[CHATBOX_SIZE-1] = 0;
  8131. clif_displaymessage(fd, msg_txt(273)); // "Commands available:"
  8132. for( cmd = (AtCommandInfo*)iter->first(iter,NULL); iter->exists(iter); cmd = (AtCommandInfo*)iter->next(iter,NULL) ) {
  8133. unsigned int slen;
  8134. if( type == 1 && gm_lvl < cmd->level )
  8135. continue;
  8136. if( type == 2 && gm_lvl < cmd->level2 )
  8137. continue;
  8138. slen = strlen(cmd->command);
  8139. // flush the text buffer if this command won't fit into it
  8140. if( slen + cur - line_buff >= CHATBOX_SIZE )
  8141. {
  8142. clif_displaymessage(fd,line_buff);
  8143. cur = line_buff;
  8144. memset(line_buff,' ',CHATBOX_SIZE);
  8145. line_buff[CHATBOX_SIZE-1] = 0;
  8146. }
  8147. memcpy(cur,cmd->command,slen);
  8148. cur += slen+(10-slen%10);
  8149. count++;
  8150. }
  8151. iter->destroy(iter);
  8152. clif_displaymessage(fd,line_buff);
  8153. sprintf(atcmd_output, msg_txt(274), count); // "%d commands found."
  8154. clif_displaymessage(fd, atcmd_output);
  8155. return;
  8156. }
  8157. /*==========================================
  8158. * @commands Lists available @ commands to you
  8159. *------------------------------------------*/
  8160. ACMD_FUNC(commands)
  8161. {
  8162. atcommand_commands_sub(sd, fd, 1);
  8163. return 0;
  8164. }
  8165. /*==========================================
  8166. * @charcommands Lists available # commands to you
  8167. *------------------------------------------*/
  8168. ACMD_FUNC(charcommands)
  8169. {
  8170. atcommand_commands_sub(sd, fd, 2);
  8171. return 0;
  8172. }