atcommand.cpp 353 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "atcommand.hpp"
  4. #include <cmath>
  5. #include <cstdlib>
  6. #include <set>
  7. #include <unordered_map>
  8. #include <common/cbasetypes.hpp>
  9. #include <common/database.hpp>
  10. #include <common/cli.hpp>
  11. #include <common/malloc.hpp>
  12. #include <common/mmo.hpp>
  13. #include <common/nullpo.hpp>
  14. #include <common/random.hpp>
  15. #include <common/showmsg.hpp>
  16. #include <common/socket.hpp>
  17. #include <common/strlib.hpp>
  18. #include <common/timer.hpp>
  19. #include <common/utilities.hpp>
  20. #include <common/utils.hpp>
  21. #include "achievement.hpp"
  22. #include "battle.hpp"
  23. #include "buyingstore.hpp"
  24. #include "channel.hpp"
  25. #include "chat.hpp"
  26. #include "chrif.hpp"
  27. #include "clan.hpp"
  28. #include "clif.hpp"
  29. #include "duel.hpp"
  30. #include "elemental.hpp"
  31. #include "guild.hpp"
  32. #include "homunculus.hpp"
  33. #include "instance.hpp"
  34. #include "intif.hpp"
  35. #include "itemdb.hpp" // MAX_ITEMGROUP
  36. #include "cashshop.hpp"
  37. #include "log.hpp"
  38. #include "mail.hpp"
  39. #include "map.hpp"
  40. #include "mapreg.hpp"
  41. #include "mercenary.hpp"
  42. #include "mob.hpp"
  43. #include "npc.hpp"
  44. #include "party.hpp"
  45. #include "pc.hpp"
  46. #include "pc_groups.hpp"
  47. #include "pet.hpp"
  48. #include "quest.hpp"
  49. #include "script.hpp"
  50. #include "storage.hpp"
  51. #include "trade.hpp"
  52. #include "vending.hpp"
  53. using namespace rathena;
  54. #define ATCOMMAND_LENGTH 50
  55. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, map_session_data* sd, const char* command, const char* message)
  56. typedef struct AtCommandInfo AtCommandInfo;
  57. int atcmd_binding_count = 0;
  58. /// Atcommand restriction usage
  59. enum e_atcmd_restict {
  60. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  61. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  62. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  63. };
  64. struct AtCommandInfo {
  65. char command[ATCOMMAND_LENGTH];
  66. AtCommandFunc func;
  67. char* at_groups; /// Quick @commands "can-use" lookup
  68. char* char_groups; /// Quick @charcommands "can-use" lookup
  69. uint8 restriction; /// Restrictions see enum e_restict
  70. };
  71. struct s_atcommand_alias_info{
  72. AtCommandInfo *command;
  73. std::set<std::string> aliases;
  74. std::string help;
  75. };
  76. char atcommand_symbol = '@'; // first char of the commands
  77. char charcommand_symbol = '#';
  78. static DBMap* atcommand_db = nullptr; //name -> AtCommandInfo
  79. static AtCommandInfo* get_atcommandinfo_byname( const char* name );
  80. class AtcommandAliasDatabase : public TypesafeYamlDatabase<std::string, s_atcommand_alias_info>{
  81. private:
  82. std::unordered_map<std::string, std::string> aliases;
  83. public:
  84. AtcommandAliasDatabase() : TypesafeYamlDatabase( "ATCOMMAND_DB", 1 ){
  85. }
  86. void clear() override;
  87. const std::string getDefaultLocation() override;
  88. uint64 parseBodyNode( const ryml::NodeRef& node ) override;
  89. // Additional
  90. const char* checkAlias( const char* alias );
  91. };
  92. void AtcommandAliasDatabase::clear(){
  93. TypesafeYamlDatabase::clear();
  94. this->aliases.clear();
  95. }
  96. const std::string AtcommandAliasDatabase::getDefaultLocation(){
  97. return std::string(conf_path) + "/atcommands.yml";
  98. }
  99. uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){
  100. std::string command;
  101. if( !this->asString( node, "Command", command ) ){
  102. return 0;
  103. }
  104. AtCommandInfo* commandinfo = get_atcommandinfo_byname( command.c_str() );
  105. if( commandinfo == nullptr ){
  106. this->invalidWarning( node["Command"], "Command %s does not exist.\n", command.c_str() );
  107. return 0;
  108. }
  109. std::shared_ptr<s_atcommand_alias_info> info = this->find( command );
  110. bool exists = info != nullptr;
  111. if( !exists ){
  112. info = std::make_shared<s_atcommand_alias_info>();
  113. info->command = commandinfo;
  114. }
  115. if( this->nodeExists( node, "Help" ) ){
  116. std::string help;
  117. if( !this->asString( node, "Help", help ) ){
  118. return 0;
  119. }
  120. info->help = help;
  121. }
  122. if( this->nodeExists( node, "Aliases" ) ){
  123. const auto& aliasesNode = node["Aliases"];
  124. if( !aliasesNode.is_seq() ){
  125. this->invalidWarning( aliasesNode, "Aliases should be a sequence.\n" );
  126. return 0;
  127. }
  128. for( const auto& subNode : aliasesNode ){
  129. std::string alias;
  130. subNode >> alias;
  131. info->aliases.insert( alias );
  132. this->aliases[alias] = command;
  133. }
  134. }
  135. if( !exists ){
  136. this->put( command, info );
  137. }
  138. return 1;
  139. }
  140. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  141. std::string alias_str( alias );
  142. std::string* command = util::umap_find( this->aliases, alias_str );
  143. if( command == nullptr ){
  144. return alias;
  145. }else{
  146. return command->c_str();
  147. }
  148. }
  149. AtcommandAliasDatabase atcommand_alias_db;
  150. static char atcmd_output[CHAT_SIZE_MAX];
  151. static char atcmd_player_name[NAME_LENGTH];
  152. const char *parent_cmd;
  153. struct atcmd_binding_data** atcmd_binding;
  154. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  155. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help
  156. static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  157. // @commands (script-based)
  158. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  159. int i = 0;
  160. if( *name == atcommand_symbol || *name == charcommand_symbol )
  161. name++; // for backwards compatibility
  162. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  163. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
  164. }
  165. /**
  166. * retrieves the help string associated with a given command.
  167. *
  168. * @param name the name of the command to retrieve help information for
  169. * @return the string associated with the command, or nullptr
  170. */
  171. static const char* atcommand_help_string( const char* command ){
  172. // remove the prefix symbol for the raw name of the command
  173. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  174. command++;
  175. }
  176. // convert alias to the real command name
  177. command = atcommand_alias_db.checkAlias( command );
  178. // attempt to find the first default help command
  179. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  180. // failed to find the help property in the configuration file
  181. if( info == nullptr ){
  182. return nullptr;
  183. }
  184. // push the result from the method
  185. return info->help.c_str();
  186. }
  187. /*==========================================
  188. * @send (used for testing packet sends from the client)
  189. *------------------------------------------*/
  190. ACMD_FUNC(send)
  191. {
  192. int len=0,type;
  193. // read message type as hex number (without the 0x)
  194. if(!message || !*message ||
  195. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  196. || sscanf(message, "%8x", &type)==1) )
  197. {
  198. int i;
  199. for (i = 900; i <= 903; ++i)
  200. clif_displaymessage(fd, msg_txt(sd,i));
  201. return -1;
  202. }
  203. #define PARSE_ERROR(error,p) \
  204. {\
  205. clif_displaymessage(fd, (error));\
  206. sprintf(atcmd_output, ">%s", (p));\
  207. clif_displaymessage(fd, atcmd_output);\
  208. }
  209. //define PARSE_ERROR
  210. #define CHECK_EOS(p) \
  211. if(*(p) == 0){\
  212. clif_displaymessage(fd, "Unexpected end of string");\
  213. return -1;\
  214. }
  215. //define CHECK_EOS
  216. #define SKIP_VALUE(p) \
  217. {\
  218. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  219. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  220. }
  221. //define SKIP_VALUE
  222. #define GET_VALUE(p,num) \
  223. {\
  224. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  225. PARSE_ERROR("Invalid number in:",(p));\
  226. return -1;\
  227. }\
  228. }
  229. //define GET_VALUE
  230. if (type > 0 && type < MAX_PACKET_DB) {
  231. int off,end;
  232. long num;
  233. if(len)
  234. {// show packet length
  235. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  236. clif_displaymessage(fd, atcmd_output);
  237. return 0;
  238. }
  239. len=packet_db[type].len;
  240. off=2;
  241. if(len == 0)
  242. {// unknown packet - ERROR
  243. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  244. clif_displaymessage(fd, atcmd_output);
  245. return -1;
  246. } else if(len == -1)
  247. {// dynamic packet
  248. len=SHRT_MAX-4; // maximum length
  249. off=4;
  250. }
  251. WFIFOHEAD(fd, len);
  252. WFIFOW(fd,0)=TOW(type);
  253. // parse packet contents
  254. SKIP_VALUE(message);
  255. while(*message != 0 && off < len){
  256. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  257. {// default (byte)
  258. GET_VALUE(message,num);
  259. WFIFOB(fd,off)=TOB(num);
  260. ++off;
  261. } else if(TOUPPER(*message) == 'B')
  262. {// byte
  263. ++message;
  264. GET_VALUE(message,num);
  265. WFIFOB(fd,off)=TOB(num);
  266. ++off;
  267. } else if(TOUPPER(*message) == 'W')
  268. {// word (2 bytes)
  269. ++message;
  270. GET_VALUE(message,num);
  271. WFIFOW(fd,off)=TOW(num);
  272. off+=2;
  273. } else if(TOUPPER(*message) == 'L')
  274. {// long word (4 bytes)
  275. ++message;
  276. GET_VALUE(message,num);
  277. WFIFOL(fd,off)=TOL(num);
  278. off+=4;
  279. } else if(TOUPPER(*message) == 'S')
  280. {// string - escapes are valid
  281. // get string length - num <= 0 means not fixed length (default)
  282. ++message;
  283. if(*message == '"'){
  284. num=0;
  285. } else {
  286. GET_VALUE(message,num);
  287. while(*message != '"')
  288. {// find start of string
  289. if(*message == 0 || ISSPACE(*message)){
  290. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  291. return -1;
  292. }
  293. ++message;
  294. }
  295. }
  296. // parse string
  297. ++message;
  298. CHECK_EOS(message);
  299. end=(num<=0? 0: min(off+((int)num),len));
  300. for(; *message != '"' && (off < end || end == 0); ++off){
  301. if(*message == '\\'){
  302. ++message;
  303. CHECK_EOS(message);
  304. switch(*message){
  305. case 'a': num=0x07; break; // Bell
  306. case 'b': num=0x08; break; // Backspace
  307. case 't': num=0x09; break; // Horizontal tab
  308. case 'n': num=0x0A; break; // Line feed
  309. case 'v': num=0x0B; break; // Vertical tab
  310. case 'f': num=0x0C; break; // Form feed
  311. case 'r': num=0x0D; break; // Carriage return
  312. case 'e': num=0x1B; break; // Escape
  313. default: num=*message; break;
  314. case 'x': // Hexadecimal
  315. {
  316. ++message;
  317. CHECK_EOS(message);
  318. if(!ISXDIGIT(*message)){
  319. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  320. return -1;
  321. }
  322. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  323. if(ISXDIGIT(*message)){
  324. ++message;
  325. CHECK_EOS(message);
  326. num<<=8;
  327. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  328. }
  329. WFIFOB(fd,off)=TOB(num);
  330. ++message;
  331. CHECK_EOS(message);
  332. continue;
  333. }
  334. case '0':
  335. case '1':
  336. case '2':
  337. case '3':
  338. case '4':
  339. case '5':
  340. case '6':
  341. case '7': // Octal
  342. {
  343. num=*message-'0'; // 1st octal digit
  344. ++message;
  345. CHECK_EOS(message);
  346. if(ISDIGIT(*message) && *message < '8'){
  347. num<<=3;
  348. num+=*message-'0'; // 2nd octal digit
  349. ++message;
  350. CHECK_EOS(message);
  351. if(ISDIGIT(*message) && *message < '8'){
  352. num<<=3;
  353. num+=*message-'0'; // 3rd octal digit
  354. ++message;
  355. CHECK_EOS(message);
  356. }
  357. }
  358. WFIFOB(fd,off)=TOB(num);
  359. continue;
  360. }
  361. }
  362. } else
  363. num=*message;
  364. WFIFOB(fd,off)=TOB(num);
  365. ++message;
  366. CHECK_EOS(message);
  367. }//for
  368. while(*message != '"')
  369. {// ignore extra characters
  370. ++message;
  371. CHECK_EOS(message);
  372. }
  373. // terminate the string
  374. if(off < end)
  375. {// fill the rest with 0's
  376. memset(WFIFOP(fd,off),0,end-off);
  377. off=end;
  378. }
  379. } else
  380. {// unknown
  381. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  382. return -1;
  383. }
  384. SKIP_VALUE(message);
  385. }
  386. if(packet_db[type].len == -1)
  387. {// send dynamic packet
  388. WFIFOW(fd,2)=TOW(off);
  389. WFIFOSET(fd,off);
  390. } else
  391. {// send static packet
  392. if(off < len)
  393. memset(WFIFOP(fd,off),0,len-off);
  394. WFIFOSET(fd,len);
  395. }
  396. } else {
  397. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  398. return -1;
  399. }
  400. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  401. clif_displaymessage(fd, atcmd_output);
  402. return 0;
  403. #undef PARSE_ERROR
  404. #undef CHECK_EOS
  405. #undef SKIP_VALUE
  406. #undef GET_VALUE
  407. }
  408. /**
  409. * Retrieves map name suggestions for a given string.
  410. * This will first check if any map names contain the given string, and will
  411. * print out MAX_SUGGESTIONS results if any maps are found.
  412. * Otherwise, suggestions will be calculated through Levenshtein distance,
  413. * and up to 5 of the closest matches will be printed.
  414. *
  415. * @author Euphy
  416. */
  417. static void warp_get_suggestions(map_session_data* sd, const char *name) {
  418. // Minimum length for suggestions is 2 characters
  419. if( strlen( name ) < 2 ){
  420. return;
  421. }
  422. std::vector<const char*> suggestions;
  423. suggestions.reserve( MAX_SUGGESTIONS );
  424. // check for maps that contain string
  425. for (int i = 0; i < map_num; i++) {
  426. struct map_data *mapdata = map_getmapdata(i);
  427. // Prevent suggestion of instance mapnames
  428. if( mapdata->instance_id != 0 ){
  429. continue;
  430. }
  431. if( strstr( mapdata->name, name ) != nullptr ){
  432. suggestions.push_back( mapdata->name );
  433. if( suggestions.size() == MAX_SUGGESTIONS ){
  434. break;
  435. }
  436. }
  437. }
  438. // if no maps found, search by edit distance
  439. if( suggestions.empty() ){
  440. // Levenshtein > 4 is bad
  441. const int LEVENSHTEIN_MAX = 4;
  442. std::unordered_map<int, std::vector<const char*>> maps;
  443. for (int i = 0; i < map_num; i++) {
  444. struct map_data *mapdata = map_getmapdata(i);
  445. // Prevent suggestion of instance mapnames
  446. if(mapdata->instance_id != 0 ){
  447. continue;
  448. }
  449. // Calculate the levenshtein distance of the two strings
  450. int distance = levenshtein(mapdata->name, name);
  451. // Check if it is above the maximum defined distance
  452. if( distance > LEVENSHTEIN_MAX ){
  453. continue;
  454. }
  455. std::vector<const char*>& vector = maps[distance];
  456. // Do not add more entries than required
  457. if( vector.size() == MAX_SUGGESTIONS ){
  458. continue;
  459. }
  460. vector.push_back(mapdata->name);
  461. }
  462. for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  463. std::vector<const char*>& vector = maps[distance];
  464. for( const char* found_map : vector ){
  465. suggestions.push_back( found_map );
  466. if( suggestions.size() == MAX_SUGGESTIONS ){
  467. break;
  468. }
  469. }
  470. if( suggestions.size() == MAX_SUGGESTIONS ){
  471. break;
  472. }
  473. }
  474. }
  475. // If no suggestion could be made, do not output anything at all
  476. if( suggestions.empty() ){
  477. return;
  478. }
  479. char buffer[CHAT_SIZE_MAX];
  480. // build the suggestion string
  481. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  482. strcat(buffer, "\n");
  483. for( const char* suggestion : suggestions ){
  484. strcat(buffer, suggestion);
  485. strcat(buffer, " ");
  486. }
  487. clif_displaymessage(sd->fd, buffer);
  488. }
  489. /*==========================================
  490. * @rura, @warp, @mapmove
  491. *------------------------------------------*/
  492. ACMD_FUNC(mapmove)
  493. {
  494. char map_name[MAP_NAME_LENGTH_EXT];
  495. unsigned short mapindex;
  496. short x = 0, y = 0;
  497. int16 m = -1;
  498. nullpo_retr(-1, sd);
  499. memset(map_name, '\0', sizeof(map_name));
  500. if (!message || !*message ||
  501. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  502. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  503. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  504. return -1;
  505. }
  506. mapindex = mapindex_name2idx(map_name, nullptr);
  507. if (mapindex)
  508. m = map_mapindex2mapid(mapindex);
  509. if (m < 0) { // m < 0 means on different server! [Kevin]
  510. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  511. if (battle_config.warp_suggestions_enabled)
  512. warp_get_suggestions(sd, map_name);
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  518. if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, pc_get_group_level(sd))) {
  522. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  523. return -1;
  524. }
  525. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  526. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  527. return -1;
  528. }
  529. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  530. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  531. return -1;
  532. }
  533. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  534. return 0;
  535. }
  536. /*==========================================
  537. * Displays where a character is. Corrected version by Silent. [Skotlex]
  538. *------------------------------------------*/
  539. ACMD_FUNC(where)
  540. {
  541. map_session_data* pl_sd;
  542. nullpo_retr(-1, sd);
  543. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  544. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  545. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  546. return -1;
  547. }
  548. pl_sd = map_nick2sd(atcmd_player_name,true);
  549. if (pl_sd == nullptr ||
  550. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  551. (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  552. ) {
  553. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  554. return -1;
  555. }
  556. 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);
  557. clif_displaymessage(fd, atcmd_output);
  558. return 0;
  559. }
  560. /*==========================================
  561. *
  562. *------------------------------------------*/
  563. ACMD_FUNC(jumpto)
  564. {
  565. map_session_data* pl_sd = nullptr;;
  566. nullpo_retr(-1, sd);
  567. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  568. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  569. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  570. return -1;
  571. }
  572. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  573. {
  574. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  575. return -1;
  576. }
  577. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  578. {
  579. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  580. return -1;
  581. }
  582. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  583. {
  584. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  585. return -1;
  586. }
  587. if( pc_isdead(sd) )
  588. {
  589. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  590. return -1;
  591. }
  592. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  593. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  594. clif_displaymessage(fd, atcmd_output);
  595. return 0;
  596. }
  597. /*==========================================
  598. *
  599. *------------------------------------------*/
  600. ACMD_FUNC(jump)
  601. {
  602. short x = 0, y = 0;
  603. nullpo_retr(-1, sd);
  604. memset(atcmd_output, '\0', sizeof(atcmd_output));
  605. sscanf(message, "%6hd %6hd", &x, &y);
  606. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  607. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  608. return -1;
  609. }
  610. if( pc_isdead(sd) )
  611. {
  612. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  613. return -1;
  614. }
  615. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  616. { //This is to prevent the pc_setpos call from printing an error.
  617. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  618. if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
  619. x = y = 0; //Invalid cell, use random spot.
  620. }
  621. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  622. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  623. clif_displaymessage(fd, atcmd_output);
  624. return 0;
  625. }
  626. /*==========================================
  627. * Display list of online characters with
  628. * various info.
  629. *------------------------------------------*/
  630. ACMD_FUNC(who) {
  631. map_session_data* pl_sd = nullptr;;
  632. struct s_mapiterator *iter = nullptr;
  633. char player_name[NAME_LENGTH] = "";
  634. int count = 0;
  635. int level = 0;
  636. StringBuf buf;
  637. /**
  638. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  639. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  640. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  641. */
  642. int display_type = 1;
  643. int map_id = -1;
  644. nullpo_retr(-1, sd);
  645. if (strstr(command, "map") != nullptr) {
  646. char map_name[MAP_NAME_LENGTH_EXT] = "";
  647. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  648. map_id = sd->bl.m;
  649. } else {
  650. sscanf(message, "%23s", player_name);
  651. }
  652. if (strstr(command, "2") != nullptr)
  653. display_type = 2;
  654. else if (strstr(command, "3") != nullptr)
  655. display_type = 3;
  656. level = pc_get_group_level(sd);
  657. StringBuf_Init(&buf);
  658. iter = mapit_getallusers();
  659. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  660. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  661. if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
  662. || (map_id >= 0 && pl_sd->bl.m != map_id))
  663. continue;
  664. switch (display_type) {
  665. case 2: {
  666. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  667. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  668. StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) "
  669. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  670. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  671. break;
  672. }
  673. case 3: {
  674. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  675. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  676. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  677. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  678. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  679. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  680. break;
  681. }
  682. default: {
  683. struct party_data *p = party_search(pl_sd->status.party_id);
  684. auto &g = pl_sd->guild;
  685. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  686. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  687. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  688. if (p != nullptr)
  689. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  690. if (g != nullptr)
  691. StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
  692. break;
  693. }
  694. }
  695. clif_displaymessage(fd, StringBuf_Value(&buf));
  696. StringBuf_Clear(&buf);
  697. count++;
  698. }
  699. }
  700. mapit_free(iter);
  701. if (map_id < 0) {
  702. if (count == 0)
  703. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  704. else if (count == 1)
  705. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  706. else
  707. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  708. } else {
  709. struct map_data *mapdata = map_getmapdata(map_id);
  710. if (count == 0)
  711. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  712. else if (count == 1)
  713. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  714. else
  715. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  716. }
  717. clif_displaymessage(fd, StringBuf_Value(&buf));
  718. StringBuf_Destroy(&buf);
  719. return 0;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------*/
  724. ACMD_FUNC(whogm)
  725. {
  726. map_session_data* pl_sd;
  727. struct s_mapiterator* iter;
  728. int j, count;
  729. int level;
  730. char match_text[CHAT_SIZE_MAX];
  731. char player_name[NAME_LENGTH];
  732. struct party_data *p;
  733. nullpo_retr(-1, sd);
  734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  735. memset(match_text, '\0', sizeof(match_text));
  736. memset(player_name, '\0', sizeof(player_name));
  737. if (sscanf(message, "%255[^\n]", match_text) < 1)
  738. strcpy(match_text, "");
  739. for (j = 0; match_text[j]; j++)
  740. match_text[j] = TOLOWER(match_text[j]);
  741. count = 0;
  742. level = pc_get_group_level(sd);
  743. iter = mapit_getallusers();
  744. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  745. {
  746. int pl_level = pc_get_group_level(pl_sd);
  747. if (!pl_level)
  748. continue;
  749. if (match_text[0])
  750. {
  751. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  752. for (j = 0; player_name[j]; j++)
  753. player_name[j] = TOLOWER(player_name[j]);
  754. // search with no case sensitive
  755. if (strstr(player_name, match_text) == nullptr)
  756. continue;
  757. }
  758. if (pl_level > level) {
  759. if (pc_isinvisible(pl_sd))
  760. continue;
  761. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  762. clif_displaymessage(fd, atcmd_output);
  763. count++;
  764. continue;
  765. }
  766. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  767. pl_sd->status.name, pl_level,
  768. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  769. clif_displaymessage(fd, atcmd_output);
  770. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  771. pl_sd->status.base_level,
  772. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  773. clif_displaymessage(fd, atcmd_output);
  774. p = party_search(pl_sd->status.party_id);
  775. auto &g = pl_sd->guild;
  776. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  777. p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None.
  778. clif_displaymessage(fd, atcmd_output);
  779. count++;
  780. }
  781. mapit_free(iter);
  782. if (count == 0)
  783. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  784. else if (count == 1)
  785. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  786. else {
  787. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  788. clif_displaymessage(fd, atcmd_output);
  789. }
  790. return 0;
  791. }
  792. /*==========================================
  793. *
  794. *------------------------------------------*/
  795. ACMD_FUNC(save)
  796. {
  797. nullpo_retr(-1, sd);
  798. if( map_getmapdata(sd->bl.m)->instance_id ) {
  799. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  800. return 1;
  801. }
  802. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  803. if (sd->status.pet_id > 0 && sd->pd)
  804. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  805. chrif_save(sd, CSAVE_NORMAL);
  806. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  807. return 0;
  808. }
  809. /*==========================================
  810. *
  811. *------------------------------------------*/
  812. ACMD_FUNC(load){
  813. nullpo_retr(-1, sd);
  814. uint16 mapindex = mapindex_name2id( sd->status.save_point.map );
  815. int16 m = map_mapindex2mapid( mapindex );
  816. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  817. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  818. return -1;
  819. }
  820. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  821. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  822. return -1;
  823. }
  824. pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT );
  825. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  826. return 0;
  827. }
  828. /*==========================================
  829. *
  830. *------------------------------------------*/
  831. ACMD_FUNC(speed)
  832. {
  833. short speed;
  834. nullpo_retr(-1, sd);
  835. memset(atcmd_output, '\0', sizeof(atcmd_output));
  836. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  837. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  838. clif_displaymessage(fd, atcmd_output);
  839. return -1;
  840. }
  841. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  842. if (speed < 0)
  843. sd->base_status.speed = DEFAULT_WALK_SPEED;
  844. else
  845. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  846. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  847. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  848. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  849. } else
  850. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  851. status_calc_bl(&sd->bl, { SCB_SPEED });
  852. return 0;
  853. }
  854. /*==========================================
  855. *
  856. *------------------------------------------*/
  857. ACMD_FUNC(storage)
  858. {
  859. nullpo_retr(-1, sd);
  860. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  861. return -1;
  862. if (storage_storageopen(sd) == 1)
  863. { //Already open.
  864. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  865. return -1;
  866. }
  867. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  868. return 0;
  869. }
  870. /*==========================================
  871. *
  872. *------------------------------------------*/
  873. ACMD_FUNC(guildstorage)
  874. {
  875. nullpo_retr(-1, sd);
  876. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  877. return -1;
  878. switch (storage_guild_storageopen(sd)) {
  879. case GSTORAGE_OPEN:
  880. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  881. break;
  882. case GSTORAGE_STORAGE_ALREADY_OPEN:
  883. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  884. return -1;
  885. case GSTORAGE_ALREADY_OPEN:
  886. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  887. return -1;
  888. case GSTORAGE_NO_GUILD:
  889. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  890. return -1;
  891. case GSTORAGE_NO_STORAGE:
  892. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  893. return -1;
  894. case GSTORAGE_NO_PERMISSION:
  895. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  896. return -1;
  897. }
  898. return 0;
  899. }
  900. /*==========================================
  901. *
  902. *------------------------------------------*/
  903. ACMD_FUNC(option)
  904. {
  905. int param1 = 0, param2 = 0, param3 = 0;
  906. nullpo_retr(-1, sd);
  907. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  908. {// failed to match the parameters so inform the user of the options
  909. const char* text;
  910. // attempt to find the setting information for this command
  911. text = atcommand_help_string( command );
  912. // notify the user of the requirement to enter an option
  913. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  914. if( text )
  915. {// send the help text associated with this command
  916. clif_displaymessage( fd, text );
  917. }
  918. return -1;
  919. }
  920. sd->sc.opt1 = param1;
  921. sd->sc.opt2 = param2;
  922. pc_setoption(sd, param3);
  923. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  924. return 0;
  925. }
  926. /*==========================================
  927. *
  928. *------------------------------------------*/
  929. ACMD_FUNC(hide)
  930. {
  931. nullpo_retr(-1, sd);
  932. if (pc_isinvisible(sd)) {
  933. sd->sc.option &= ~OPTION_INVISIBLE;
  934. if (sd->disguise)
  935. status_set_viewdata(&sd->bl, sd->disguise);
  936. else
  937. status_set_viewdata(&sd->bl, sd->status.class_);
  938. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  939. // increment the number of pvp players on the map
  940. map_getmapdata(sd->bl.m)->users_pvp++;
  941. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  942. {// register the player for ranking calculations
  943. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  944. }
  945. //bugreport:2266
  946. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  947. } else {
  948. sd->sc.option |= OPTION_INVISIBLE;
  949. sd->vd.class_ = JT_INVISIBLE;
  950. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  951. // decrement the number of pvp players on the map
  952. map_getmapdata(sd->bl.m)->users_pvp--;
  953. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  954. {// unregister the player for ranking
  955. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  956. sd->pvp_timer = INVALID_TIMER;
  957. }
  958. }
  959. clif_changeoption(&sd->bl);
  960. return 0;
  961. }
  962. ACMD_FUNC(resetcooltime)
  963. {
  964. nullpo_retr(-1, sd);
  965. for( size_t i = 0; i < ARRAYLENGTH( sd->scd ); i++ ){
  966. if( sd->scd[i] != nullptr ) {
  967. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( sd->scd[i]->skill_id )->name ); // Found skill '%s', unblocking...
  968. clif_displaymessage( sd->fd, atcmd_output );
  969. if (battle_config.display_status_timers)
  970. clif_skill_cooldown( *sd, sd->scd[i]->skill_id, 0 );
  971. delete_timer(sd->scd[i]->timer, skill_blockpc_end);
  972. aFree(sd->scd[i]);
  973. sd->scd[i] = nullptr;
  974. }
  975. }
  976. if( sd->hd != nullptr && hom_is_active( sd->hd ) ){
  977. for( const uint16& skill_id : sd->hd->blockskill ){
  978. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( skill_id )->name ); // Found skill '%s', unblocking...
  979. clif_displaymessage( sd->fd, atcmd_output );
  980. if (battle_config.display_status_timers)
  981. clif_skill_cooldown( *sd, skill_id, 0 );
  982. }
  983. sd->hd->blockskill.clear();
  984. }
  985. if( sd->md != nullptr ){
  986. for( const uint16& skill_id : sd->md->blockskill ){
  987. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( skill_id )->name ); // Found skill '%s', unblocking...
  988. clif_displaymessage( sd->fd, atcmd_output );
  989. if (battle_config.display_status_timers)
  990. clif_skill_cooldown( *sd, skill_id, 0 );
  991. }
  992. sd->md->blockskill.clear();
  993. }
  994. return 0;
  995. }
  996. /*==========================================
  997. * Changes a character's class
  998. *------------------------------------------*/
  999. ACMD_FUNC(jobchange)
  1000. {
  1001. int job = 0, upper = 0;
  1002. const char* text;
  1003. nullpo_retr(-1, sd);
  1004. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  1005. int i;
  1006. bool found = false;
  1007. upper = 0;
  1008. // Normal Jobs
  1009. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  1010. if (strncmpi(message, job_name(i), 16) == 0) {
  1011. job = i;
  1012. found = true;
  1013. }
  1014. }
  1015. // High Jobs, Babys, Third, and Fourth
  1016. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  1017. if (strncmpi(message, job_name(i), 16) == 0) {
  1018. job = i;
  1019. found = true;
  1020. }
  1021. }
  1022. if (!found) {
  1023. text = atcommand_help_string(command);
  1024. if (text)
  1025. clif_displaymessage(fd, text);
  1026. return -1;
  1027. }
  1028. }
  1029. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  1030. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  1031. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  1032. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  1033. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  1034. { // Deny direct transformation into dummy jobs
  1035. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1036. return 0;
  1037. }
  1038. if (pcdb_checkid(job))
  1039. {
  1040. if (pc_jobchange(sd, job, upper))
  1041. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1042. else {
  1043. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1044. return -1;
  1045. }
  1046. } else {
  1047. text = atcommand_help_string(command);
  1048. if (text)
  1049. clif_displaymessage(fd, text);
  1050. return -1;
  1051. }
  1052. return 0;
  1053. }
  1054. /*==========================================
  1055. *
  1056. *------------------------------------------*/
  1057. ACMD_FUNC(kill)
  1058. {
  1059. nullpo_retr(-1, sd);
  1060. status_kill(&sd->bl);
  1061. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1062. if (fd != sd->fd)
  1063. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1064. return 0;
  1065. }
  1066. /*==========================================
  1067. *
  1068. *------------------------------------------*/
  1069. ACMD_FUNC(alive)
  1070. {
  1071. nullpo_retr(-1, sd);
  1072. if (!status_revive(&sd->bl, 100, 100))
  1073. {
  1074. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1075. return -1;
  1076. }
  1077. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  1078. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1079. return 0;
  1080. }
  1081. /*==========================================
  1082. * +kamic [LuzZza]
  1083. *------------------------------------------*/
  1084. ACMD_FUNC(kami)
  1085. {
  1086. unsigned long color=0;
  1087. nullpo_retr(-1, sd);
  1088. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1089. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  1090. if (!message || !*message) {
  1091. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1092. return -1;
  1093. }
  1094. sscanf(message, "%255[^\n]", atcmd_output);
  1095. if (strstr(command, "l") != nullptr)
  1096. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1097. else
  1098. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  1099. } else {
  1100. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1101. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1102. return -1;
  1103. }
  1104. if(color > 0xFFFFFF) {
  1105. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1106. return -1;
  1107. }
  1108. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1109. }
  1110. return 0;
  1111. }
  1112. /*==========================================
  1113. *
  1114. *------------------------------------------*/
  1115. ACMD_FUNC(heal)
  1116. {
  1117. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1118. nullpo_retr(-1, sd);
  1119. sscanf(message, "%11d %11d", &hp, &sp);
  1120. // some overflow checks
  1121. if( hp == INT_MIN ) hp++;
  1122. if( sp == INT_MIN ) sp++;
  1123. if ( hp == 0 && sp == 0 ) {
  1124. if (!status_percent_heal(&sd->bl, 100, 100))
  1125. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1126. else
  1127. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1128. return 0;
  1129. }
  1130. if ( hp > 0 && sp >= 0 ) {
  1131. if(!status_heal(&sd->bl, hp, sp, 0))
  1132. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1133. else
  1134. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1135. return 0;
  1136. }
  1137. if ( hp < 0 && sp <= 0 ) {
  1138. status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
  1139. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1140. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1141. return 0;
  1142. }
  1143. //Opposing signs.
  1144. if ( hp ) {
  1145. if (hp > 0)
  1146. status_heal(&sd->bl, hp, 0, 0);
  1147. else {
  1148. status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
  1149. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1150. }
  1151. }
  1152. if ( sp ) {
  1153. if (sp > 0)
  1154. status_heal(&sd->bl, 0, sp, 0);
  1155. else
  1156. status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
  1157. }
  1158. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1159. return 0;
  1160. }
  1161. /*==========================================
  1162. * Recover's AP and allows exact adjustments. [Rytech]
  1163. *------------------------------------------*/
  1164. ACMD_FUNC(healap)
  1165. {
  1166. int ap = 0;
  1167. nullpo_retr(-1, sd);
  1168. sscanf(message, "%11d", &ap);
  1169. // Overflow check.
  1170. if (ap == INT_MIN) ap++;
  1171. if (ap == 0) {
  1172. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1173. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1174. else
  1175. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1176. return 0;
  1177. }else if (ap > 0) {
  1178. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1179. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1180. else
  1181. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1182. return 0;
  1183. }else{
  1184. status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1185. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1186. return 0;
  1187. }
  1188. }
  1189. /*==========================================
  1190. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1191. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1192. *------------------------------------------*/
  1193. ACMD_FUNC(item)
  1194. {
  1195. char item_name[100];
  1196. int number = 0, bound = BOUND_NONE;
  1197. char flag = 0;
  1198. char *itemlist;
  1199. nullpo_retr(-1, sd);
  1200. memset(item_name, '\0', sizeof(item_name));
  1201. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1202. if (!strcmpi(parent_cmd,"itembound")) {
  1203. if (!message || !*message || (
  1204. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1205. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1206. {
  1207. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1208. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1209. return -1;
  1210. }
  1211. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1212. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1213. return -1;
  1214. }
  1215. } else if (!message || !*message || (
  1216. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1217. sscanf(message, "%99s %11d", item_name, &number) < 1
  1218. )) {
  1219. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1220. return -1;
  1221. }
  1222. std::vector<std::shared_ptr<item_data>> items;
  1223. itemlist = strtok(item_name, ":");
  1224. while( itemlist != nullptr ){
  1225. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1226. if( item == nullptr ){
  1227. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1228. }
  1229. if( item == nullptr ){
  1230. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1231. return -1;
  1232. }
  1233. items.push_back( item );
  1234. itemlist = strtok(nullptr, ":"); //next itemline
  1235. }
  1236. if (number <= 0)
  1237. number = 1;
  1238. int get_count = number;
  1239. // Produce items in list
  1240. for( const auto& item : items ){
  1241. t_itemid item_id = item->nameid;
  1242. //Check if it's stackable.
  1243. if( !itemdb_isstackable2( item.get() ) ){
  1244. get_count = 1;
  1245. }
  1246. for( int i = 0; i < number; i += get_count ){
  1247. // if not pet egg
  1248. if (!pet_create_egg(sd, item_id)) {
  1249. struct item item_tmp = {};
  1250. item_tmp.nameid = item_id;
  1251. item_tmp.identify = 1;
  1252. item_tmp.bound = bound;
  1253. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1254. clif_additem(sd, 0, 0, flag);
  1255. }
  1256. }
  1257. }
  1258. if (flag == 0)
  1259. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1260. return 0;
  1261. }
  1262. /*==========================================
  1263. *
  1264. *------------------------------------------*/
  1265. ACMD_FUNC(item2)
  1266. {
  1267. char item_name[100];
  1268. int number = 0, bound = BOUND_NONE;
  1269. int identify = 0, refine = 0, attr = 0;
  1270. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1271. nullpo_retr(-1, sd);
  1272. memset(item_name, '\0', sizeof(item_name));
  1273. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1274. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1275. if (!message || !*message || (
  1276. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1277. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1278. {
  1279. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1280. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1281. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1282. return -1;
  1283. }
  1284. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1285. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1286. return -1;
  1287. }
  1288. } else if ( !message || !*message || (
  1289. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1290. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1291. )) {
  1292. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1293. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1294. return -1;
  1295. }
  1296. if (number <= 0)
  1297. number = 1;
  1298. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1299. if( item_data == nullptr ){
  1300. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1301. }
  1302. if( item_data != nullptr ){
  1303. int loop, get_count, i;
  1304. char flag = 0;
  1305. //Check if it's stackable.
  1306. if( !itemdb_isstackable2( item_data.get() ) ){
  1307. loop = number;
  1308. get_count = 1;
  1309. }else{
  1310. loop = 1;
  1311. get_count = number;
  1312. }
  1313. if( itemdb_isequip2( item_data.get() ) ){
  1314. refine = cap_value( refine, 0, MAX_REFINE );
  1315. }else{
  1316. // All other items cannot be refined and are always identified
  1317. identify = 1;
  1318. refine = attr = 0;
  1319. }
  1320. for (i = 0; i < loop; i++) {
  1321. // if not pet egg
  1322. if (!pet_create_egg(sd, item_data->nameid)) {
  1323. struct item item_tmp = {};
  1324. item_tmp.nameid = item_data->nameid;
  1325. item_tmp.identify = identify;
  1326. item_tmp.refine = refine;
  1327. item_tmp.attribute = attr;
  1328. item_tmp.card[0] = c1;
  1329. item_tmp.card[1] = c2;
  1330. item_tmp.card[2] = c3;
  1331. item_tmp.card[3] = c4;
  1332. item_tmp.bound = bound;
  1333. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1334. clif_additem(sd, 0, 0, flag);
  1335. }
  1336. }
  1337. if (flag == 0)
  1338. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1339. } else {
  1340. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1341. return -1;
  1342. }
  1343. return 0;
  1344. }
  1345. /*==========================================
  1346. *
  1347. *------------------------------------------*/
  1348. ACMD_FUNC(itemreset)
  1349. {
  1350. int i;
  1351. nullpo_retr(-1, sd);
  1352. for (i = 0; i < MAX_INVENTORY; i++) {
  1353. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  1354. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1355. }
  1356. }
  1357. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1358. return 0;
  1359. }
  1360. /*==========================================
  1361. * Atcommand @lvlup
  1362. *------------------------------------------*/
  1363. ACMD_FUNC(baselevelup)
  1364. {
  1365. int level=0, i=0, status_point=0, trait_point=0;
  1366. nullpo_retr(-1, sd);
  1367. level = atoi(message);
  1368. if (!message || !*message || !level) {
  1369. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1370. return -1;
  1371. }
  1372. if (level > 0) {
  1373. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1374. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1375. return -1;
  1376. } // End Addition
  1377. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1378. level = pc_maxbaselv(sd) - sd->status.base_level;
  1379. for (i = 0; i < level; i++)
  1380. {
  1381. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1382. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1383. }
  1384. sd->status.status_point += status_point;
  1385. sd->status.trait_point += trait_point;
  1386. sd->status.base_level += (unsigned int)level;
  1387. status_calc_pc(sd, SCO_FORCE);
  1388. status_percent_heal(&sd->bl, 100, 100);
  1389. clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
  1390. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1391. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1392. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1393. }
  1394. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1395. } else {
  1396. if (sd->status.base_level == 1) {
  1397. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1398. return -1;
  1399. }
  1400. level*=-1;
  1401. if ((unsigned int)level >= sd->status.base_level)
  1402. level = sd->status.base_level-1;
  1403. for (i = 0; i > -level; i--)
  1404. {
  1405. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1406. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1407. }
  1408. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1409. pc_resetstate(sd);
  1410. if (sd->status.status_point < status_point)
  1411. sd->status.status_point = 0;
  1412. else
  1413. sd->status.status_point -= status_point;
  1414. if (sd->status.trait_point < trait_point)
  1415. sd->status.trait_point = 0;
  1416. else
  1417. sd->status.trait_point -= trait_point;
  1418. sd->status.base_level -= (unsigned int)level;
  1419. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1420. status_calc_pc(sd, SCO_FORCE);
  1421. level*=-1;
  1422. }
  1423. sd->status.base_exp = 0;
  1424. clif_updatestatus(*sd, SP_STATUSPOINT);
  1425. clif_updatestatus(*sd, SP_TRAITPOINT);
  1426. clif_updatestatus(*sd, SP_BASELEVEL);
  1427. clif_updatestatus(*sd, SP_BASEEXP);
  1428. clif_updatestatus(*sd, SP_NEXTBASEEXP);
  1429. pc_baselevelchanged(sd);
  1430. if(sd->status.party_id)
  1431. party_send_levelup(sd);
  1432. if( level > 0 && battle_config.atcommand_levelup_events )
  1433. npc_script_event( *sd, NPCE_BASELVUP );
  1434. return 0;
  1435. }
  1436. /*==========================================
  1437. *
  1438. *------------------------------------------*/
  1439. ACMD_FUNC(joblevelup)
  1440. {
  1441. int level=0;
  1442. nullpo_retr(-1, sd);
  1443. level = atoi(message);
  1444. if (!message || !*message || !level) {
  1445. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1446. return -1;
  1447. }
  1448. if (level > 0) {
  1449. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1450. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1451. return -1;
  1452. }
  1453. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1454. level = pc_maxjoblv(sd) - sd->status.job_level;
  1455. sd->status.job_level += (unsigned int)level;
  1456. sd->status.skill_point += level;
  1457. clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
  1458. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1459. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1460. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1461. } else {
  1462. if (sd->status.job_level == 1) {
  1463. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1464. return -1;
  1465. }
  1466. level *=-1;
  1467. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1468. level = sd->status.job_level-1;
  1469. sd->status.job_level -= (unsigned int)level;
  1470. if (sd->status.skill_point < level)
  1471. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1472. if (sd->status.skill_point < level)
  1473. sd->status.skill_point = 0;
  1474. else
  1475. sd->status.skill_point -= level;
  1476. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1477. level *=-1;
  1478. }
  1479. sd->status.job_exp = 0;
  1480. clif_updatestatus(*sd, SP_JOBLEVEL);
  1481. clif_updatestatus(*sd, SP_JOBEXP);
  1482. clif_updatestatus(*sd, SP_NEXTJOBEXP);
  1483. clif_updatestatus(*sd, SP_SKILLPOINT);
  1484. status_calc_pc(sd, SCO_FORCE);
  1485. if( level > 0 && battle_config.atcommand_levelup_events )
  1486. npc_script_event( *sd, NPCE_JOBLVUP );
  1487. return 0;
  1488. }
  1489. /*==========================================
  1490. * @help
  1491. *------------------------------------------*/
  1492. ACMD_FUNC(help){
  1493. const char *command_name = nullptr;
  1494. nullpo_retr(-1, sd);
  1495. if (!message || !*message) {
  1496. command_name = "help"; // If no command_name specified, display help for @help.
  1497. } else {
  1498. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1499. ++message;
  1500. command_name = atcommand_alias_db.checkAlias(message);
  1501. }
  1502. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1503. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1504. clif_displaymessage(fd, atcmd_output);
  1505. atcommand_get_suggestions(sd, command_name, true);
  1506. return -1;
  1507. }
  1508. // attempt to find the first default help command
  1509. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1510. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1511. if( text == nullptr ){
  1512. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1513. clif_displaymessage(fd, atcmd_output);
  1514. atcommand_get_suggestions(sd, command_name, true);
  1515. return -1;
  1516. }
  1517. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1518. clif_displaymessage(fd, atcmd_output);
  1519. { // Display aliases
  1520. StringBuf buf;
  1521. bool has_aliases = false;
  1522. StringBuf_Init(&buf);
  1523. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1524. for( const std::string& alias : info->aliases ){
  1525. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1526. has_aliases = true;
  1527. }
  1528. if (has_aliases)
  1529. clif_displaymessage(fd, StringBuf_Value(&buf));
  1530. StringBuf_Destroy(&buf);
  1531. }
  1532. // Display help contents
  1533. clif_displaymessage(fd, text);
  1534. return 0;
  1535. }
  1536. /*==========================================
  1537. *
  1538. *------------------------------------------*/
  1539. ACMD_FUNC(pvpoff)
  1540. {
  1541. nullpo_retr(-1, sd);
  1542. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1543. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1544. return -1;
  1545. }
  1546. map_setmapflag(sd->bl.m, MF_PVP, false);
  1547. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1548. return 0;
  1549. }
  1550. /*==========================================
  1551. *
  1552. *------------------------------------------*/
  1553. ACMD_FUNC(pvpon)
  1554. {
  1555. nullpo_retr(-1, sd);
  1556. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1557. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1558. return -1;
  1559. }
  1560. map_setmapflag(sd->bl.m, MF_PVP, true);
  1561. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1562. return 0;
  1563. }
  1564. /*==========================================
  1565. *
  1566. *------------------------------------------*/
  1567. ACMD_FUNC(gvgoff)
  1568. {
  1569. nullpo_retr(-1, sd);
  1570. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1571. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1572. return -1;
  1573. }
  1574. map_setmapflag(sd->bl.m, MF_GVG, false);
  1575. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1576. return 0;
  1577. }
  1578. /*==========================================
  1579. *
  1580. *------------------------------------------*/
  1581. ACMD_FUNC(gvgon)
  1582. {
  1583. nullpo_retr(-1, sd);
  1584. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1585. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1586. return -1;
  1587. }
  1588. map_setmapflag(sd->bl.m, MF_GVG, true);
  1589. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1590. return 0;
  1591. }
  1592. /*==========================================
  1593. *
  1594. *------------------------------------------*/
  1595. ACMD_FUNC(model)
  1596. {
  1597. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1598. nullpo_retr(-1, sd);
  1599. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1600. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1601. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1602. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1603. clif_displaymessage(fd, atcmd_output);
  1604. return -1;
  1605. }
  1606. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1607. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1608. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1609. pc_changelook(sd, LOOK_HAIR, hair_style);
  1610. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1611. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1612. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1613. } else {
  1614. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1615. return -1;
  1616. }
  1617. return 0;
  1618. }
  1619. /*==========================================
  1620. * @bodystyle [Rytech]
  1621. *------------------------------------------*/
  1622. ACMD_FUNC(bodystyle)
  1623. {
  1624. int body_style = 0;
  1625. nullpo_retr(-1, sd);
  1626. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1627. if ( (sd->class_ & JOBL_FOURTH) || !(sd->class_ & JOBL_THIRD) || (sd->class_ & MAPID_THIRDMASK) == MAPID_SUPER_NOVICE_E || (sd->class_ & MAPID_THIRDMASK) == MAPID_STAR_EMPEROR || (sd->class_ & MAPID_THIRDMASK) == MAPID_SOUL_REAPER) {
  1628. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1629. return -1;
  1630. }
  1631. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1632. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1633. clif_displaymessage(fd, atcmd_output);
  1634. return -1;
  1635. }
  1636. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1637. pc_changelook(sd, LOOK_BODY2, body_style);
  1638. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1639. } else {
  1640. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1641. return -1;
  1642. }
  1643. return 0;
  1644. }
  1645. /*==========================================
  1646. * @dye && @ccolor
  1647. *------------------------------------------*/
  1648. ACMD_FUNC(dye)
  1649. {
  1650. int cloth_color = 0;
  1651. nullpo_retr(-1, sd);
  1652. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1653. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1654. sprintf(atcmd_output, msg_txt(sd,992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>).
  1655. clif_displaymessage(fd, atcmd_output);
  1656. return -1;
  1657. }
  1658. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1659. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1660. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1661. } else {
  1662. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1663. return -1;
  1664. }
  1665. return 0;
  1666. }
  1667. /*==========================================
  1668. * @hairstyle && @hstyle
  1669. *------------------------------------------*/
  1670. ACMD_FUNC(hair_style)
  1671. {
  1672. int hair_style = 0;
  1673. nullpo_retr(-1, sd);
  1674. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1675. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1676. sprintf(atcmd_output, msg_txt(sd,993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>).
  1677. clif_displaymessage(fd, atcmd_output);
  1678. return -1;
  1679. }
  1680. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1681. pc_changelook(sd, LOOK_HAIR, hair_style);
  1682. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1683. } else {
  1684. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1685. return -1;
  1686. }
  1687. return 0;
  1688. }
  1689. /*==========================================
  1690. * @haircolor && @hcolor
  1691. *------------------------------------------*/
  1692. ACMD_FUNC(hair_color)
  1693. {
  1694. int hair_color = 0;
  1695. nullpo_retr(-1, sd);
  1696. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1697. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1698. sprintf(atcmd_output, msg_txt(sd,994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>).
  1699. clif_displaymessage(fd, atcmd_output);
  1700. return -1;
  1701. }
  1702. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1703. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1704. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1705. } else {
  1706. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1707. return -1;
  1708. }
  1709. return 0;
  1710. }
  1711. /*==========================================
  1712. * @go [city_number or city_name] - Updated by Harbin
  1713. *------------------------------------------*/
  1714. ACMD_FUNC(go)
  1715. {
  1716. int i;
  1717. int town;
  1718. char map_name[MAP_NAME_LENGTH];
  1719. const struct {
  1720. char map[MAP_NAME_LENGTH];
  1721. int x, y;
  1722. } data[] = {
  1723. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1724. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1725. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1726. { MAP_PAYON, 162, 233 }, // 3=Payon
  1727. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1728. #ifdef RENEWAL
  1729. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1730. #else
  1731. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1732. #endif
  1733. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1734. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1735. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1736. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1737. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1738. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1739. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1740. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1741. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1742. #ifdef RENEWAL
  1743. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1744. #else
  1745. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1746. #endif
  1747. { MAP_JAIL, 23, 61 }, // 16=Prison
  1748. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1749. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1750. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1751. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1752. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1753. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1754. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1755. { MAP_VEINS, 216, 123 }, // 24=Veins
  1756. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1757. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1758. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1759. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1760. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1761. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1762. { MAP_MORA, 44, 151 }, // 31=Mora
  1763. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1764. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1765. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1766. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1767. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1768. };
  1769. nullpo_retr(-1, sd);
  1770. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1771. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1772. return 0;
  1773. }
  1774. memset(map_name, '\0', sizeof(map_name));
  1775. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1776. // get the number
  1777. town = atoi(message);
  1778. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1779. {// no value matched so send the list of locations
  1780. const char* text;
  1781. // attempt to find the text help string
  1782. text = atcommand_help_string( command );
  1783. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1784. if( text )
  1785. {// send the text to the client
  1786. clif_displaymessage( fd, text );
  1787. }
  1788. return -1;
  1789. }
  1790. // get possible name of the city
  1791. map_name[MAP_NAME_LENGTH-1] = '\0';
  1792. for (i = 0; map_name[i]; i++)
  1793. map_name[i] = TOLOWER(map_name[i]);
  1794. // try to identify the map name
  1795. if (strncmp(map_name, "prontera", 3) == 0) {
  1796. town = 0;
  1797. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1798. strncmp(map_name, "morroc", 4) == 0) {
  1799. town = 1;
  1800. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1801. town = 2;
  1802. } else if (strncmp(map_name, "payon", 3) == 0) {
  1803. town = 3;
  1804. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1805. town = 4;
  1806. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1807. town = 5;
  1808. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1809. town = 6;
  1810. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1811. strcmp(map_name, "christmas") == 0 ||
  1812. strncmp(map_name, "xmas", 3) == 0 ||
  1813. strncmp(map_name, "x-mas", 3) == 0) {
  1814. town = 7;
  1815. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1816. town = 8;
  1817. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1818. strncmp(map_name, "yuno", 3) == 0) {
  1819. town = 9;
  1820. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1821. town = 10;
  1822. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1823. strncmp(map_name, "gonryun", 3) == 0) {
  1824. town = 11;
  1825. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1826. town = 12;
  1827. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1828. town = 13;
  1829. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1830. town = 14;
  1831. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1832. strncmp(map_name, "startpoint", 3) == 0 ||
  1833. strncmp(map_name, "beginning", 3) == 0) {
  1834. town = 15;
  1835. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1836. strncmp(map_name, "prison", 3) == 0 ||
  1837. strncmp(map_name, "jail", 3) == 0) {
  1838. town = 16;
  1839. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1840. town = 17;
  1841. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1842. town = 18;
  1843. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1844. town = 19;
  1845. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1846. town = 20;
  1847. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1848. town = 21;
  1849. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1850. town = 22;
  1851. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1852. town = 23;
  1853. } else if (strncmp(map_name, "veins", 3) == 0) {
  1854. town = 24;
  1855. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1856. town = 25;
  1857. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1858. town = 26;
  1859. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1860. town = 27;
  1861. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1862. town = 28;
  1863. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1864. town = 29;
  1865. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1866. town = 30;
  1867. } else if (strcmp(map_name, "mora") == 0) {
  1868. town = 31;
  1869. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1870. town = 32;
  1871. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1872. town = 33;
  1873. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1874. town = 34;
  1875. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1876. town = 35;
  1877. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1878. town = 36;
  1879. }
  1880. if (town >= 0 && town < ARRAYLENGTH(data))
  1881. {
  1882. int16 m = map_mapname2mapid(data[town].map);
  1883. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1884. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1885. return -1;
  1886. }
  1887. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1888. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1889. return -1;
  1890. }
  1891. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1892. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1893. } else {
  1894. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1895. return -1;
  1896. }
  1897. } else { // if you arrive here, you have an error in town variable when reading of names
  1898. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1899. return -1;
  1900. }
  1901. return 0;
  1902. }
  1903. /*==========================================
  1904. *
  1905. *------------------------------------------*/
  1906. ACMD_FUNC(monster)
  1907. {
  1908. char name[NAME_LENGTH];
  1909. char monster[NAME_LENGTH];
  1910. char eventname[EVENT_NAME_LENGTH] = "";
  1911. int mob_id;
  1912. int number = 0;
  1913. int count;
  1914. int i, range;
  1915. short mx, my;
  1916. unsigned int size;
  1917. nullpo_retr(-1, sd);
  1918. memset(name, '\0', sizeof(name));
  1919. memset(monster, '\0', sizeof(monster));
  1920. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1921. if (!message || !*message) {
  1922. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1923. return -1;
  1924. }
  1925. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1926. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1927. //All data can be left as it is.
  1928. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1929. //Here, it is possible name was not given and we are using monster for it.
  1930. if (count < 3) //Blank mob's name.
  1931. name[0] = '\0';
  1932. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1933. //All data can be left as it is.
  1934. } else if (sscanf(message, "%23s", monster) > 0) {
  1935. //As before, name may be already filled.
  1936. name[0] = '\0';
  1937. } else {
  1938. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1939. return -1;
  1940. }
  1941. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1942. mob_id = mobdb_checkid(atoi(monster));
  1943. if (mob_id == 0) {
  1944. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1945. return -1;
  1946. }
  1947. if (mob_id == MOBID_EMPERIUM) {
  1948. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1949. return -1;
  1950. }
  1951. if (number <= 0)
  1952. number = 1;
  1953. if( !name[0] )
  1954. strcpy(name, "--ja--");
  1955. // 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
  1956. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1957. number = battle_config.atc_spawn_quantity_limit;
  1958. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1959. if (strcmp(parent_cmd, "monstersmall") == 0)
  1960. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1961. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1962. size = SZ_BIG;
  1963. else
  1964. size = SZ_SMALL;
  1965. if (battle_config.etc_log)
  1966. 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);
  1967. count = 0;
  1968. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1969. for (i = 0; i < number; i++) {
  1970. int k;
  1971. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1972. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1973. if(k) {
  1974. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1975. count ++;
  1976. }
  1977. }
  1978. if (count != 0)
  1979. if (number == count)
  1980. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1981. else {
  1982. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1983. clif_displaymessage(fd, atcmd_output);
  1984. }
  1985. else {
  1986. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1987. return -1;
  1988. }
  1989. return 0;
  1990. }
  1991. /*==========================================
  1992. *
  1993. *------------------------------------------*/
  1994. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1995. {
  1996. struct mob_data *md;
  1997. int flag;
  1998. nullpo_ret(md=(struct mob_data *)bl);
  1999. flag = va_arg(ap, int);
  2000. if (md->guardian_data)
  2001. return 0; //Do not touch WoE mobs!
  2002. if (flag)
  2003. status_zap(bl,md->status.hp, 0);
  2004. else
  2005. status_kill(bl);
  2006. return 1;
  2007. }
  2008. ACMD_FUNC(killmonster)
  2009. {
  2010. int map_id, drop_flag;
  2011. char map_name[MAP_NAME_LENGTH_EXT];
  2012. nullpo_retr(-1, sd);
  2013. memset(map_name, '\0', sizeof(map_name));
  2014. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2015. map_id = sd->bl.m;
  2016. else {
  2017. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2018. map_id = sd->bl.m;
  2019. }
  2020. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2021. drop_flag = strcmpi(parent_cmd, "killmonster2");
  2022. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  2023. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  2024. return 0;
  2025. }
  2026. /*==========================================
  2027. *
  2028. *------------------------------------------*/
  2029. ACMD_FUNC(refine)
  2030. {
  2031. int j, position = 0, refine = 0, current_position, final_refine;
  2032. int count;
  2033. nullpo_retr(-1, sd);
  2034. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2035. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2036. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2037. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2038. clif_displaymessage(fd, atcmd_output);
  2039. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2040. clif_displaymessage(fd, atcmd_output);
  2041. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2042. clif_displaymessage(fd, atcmd_output);
  2043. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2044. clif_displaymessage(fd, atcmd_output);
  2045. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2046. clif_displaymessage(fd, atcmd_output);
  2047. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2048. clif_displaymessage(fd, atcmd_output);
  2049. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2050. clif_displaymessage(fd, atcmd_output);
  2051. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2052. clif_displaymessage(fd, atcmd_output);
  2053. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2054. clif_displaymessage(fd, atcmd_output);
  2055. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2056. clif_displaymessage(fd, atcmd_output);
  2057. sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor
  2058. clif_displaymessage(fd, atcmd_output);
  2059. sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon
  2060. clif_displaymessage(fd, atcmd_output);
  2061. sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield
  2062. clif_displaymessage(fd, atcmd_output);
  2063. sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes
  2064. clif_displaymessage(fd, atcmd_output);
  2065. sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory
  2066. clif_displaymessage(fd, atcmd_output);
  2067. sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory
  2068. clif_displaymessage(fd, atcmd_output);
  2069. return -1;
  2070. }
  2071. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2072. count = 0;
  2073. for (j = 0; j < EQI_MAX; j++) {
  2074. int i;
  2075. if ((i = sd->equip_index[j]) < 0)
  2076. continue;
  2077. if(j == EQI_AMMO)
  2078. continue;
  2079. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2080. continue;
  2081. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2082. continue;
  2083. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2084. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2085. sd->inventory.u.items_inventory[i].refine = final_refine;
  2086. current_position = sd->inventory.u.items_inventory[i].equip;
  2087. pc_unequipitem(sd, i, 3);
  2088. clif_refine( *sd, i, ITEMREFINING_SUCCESS );
  2089. clif_delitem( *sd, i, 1, 3 );
  2090. clif_additem(sd, i, 1, 0);
  2091. pc_equipitem(sd, i, current_position);
  2092. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2093. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2094. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2095. }
  2096. count++;
  2097. }
  2098. }
  2099. if (count == 0)
  2100. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2101. else if (count == 1)
  2102. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2103. else {
  2104. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2105. clif_displaymessage(fd, atcmd_output);
  2106. }
  2107. return 0;
  2108. }
  2109. /*==========================================
  2110. *
  2111. *------------------------------------------*/
  2112. ACMD_FUNC(grade)
  2113. {
  2114. int j, position = 0, grade = 0, current_position, final_grade;
  2115. int count;
  2116. nullpo_retr(-1, sd);
  2117. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2118. if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) {
  2119. clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <equip position> <+/- amount>).
  2120. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2121. clif_displaymessage(fd, atcmd_output);
  2122. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2123. clif_displaymessage(fd, atcmd_output);
  2124. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2125. clif_displaymessage(fd, atcmd_output);
  2126. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2127. clif_displaymessage(fd, atcmd_output);
  2128. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2129. clif_displaymessage(fd, atcmd_output);
  2130. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2131. clif_displaymessage(fd, atcmd_output);
  2132. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2133. clif_displaymessage(fd, atcmd_output);
  2134. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2135. clif_displaymessage(fd, atcmd_output);
  2136. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2137. clif_displaymessage(fd, atcmd_output);
  2138. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2139. clif_displaymessage(fd, atcmd_output);
  2140. return -1;
  2141. }
  2142. grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE);
  2143. count = 0;
  2144. for (j = 0; j < EQI_MAX; j++) {
  2145. int i;
  2146. if ((i = sd->equip_index[j]) < 0)
  2147. continue;
  2148. if(j == EQI_AMMO)
  2149. continue;
  2150. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2151. continue;
  2152. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2153. continue;
  2154. final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE);
  2155. if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) {
  2156. sd->inventory.u.items_inventory[i].enchantgrade = final_grade;
  2157. current_position = sd->inventory.u.items_inventory[i].equip;
  2158. pc_unequipitem(sd, i, 3);
  2159. clif_delitem( *sd, i, 1, 3 );
  2160. clif_additem(sd, i, 1, 0);
  2161. pc_equipitem(sd, i, current_position);
  2162. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2163. count++;
  2164. }
  2165. }
  2166. sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded.
  2167. clif_displaymessage(fd, atcmd_output);
  2168. return 0;
  2169. }
  2170. /*==========================================
  2171. *
  2172. *------------------------------------------*/
  2173. ACMD_FUNC(produce)
  2174. {
  2175. char item_name[100];
  2176. t_itemid item_id;
  2177. int attribute = 0, star = 0;
  2178. nullpo_retr(-1, sd);
  2179. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2180. memset(item_name, '\0', sizeof(item_name));
  2181. if (!message || !*message || (
  2182. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2183. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2184. )) {
  2185. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2186. return -1;
  2187. }
  2188. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2189. if( item_data == nullptr ){
  2190. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2191. }
  2192. if( item_data == nullptr ){
  2193. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2194. return -1;
  2195. }
  2196. item_id = item_data->nameid;
  2197. if( itemdb_isequip2( item_data.get() ) ){
  2198. char flag = 0;
  2199. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2200. attribute = ATTRIBUTE_NORMAL;
  2201. if (star < MIN_STAR || star > MAX_STAR)
  2202. star = 0;
  2203. struct item tmp_item = {};
  2204. tmp_item.nameid = item_id;
  2205. tmp_item.amount = 1;
  2206. tmp_item.identify = 1;
  2207. tmp_item.card[0] = CARD0_FORGE;
  2208. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2209. ((star*5) << 8) + attribute:0;
  2210. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2211. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2212. clif_produceeffect(sd, 0, item_id);
  2213. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2214. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2215. clif_additem(sd, 0, 0, flag);
  2216. } else {
  2217. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2218. clif_displaymessage(fd, atcmd_output);
  2219. return -1;
  2220. }
  2221. return 0;
  2222. }
  2223. /*==========================================
  2224. *
  2225. *------------------------------------------*/
  2226. ACMD_FUNC(memo)
  2227. {
  2228. int position = 0;
  2229. nullpo_retr(-1, sd);
  2230. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2231. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2232. {
  2233. int i;
  2234. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2235. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2236. {
  2237. if( strcmp( "", sd->status.memo_point[i].map ) != 0 )
  2238. sprintf( atcmd_output, "%d - %s (%d,%d)", i, sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y );
  2239. else
  2240. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2241. clif_displaymessage(sd->fd, atcmd_output);
  2242. }
  2243. return 0;
  2244. }
  2245. if( position < 0 || position >= MAX_MEMOPOINTS )
  2246. {
  2247. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2248. clif_displaymessage(fd, atcmd_output);
  2249. return -1;
  2250. }
  2251. return !pc_memo( sd, position );
  2252. }
  2253. /*==========================================
  2254. *
  2255. *------------------------------------------*/
  2256. ACMD_FUNC(gat)
  2257. {
  2258. int y;
  2259. nullpo_retr(-1, sd);
  2260. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2261. for (y = 2; y >= -2; y--) {
  2262. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2263. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2264. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2265. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2266. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2267. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2268. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2269. clif_displaymessage(fd, atcmd_output);
  2270. }
  2271. return 0;
  2272. }
  2273. /*==========================================
  2274. *
  2275. *------------------------------------------*/
  2276. ACMD_FUNC(displaystatus)
  2277. {
  2278. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2279. nullpo_retr(-1, sd);
  2280. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2281. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2282. return -1;
  2283. }
  2284. if (i < 2) flag = 1;
  2285. if (i < 3) tick = 0;
  2286. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2287. return 0;
  2288. }
  2289. /*==========================================
  2290. * @stpoint (Rewritten by [Yor])
  2291. *------------------------------------------*/
  2292. ACMD_FUNC(statuspoint)
  2293. {
  2294. int point;
  2295. unsigned int new_status_point;
  2296. if (!message || !*message || (point = atoi(message)) == 0) {
  2297. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2298. return -1;
  2299. }
  2300. if(point < 0)
  2301. {
  2302. if(sd->status.status_point < (unsigned int)(-point))
  2303. {
  2304. new_status_point = 0;
  2305. }
  2306. else
  2307. {
  2308. new_status_point = sd->status.status_point + point;
  2309. }
  2310. }
  2311. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2312. {
  2313. new_status_point = UINT_MAX;
  2314. }
  2315. else
  2316. {
  2317. new_status_point = sd->status.status_point + point;
  2318. }
  2319. if (new_status_point != sd->status.status_point) {
  2320. sd->status.status_point = new_status_point;
  2321. clif_updatestatus(*sd, SP_STATUSPOINT);
  2322. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2323. } else {
  2324. if (point < 0)
  2325. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2326. else
  2327. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2328. return -1;
  2329. }
  2330. return 0;
  2331. }
  2332. /*==========================================
  2333. * @trpoint
  2334. *------------------------------------------*/
  2335. ACMD_FUNC(traitpoint)
  2336. {
  2337. int point;
  2338. unsigned int new_trait_point;
  2339. if (!message || !*message || (point = atoi(message)) == 0) {
  2340. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2341. return -1;
  2342. }
  2343. if (point < 0)
  2344. {
  2345. if (sd->status.trait_point < (unsigned int)(-point))
  2346. {
  2347. new_trait_point = 0;
  2348. }
  2349. else
  2350. {
  2351. new_trait_point = sd->status.trait_point + point;
  2352. }
  2353. }
  2354. else if (UINT_MAX - sd->status.trait_point < (unsigned int)point)
  2355. {
  2356. new_trait_point = UINT_MAX;
  2357. }
  2358. else
  2359. {
  2360. new_trait_point = sd->status.trait_point + point;
  2361. }
  2362. if (new_trait_point != sd->status.trait_point) {
  2363. sd->status.trait_point = new_trait_point;
  2364. clif_updatestatus(*sd, SP_TRAITPOINT);
  2365. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2366. }
  2367. else {
  2368. if (point < 0)
  2369. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2370. else
  2371. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2372. return -1;
  2373. }
  2374. return 0;
  2375. }
  2376. /*==========================================
  2377. * @skpoint (Rewritten by [Yor])
  2378. *------------------------------------------*/
  2379. ACMD_FUNC(skillpoint)
  2380. {
  2381. int point;
  2382. unsigned int new_skill_point;
  2383. nullpo_retr(-1, sd);
  2384. if (!message || !*message || (point = atoi(message)) == 0) {
  2385. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2386. return -1;
  2387. }
  2388. if(point < 0)
  2389. {
  2390. if(sd->status.skill_point < (unsigned int)(-point))
  2391. {
  2392. new_skill_point = 0;
  2393. }
  2394. else
  2395. {
  2396. new_skill_point = sd->status.skill_point + point;
  2397. }
  2398. }
  2399. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2400. {
  2401. new_skill_point = UINT_MAX;
  2402. }
  2403. else
  2404. {
  2405. new_skill_point = sd->status.skill_point + point;
  2406. }
  2407. if (new_skill_point != sd->status.skill_point) {
  2408. sd->status.skill_point = new_skill_point;
  2409. clif_updatestatus(*sd, SP_SKILLPOINT);
  2410. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2411. } else {
  2412. if (point < 0)
  2413. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2414. else
  2415. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2416. return -1;
  2417. }
  2418. return 0;
  2419. }
  2420. /*==========================================
  2421. * @zeny
  2422. *------------------------------------------*/
  2423. ACMD_FUNC(zeny)
  2424. {
  2425. int zeny=0, ret=-1;
  2426. nullpo_retr(-1, sd);
  2427. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2428. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2429. return -1;
  2430. }
  2431. if(zeny > 0){
  2432. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
  2433. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2434. }
  2435. else {
  2436. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2437. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
  2438. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2439. }
  2440. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2441. return 0;
  2442. }
  2443. /*==========================================
  2444. *
  2445. *------------------------------------------*/
  2446. ACMD_FUNC(param)
  2447. {
  2448. nullpo_retr(-1, sd);
  2449. uint8 stat;
  2450. int value = 0;
  2451. uint16 new_value, status, max_status;
  2452. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2453. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2454. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2455. return -1;
  2456. }
  2457. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2458. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2459. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2460. return -1;
  2461. }
  2462. if( stat < PARAM_POW ){
  2463. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2464. }else{
  2465. if( !( sd->class_ & JOBL_FOURTH ) ){
  2466. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2467. return -1;
  2468. }
  2469. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2470. }
  2471. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2472. max_status = SHRT_MAX;
  2473. }else{
  2474. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2475. }
  2476. if( value > 0 && status + value >= max_status ){
  2477. new_value = max_status;
  2478. }else if( value < 0 && abs( value ) >= status ){
  2479. if( stat < PARAM_POW ){
  2480. new_value = 1;
  2481. }else{
  2482. new_value = 0;
  2483. }
  2484. }else{
  2485. new_value = status + value;
  2486. }
  2487. if( new_value != status ){
  2488. if (stat < PARAM_POW) {
  2489. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2490. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + stat ) );
  2491. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + stat ) );
  2492. } else {
  2493. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2494. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + stat - PARAM_POW ) );
  2495. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + stat - PARAM_POW ) );
  2496. }
  2497. status_calc_pc(sd, SCO_FORCE);
  2498. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2499. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2500. } else {
  2501. if (value < 0)
  2502. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2503. else
  2504. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2505. return -1;
  2506. }
  2507. return 0;
  2508. }
  2509. /*==========================================
  2510. * Stat all by fritz (rewritten by [Yor])
  2511. *------------------------------------------*/
  2512. ACMD_FUNC(stat_all)
  2513. {
  2514. nullpo_retr(-1, sd);
  2515. int value = 0;
  2516. uint8 count, i;
  2517. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2518. for (i = PARAM_STR; i < PARAM_POW; i++)
  2519. status[i] = pc_getstat(sd, SP_STR + i);
  2520. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2521. for (i = PARAM_STR; i < PARAM_POW; i++)
  2522. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2523. value = SHRT_MAX;
  2524. } else {
  2525. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2526. for (i = PARAM_STR; i < PARAM_POW; i++)
  2527. max_status[i] = SHRT_MAX;
  2528. } else {
  2529. for (i = PARAM_STR; i < PARAM_POW; i++)
  2530. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2531. }
  2532. }
  2533. count = 0;
  2534. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2535. short new_value;
  2536. if (value > 0 && status[i] + value >= max_status[i])
  2537. new_value = max_status[i];
  2538. else if (value < 0 && abs(value) >= status[i])
  2539. new_value = 1;
  2540. else
  2541. new_value = status[i] + value;
  2542. if (new_value != status[i]) {
  2543. pc_setstat( sd, SP_STR + i, new_value );
  2544. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  2545. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  2546. count++;
  2547. }
  2548. }
  2549. if (count > 0) { // if at least 1 stat modified
  2550. status_calc_pc(sd, SCO_FORCE);
  2551. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2552. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2553. } else {
  2554. if (value < 0)
  2555. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2556. else
  2557. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2558. return -1;
  2559. }
  2560. return 0;
  2561. }
  2562. /*==========================================
  2563. * Traits
  2564. *------------------------------------------*/
  2565. ACMD_FUNC(trait_all) {
  2566. nullpo_retr(-1, sd);
  2567. #ifndef RENEWAL
  2568. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2569. clif_displaymessage(fd, atcmd_output);
  2570. return -1;
  2571. #endif
  2572. if( !( sd->class_ & JOBL_FOURTH ) ){
  2573. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2574. return -1;
  2575. }
  2576. int value = 0;
  2577. uint8 i;
  2578. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2579. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2580. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2581. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2582. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2583. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2584. value = SHRT_MAX;
  2585. } else {
  2586. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2587. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2588. max_status[i] = SHRT_MAX;
  2589. } else {
  2590. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2591. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2592. }
  2593. }
  2594. uint8 count = 0;
  2595. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2596. short new_value;
  2597. if (value > 0 && status[i] + value >= max_status[i])
  2598. new_value = max_status[i];
  2599. else if (value < 0 && abs(value) >= status[i])
  2600. new_value = 0;
  2601. else
  2602. new_value = status[i] + value;
  2603. if (new_value != status[i]) {
  2604. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2605. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  2606. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  2607. count++;
  2608. }
  2609. }
  2610. if (count > 0) { // if at least 1 stat modified
  2611. status_calc_pc(sd, SCO_FORCE);
  2612. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2613. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2614. } else {
  2615. if (value < 0)
  2616. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2617. else
  2618. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2619. return -1;
  2620. }
  2621. return 0;
  2622. }
  2623. /*==========================================
  2624. *
  2625. *------------------------------------------*/
  2626. ACMD_FUNC(guildlevelup) {
  2627. int level = 0;
  2628. short added_level;
  2629. nullpo_retr(-1, sd);
  2630. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2631. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2632. return -1;
  2633. }
  2634. auto &guild_info = sd->guild;
  2635. if (sd->status.guild_id <= 0 || guild_info == nullptr) {
  2636. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2637. return -1;
  2638. }
  2639. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2640. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2641. // return -1;
  2642. //}
  2643. added_level = (short)level;
  2644. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow
  2645. added_level = (short)MAX_GUILDLEVEL - guild_info->guild.guild_lv;
  2646. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow
  2647. added_level = 1 - guild_info->guild.guild_lv;
  2648. if (added_level != 0) {
  2649. intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2650. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2651. } else {
  2652. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2653. return -1;
  2654. }
  2655. return 0;
  2656. }
  2657. /*==========================================
  2658. *
  2659. *------------------------------------------*/
  2660. ACMD_FUNC(makeegg) {
  2661. int id;
  2662. nullpo_retr(-1, sd);
  2663. if (!message || !*message) {
  2664. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2665. return -1;
  2666. }
  2667. // for monster name
  2668. if ((id = mobdb_searchname(message)) != 0)
  2669. ;
  2670. else
  2671. id = atoi(message);
  2672. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2673. if( pet == nullptr ){
  2674. t_itemid nameid;
  2675. // for egg name
  2676. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2677. if( item_data != nullptr ){
  2678. nameid = item_data->nameid;
  2679. }else{
  2680. nameid = strtoul( message, nullptr, 10 );
  2681. }
  2682. pet = pet_db_search( nameid, PET_EGG );
  2683. }
  2684. int res(-1);
  2685. if (pet != nullptr) {
  2686. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2687. if(mdb){
  2688. sd->catch_target_class = pet->class_;
  2689. if(intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mdb->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, mdb->jname.c_str())){
  2690. res = 0;
  2691. } else {
  2692. res = -2; //char server down
  2693. }
  2694. }
  2695. }
  2696. switch(res){
  2697. case -1:
  2698. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2699. break;
  2700. case -2:
  2701. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2702. break;
  2703. }
  2704. return res;
  2705. }
  2706. /*==========================================
  2707. *
  2708. *------------------------------------------*/
  2709. ACMD_FUNC(hatch) {
  2710. nullpo_retr(-1, sd);
  2711. if (sd->status.pet_id <= 0)
  2712. clif_sendegg(sd);
  2713. else {
  2714. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2715. return -1;
  2716. }
  2717. return 0;
  2718. }
  2719. /*==========================================
  2720. *
  2721. *------------------------------------------*/
  2722. ACMD_FUNC(petfriendly) {
  2723. int friendly;
  2724. struct pet_data *pd;
  2725. nullpo_retr(-1, sd);
  2726. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2727. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2728. return -1;
  2729. }
  2730. pd = sd->pd;
  2731. if (!pd) {
  2732. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2733. return -1;
  2734. }
  2735. if (friendly < 0 || friendly > 1000)
  2736. {
  2737. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2738. return -1;
  2739. }
  2740. if (friendly == pd->pet.intimate) {
  2741. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2742. return -1;
  2743. }
  2744. pet_set_intimate(pd, friendly);
  2745. clif_send_petstatus(sd);
  2746. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2747. return 0;
  2748. }
  2749. /*==========================================
  2750. *
  2751. *------------------------------------------*/
  2752. ACMD_FUNC(pethungry)
  2753. {
  2754. int hungry;
  2755. struct pet_data *pd;
  2756. nullpo_retr(-1, sd);
  2757. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2758. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2759. return -1;
  2760. }
  2761. pd = sd->pd;
  2762. if (!sd->status.pet_id || !pd) {
  2763. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2764. return -1;
  2765. }
  2766. if (hungry < 0 || hungry > 100) {
  2767. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2768. return -1;
  2769. }
  2770. if (hungry == pd->pet.hungry) {
  2771. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2772. return -1;
  2773. }
  2774. pd->pet.hungry = hungry;
  2775. clif_send_petstatus(sd);
  2776. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2777. return 0;
  2778. }
  2779. /*==========================================
  2780. *
  2781. *------------------------------------------*/
  2782. ACMD_FUNC(petrename)
  2783. {
  2784. struct pet_data *pd;
  2785. nullpo_retr(-1, sd);
  2786. if (!sd->status.pet_id || !sd->pd) {
  2787. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2788. return -1;
  2789. }
  2790. pd = sd->pd;
  2791. if (!pd->pet.rename_flag) {
  2792. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2793. return -1;
  2794. }
  2795. pd->pet.rename_flag = 0;
  2796. intif_save_petdata(sd->status.account_id, &pd->pet);
  2797. clif_send_petstatus(sd);
  2798. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2799. return 0;
  2800. }
  2801. /*==========================================
  2802. *
  2803. *------------------------------------------*/
  2804. ACMD_FUNC(recall) {
  2805. map_session_data* pl_sd = nullptr;;
  2806. nullpo_retr(-1, sd);
  2807. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2808. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2809. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2810. return -1;
  2811. }
  2812. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  2813. {
  2814. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2815. return -1;
  2816. }
  2817. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2818. {
  2819. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  2820. return -1;
  2821. }
  2822. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2823. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2824. return -1;
  2825. }
  2826. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2827. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2828. return -1;
  2829. }
  2830. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2831. return -1;
  2832. }
  2833. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2834. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2835. return -1;
  2836. }
  2837. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2838. clif_displaymessage(fd, atcmd_output);
  2839. return 0;
  2840. }
  2841. /*==========================================
  2842. * charblock command (usage: charblock <player_name>)
  2843. * This command do a definitiv ban on a player
  2844. *------------------------------------------*/
  2845. ACMD_FUNC(char_block)
  2846. {
  2847. nullpo_retr(-1, sd);
  2848. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2849. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2850. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2851. clif_displaymessage(fd, atcmd_output);
  2852. return -1;
  2853. }
  2854. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2855. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2856. clif_displaymessage(fd, atcmd_output);
  2857. return 0;
  2858. }
  2859. /*==========================================
  2860. * accountban command (usage: ban <%time> <player_name>)
  2861. * charban command (usage: charban <%time> <player_name>)
  2862. * %time see common/timer.cpp::solve_time()
  2863. *------------------------------------------*/
  2864. ACMD_FUNC(char_ban)
  2865. {
  2866. char *modif_p, output[CHAT_SIZE_MAX];
  2867. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2868. enum chrif_req_op bantype;
  2869. nullpo_retr(-1, sd);
  2870. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2871. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2872. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2873. if (strcmpi(parent_cmd,"charban") == 0)
  2874. bantype = CHRIF_OP_BAN;
  2875. else if (strcmpi(parent_cmd,"ban") == 0)
  2876. bantype = CHRIF_OP_LOGIN_BAN;
  2877. else
  2878. return -1;
  2879. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2880. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2881. clif_displaymessage(fd, output);
  2882. return -1;
  2883. }
  2884. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2885. modif_p = atcmd_output;
  2886. timediff = (int32)solve_time(modif_p); //discard seconds
  2887. if (timediff == 0) { //allow negative ?
  2888. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2889. clif_displaymessage(fd, output);
  2890. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  2891. return -1;
  2892. }
  2893. if( timediff < 0 && (
  2894. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2895. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2896. ))
  2897. {
  2898. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2899. return -1;
  2900. }
  2901. if (bantype == CHRIF_OP_BAN)
  2902. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2903. else
  2904. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2905. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2906. clif_displaymessage(fd, output);
  2907. return 0;
  2908. }
  2909. /*==========================================
  2910. * charunblock command (usage: charunblock <player_name>)
  2911. *------------------------------------------*/
  2912. ACMD_FUNC(char_unblock)
  2913. {
  2914. nullpo_retr(-1, sd);
  2915. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2916. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2917. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2918. clif_displaymessage(fd, atcmd_output);
  2919. return -1;
  2920. }
  2921. // send answer to login server via char-server
  2922. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2923. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2924. clif_displaymessage(fd, atcmd_output);
  2925. return 0;
  2926. }
  2927. /*==========================================
  2928. * acc unban command (usage: unban <player_name>)
  2929. * char unban command (usage: charunban <player_name>)
  2930. *------------------------------------------*/
  2931. ACMD_FUNC(char_unban){
  2932. enum chrif_req_op unbantype;
  2933. nullpo_retr(-1, sd);
  2934. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2935. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2936. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2937. if (strcmpi(parent_cmd,"charunban") == 0)
  2938. unbantype = CHRIF_OP_UNBAN;
  2939. else if (strcmpi(parent_cmd,"unban") == 0)
  2940. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2941. else
  2942. return -1;
  2943. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2944. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2945. clif_displaymessage(fd, atcmd_output);
  2946. return -1;
  2947. }
  2948. if (unbantype == CHRIF_OP_UNBAN)
  2949. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2950. else
  2951. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2952. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2953. clif_displaymessage(fd, atcmd_output);
  2954. return 0;
  2955. }
  2956. /*==========================================
  2957. *
  2958. *------------------------------------------*/
  2959. ACMD_FUNC(night)
  2960. {
  2961. nullpo_retr(-1, sd);
  2962. if (night_flag != 1) {
  2963. map_night_timer(night_timer_tid, 0, 0, 1);
  2964. } else {
  2965. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2966. return -1;
  2967. }
  2968. return 0;
  2969. }
  2970. /*==========================================
  2971. *
  2972. *------------------------------------------*/
  2973. ACMD_FUNC(day)
  2974. {
  2975. nullpo_retr(-1, sd);
  2976. if (night_flag != 0) {
  2977. map_day_timer(day_timer_tid, 0, 0, 1);
  2978. } else {
  2979. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2980. return -1;
  2981. }
  2982. return 0;
  2983. }
  2984. /*==========================================
  2985. *
  2986. *------------------------------------------*/
  2987. ACMD_FUNC(doom)
  2988. {
  2989. map_session_data* pl_sd;
  2990. struct s_mapiterator* iter;
  2991. nullpo_retr(-1, sd);
  2992. iter = mapit_getallusers();
  2993. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2994. {
  2995. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2996. {
  2997. status_kill(&pl_sd->bl);
  2998. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2999. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3000. }
  3001. }
  3002. mapit_free(iter);
  3003. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3004. return 0;
  3005. }
  3006. /*==========================================
  3007. *
  3008. *------------------------------------------*/
  3009. ACMD_FUNC(doommap)
  3010. {
  3011. map_session_data* pl_sd;
  3012. struct s_mapiterator* iter;
  3013. nullpo_retr(-1, sd);
  3014. iter = mapit_getallusers();
  3015. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3016. {
  3017. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3018. {
  3019. status_kill(&pl_sd->bl);
  3020. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3021. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3022. }
  3023. }
  3024. mapit_free(iter);
  3025. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3026. return 0;
  3027. }
  3028. /*==========================================
  3029. *
  3030. *------------------------------------------*/
  3031. static void atcommand_raise_sub(map_session_data* sd) {
  3032. status_revive(&sd->bl, 100, 100);
  3033. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  3034. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3035. }
  3036. /*==========================================
  3037. *
  3038. *------------------------------------------*/
  3039. ACMD_FUNC(raise)
  3040. {
  3041. map_session_data* pl_sd;
  3042. struct s_mapiterator* iter;
  3043. nullpo_retr(-1, sd);
  3044. iter = mapit_getallusers();
  3045. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3046. if( pc_isdead(pl_sd) )
  3047. atcommand_raise_sub(pl_sd);
  3048. mapit_free(iter);
  3049. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3050. return 0;
  3051. }
  3052. /*==========================================
  3053. *
  3054. *------------------------------------------*/
  3055. ACMD_FUNC(raisemap)
  3056. {
  3057. map_session_data* pl_sd;
  3058. struct s_mapiterator* iter;
  3059. nullpo_retr(-1, sd);
  3060. iter = mapit_getallusers();
  3061. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3062. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3063. atcommand_raise_sub(pl_sd);
  3064. mapit_free(iter);
  3065. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3066. return 0;
  3067. }
  3068. /*==========================================
  3069. *
  3070. *------------------------------------------*/
  3071. ACMD_FUNC(kick)
  3072. {
  3073. map_session_data *pl_sd;
  3074. nullpo_retr(-1, sd);
  3075. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3076. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3077. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3078. return -1;
  3079. }
  3080. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  3081. {
  3082. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3083. return -1;
  3084. }
  3085. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3086. {
  3087. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3088. return -1;
  3089. }
  3090. clif_GM_kick(sd, pl_sd);
  3091. return 0;
  3092. }
  3093. /*==========================================
  3094. *
  3095. *------------------------------------------*/
  3096. ACMD_FUNC(kickall)
  3097. {
  3098. map_session_data* pl_sd;
  3099. struct s_mapiterator* iter;
  3100. nullpo_retr(-1, sd);
  3101. iter = mapit_getallusers();
  3102. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3103. {
  3104. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3105. if (sd->status.account_id != pl_sd->status.account_id)
  3106. clif_GM_kick(nullptr, pl_sd);
  3107. }
  3108. }
  3109. mapit_free(iter);
  3110. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. *
  3115. *------------------------------------------*/
  3116. ACMD_FUNC(allskill)
  3117. {
  3118. nullpo_retr(-1, sd);
  3119. pc_allskillup(sd); // all skills
  3120. sd->status.skill_point = 0; // 0 skill points
  3121. clif_updatestatus(*sd, SP_SKILLPOINT); // update
  3122. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3123. return 0;
  3124. }
  3125. /*==========================================
  3126. *
  3127. *------------------------------------------*/
  3128. ACMD_FUNC(questskill)
  3129. {
  3130. uint16 skill_id;
  3131. nullpo_retr(-1, sd);
  3132. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3133. {// also send a list of skills applicable to this command
  3134. const char* text;
  3135. // attempt to find the text corresponding to this command
  3136. text = atcommand_help_string( command );
  3137. // send the error message as always
  3138. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3139. if( text )
  3140. {// send the skill ID list associated with this command
  3141. clif_displaymessage( fd, text );
  3142. }
  3143. return -1;
  3144. }
  3145. if (skill_id >= MAX_SKILL_ID) {
  3146. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3147. return -1;
  3148. }
  3149. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3150. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3151. return -1;
  3152. }
  3153. if (pc_checkskill(sd, skill_id) > 0) {
  3154. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3155. return -1;
  3156. }
  3157. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3158. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3159. return 0;
  3160. }
  3161. /*==========================================
  3162. *
  3163. *------------------------------------------*/
  3164. ACMD_FUNC(lostskill)
  3165. {
  3166. uint16 skill_id = 0, sk_idx = 0;
  3167. nullpo_retr(-1, sd);
  3168. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3169. {// also send a list of skills applicable to this command
  3170. const char* text;
  3171. // attempt to find the text corresponding to this command
  3172. text = atcommand_help_string( command );
  3173. // send the error message as always
  3174. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3175. if( text )
  3176. {// send the skill ID list associated with this command
  3177. clif_displaymessage( fd, text );
  3178. }
  3179. return -1;
  3180. }
  3181. if (!(sk_idx = skill_get_index(skill_id))) {
  3182. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3183. return -1;
  3184. }
  3185. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3186. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3187. return -1;
  3188. }
  3189. if (pc_checkskill(sd, skill_id) == 0) {
  3190. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3191. return -1;
  3192. }
  3193. sd->status.skill[sk_idx].lv = 0;
  3194. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3195. clif_deleteskill(*sd,skill_id);
  3196. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3197. return 0;
  3198. }
  3199. /*==========================================
  3200. *
  3201. *------------------------------------------*/
  3202. ACMD_FUNC(spiritball)
  3203. {
  3204. int number;
  3205. nullpo_retr(-1, sd);
  3206. if( !message || !*message || ( number = atoi( message ) ) < 0 || number > MAX_SPIRITBALL ){
  3207. char msg[CHAT_SIZE_MAX];
  3208. safesnprintf( msg, sizeof( msg ), msg_txt( sd, 1028 ), MAX_SPIRITBALL ); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  3209. clif_displaymessage(fd, msg);
  3210. return -1;
  3211. }
  3212. if( sd->spiritball > 0 )
  3213. pc_delspiritball(sd, sd->spiritball, 1);
  3214. sd->spiritball = number;
  3215. clif_spiritball(&sd->bl);
  3216. // no message, player can look the difference
  3217. return 0;
  3218. }
  3219. ACMD_FUNC(soulball)
  3220. {
  3221. int number;
  3222. nullpo_retr(-1, sd);
  3223. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3224. char msg[CHAT_SIZE_MAX];
  3225. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3226. clif_displaymessage(fd, msg);
  3227. return -1;
  3228. }
  3229. if (sd->soulball > 0)
  3230. pc_delsoulball( *sd, sd->soulball, true );
  3231. pc_addsoulball( *sd, number );
  3232. clif_soulball(sd);
  3233. return 0;
  3234. }
  3235. /*==========================================
  3236. *
  3237. *------------------------------------------*/
  3238. ACMD_FUNC(party)
  3239. {
  3240. char party[NAME_LENGTH];
  3241. nullpo_retr(-1, sd);
  3242. memset(party, '\0', sizeof(party));
  3243. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3244. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3245. return -1;
  3246. }
  3247. party_create( *sd, party, 0, 0 );
  3248. return 0;
  3249. }
  3250. /*==========================================
  3251. *
  3252. *------------------------------------------*/
  3253. ACMD_FUNC(guild)
  3254. {
  3255. char guild[NAME_LENGTH];
  3256. int prev;
  3257. nullpo_retr(-1, sd);
  3258. memset(guild, '\0', sizeof(guild));
  3259. if (sd->clan) {
  3260. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3261. return -1;
  3262. }
  3263. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3264. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3265. return -1;
  3266. }
  3267. prev = battle_config.guild_emperium_check;
  3268. battle_config.guild_emperium_check = 0;
  3269. guild_create( *sd, guild );
  3270. battle_config.guild_emperium_check = prev;
  3271. return 0;
  3272. }
  3273. ACMD_FUNC(breakguild)
  3274. {
  3275. nullpo_retr(-1, sd);
  3276. if (sd->status.guild_id) { // Check if the player has a guild
  3277. if (sd->guild) { // Check if guild was found
  3278. if (sd->state.gmaster_flag) { // Check if player is guild master
  3279. // Break guild
  3280. int ret = guild_break( *sd, sd->guild->guild.name );
  3281. if (ret) { // Check if anything went wrong
  3282. return 0; // Guild was broken
  3283. } else {
  3284. return -1; // Something went wrong
  3285. }
  3286. } else { // Not guild master
  3287. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3288. return -1;
  3289. }
  3290. } else { // Guild was not found. HOW?
  3291. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3292. return -1;
  3293. }
  3294. } else { // Player does not have a guild
  3295. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3296. return -1;
  3297. }
  3298. }
  3299. /**
  3300. * Start WoE:FE
  3301. */
  3302. ACMD_FUNC(agitstart)
  3303. {
  3304. nullpo_retr(-1, sd);
  3305. if( guild_agit_start() ){
  3306. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3307. return 0;
  3308. }else{
  3309. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3310. return -1;
  3311. }
  3312. }
  3313. /**
  3314. * Start WoE:SE
  3315. */
  3316. ACMD_FUNC(agitstart2)
  3317. {
  3318. nullpo_retr(-1, sd);
  3319. if( guild_agit2_start() ){
  3320. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3321. return 0;
  3322. }else{
  3323. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3324. return -1;
  3325. }
  3326. }
  3327. /**
  3328. * Start WoE:TE
  3329. */
  3330. ACMD_FUNC(agitstart3)
  3331. {
  3332. nullpo_retr(-1, sd);
  3333. if( guild_agit3_start() ){
  3334. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3335. return 0;
  3336. }else{
  3337. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3338. return -1;
  3339. }
  3340. }
  3341. /**
  3342. * End WoE:FE
  3343. */
  3344. ACMD_FUNC(agitend)
  3345. {
  3346. nullpo_retr(-1, sd);
  3347. if( guild_agit_end() ){
  3348. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3349. return 0;
  3350. }else{
  3351. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3352. return -1;
  3353. }
  3354. }
  3355. /**
  3356. * End WoE:SE
  3357. */
  3358. ACMD_FUNC(agitend2)
  3359. {
  3360. nullpo_retr(-1, sd);
  3361. if( guild_agit2_end() ){
  3362. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3363. return 0;
  3364. }else{
  3365. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3366. return -1;
  3367. }
  3368. }
  3369. /**
  3370. * End WoE:TE
  3371. */
  3372. ACMD_FUNC(agitend3)
  3373. {
  3374. nullpo_retr(-1, sd);
  3375. if( guild_agit3_end() ){
  3376. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3377. return 0;
  3378. }else{
  3379. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3380. return -1;
  3381. }
  3382. }
  3383. /*==========================================
  3384. * @mapexit - shuts down the map server
  3385. *------------------------------------------*/
  3386. ACMD_FUNC(mapexit)
  3387. {
  3388. nullpo_retr(-1, sd);
  3389. global_core->signal_shutdown();
  3390. return 0;
  3391. }
  3392. /*==========================================
  3393. * idsearch <part_of_name>: revrited by [Yor]
  3394. *------------------------------------------*/
  3395. ACMD_FUNC(idsearch)
  3396. {
  3397. nullpo_retr(-1, sd);
  3398. char item_name[100];
  3399. memset(item_name, '\0', sizeof(item_name));
  3400. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3401. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3402. return -1;
  3403. }
  3404. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3405. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3406. clif_displaymessage(fd, atcmd_output);
  3407. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  3408. uint16 match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3409. if (match == MAX_SEARCH) {
  3410. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3411. clif_displaymessage(fd, atcmd_output);
  3412. }
  3413. for(const auto &result : item_array) {
  3414. std::shared_ptr<item_data> id = result.second;
  3415. sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
  3416. clif_displaymessage(fd, atcmd_output);
  3417. }
  3418. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3419. clif_displaymessage(fd, atcmd_output);
  3420. return 0;
  3421. }
  3422. /*==========================================
  3423. * Recall All Characters Online To Your Location
  3424. *------------------------------------------*/
  3425. ACMD_FUNC(recallall)
  3426. {
  3427. map_session_data* pl_sd;
  3428. struct s_mapiterator* iter;
  3429. int count;
  3430. nullpo_retr(-1, sd);
  3431. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3432. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3433. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3434. return -1;
  3435. }
  3436. count = 0;
  3437. iter = mapit_getallusers();
  3438. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3439. {
  3440. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3441. {
  3442. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3443. continue; // Don't waste time warping the character to the same place.
  3444. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3445. count++;
  3446. else {
  3447. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3448. count++;
  3449. }
  3450. }
  3451. }
  3452. }
  3453. mapit_free(iter);
  3454. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3455. if (count) {
  3456. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3457. clif_displaymessage(fd, atcmd_output);
  3458. }
  3459. return 0;
  3460. }
  3461. /*==========================================
  3462. * Recall online characters of a guild to your location
  3463. *------------------------------------------*/
  3464. ACMD_FUNC(guildrecall)
  3465. {
  3466. map_session_data* pl_sd;
  3467. struct s_mapiterator* iter;
  3468. int count;
  3469. char guild_name[NAME_LENGTH];
  3470. nullpo_retr(-1, sd);
  3471. memset(guild_name, '\0', sizeof(guild_name));
  3472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3473. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3474. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3475. return -1;
  3476. }
  3477. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3478. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3479. return -1;
  3480. }
  3481. auto g = guild_searchnameid(guild_name);
  3482. if (!g) {
  3483. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3484. return -1;
  3485. }
  3486. count = 0;
  3487. iter = mapit_getallusers();
  3488. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3489. {
  3490. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild.guild_id)
  3491. {
  3492. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3493. continue; // Skip GMs greater than you... or chars already on the cell
  3494. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3495. count++;
  3496. else{
  3497. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3498. count++;
  3499. }
  3500. }
  3501. }
  3502. }
  3503. mapit_free(iter);
  3504. sprintf(atcmd_output, msg_txt(sd,93), g->guild.name); // All online characters of the %s guild have been recalled to your position.
  3505. clif_displaymessage(fd, atcmd_output);
  3506. if (count) {
  3507. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3508. clif_displaymessage(fd, atcmd_output);
  3509. }
  3510. return 0;
  3511. }
  3512. /*==========================================
  3513. * Recall online characters of a party to your location
  3514. *------------------------------------------*/
  3515. ACMD_FUNC(partyrecall)
  3516. {
  3517. map_session_data* pl_sd;
  3518. struct s_mapiterator* iter;
  3519. char party_name[NAME_LENGTH];
  3520. struct party_data *p;
  3521. int count;
  3522. nullpo_retr(-1, sd);
  3523. memset(party_name, '\0', sizeof(party_name));
  3524. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3525. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3526. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3527. return -1;
  3528. }
  3529. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3530. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3531. return -1;
  3532. }
  3533. if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
  3534. (p = party_search(atoi(message))) == nullptr)
  3535. {
  3536. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3537. return -1;
  3538. }
  3539. count = 0;
  3540. iter = mapit_getallusers();
  3541. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3542. {
  3543. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3544. {
  3545. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y))
  3546. continue; // Skip GMs greater than you... or chars already on the cell
  3547. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3548. count++;
  3549. else{
  3550. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3551. count++;
  3552. }
  3553. }
  3554. }
  3555. }
  3556. mapit_free(iter);
  3557. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3558. clif_displaymessage(fd, atcmd_output);
  3559. if (count) {
  3560. sprintf(atcmd_output, msg_txt(sd,1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled.
  3561. clif_displaymessage(fd, atcmd_output);
  3562. }
  3563. return 0;
  3564. }
  3565. /*==========================================
  3566. *
  3567. *------------------------------------------*/
  3568. void atcommand_doload();
  3569. ACMD_FUNC(reload) {
  3570. nullpo_retr(-1, sd);
  3571. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3572. const char* text;
  3573. text = atcommand_help_string( command );
  3574. if(text)
  3575. clif_displaymessage( fd, text );
  3576. return -1;
  3577. }
  3578. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3579. itemdb_reload();
  3580. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3581. } else if (strstr(command, "cashdb") || strncmp(message, "cashdb", 4) == 0) {
  3582. cashshop_reloaddb();
  3583. clif_displaymessage( fd, msg_txt( sd, 832 ) ); // Cash shop database has been reloaded.
  3584. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3585. mob_reload();
  3586. pet_db.reload();
  3587. hom_reload();
  3588. mercenary_db.reload();
  3589. elemental_db.reload();
  3590. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3591. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3592. skill_reload();
  3593. homunculus_db.reload();
  3594. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3595. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3596. atcommand_doload();
  3597. pc_groups_reload();
  3598. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3599. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3600. struct Battle_Config prev_config;
  3601. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3602. battle_config_read(BATTLE_CONF_FILENAME);
  3603. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3604. || prev_config.item_rate_common != battle_config.item_rate_common
  3605. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3606. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3607. || prev_config.item_rate_card != battle_config.item_rate_card
  3608. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3609. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3610. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3611. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3612. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3613. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3614. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3615. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3616. || prev_config.item_rate_use != battle_config.item_rate_use
  3617. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3618. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3619. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3620. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3621. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3622. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3623. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3624. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3625. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3626. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3627. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3628. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3629. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3630. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3631. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3632. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3633. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3634. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3635. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3636. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3637. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3638. )
  3639. { // Exp or Drop rates changed.
  3640. mob_reload(); //Needed as well so rate changes take effect.
  3641. }
  3642. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3643. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3644. status_readdb( true );
  3645. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3646. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3647. pc_readdb();
  3648. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3649. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3650. pc_read_motd();
  3651. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3652. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3653. struct s_mapiterator* iter;
  3654. map_session_data* pl_sd;
  3655. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3656. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3657. iter = mapit_getallusers();
  3658. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3659. pc_close_npc(pl_sd,1);
  3660. clif_cutin( *pl_sd, "", 255 );
  3661. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3662. bg_queue_leave(pl_sd);
  3663. }
  3664. mapit_free(iter);
  3665. for (auto &bg : bg_queues) {
  3666. for (auto &bg_sd : bg->teama_members)
  3667. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3668. for (auto &bg_sd : bg->teamb_members)
  3669. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3670. bg_queue_clear(bg, true);
  3671. }
  3672. flush_fifos();
  3673. map_reloadnpc(true); // reload config files seeking for npcs
  3674. script_reload();
  3675. npc_reload();
  3676. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3677. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3678. map_msg_reload();
  3679. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3680. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3681. if (quest_db.reload())
  3682. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3683. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3684. if (instance_db.reload())
  3685. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3686. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3687. achievement_db_reload();
  3688. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3689. } else if (strstr(command, "attendancedb") || strncmp(message, "attendancedb", 4) == 0) {
  3690. attendance_db.reload();
  3691. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3692. }else if( strstr( command, "barterdb" ) || strncmp( message, "barterdb", 4 ) == 0 ){
  3693. barter_db.reload();
  3694. clif_displaymessage(fd, msg_txt(sd, 830)); // Barter database has been reloaded.
  3695. } else if (strstr(command, "logconf") || strncmp(message, "logconf", 3) == 0) {
  3696. log_config_read(LOG_CONF_NAME);
  3697. clif_displaymessage(fd, msg_txt(sd,1536)); // Log configuration has been reloaded.
  3698. }
  3699. return 0;
  3700. }
  3701. /*==========================================
  3702. * @partysharelvl <share_range> [Akinari]
  3703. * Updates char server party share level range in runtime
  3704. * Temporary - Permanent update in inter_athena.conf
  3705. *------------------------------------------*/
  3706. ACMD_FUNC(partysharelvl) {
  3707. unsigned int share_lvl;
  3708. nullpo_retr(-1, sd);
  3709. if(!message || !*message) {
  3710. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3711. return -1;
  3712. } else {
  3713. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3714. }
  3715. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3716. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3717. else //Char server offline
  3718. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3719. return 0;
  3720. }
  3721. /*==========================================
  3722. * @mapinfo [0-3] <map name> by MC_Cameri
  3723. * => Shows information about the map [map name]
  3724. * 0 = no additional information
  3725. * 1 = Show users in that map and their location
  3726. * 2 = Shows NPCs in that map
  3727. * 3 = Shows the chats in that map
  3728. *------------------------------------------*/
  3729. ACMD_FUNC(mapinfo) {
  3730. map_session_data* pl_sd;
  3731. struct s_mapiterator* iter;
  3732. struct chat_data *cd = nullptr;
  3733. char direction[12];
  3734. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3735. unsigned short m_index;
  3736. char mapname[MAP_NAME_LENGTH];
  3737. nullpo_retr(-1, sd);
  3738. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3739. memset(mapname, '\0', sizeof(mapname));
  3740. memset(direction, '\0', sizeof(direction));
  3741. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3742. if (list < 0 || list > 3) {
  3743. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3744. return -1;
  3745. }
  3746. if (mapname[0] == '\0') {
  3747. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3748. m_id = map_mapindex2mapid(sd->mapindex);
  3749. } else {
  3750. m_id = map_mapname2mapid(mapname);
  3751. }
  3752. if (m_id < 0) {
  3753. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3754. return -1;
  3755. }
  3756. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3757. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3758. // count chats (for initial message)
  3759. chat_num = 0;
  3760. iter = mapit_getallusers();
  3761. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3762. if( pl_sd->mapindex == m_index ) {
  3763. if( pl_sd->state.vending )
  3764. vend_num++;
  3765. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
  3766. chat_num++;
  3767. }
  3768. }
  3769. mapit_free(iter);
  3770. struct map_data *mapdata = map_getmapdata(m_id);
  3771. sprintf(atcmd_output, msg_txt(sd,1040), mapname, mapdata->users, mapdata->npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3772. clif_displaymessage(fd, atcmd_output);
  3773. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3774. if (map_getmapflag(m_id, MF_TOWN))
  3775. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3776. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3777. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3778. clif_displaymessage(fd, atcmd_output);
  3779. }
  3780. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3781. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3782. else
  3783. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3784. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3785. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3786. clif_displaymessage(fd, atcmd_output);
  3787. }
  3788. /* Skill damage adjustment info [Cydh] */
  3789. if (mapdata->getMapFlag(MF_SKILL_DAMAGE)) {
  3790. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3791. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3792. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3793. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3794. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3795. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3796. mapdata->damage_adjust.caster);
  3797. clif_displaymessage(fd, atcmd_output);
  3798. if (!mapdata->skill_damage.empty()) {
  3799. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3800. for (const auto& skilldmg : mapdata->skill_damage) {
  3801. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3802. skill_get_name(skilldmg.first),
  3803. skilldmg.second.rate[SKILLDMG_PC],
  3804. skilldmg.second.rate[SKILLDMG_MOB],
  3805. skilldmg.second.rate[SKILLDMG_BOSS],
  3806. skilldmg.second.rate[SKILLDMG_OTHER],
  3807. skilldmg.second.caster);
  3808. clif_displaymessage(fd,atcmd_output);
  3809. }
  3810. }
  3811. }
  3812. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3813. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3814. for (const auto &it : mapdata->skill_duration) {
  3815. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3816. clif_displaymessage(fd, atcmd_output);
  3817. }
  3818. }
  3819. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3820. if (map_getmapflag(m_id, MF_PVP))
  3821. strcat(atcmd_output, " Pvp ON |");
  3822. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3823. strcat(atcmd_output, " NoGuild |");
  3824. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3825. strcat(atcmd_output, " NoParty |");
  3826. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3827. strcat(atcmd_output, " NightmareDrop |");
  3828. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3829. strcat(atcmd_output, " NoCalcRank |");
  3830. clif_displaymessage(fd, atcmd_output);
  3831. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3832. if (map_getmapflag(m_id, MF_GVG))
  3833. strcat(atcmd_output, " GvG ON |");
  3834. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3835. strcat(atcmd_output, " GvG Dungeon |");
  3836. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3837. strcat(atcmd_output, " GvG Castle |");
  3838. if (map_getmapflag(m_id, MF_GVG_TE))
  3839. strcat(atcmd_output, " GvG TE |");
  3840. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3841. strcat(atcmd_output, " GvG TE Castle |");
  3842. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3843. strcat(atcmd_output, " NoParty |");
  3844. clif_displaymessage(fd, atcmd_output);
  3845. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3846. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3847. strcat(atcmd_output, " NoTeleport |");
  3848. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3849. strcat(atcmd_output, " Monster NoTeleport |");
  3850. if (map_getmapflag(m_id, MF_NOWARP))
  3851. strcat(atcmd_output, " NoWarp |");
  3852. if (map_getmapflag(m_id, MF_NOWARPTO))
  3853. strcat(atcmd_output, " NoWarpTo |");
  3854. if (map_getmapflag(m_id, MF_NORETURN))
  3855. strcat(atcmd_output, " NoReturn |");
  3856. if (map_getmapflag(m_id, MF_NOGO))
  3857. strcat(atcmd_output, " NoGo |"); //
  3858. if (map_getmapflag(m_id, MF_NOMEMO))
  3859. strcat(atcmd_output, " NoMemo |");
  3860. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_SOURCE))
  3861. strcat(atcmd_output, " PrivateAirship_Source |");
  3862. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_DESTINATION))
  3863. strcat(atcmd_output, " PrivateAirship_Destination |");
  3864. clif_displaymessage(fd, atcmd_output);
  3865. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3866. (map_getmapflag(m_id, MF_NOEXPPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map_getmapflag(m_id, MF_NOZENYPENALTY)) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3867. clif_displaymessage(fd, atcmd_output);
  3868. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3869. if (!mapdata->save.map)
  3870. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3871. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3872. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3873. clif_displaymessage(fd, atcmd_output);
  3874. }
  3875. else {
  3876. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3877. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3878. clif_displaymessage(fd, atcmd_output);
  3879. }
  3880. }
  3881. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3882. if (map_getmapflag(m_id, MF_SNOW))
  3883. strcat(atcmd_output, " Snow |");
  3884. if (map_getmapflag(m_id, MF_FOG))
  3885. strcat(atcmd_output, " Fog |");
  3886. if (map_getmapflag(m_id, MF_SAKURA))
  3887. strcat(atcmd_output, " Sakura |");
  3888. if (map_getmapflag(m_id, MF_CLOUDS))
  3889. strcat(atcmd_output, " Clouds |");
  3890. if (map_getmapflag(m_id, MF_CLOUDS2))
  3891. strcat(atcmd_output, " Clouds2 |");
  3892. if (map_getmapflag(m_id, MF_FIREWORKS))
  3893. strcat(atcmd_output, " Fireworks |");
  3894. if (map_getmapflag(m_id, MF_LEAVES))
  3895. strcat(atcmd_output, " Leaves |");
  3896. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3897. strcat(atcmd_output, " Displays Night |");
  3898. clif_displaymessage(fd, atcmd_output);
  3899. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3900. if (map_getmapflag(m_id, MF_NOBRANCH))
  3901. strcat(atcmd_output, " NoBranch |");
  3902. if (map_getmapflag(m_id, MF_NOTRADE))
  3903. strcat(atcmd_output, " NoTrade |");
  3904. if (map_getmapflag(m_id, MF_NOVENDING))
  3905. strcat(atcmd_output, " NoVending |");
  3906. if (map_getmapflag(m_id, MF_NOBUYINGSTORE))
  3907. strcat(atcmd_output, " NoBuyingstore |");
  3908. if (map_getmapflag(m_id, MF_NODROP))
  3909. strcat(atcmd_output, " NoDrop |");
  3910. if (map_getmapflag(m_id, MF_NOSKILL))
  3911. strcat(atcmd_output, " NoSkill |");
  3912. if (map_getmapflag(m_id, MF_NOICEWALL))
  3913. strcat(atcmd_output, " NoIcewall |");
  3914. if (map_getmapflag(m_id, MF_ALLOWKS))
  3915. strcat(atcmd_output, " AllowKS |");
  3916. if (map_getmapflag(m_id, MF_RESET))
  3917. strcat(atcmd_output, " Reset |");
  3918. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3919. strcat(atcmd_output, " HideMobHPBar |");
  3920. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3921. strcat(atcmd_output, " NoCommand |");
  3922. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3923. strcat(atcmd_output, " NoBaseEXP |");
  3924. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3925. strcat(atcmd_output, " NoJobEXP |");
  3926. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3927. strcat(atcmd_output, " NoMobLoot |");
  3928. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3929. strcat(atcmd_output, " NoMVPLoot |");
  3930. if (map_getmapflag(m_id, MF_NORENEWALEXPPENALTY))
  3931. strcat(atcmd_output, " NoRenewalExpPenalty |");
  3932. if (map_getmapflag(m_id, MF_NORENEWALDROPPENALTY))
  3933. strcat(atcmd_output, " NoRenewalDropPenalty |");
  3934. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3935. strcat(atcmd_output, " PartyLock |");
  3936. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3937. strcat(atcmd_output, " GuildLock |");
  3938. if (map_getmapflag(m_id, MF_LOADEVENT))
  3939. strcat(atcmd_output, " Loadevent |");
  3940. if (map_getmapflag(m_id, MF_NODYNAMICNPC))
  3941. strcat(atcmd_output, " NoDynamicNPC |");
  3942. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3943. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3944. if (map_getmapflag(m_id, MF_NOUSECART))
  3945. strcat(atcmd_output, " NoUsecart |");
  3946. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3947. strcat(atcmd_output, " NoItemConsumption |");
  3948. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3949. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3950. if (map_getmapflag(m_id, MF_FORCEMINEFFECT))
  3951. strcat(atcmd_output, " ForceMinEffect |");
  3952. if (map_getmapflag(m_id, MF_NOLOCKON))
  3953. strcat(atcmd_output, " NoLockOn |");
  3954. if (map_getmapflag(m_id, MF_NOTOMB))
  3955. strcat(atcmd_output, " NoTomb |");
  3956. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3957. strcat(atcmd_output, " NoCostume |");
  3958. if (map_getmapflag(m_id, MF_NOBANK))
  3959. strcat(atcmd_output, " NoBank |");
  3960. if (map_getmapflag(m_id, MF_NOCASHSHOP))
  3961. strcat(atcmd_output, " NoCashShop |");
  3962. if (map_getmapflag(m_id, MF_NORODEX))
  3963. strcat(atcmd_output, " NoRODex |");
  3964. if (map_getmapflag(m_id, MF_NOPETCAPTURE))
  3965. strcat(atcmd_output, " NoPetCapture |");
  3966. clif_displaymessage(fd, atcmd_output);
  3967. switch (list) {
  3968. case 0:
  3969. // Do nothing. It's list 0, no additional display.
  3970. break;
  3971. case 1:
  3972. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3973. iter = mapit_getallusers();
  3974. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3975. {
  3976. if (pl_sd->mapindex == m_index) {
  3977. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3978. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3979. clif_displaymessage(fd, atcmd_output);
  3980. }
  3981. }
  3982. mapit_free(iter);
  3983. break;
  3984. case 2:
  3985. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3986. for (i = 0; i < mapdata->npc_num;)
  3987. {
  3988. struct npc_data *nd = mapdata->npc[i];
  3989. switch(nd->ud.dir) {
  3990. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3991. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3992. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3993. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3994. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3995. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3996. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3997. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3998. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3999. }
  4000. if(strcmp(nd->name,nd->exname) == 0)
  4001. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  4002. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4003. else
  4004. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  4005. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4006. clif_displaymessage(fd, atcmd_output);
  4007. }
  4008. break;
  4009. case 3:
  4010. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  4011. iter = mapit_getallusers();
  4012. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4013. {
  4014. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
  4015. pl_sd->mapindex == m_index &&
  4016. cd->usersd[0] == pl_sd)
  4017. {
  4018. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  4019. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4020. clif_displaymessage(fd, atcmd_output);
  4021. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  4022. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  4023. clif_displaymessage(fd, atcmd_output);
  4024. }
  4025. }
  4026. mapit_free(iter);
  4027. break;
  4028. default: // normally impossible to arrive here
  4029. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  4030. return -1;
  4031. break;
  4032. }
  4033. return 0;
  4034. }
  4035. /*==========================================
  4036. *
  4037. *------------------------------------------*/
  4038. ACMD_FUNC(mount_peco)
  4039. {
  4040. nullpo_retr(-1, sd);
  4041. if (sd->disguise) {
  4042. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4043. return -1;
  4044. }
  4045. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4046. if( !(sd->sc.option&OPTION_DRAGON) ) {
  4047. unsigned int option = OPTION_DRAGON1;
  4048. if( message[0] ) {
  4049. int color = atoi(message);
  4050. option = ( color == 2 ? OPTION_DRAGON2 :
  4051. color == 3 ? OPTION_DRAGON3 :
  4052. color == 4 ? OPTION_DRAGON4 :
  4053. color == 5 ? OPTION_DRAGON5 :
  4054. OPTION_DRAGON1 );
  4055. }
  4056. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4057. pc_setoption(sd, sd->sc.option|option);
  4058. } else {
  4059. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4060. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  4061. }
  4062. return 0;
  4063. }
  4064. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || (pc_checkskill(sd, WH_HAWK_M) || battle_config.warg_can_falcon)) ) {
  4065. if( !pc_isridingwug(sd) ) {
  4066. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4067. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4068. } else {
  4069. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4070. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4071. }
  4072. return 0;
  4073. }
  4074. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4075. if( !pc_ismadogear(sd) ) {
  4076. e_mado_type type = MADO_ROBOT;
  4077. if (message[0]) {
  4078. int tmp = strtol(message, nullptr, 10);
  4079. switch (tmp) {
  4080. case MADO_ROBOT:
  4081. case MADO_SUIT:
  4082. type = static_cast<e_mado_type>(tmp);
  4083. break;
  4084. default:
  4085. type = MADO_ROBOT;
  4086. break;
  4087. }
  4088. }
  4089. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4090. pc_setmadogear(sd, true, type);
  4091. } else {
  4092. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4093. pc_setmadogear(sd, false);
  4094. }
  4095. return 0;
  4096. }
  4097. if (!pc_isriding(sd)) { // if actually no peco
  4098. if (!pc_checkskill(sd, KN_RIDING)) {
  4099. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4100. return -1;
  4101. }
  4102. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4103. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4104. } else {//Dismount
  4105. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4106. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4107. }
  4108. return 0;
  4109. }
  4110. /*==========================================
  4111. *Spy Commands by Syrus22
  4112. *------------------------------------------*/
  4113. ACMD_FUNC(guildspy)
  4114. {
  4115. char guild_name[NAME_LENGTH];
  4116. nullpo_retr(-1, sd);
  4117. memset(guild_name, '\0', sizeof(guild_name));
  4118. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4119. if (!enable_spy)
  4120. {
  4121. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4122. return -1;
  4123. }
  4124. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4125. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4126. return -1;
  4127. }
  4128. auto g = guild_searchnameid(guild_name);
  4129. if (!g) {
  4130. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4131. return -1;
  4132. }
  4133. if (sd->guildspy == g->guild.guild_id) {
  4134. sd->guildspy = 0;
  4135. sprintf(atcmd_output, msg_txt(sd,103), g->guild.name); // No longer spying on the %s guild.
  4136. clif_displaymessage(fd, atcmd_output);
  4137. } else {
  4138. sd->guildspy = g->guild.guild_id;
  4139. sprintf(atcmd_output, msg_txt(sd,104), g->guild.name); // Spying on the %s guild.
  4140. clif_displaymessage(fd, atcmd_output);
  4141. }
  4142. return 0;
  4143. }
  4144. /*==========================================
  4145. *
  4146. *------------------------------------------*/
  4147. ACMD_FUNC(partyspy)
  4148. {
  4149. char party_name[NAME_LENGTH];
  4150. struct party_data *p;
  4151. nullpo_retr(-1, sd);
  4152. memset(party_name, '\0', sizeof(party_name));
  4153. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4154. if (!enable_spy)
  4155. {
  4156. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4157. return -1;
  4158. }
  4159. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4160. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4161. return -1;
  4162. }
  4163. if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
  4164. (p = party_search(atoi(message))) != nullptr) {
  4165. if (sd->partyspy == p->party.party_id) {
  4166. sd->partyspy = 0;
  4167. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4168. clif_displaymessage(fd, atcmd_output);
  4169. } else {
  4170. sd->partyspy = p->party.party_id;
  4171. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4172. clif_displaymessage(fd, atcmd_output);
  4173. }
  4174. } else {
  4175. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4176. return -1;
  4177. }
  4178. return 0;
  4179. }
  4180. ACMD_FUNC(clanspy){
  4181. char clan_name[NAME_LENGTH];
  4182. struct clan* c;
  4183. nullpo_retr(-1, sd);
  4184. memset(clan_name, '\0', sizeof(clan_name));
  4185. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4186. if( !enable_spy ){
  4187. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4188. return -1;
  4189. }
  4190. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4191. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4192. return -1;
  4193. }
  4194. if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
  4195. (c = clan_search(atoi(message))) != nullptr) {
  4196. if (sd->clanspy == c->id) {
  4197. sd->clanspy = 0;
  4198. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4199. clif_displaymessage(fd, atcmd_output);
  4200. }
  4201. else {
  4202. sd->clanspy = c->id;
  4203. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4204. clif_displaymessage(fd, atcmd_output);
  4205. }
  4206. }
  4207. else {
  4208. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4209. return -1;
  4210. }
  4211. return 0;
  4212. }
  4213. /*==========================================
  4214. * @repairall [Valaris]
  4215. *------------------------------------------*/
  4216. ACMD_FUNC(repairall)
  4217. {
  4218. int count, i;
  4219. nullpo_retr(-1, sd);
  4220. count = 0;
  4221. for (i = 0; i < MAX_INVENTORY; i++) {
  4222. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1 && !itemdb_ishatched_egg(&sd->inventory.u.items_inventory[i])) {
  4223. sd->inventory.u.items_inventory[i].attribute = 0;
  4224. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4225. count++;
  4226. }
  4227. }
  4228. if (count > 0) {
  4229. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  4230. clif_equiplist(sd);
  4231. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4232. } else {
  4233. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4234. return -1;
  4235. }
  4236. return 0;
  4237. }
  4238. /*==========================================
  4239. * @nuke [Valaris]
  4240. *------------------------------------------*/
  4241. ACMD_FUNC(nuke)
  4242. {
  4243. map_session_data *pl_sd;
  4244. nullpo_retr(-1, sd);
  4245. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4246. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4247. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4248. return -1;
  4249. }
  4250. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
  4251. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4252. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4253. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4254. } else {
  4255. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4256. return -1;
  4257. }
  4258. } else {
  4259. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4260. return -1;
  4261. }
  4262. return 0;
  4263. }
  4264. /*==========================================
  4265. * @tonpc
  4266. *------------------------------------------*/
  4267. ACMD_FUNC(tonpc)
  4268. {
  4269. char npcname[NPC_NAME_LENGTH];
  4270. struct npc_data *nd;
  4271. nullpo_retr(-1, sd);
  4272. memset(npcname, 0, sizeof(npcname));
  4273. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4274. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4275. return -1;
  4276. }
  4277. if ((nd = npc_name2id(npcname)) != nullptr) {
  4278. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4279. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4280. else
  4281. return -1;
  4282. } else {
  4283. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4284. return -1;
  4285. }
  4286. return 0;
  4287. }
  4288. /*==========================================
  4289. *
  4290. *------------------------------------------*/
  4291. ACMD_FUNC(shownpc)
  4292. {
  4293. char NPCname[NPC_NAME_LENGTH];
  4294. nullpo_retr(-1, sd);
  4295. memset(NPCname, '\0', sizeof(NPCname));
  4296. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4297. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4298. return -1;
  4299. }
  4300. npc_data* nd = npc_name2id(NPCname);
  4301. if (nd) {
  4302. npc_enable(*nd, NPCVIEW_ENABLE);
  4303. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4304. } else {
  4305. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4306. return -1;
  4307. }
  4308. return 0;
  4309. }
  4310. /*==========================================
  4311. *
  4312. *------------------------------------------*/
  4313. ACMD_FUNC(hidenpc)
  4314. {
  4315. char NPCname[NPC_NAME_LENGTH];
  4316. nullpo_retr(-1, sd);
  4317. memset(NPCname, '\0', sizeof(NPCname));
  4318. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4319. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4320. return -1;
  4321. }
  4322. npc_data* nd = npc_name2id(NPCname);
  4323. if (!nd) {
  4324. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4325. return -1;
  4326. }
  4327. npc_enable(*nd, NPCVIEW_DISABLE);
  4328. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4329. return 0;
  4330. }
  4331. ACMD_FUNC(loadnpc)
  4332. {
  4333. if (!message || !*message) {
  4334. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4335. return -1;
  4336. }
  4337. if (!npc_addsrcfile(message, true)) {
  4338. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4339. return -1;
  4340. }
  4341. npc_read_event_script();
  4342. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4343. npc_event_doall_path( script_config.init_event_name, message );
  4344. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4345. return 0;
  4346. }
  4347. ACMD_FUNC(unloadnpc)
  4348. {
  4349. struct npc_data *nd;
  4350. char NPCname[NPC_NAME_LENGTH];
  4351. nullpo_retr(-1, sd);
  4352. memset(NPCname, '\0', sizeof(NPCname));
  4353. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4354. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4355. return -1;
  4356. }
  4357. if ((nd = npc_name2id(NPCname)) == nullptr) {
  4358. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4359. return -1;
  4360. }
  4361. npc_unload_duplicates(nd);
  4362. npc_unload(nd,true);
  4363. npc_read_event_script();
  4364. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4365. return 0;
  4366. }
  4367. ACMD_FUNC(reloadnpcfile) {
  4368. if (!message || !*message) {
  4369. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4370. return -1;
  4371. }
  4372. if (npc_unloadfile(message))
  4373. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4374. if (!npc_addsrcfile(message, true)) {
  4375. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4376. return -1;
  4377. }
  4378. npc_read_event_script();
  4379. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4380. npc_event_doall_path( script_config.init_event_name, message );
  4381. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4382. return 0;
  4383. }
  4384. /*==========================================
  4385. * time in txt for time command (by [Yor])
  4386. *------------------------------------------*/
  4387. char* txt_time(t_tick duration_)
  4388. {
  4389. int days, hours, minutes, seconds;
  4390. char temp[CHAT_SIZE_MAX];
  4391. static char temp1[CHAT_SIZE_MAX];
  4392. memset(temp, '\0', sizeof(temp));
  4393. memset(temp1, '\0', sizeof(temp1));
  4394. // Cap it
  4395. int duration = (int)duration_;
  4396. days = duration / (60 * 60 * 24);
  4397. duration = duration - (60 * 60 * 24 * days);
  4398. hours = duration / (60 * 60);
  4399. duration = duration - (60 * 60 * hours);
  4400. minutes = duration / 60;
  4401. seconds = duration - (60 * minutes);
  4402. if (days == 1)
  4403. sprintf(temp, msg_txt(nullptr,219), days); // %d day
  4404. else if (days > 1)
  4405. sprintf(temp, msg_txt(nullptr,220), days); // %d days
  4406. if (hours == 1)
  4407. sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
  4408. else if (hours > 1)
  4409. sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
  4410. if (minutes < 2)
  4411. sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
  4412. else
  4413. sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
  4414. if (seconds == 1)
  4415. sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
  4416. else if (seconds > 1)
  4417. sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
  4418. return temp1;
  4419. }
  4420. /*==========================================
  4421. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4422. * Calculation management of GM modification (@day/@night GM commands) is done
  4423. *------------------------------------------*/
  4424. ACMD_FUNC(servertime)
  4425. {
  4426. const struct TimerData * timer_data;
  4427. time_t time_server; // variable for number of seconds (used with time() function)
  4428. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4429. char temp[CHAT_SIZE_MAX];
  4430. nullpo_retr(-1, sd);
  4431. memset(temp, '\0', sizeof(temp));
  4432. time(&time_server); // get time in seconds since 1/1/1970
  4433. datetime = localtime(&time_server); // convert seconds in structure
  4434. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4435. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4436. clif_displaymessage(fd, temp);
  4437. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4438. if (night_flag == 0)
  4439. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4440. else
  4441. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4442. } else if (battle_config.night_duration == 0)
  4443. if (night_flag == 1) { // we start with night
  4444. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4445. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4446. clif_displaymessage(fd, temp);
  4447. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4448. } else
  4449. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4450. } else
  4451. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4452. else if (battle_config.day_duration == 0)
  4453. if (night_flag == 0) { // we start with day
  4454. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4455. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4456. clif_displaymessage(fd, temp);
  4457. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4458. } else
  4459. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4460. } else
  4461. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4462. else {
  4463. const struct TimerData * timer_data2;
  4464. if (night_flag == 0) {
  4465. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4466. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4467. clif_displaymessage(fd, temp);
  4468. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4469. sprintf(temp, msg_txt(sd,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.
  4470. else
  4471. sprintf(temp, msg_txt(sd,237), txt_time(DIFF_TICK(timer_data2->tick,timer_data->tick)/1000)); // Game time: After, the game will be in night for %s.
  4472. clif_displaymessage(fd, temp);
  4473. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4474. clif_displaymessage(fd, temp);
  4475. } else
  4476. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4477. } else {
  4478. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4479. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4480. clif_displaymessage(fd, temp);
  4481. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4482. sprintf(temp, msg_txt(sd,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.
  4483. else
  4484. sprintf(temp, msg_txt(sd,239), txt_time(DIFF_TICK(timer_data2->tick, timer_data->tick) / 1000)); // Game time: After, the game will be in daylight for %s.
  4485. clif_displaymessage(fd, temp);
  4486. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4487. clif_displaymessage(fd, temp);
  4488. } else
  4489. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4490. }
  4491. }
  4492. return 0;
  4493. }
  4494. /*==========================================
  4495. * @jail <char_name> by [Yor]
  4496. * Special warp! No check with nowarp and nowarpto flag
  4497. *------------------------------------------*/
  4498. ACMD_FUNC(jail)
  4499. {
  4500. map_session_data *pl_sd;
  4501. nullpo_retr(-1, sd);
  4502. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4503. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4504. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4505. return -1;
  4506. }
  4507. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4508. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4509. return -1;
  4510. }
  4511. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4512. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4513. return -1;
  4514. }
  4515. if (pl_sd->sc.getSCE(SC_JAILED)) {
  4516. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4517. return -1;
  4518. }
  4519. pc_jail(*pl_sd);
  4520. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4521. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4522. return 0;
  4523. }
  4524. /*==========================================
  4525. * @unjail/@discharge <char_name> by [Yor]
  4526. * Special warp! No check with nowarp and nowarpto flag
  4527. *------------------------------------------*/
  4528. ACMD_FUNC(unjail)
  4529. {
  4530. map_session_data *pl_sd;
  4531. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4532. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4533. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4534. return -1;
  4535. }
  4536. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4537. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4538. return -1;
  4539. }
  4540. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4541. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4542. return -1;
  4543. }
  4544. if (!pl_sd->sc.getSCE(SC_JAILED)) {
  4545. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4546. return -1;
  4547. }
  4548. //Reset jail time to 1 sec.
  4549. pc_jail(*pl_sd, 0);
  4550. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4551. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4552. return 0;
  4553. }
  4554. ACMD_FUNC(jailfor) {
  4555. map_session_data* pl_sd = nullptr;;
  4556. char * modif_p;
  4557. int jailtime = 0;
  4558. nullpo_retr(-1, sd);
  4559. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4560. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4561. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4562. return -1;
  4563. }
  4564. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4565. modif_p = atcmd_output;
  4566. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4567. if (jailtime == 0) {
  4568. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4569. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  4570. return -1;
  4571. }
  4572. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4573. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4574. return -1;
  4575. }
  4576. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4577. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4578. return -1;
  4579. }
  4580. // Added by Coltaro
  4581. if(pl_sd->sc.getSCE(SC_JAILED) && pl_sd->sc.getSCE(SC_JAILED)->val1 != INT_MAX) { // Update the player's jail time
  4582. jailtime += pl_sd->sc.getSCE(SC_JAILED)->val1;
  4583. if (jailtime <= 0) {
  4584. jailtime = 0;
  4585. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4586. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4587. } else {
  4588. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4589. char timestr[21];
  4590. time_t now=time(nullptr);
  4591. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4592. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); // %s in jail for %d years, %d months, %d days, %d hours and %d minutes
  4593. clif_displaymessage(pl_sd->fd, atcmd_output);
  4594. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1138),year,month,day,hour,minute); // This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes
  4595. clif_displaymessage(fd, atcmd_output);
  4596. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4597. sprintf(atcmd_output,"Release date is: %s",timestr);
  4598. clif_displaymessage(pl_sd->fd, atcmd_output);
  4599. clif_displaymessage(fd, atcmd_output);
  4600. }
  4601. } else if (jailtime < 0) {
  4602. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4603. return -1;
  4604. }
  4605. pc_jail(*pl_sd, jailtime);
  4606. return 0;
  4607. }
  4608. //By Coltaro
  4609. ACMD_FUNC(jailtime){
  4610. int year, month, day, hour, minute, second;
  4611. char timestr[21];
  4612. time_t now = time(nullptr);
  4613. nullpo_retr(-1, sd);
  4614. if (!sd->sc.getSCE(SC_JAILED)) {
  4615. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4616. return -1;
  4617. }
  4618. if (sd->sc.getSCE(SC_JAILED)->val1 == INT_MAX) {
  4619. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4620. return 0;
  4621. }
  4622. if (sd->sc.getSCE(SC_JAILED)->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4623. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4624. return -1;
  4625. }
  4626. // Get remaining jail time
  4627. split_time(sd->sc.getSCE(SC_JAILED)->val1*60,&year,&month,&day,&hour,&minute,&second);
  4628. sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes
  4629. clif_displaymessage(fd, atcmd_output);
  4630. timestamp2string(timestr,20,now+sd->sc.getSCE(SC_JAILED)->val1*60,"%Y-%m-%d %H:%M");
  4631. sprintf(atcmd_output,"Release date is: %s",timestr);
  4632. clif_displaymessage(fd, atcmd_output);
  4633. return 0;
  4634. }
  4635. /*==========================================
  4636. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4637. *------------------------------------------*/
  4638. ACMD_FUNC(disguise)
  4639. {
  4640. int id = 0;
  4641. nullpo_retr(-1, sd);
  4642. if (!message || !*message) {
  4643. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4644. return -1;
  4645. }
  4646. if ((id = atoi(message)) > 0)
  4647. { //Acquired an ID
  4648. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4649. id = 0; //Invalid id for either mobs or npcs.
  4650. } else { //Acquired a Name
  4651. if ((id = mobdb_searchname(message)) == 0)
  4652. {
  4653. struct npc_data* nd = npc_name2id(message);
  4654. if (nd != nullptr)
  4655. id = nd->class_;
  4656. }
  4657. }
  4658. if (id == 0)
  4659. {
  4660. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4661. return -1;
  4662. }
  4663. if(pc_isriding(sd))
  4664. {
  4665. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4666. return -1;
  4667. }
  4668. if (sd->sc.getSCE(SC_MONSTER_TRANSFORM) || sd->sc.getSCE(SC_ACTIVE_MONSTER_TRANSFORM)) {
  4669. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4670. return -1;
  4671. }
  4672. pc_disguise(sd, id);
  4673. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4674. return 0;
  4675. }
  4676. /*==========================================
  4677. * DisguiseAll
  4678. *------------------------------------------*/
  4679. ACMD_FUNC(disguiseall)
  4680. {
  4681. int mob_id=0;
  4682. map_session_data *pl_sd;
  4683. struct s_mapiterator* iter;
  4684. nullpo_retr(-1, sd);
  4685. if (!message || !*message) {
  4686. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4687. return -1;
  4688. }
  4689. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4690. mob_id = atoi(message);
  4691. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4692. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4693. return -1;
  4694. }
  4695. iter = mapit_getallusers();
  4696. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4697. pc_disguise(pl_sd, mob_id);
  4698. mapit_free(iter);
  4699. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4700. return 0;
  4701. }
  4702. /*==========================================
  4703. * DisguiseGuild
  4704. *------------------------------------------*/
  4705. ACMD_FUNC(disguiseguild)
  4706. {
  4707. int id = 0, i;
  4708. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4709. memset(monster, '\0', sizeof(monster));
  4710. memset(guild, '\0', sizeof(guild));
  4711. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4712. clif_displaymessage(fd, msg_txt(sd,1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>).
  4713. return -1;
  4714. }
  4715. if( (id = atoi(monster)) > 0 ) {
  4716. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4717. id = 0;
  4718. } else {
  4719. if( (id = mobdb_searchname(monster)) == 0 ) {
  4720. struct npc_data* nd = npc_name2id(monster);
  4721. if( nd != nullptr )
  4722. id = nd->class_;
  4723. }
  4724. }
  4725. if( id == 0 ) {
  4726. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4727. return -1;
  4728. }
  4729. auto g = guild_searchnameid(guild);
  4730. if (!g) {
  4731. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4732. return -1;
  4733. }
  4734. for( i = 0; i < g->guild.max_member; i++ ){
  4735. map_session_data *pl_sd;
  4736. if( (pl_sd = g->guild.member[i].sd) && !pc_isriding(pl_sd) )
  4737. pc_disguise(pl_sd, id);
  4738. }
  4739. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @undisguise by [Yor]
  4744. *------------------------------------------*/
  4745. ACMD_FUNC(undisguise)
  4746. {
  4747. nullpo_retr(-1, sd);
  4748. if (sd->disguise) {
  4749. pc_disguise(sd, 0);
  4750. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4751. } else {
  4752. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4753. return -1;
  4754. }
  4755. return 0;
  4756. }
  4757. /*==========================================
  4758. * UndisguiseAll
  4759. *------------------------------------------*/
  4760. ACMD_FUNC(undisguiseall)
  4761. {
  4762. map_session_data *pl_sd;
  4763. struct s_mapiterator* iter;
  4764. nullpo_retr(-1, sd);
  4765. iter = mapit_getallusers();
  4766. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4767. if( pl_sd->disguise )
  4768. pc_disguise(pl_sd, 0);
  4769. mapit_free(iter);
  4770. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4771. return 0;
  4772. }
  4773. /*==========================================
  4774. * UndisguiseGuild
  4775. *------------------------------------------*/
  4776. ACMD_FUNC(undisguiseguild)
  4777. {
  4778. char guild_name[NAME_LENGTH];
  4779. int i;
  4780. nullpo_retr(-1, sd);
  4781. memset(guild_name, '\0', sizeof(guild_name));
  4782. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4783. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4784. return -1;
  4785. }
  4786. auto g = guild_searchnameid(guild_name);
  4787. if (!g) {
  4788. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4789. return -1;
  4790. }
  4791. for(i = 0; i < g->guild.max_member; i++){
  4792. map_session_data *pl_sd;
  4793. if( (pl_sd = g->guild.member[i].sd) && pl_sd->disguise )
  4794. pc_disguise(pl_sd, 0);
  4795. }
  4796. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4797. return 0;
  4798. }
  4799. /*==========================================
  4800. * @exp by [Skotlex]
  4801. *------------------------------------------*/
  4802. ACMD_FUNC(exp)
  4803. {
  4804. char output[CHAT_SIZE_MAX];
  4805. double nextb, nextj;
  4806. nullpo_retr(-1, sd);
  4807. memset(output, '\0', sizeof(output));
  4808. nextb = (double)pc_nextbaseexp(sd);
  4809. if (nextb)
  4810. nextb = sd->status.base_exp*100.0/nextb;
  4811. nextj = (double)pc_nextjobexp(sd);
  4812. if (nextj)
  4813. nextj = sd->status.job_exp*100.0/nextj;
  4814. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4815. clif_displaymessage(fd, output);
  4816. return 0;
  4817. }
  4818. /*==========================================
  4819. * @broadcast by [Valaris]
  4820. *------------------------------------------*/
  4821. ACMD_FUNC(broadcast)
  4822. {
  4823. nullpo_retr(-1, sd);
  4824. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4825. if (!message || !*message) {
  4826. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4827. return -1;
  4828. }
  4829. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4830. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4831. return 0;
  4832. }
  4833. /*==========================================
  4834. * @localbroadcast by [Valaris]
  4835. *------------------------------------------*/
  4836. ACMD_FUNC(localbroadcast)
  4837. {
  4838. nullpo_retr(-1, sd);
  4839. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4840. if (!message || !*message) {
  4841. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4842. return -1;
  4843. }
  4844. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4845. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4846. return 0;
  4847. }
  4848. /*==========================================
  4849. * @email <actual@email> <new@email> by [Yor]
  4850. *------------------------------------------*/
  4851. ACMD_FUNC(email)
  4852. {
  4853. char actual_email[100];
  4854. char new_email[100];
  4855. nullpo_retr(-1, sd);
  4856. memset(actual_email, '\0', sizeof(actual_email));
  4857. memset(new_email, '\0', sizeof(new_email));
  4858. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4859. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4860. return -1;
  4861. }
  4862. if (e_mail_check(actual_email) == 0) {
  4863. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4864. return -1;
  4865. } else if (e_mail_check(new_email) == 0) {
  4866. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4867. return -1;
  4868. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4869. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4870. return -1;
  4871. } else if (strcmpi(actual_email, new_email) == 0) {
  4872. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4873. return -1;
  4874. }
  4875. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4876. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4877. return 0;
  4878. }
  4879. /*==========================================
  4880. *@effect
  4881. *------------------------------------------*/
  4882. ACMD_FUNC(effect)
  4883. {
  4884. int type = EF_NONE;
  4885. nullpo_retr(-1, sd);
  4886. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4887. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4888. return -1;
  4889. }
  4890. if( type <= EF_NONE || type >= EF_MAX ){
  4891. sprintf(atcmd_output, msg_txt(sd,1152),EF_NONE+1,EF_MAX-1); // Please enter a valid effect id in the range from %d to %d.
  4892. clif_displaymessage(fd, atcmd_output);
  4893. return -1;
  4894. }
  4895. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4896. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @killer by MouseJstr
  4901. * enable killing players even when not in pvp
  4902. *------------------------------------------*/
  4903. ACMD_FUNC(killer)
  4904. {
  4905. nullpo_retr(-1, sd);
  4906. sd->state.killer = !sd->state.killer;
  4907. if(sd->state.killer)
  4908. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4909. else {
  4910. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4911. pc_stop_attack(sd);
  4912. }
  4913. return 0;
  4914. }
  4915. /*==========================================
  4916. * @killable by MouseJstr
  4917. * enable other people killing you
  4918. *------------------------------------------*/
  4919. ACMD_FUNC(killable)
  4920. {
  4921. nullpo_retr(-1, sd);
  4922. sd->state.killable = !sd->state.killable;
  4923. if(sd->state.killable)
  4924. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4925. else {
  4926. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4927. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4928. }
  4929. return 0;
  4930. }
  4931. /*==========================================
  4932. * @skillon by MouseJstr
  4933. * turn skills on for the map
  4934. *------------------------------------------*/
  4935. ACMD_FUNC(skillon)
  4936. {
  4937. nullpo_retr(-1, sd);
  4938. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4939. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4940. return 0;
  4941. }
  4942. /*==========================================
  4943. * @skilloff by MouseJstr
  4944. * Turn skills off on the map
  4945. *------------------------------------------*/
  4946. ACMD_FUNC(skilloff)
  4947. {
  4948. nullpo_retr(-1, sd);
  4949. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4950. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4951. return 0;
  4952. }
  4953. /*==========================================
  4954. * @npcmove by MouseJstr
  4955. * move a npc
  4956. *------------------------------------------*/
  4957. ACMD_FUNC(npcmove)
  4958. {
  4959. short x = 0, y = 0;
  4960. struct npc_data *nd = 0;
  4961. char npc_name[NPC_NAME_LENGTH];
  4962. nullpo_retr(-1, sd);
  4963. memset(npc_name, '\0', sizeof npc_name);
  4964. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4965. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4966. return -1;
  4967. }
  4968. if ((nd = npc_name2id(npc_name)) == nullptr)
  4969. {
  4970. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4971. return -1;
  4972. }
  4973. if ( npc_movenpc( nd, x, y ) )
  4974. { //actually failed to move
  4975. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4976. return -1; //Not on a map.
  4977. } else
  4978. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4979. return 0;
  4980. }
  4981. /*==========================================
  4982. * @addwarp by MouseJstr
  4983. * Create a new static warp point.
  4984. *------------------------------------------*/
  4985. ACMD_FUNC(addwarp)
  4986. {
  4987. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4988. short x,y;
  4989. unsigned short m;
  4990. struct npc_data* nd;
  4991. nullpo_retr(-1, sd);
  4992. memset(warpname, '\0', sizeof(warpname));
  4993. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4994. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4995. return -1;
  4996. }
  4997. m = mapindex_name2id(mapname);
  4998. if( m == 0 )
  4999. {
  5000. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  5001. clif_displaymessage(fd, atcmd_output);
  5002. return -1;
  5003. }
  5004. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5005. if( nd == nullptr )
  5006. return -1;
  5007. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  5008. clif_displaymessage(fd, atcmd_output);
  5009. return 0;
  5010. }
  5011. /*==========================================
  5012. * @follow by [MouseJstr]
  5013. * Follow a player .. staying no more then 5 spaces away
  5014. *------------------------------------------*/
  5015. ACMD_FUNC(follow)
  5016. {
  5017. map_session_data* pl_sd = nullptr;;
  5018. nullpo_retr(-1, sd);
  5019. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5020. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5021. if (sd->followtarget == -1)
  5022. return -1;
  5023. pc_stop_following (sd);
  5024. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5025. return 0;
  5026. }
  5027. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5028. {
  5029. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5030. return -1;
  5031. }
  5032. if (sd->followtarget == pl_sd->bl.id) {
  5033. pc_stop_following (sd);
  5034. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5035. } else {
  5036. pc_follow(sd, pl_sd->bl.id);
  5037. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5038. }
  5039. return 0;
  5040. }
  5041. /*==========================================
  5042. * @dropall by [MouseJstr] and [Xantara]
  5043. * Drops all your possession on the ground based on item type
  5044. *------------------------------------------*/
  5045. ACMD_FUNC(dropall)
  5046. {
  5047. int8 type = -1;
  5048. uint16 i, count = 0, count2 = 0;
  5049. nullpo_retr(-1, sd);
  5050. if( message[0] ) {
  5051. type = atoi(message);
  5052. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  5053. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  5054. {
  5055. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  5056. clif_displaymessage(fd, msg_txt(sd,1493)); // Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5057. return -1;
  5058. }
  5059. }
  5060. for( i = 0; i < MAX_INVENTORY; i++ ) {
  5061. if( sd->inventory.u.items_inventory[i].amount ) {
  5062. std::shared_ptr<item_data> id = item_db.find(sd->inventory.u.items_inventory[i].nameid);
  5063. if( id == nullptr ) {
  5064. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->inventory.u.items_inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  5065. continue;
  5066. }
  5067. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  5068. continue;
  5069. if( type == -1 || type == (uint8)id->type ) {
  5070. if( sd->inventory.u.items_inventory[i].equip != 0 )
  5071. pc_unequipitem(sd, i, 3);
  5072. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5073. pet_return_egg( sd, sd->pd );
  5074. }
  5075. pc_equipswitch_remove(sd, i);
  5076. int amount = sd->inventory.u.items_inventory[i].amount;
  5077. if(pc_dropitem(sd, i, amount))
  5078. count += amount;
  5079. else count2 += amount;
  5080. }
  5081. }
  5082. }
  5083. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  5084. clif_displaymessage(fd, atcmd_output);
  5085. return 0;
  5086. }
  5087. /*==========================================
  5088. * @stockall by [Hanashi]
  5089. * transfer items from cart to inventory
  5090. *------------------------------------------*/
  5091. ACMD_FUNC(stockall)
  5092. {
  5093. nullpo_retr(-1, sd);
  5094. if (!pc_iscarton(sd)) {
  5095. clif_displaymessage(fd, msg_txt(sd,1533)); // You do not have a cart.
  5096. return -1;
  5097. }
  5098. int8 type = -1;
  5099. if ( message[0] ) {
  5100. type = atoi(message);
  5101. switch (type) {
  5102. case -1:
  5103. case IT_HEALING:
  5104. case IT_USABLE:
  5105. case IT_ETC:
  5106. case IT_WEAPON:
  5107. case IT_ARMOR:
  5108. case IT_CARD:
  5109. case IT_PETEGG:
  5110. case IT_PETARMOR:
  5111. case IT_AMMO:
  5112. break;
  5113. default:
  5114. clif_displaymessage(fd, msg_txt(sd, 1534)); // Usage: @stockall {<type>}
  5115. clif_displaymessage(fd, msg_txt(sd, 1493)); // Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5116. return -1;
  5117. }
  5118. }
  5119. uint16 count = 0, count2 = 0;
  5120. for ( uint16 i = 0; i < MAX_CART; i++ ) {
  5121. if ( sd->cart.u.items_cart[i].amount > 0 ) {
  5122. std::shared_ptr<item_data> id = item_db.find(sd->cart.u.items_cart[i].nameid);
  5123. if ( id == nullptr ) {
  5124. ShowDebug("Non-existent item %u on stockall list (account_id: %d, char_id: %d)\n", sd->cart.u.items_cart[i].nameid, sd->status.account_id, sd->status.char_id);
  5125. continue;
  5126. }
  5127. if ( type == -1 || static_cast<item_types>(type) == id->type ) {
  5128. if (pc_getitemfromcart(sd, i, sd->cart.u.items_cart[i].amount))
  5129. count += sd->cart.u.items_cart[i].amount;
  5130. else
  5131. count2 += sd->cart.u.items_cart[i].amount;
  5132. }
  5133. }
  5134. }
  5135. sprintf(atcmd_output, msg_txt(sd,1535), count,count2); // %d items are transferred (%d skipped)!
  5136. clif_displaymessage(fd, atcmd_output);
  5137. return 0;
  5138. }
  5139. /*==========================================
  5140. * @storeall by [MouseJstr]
  5141. * Put everything into storage
  5142. *------------------------------------------*/
  5143. ACMD_FUNC(storeall)
  5144. {
  5145. int i;
  5146. nullpo_retr(-1, sd);
  5147. if (sd->state.storage_flag != 1)
  5148. { //Open storage.
  5149. if( storage_storageopen(sd) == 1 ) {
  5150. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5151. return -1;
  5152. }
  5153. }
  5154. for (i = 0; i < MAX_INVENTORY; i++) {
  5155. if (sd->inventory.u.items_inventory[i].amount) {
  5156. if(sd->inventory.u.items_inventory[i].equip != 0)
  5157. pc_unequipitem(sd, i, 3);
  5158. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5159. pet_return_egg( sd, sd->pd );
  5160. }
  5161. pc_equipswitch_remove(sd, i);
  5162. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5163. }
  5164. }
  5165. storage_storageclose(sd);
  5166. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5167. return 0;
  5168. }
  5169. ACMD_FUNC(clearstorage)
  5170. {
  5171. int i, j;
  5172. nullpo_retr(-1, sd);
  5173. if (sd->state.storage_flag == 1) {
  5174. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5175. return -1;
  5176. }
  5177. if (sd->state.storage_flag == 3) {
  5178. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5179. return -1;
  5180. }
  5181. j = sd->storage.amount;
  5182. for (i = 0; i < j; ++i) {
  5183. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5184. }
  5185. sd->state.storage_flag = 1;
  5186. storage_storageclose(sd);
  5187. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5188. return 0;
  5189. }
  5190. ACMD_FUNC(cleargstorage)
  5191. {
  5192. int i, j;
  5193. struct s_storage *gstorage;
  5194. nullpo_retr(-1, sd);
  5195. if (!sd->guild) {
  5196. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5197. return -1;
  5198. }
  5199. if (sd->state.storage_flag == 1) {
  5200. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5201. return -1;
  5202. }
  5203. if (sd->state.storage_flag == 2) {
  5204. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5205. return -1;
  5206. }
  5207. if (sd->state.storage_flag == 3) {
  5208. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5209. return -1;
  5210. }
  5211. gstorage = guild2storage2(sd->status.guild_id);
  5212. if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5213. return -1;
  5214. }
  5215. j = gstorage->amount;
  5216. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5217. for (i = 0; i < j; ++i) {
  5218. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5219. }
  5220. storage_guild_storageclose(sd);
  5221. gstorage->lock = false; // Cleaning done, release lock
  5222. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5223. return 0;
  5224. }
  5225. ACMD_FUNC(clearcart)
  5226. {
  5227. int i;
  5228. nullpo_retr(-1, sd);
  5229. if (pc_iscarton(sd) == 0) {
  5230. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5231. return -1;
  5232. }
  5233. if (sd->state.vending == 1) { //Somehow...
  5234. return -1;
  5235. }
  5236. for (i = 0; i < MAX_CART; i++) {
  5237. if (sd->cart.u.items_cart[i].nameid > 0)
  5238. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5239. }
  5240. clif_clearcart(fd);
  5241. clif_updatestatus(*sd,SP_CARTINFO);
  5242. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5243. return 0;
  5244. }
  5245. /*==========================================
  5246. * @skillid by [MouseJstr]
  5247. * lookup a skill by name
  5248. *------------------------------------------*/
  5249. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5250. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5251. ACMD_FUNC(skillid) {
  5252. int i, found = 0;
  5253. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5254. nullpo_retr(-1, sd);
  5255. if (!message || !*message) {
  5256. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5257. return -1;
  5258. }
  5259. size_t skillen = strlen( message );
  5260. for(const auto & skill : skill_db) {
  5261. uint16 skill_id = skill.second->nameid;
  5262. uint16 idx = skill_get_index(skill_id);
  5263. const char *name = skill.second->name;
  5264. const char *desc = skill.second->desc;
  5265. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5266. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5267. clif_displaymessage(fd, atcmd_output);
  5268. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5269. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5270. }
  5271. }
  5272. if( found ) {
  5273. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5274. clif_displaymessage(fd, atcmd_output);
  5275. }
  5276. for(i = 0; i < found; i++) { /* partials */
  5277. clif_displaymessage(fd, partials[i]);
  5278. }
  5279. return 0;
  5280. }
  5281. /*==========================================
  5282. * @useskill by [MouseJstr]
  5283. * A way of using skills without having to find them in the skills menu
  5284. *------------------------------------------*/
  5285. ACMD_FUNC(useskill)
  5286. {
  5287. map_session_data* pl_sd = nullptr;;
  5288. struct block_list *bl;
  5289. uint16 skill_id;
  5290. uint16 skill_lv;
  5291. nullpo_retr(-1, sd);
  5292. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5293. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5294. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5295. return -1;
  5296. }
  5297. if (!skill_id || !skill_db.find(skill_id)) {
  5298. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5299. return -1;
  5300. }
  5301. if (!skill_lv)
  5302. skill_lv = 1;
  5303. if(!strcmp(atcmd_player_name,"self"))
  5304. pl_sd = sd; //quick keyword
  5305. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
  5306. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5307. return -1;
  5308. }
  5309. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5310. {
  5311. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5312. return -1;
  5313. }
  5314. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5315. bl = &sd->hd->bl;
  5316. else
  5317. bl = &sd->bl;
  5318. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5319. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5320. else
  5321. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5322. return 0;
  5323. }
  5324. /*==========================================
  5325. * @displayskill by [Skotlex]
  5326. * Debug command to locate new skill IDs. It sends the
  5327. * three possible skill-effect packets to the area.
  5328. *------------------------------------------*/
  5329. ACMD_FUNC(displayskill)
  5330. {
  5331. t_tick tick;
  5332. uint16 skill_id;
  5333. uint16 skill_lv = 1;
  5334. uint16 type = 0;
  5335. nullpo_retr(-1, sd);
  5336. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5337. {
  5338. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5339. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5340. return -1;
  5341. }
  5342. status_data* status = status_get_status_data(sd->bl);
  5343. tick = gettick();
  5344. if (type == 0 || type == 1)
  5345. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE);
  5346. if (type == 0 || type == 2)
  5347. clif_skill_damage(&sd->bl, &sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  5348. if (type == 0 || type == 3)
  5349. clif_skill_nodamage(&sd->bl, sd->bl, skill_id, skill_lv);
  5350. if (type == 0 || type == 4)
  5351. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  5352. return 0;
  5353. }
  5354. /*==========================================
  5355. * @displayskillcast by [Rytech]
  5356. * Debug command to view casting animations for skills.
  5357. * Can target self or the ground. Ground target can be
  5358. * useful for seeing casting circle size.
  5359. *------------------------------------------*/
  5360. ACMD_FUNC(displayskillcast)
  5361. {
  5362. uint16 skill_id;
  5363. uint16 skill_lv = 1;
  5364. uint16 cast_time = 5000;
  5365. uint16 target_type = 0;
  5366. nullpo_retr(-1, sd);
  5367. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5368. {
  5369. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5370. return -1;
  5371. }
  5372. if ( target_type == 1)
  5373. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5374. else
  5375. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5376. return 0;
  5377. }
  5378. /*==========================================
  5379. * @displayskillunit by [Rytech]
  5380. * Debug command to view unit animations for skills.
  5381. *------------------------------------------*/
  5382. ACMD_FUNC(displayskillunit)
  5383. {
  5384. uint16 unit_id;
  5385. uint16 range = 0;
  5386. uint16 skill_lv = 1;
  5387. nullpo_retr(-1, sd);
  5388. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5389. {
  5390. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5391. return -1;
  5392. }
  5393. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5394. return 0;
  5395. }
  5396. /*==========================================
  5397. * @skilltree by [MouseJstr]
  5398. * prints the skill tree for a player required to get to a skill
  5399. *------------------------------------------*/
  5400. ACMD_FUNC(skilltree)
  5401. {
  5402. map_session_data* pl_sd = nullptr;;
  5403. uint16 skill_id;
  5404. nullpo_retr(-1, sd);
  5405. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5406. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5407. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5408. return -1;
  5409. }
  5410. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5411. {
  5412. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5413. return -1;
  5414. }
  5415. int c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5416. sprintf(atcmd_output, msg_txt(sd,1168), job_name(c), pc_checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points).
  5417. clif_displaymessage(fd, atcmd_output);
  5418. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5419. if (entry == nullptr) {
  5420. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5421. return 0;
  5422. }
  5423. bool meets = true;
  5424. for (const auto &it : entry->need) {
  5425. if (pc_checkskill(sd, it.first) < it.second) {
  5426. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5427. clif_displaymessage(fd, atcmd_output);
  5428. meets = false;
  5429. }
  5430. }
  5431. if (meets) {
  5432. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5433. }
  5434. return 0;
  5435. }
  5436. // Hand a ring with partners name on it to this char
  5437. void getring (map_session_data* sd)
  5438. {
  5439. char flag = 0;
  5440. t_itemid item_id;
  5441. struct item item_tmp;
  5442. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5443. memset(&item_tmp, 0, sizeof(item_tmp));
  5444. item_tmp.nameid = item_id;
  5445. item_tmp.identify = 1;
  5446. item_tmp.card[0] = CARD0_FORGE;
  5447. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5448. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5449. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5450. clif_additem(sd,0,0,flag);
  5451. }
  5452. }
  5453. /*==========================================
  5454. * @marry by [MouseJstr], fixed by Lupus
  5455. * Marry two players
  5456. *------------------------------------------*/
  5457. ACMD_FUNC(marry)
  5458. {
  5459. map_session_data* pl_sd = nullptr;;
  5460. nullpo_retr(-1, sd);
  5461. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5462. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5463. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5464. return -1;
  5465. }
  5466. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  5467. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5468. return -1;
  5469. }
  5470. if (!pc_inventoryblank(sd)) {
  5471. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5472. return -1;
  5473. }
  5474. if (!pc_inventoryblank(pl_sd)) {
  5475. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5476. return -1;
  5477. }
  5478. uint32 w = 0;
  5479. if (w = itemdb_weight((sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + sd->weight > sd->max_weight) {
  5480. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5481. return -1;
  5482. }
  5483. if (w = itemdb_weight((pl_sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + pl_sd->weight > pl_sd->max_weight) {
  5484. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5485. return -1;
  5486. }
  5487. if (pc_marriage(sd, pl_sd)) {
  5488. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5489. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5490. if( pl_sd->bl.m != sd->bl.m )
  5491. clif_wedding_effect(&sd->bl);
  5492. getring(sd); // Auto-give named rings (Aru)
  5493. getring(pl_sd);
  5494. return 0;
  5495. }
  5496. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5497. return -1;
  5498. }
  5499. /*==========================================
  5500. * @divorce by [MouseJstr], fixed by [Lupus]
  5501. * divorce two players
  5502. *------------------------------------------*/
  5503. ACMD_FUNC(divorce)
  5504. {
  5505. nullpo_retr(-1, sd);
  5506. if (!pc_divorce(sd)) {
  5507. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5508. clif_displaymessage(fd, atcmd_output);
  5509. return -1;
  5510. }
  5511. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5512. clif_displaymessage(fd, atcmd_output);
  5513. return 0;
  5514. }
  5515. /*==========================================
  5516. * @changelook by [Celest]
  5517. *------------------------------------------*/
  5518. ACMD_FUNC(changelook)
  5519. {
  5520. int i, j = 0, k = 0;
  5521. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5522. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5523. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5524. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5525. return -1;
  5526. } else if ( i == 2 ) {
  5527. if (j < 1 || j > 8)
  5528. j = 1;
  5529. j = pos[j - 1];
  5530. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5531. k = j; // swap
  5532. j = LOOK_HEAD_TOP;
  5533. }
  5534. clif_changelook(&sd->bl,j,k);
  5535. return 0;
  5536. }
  5537. /*==========================================
  5538. * @autotrade by durf [Lupus] [Paradox924X]
  5539. * Turns on/off Autotrade for a specific player
  5540. *------------------------------------------*/
  5541. ACMD_FUNC(autotrade) {
  5542. nullpo_retr(-1, sd);
  5543. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5544. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5545. return -1;
  5546. }
  5547. if( pc_isdead(sd) ) {
  5548. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5549. return -1;
  5550. }
  5551. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5552. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5553. return -1;
  5554. }
  5555. sd->state.autotrade = 1;
  5556. if (battle_config.autotrade_monsterignore)
  5557. sd->state.block_action |= PCBLOCK_IMMUNE;
  5558. if( sd->state.vending ){
  5559. vending_update(*sd);
  5560. }else if( sd->state.buyingstore ){
  5561. buyingstore_update(*sd);
  5562. }
  5563. if( battle_config.at_timeout ) {
  5564. int timeout = atoi(message);
  5565. status_change_start(nullptr,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5566. }
  5567. if (battle_config.at_logout_event)
  5568. npc_script_event( *sd, NPCE_LOGOUT );
  5569. channel_pcquit(sd,0xF); //leave all chan
  5570. clif_authfail_fd(sd->fd, 15);
  5571. chrif_save(sd, CSAVE_AUTOTRADE);
  5572. return 0;
  5573. }
  5574. /*==========================================
  5575. * @changegm by durf (changed by Lupus)
  5576. * Changes Master of your Guild to a specified guild member
  5577. *------------------------------------------*/
  5578. ACMD_FUNC(changegm)
  5579. {
  5580. map_session_data *pl_sd;
  5581. nullpo_retr(-1, sd);
  5582. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5583. if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
  5584. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5585. return -1;
  5586. }
  5587. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5588. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5589. return -1;
  5590. }
  5591. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5592. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5593. return -1;
  5594. }
  5595. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
  5596. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5597. return -1;
  5598. }
  5599. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5600. #if PACKETVER >= 20151001
  5601. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_IN_SIEGE_TIME);
  5602. #else
  5603. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5604. #endif
  5605. return -1;
  5606. }
  5607. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
  5608. #if PACKETVER >= 20151001
  5609. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_NOT_TIME);
  5610. #else
  5611. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5612. #endif
  5613. return -1;
  5614. }
  5615. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5616. return 0;
  5617. }
  5618. /*==========================================
  5619. * @changeleader by Skotlex
  5620. * Changes the leader of a party.
  5621. *------------------------------------------*/
  5622. ACMD_FUNC(changeleader)
  5623. {
  5624. nullpo_retr(-1, sd);
  5625. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5626. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5627. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5628. return -1;
  5629. }
  5630. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
  5631. return 0;
  5632. }
  5633. /*==========================================
  5634. * @partyoption by Skotlex
  5635. * Used to change the item share setting of a party.
  5636. *------------------------------------------*/
  5637. ACMD_FUNC(partyoption)
  5638. {
  5639. struct party_data *p;
  5640. int mi, option;
  5641. char w1[16], w2[16];
  5642. nullpo_retr(-1, sd);
  5643. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
  5644. {
  5645. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5646. return -1;
  5647. }
  5648. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5649. if (mi == MAX_PARTY)
  5650. return -1; //Shouldn't happen
  5651. if (!p->party.member[mi].leader)
  5652. {
  5653. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5654. return -1;
  5655. }
  5656. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5657. {
  5658. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5659. return -1;
  5660. }
  5661. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5662. //Change item share type.
  5663. if (option != p->party.item)
  5664. party_changeoption(sd, p->party.exp, option);
  5665. else
  5666. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5667. return 0;
  5668. }
  5669. /*==========================================
  5670. * @autoloot by Upa-Kun
  5671. * Turns on/off AutoLoot for a specific player
  5672. *------------------------------------------*/
  5673. ACMD_FUNC(autoloot)
  5674. {
  5675. int rate;
  5676. nullpo_retr(-1, sd);
  5677. // autoloot command without value
  5678. if(!message || !*message)
  5679. {
  5680. if (sd->state.autoloot)
  5681. rate = 0;
  5682. else
  5683. rate = 10000;
  5684. } else {
  5685. double drate;
  5686. drate = atof(message);
  5687. rate = (int)(drate*100);
  5688. }
  5689. if (rate < 0) rate = 0;
  5690. if (rate > 10000) rate = 10000;
  5691. sd->state.autoloot = rate;
  5692. if (sd->state.autoloot) {
  5693. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below.
  5694. clif_displaymessage(fd, atcmd_output);
  5695. }else
  5696. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5697. return 0;
  5698. }
  5699. /*==========================================
  5700. * @alootid
  5701. *------------------------------------------*/
  5702. ACMD_FUNC(autolootitem)
  5703. {
  5704. std::shared_ptr<item_data> item_data;
  5705. int i;
  5706. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5707. nullpo_retr(-1, sd);
  5708. if (message && *message) {
  5709. if (message[0] == '+') {
  5710. message++;
  5711. action = 1;
  5712. }
  5713. else if (message[0] == '-') {
  5714. message++;
  5715. action = 2;
  5716. }
  5717. else if (!strcmp(message,"reset"))
  5718. action = 4;
  5719. }
  5720. if (action < 3) // add or remove
  5721. {
  5722. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5723. if( item_data == nullptr ){
  5724. item_data = item_db.searchname( message );
  5725. }
  5726. if( item_data == nullptr ){
  5727. // No items founds in the DB with Id or Name
  5728. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5729. return -1;
  5730. }
  5731. }
  5732. switch(action) {
  5733. case 1:
  5734. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5735. if (i != AUTOLOOTITEM_SIZE) {
  5736. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5737. return -1;
  5738. }
  5739. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5740. if (i == AUTOLOOTITEM_SIZE) {
  5741. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5742. return -1;
  5743. }
  5744. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5745. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Autolooting item: '%s'/'%s' {%u}
  5746. clif_displaymessage(fd, atcmd_output);
  5747. sd->state.autolooting = 1;
  5748. break;
  5749. case 2:
  5750. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5751. if (i == AUTOLOOTITEM_SIZE) {
  5752. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5753. return -1;
  5754. }
  5755. sd->state.autolootid[i] = 0;
  5756. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid); // Removed item: '%s'/'%s' {%u} from your autolootitem list.
  5757. clif_displaymessage(fd, atcmd_output);
  5758. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5759. if (i == AUTOLOOTITEM_SIZE) {
  5760. sd->state.autolooting = 0;
  5761. }
  5762. break;
  5763. case 3:
  5764. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5765. clif_displaymessage(fd, atcmd_output);
  5766. clif_displaymessage(fd, msg_txt(sd,1196)); // To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
  5767. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5768. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5769. if (i == AUTOLOOTITEM_SIZE) {
  5770. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5771. } else {
  5772. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5773. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5774. {
  5775. if (sd->state.autolootid[i] == 0)
  5776. continue;
  5777. item_data = item_db.find( sd->state.autolootid[i] );
  5778. if( item_data == nullptr ){
  5779. 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);
  5780. continue;
  5781. }
  5782. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
  5783. clif_displaymessage(fd, atcmd_output);
  5784. }
  5785. }
  5786. break;
  5787. case 4:
  5788. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5789. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5790. sd->state.autolooting = 0;
  5791. break;
  5792. }
  5793. return 0;
  5794. }
  5795. /*==========================================
  5796. * @autoloottype
  5797. * Flags:
  5798. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5799. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5800. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5801. * 262144: IT_CASH
  5802. *------------------------------------------
  5803. * Credits:
  5804. * chriser
  5805. * Aleos
  5806. *------------------------------------------*/
  5807. ACMD_FUNC(autoloottype)
  5808. {
  5809. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5810. enum item_types type= IT_UNKNOWN;
  5811. int ITEM_MAX = 1533;
  5812. nullpo_retr(-1, sd);
  5813. if (message && *message) {
  5814. if (message[0] == '+') {
  5815. message++;
  5816. action = 1;
  5817. }
  5818. else if (message[0] == '-') {
  5819. message++;
  5820. action = 2;
  5821. }
  5822. else if (!strcmp(message,"reset"))
  5823. action = 4;
  5824. }
  5825. if (action < 3) { // add or remove
  5826. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5827. type = IT_HEALING;
  5828. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5829. type = IT_USABLE;
  5830. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5831. type = IT_ETC;
  5832. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5833. type = IT_ARMOR;
  5834. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5835. type = IT_WEAPON;
  5836. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5837. type = IT_CARD;
  5838. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5839. type = IT_PETEGG;
  5840. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5841. type = IT_PETARMOR;
  5842. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5843. type = IT_AMMO;
  5844. else {
  5845. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5846. return -1;
  5847. }
  5848. }
  5849. switch (action) {
  5850. case 1:
  5851. if (sd->state.autoloottype&(1<<type)) {
  5852. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5853. return -1;
  5854. }
  5855. if (sd->state.autoloottype == ITEM_MAX) {
  5856. clif_displaymessage(fd, msg_txt(sd,1482)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -<type name or ID>.
  5857. return -1;
  5858. }
  5859. sd->state.autoloottype |= (1<<type); // Stores the type
  5860. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5861. clif_displaymessage(fd, atcmd_output);
  5862. break;
  5863. case 2:
  5864. if (!(sd->state.autoloottype&(1<<type))) {
  5865. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5866. return -1;
  5867. }
  5868. sd->state.autoloottype &= ~(1<<type);
  5869. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5870. clif_displaymessage(fd, atcmd_output);
  5871. break;
  5872. case 3:
  5873. clif_displaymessage(fd, msg_txt(sd,1486)); // To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>".
  5874. clif_displaymessage(fd, msg_txt(sd,1487)); // Type List: healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
  5875. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5876. if (sd->state.autoloottype == 0)
  5877. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5878. else {
  5879. uint8 i = 0;
  5880. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5881. while (i < IT_MAX) {
  5882. if (sd->state.autoloottype&(1<<i)) {
  5883. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5884. clif_displaymessage(fd, atcmd_output);
  5885. }
  5886. i++;
  5887. }
  5888. }
  5889. break;
  5890. case 4:
  5891. sd->state.autoloottype = 0;
  5892. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5893. break;
  5894. }
  5895. return 0;
  5896. }
  5897. /*==========================================
  5898. * It is made to rain.
  5899. * No longer available, keeping here just in case it's back someday. [Ind]
  5900. *------------------------------------------*/
  5901. //ACMD_FUNC(rain)
  5902. //{
  5903. // nullpo_retr(-1, sd);
  5904. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5905. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5906. // clif_weather(sd->bl.m);
  5907. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5908. // } else {
  5909. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5910. // clif_weather(sd->bl.m);
  5911. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5912. // }
  5913. // return 0;
  5914. //}
  5915. /*==========================================
  5916. * It is made to snow.
  5917. *------------------------------------------*/
  5918. ACMD_FUNC(snow)
  5919. {
  5920. nullpo_retr(-1, sd);
  5921. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5922. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5923. clif_weather(sd->bl.m);
  5924. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5925. } else {
  5926. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5927. clif_weather(sd->bl.m);
  5928. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5929. }
  5930. return 0;
  5931. }
  5932. /*==========================================
  5933. * Cherry tree snowstorm is made to fall. (Sakura)
  5934. *------------------------------------------*/
  5935. ACMD_FUNC(sakura)
  5936. {
  5937. nullpo_retr(-1, sd);
  5938. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5939. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5940. clif_weather(sd->bl.m);
  5941. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5942. } else {
  5943. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5944. clif_weather(sd->bl.m);
  5945. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5946. }
  5947. return 0;
  5948. }
  5949. /*==========================================
  5950. * Clouds appear.
  5951. *------------------------------------------*/
  5952. ACMD_FUNC(clouds)
  5953. {
  5954. nullpo_retr(-1, sd);
  5955. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5956. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5957. clif_weather(sd->bl.m);
  5958. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5959. } else {
  5960. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5961. clif_weather(sd->bl.m);
  5962. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5963. }
  5964. return 0;
  5965. }
  5966. /*==========================================
  5967. * Different type of clouds using effect 516
  5968. *------------------------------------------*/
  5969. ACMD_FUNC(clouds2)
  5970. {
  5971. nullpo_retr(-1, sd);
  5972. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5973. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5974. clif_weather(sd->bl.m);
  5975. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5976. } else {
  5977. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5978. clif_weather(sd->bl.m);
  5979. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5980. }
  5981. return 0;
  5982. }
  5983. /*==========================================
  5984. * Fog hangs over.
  5985. *------------------------------------------*/
  5986. ACMD_FUNC(fog)
  5987. {
  5988. nullpo_retr(-1, sd);
  5989. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5990. map_setmapflag(sd->bl.m, MF_FOG, false);
  5991. clif_weather(sd->bl.m);
  5992. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5993. } else {
  5994. map_setmapflag(sd->bl.m, MF_FOG, true);
  5995. clif_weather(sd->bl.m);
  5996. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5997. }
  5998. return 0;
  5999. }
  6000. /*==========================================
  6001. * Fallen leaves fall.
  6002. *------------------------------------------*/
  6003. ACMD_FUNC(leaves)
  6004. {
  6005. nullpo_retr(-1, sd);
  6006. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  6007. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6008. clif_weather(sd->bl.m);
  6009. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  6010. } else {
  6011. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  6012. clif_weather(sd->bl.m);
  6013. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  6014. }
  6015. return 0;
  6016. }
  6017. /*==========================================
  6018. * Fireworks appear.
  6019. *------------------------------------------*/
  6020. ACMD_FUNC(fireworks)
  6021. {
  6022. nullpo_retr(-1, sd);
  6023. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  6024. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6025. clif_weather(sd->bl.m);
  6026. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  6027. } else {
  6028. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  6029. clif_weather(sd->bl.m);
  6030. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  6031. }
  6032. return 0;
  6033. }
  6034. /*==========================================
  6035. * Clearing Weather Effects by Dexity
  6036. *------------------------------------------*/
  6037. ACMD_FUNC(clearweather)
  6038. {
  6039. nullpo_retr(-1, sd);
  6040. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  6041. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6042. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6043. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6044. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6045. map_setmapflag(sd->bl.m, MF_FOG, false);
  6046. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6047. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6048. clif_weather(sd->bl.m);
  6049. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  6050. return 0;
  6051. }
  6052. /*===============================================================
  6053. * Sound Command - plays a sound for everyone around! [Codemaster]
  6054. *---------------------------------------------------------------*/
  6055. ACMD_FUNC(sound)
  6056. {
  6057. char sound_file[100];
  6058. memset(sound_file, '\0', sizeof(sound_file));
  6059. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6060. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6061. return -1;
  6062. }
  6063. if(strstr(sound_file, ".wav") == nullptr)
  6064. strcat(sound_file, ".wav");
  6065. clif_soundeffect( sd->bl, sound_file, 0, AREA );
  6066. return 0;
  6067. }
  6068. /*==========================================
  6069. * MOB Search
  6070. *------------------------------------------*/
  6071. ACMD_FUNC(mobsearch)
  6072. {
  6073. nullpo_retr(-1, sd);
  6074. char mob_name[100]={0};
  6075. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6076. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6077. return -1;
  6078. }
  6079. int mob_id = strtol(mob_name, nullptr, 10);
  6080. if (mob_id == 0)
  6081. mob_id = mobdb_searchname(mob_name);
  6082. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6083. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6084. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6085. clif_displaymessage(fd, atcmd_output);
  6086. return -1;
  6087. }
  6088. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6089. // strcpy(mob_name, mob->name.c_str()); // --en--
  6090. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6091. clif_displaymessage(fd, atcmd_output);
  6092. s_mapiterator* it = mapit_geteachmob();
  6093. int number = 0;
  6094. for(;;)
  6095. {
  6096. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6097. if( md == nullptr )
  6098. break;// no more mobs
  6099. if( md->bl.m != sd->bl.m )
  6100. continue;
  6101. if( md->mob_id != mob_id )
  6102. continue;
  6103. ++number;
  6104. if( md->spawn_timer == INVALID_TIMER )
  6105. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6106. else
  6107. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6108. clif_displaymessage(fd, atcmd_output);
  6109. }
  6110. mapit_free(it);
  6111. return 0;
  6112. }
  6113. /*==========================================
  6114. * @cleanmap - cleans items on the ground
  6115. * @cleanarea - cleans items on the ground within an specified area
  6116. *------------------------------------------*/
  6117. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6118. {
  6119. nullpo_ret(bl);
  6120. map_clearflooritem(bl);
  6121. return 0;
  6122. }
  6123. ACMD_FUNC(cleanmap)
  6124. {
  6125. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6126. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6127. return 0;
  6128. }
  6129. ACMD_FUNC(cleanarea)
  6130. {
  6131. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6132. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  6133. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - (AREA_SIZE * 2), sd->bl.y - (AREA_SIZE * 2), sd->bl.x + (AREA_SIZE * 2), sd->bl.y + (AREA_SIZE * 2), BL_ITEM);
  6134. }
  6135. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  6136. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  6137. }
  6138. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  6139. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6140. }
  6141. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6142. return 0;
  6143. }
  6144. /*==========================================
  6145. * make a NPC/PET talk
  6146. * @npctalkc [SnakeDrak]
  6147. *------------------------------------------*/
  6148. ACMD_FUNC(npctalk)
  6149. {
  6150. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  6151. struct npc_data *nd;
  6152. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6153. unsigned long color=0;
  6154. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6155. return -1; //no "chatting" while muted.
  6156. if(!ifcolor) {
  6157. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6158. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6159. return -1;
  6160. }
  6161. }
  6162. else {
  6163. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6164. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6165. return -1;
  6166. }
  6167. }
  6168. if (!(nd = npc_name2id(name))) {
  6169. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6170. return -1;
  6171. }
  6172. strtok(name, "#"); // discard extra name identifier if present
  6173. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6174. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6175. else clif_disp_overhead(&nd->bl, temp);
  6176. return 0;
  6177. }
  6178. ACMD_FUNC(pettalk)
  6179. {
  6180. char mes[100],temp[CHAT_SIZE_MAX];
  6181. struct pet_data *pd;
  6182. nullpo_retr(-1, sd);
  6183. if ( battle_config.min_chat_delay ) {
  6184. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6185. return 0;
  6186. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6187. }
  6188. if(!sd->status.pet_id || !(pd=sd->pd))
  6189. {
  6190. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6191. return -1;
  6192. }
  6193. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6194. return -1; //no "chatting" while muted.
  6195. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6196. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6197. return -1;
  6198. }
  6199. if (message[0] == '/')
  6200. {// pet emotion processing
  6201. const char* emo[] = {
  6202. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6203. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6204. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6205. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6206. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6207. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6208. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6209. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6210. "/whisp"
  6211. };
  6212. int i;
  6213. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6214. if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
  6215. if( i < ARRAYLENGTH(emo) )
  6216. {
  6217. if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
  6218. sd->emotionlasttime = time(nullptr);
  6219. return 0;
  6220. }
  6221. sd->emotionlasttime = time(nullptr);
  6222. clif_emotion(&pd->bl, i);
  6223. return 0;
  6224. }
  6225. }
  6226. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6227. clif_disp_overhead(&pd->bl, temp);
  6228. return 0;
  6229. }
  6230. /// @users - displays the number of players present on each map (and percentage)
  6231. /// #users displays on the target user instead of self
  6232. ACMD_FUNC(users)
  6233. {
  6234. char buf[CHAT_SIZE_MAX];
  6235. int i;
  6236. int users[MAX_MAPINDEX];
  6237. int users_all;
  6238. struct s_mapiterator* iter;
  6239. memset(users, 0, sizeof(users));
  6240. users_all = 0;
  6241. // count users on each map
  6242. iter = mapit_getallusers();
  6243. for(;;)
  6244. {
  6245. map_session_data* sd2 = (map_session_data*)mapit_next(iter);
  6246. if( sd2 == nullptr )
  6247. break;// no more users
  6248. if( sd2->mapindex >= MAX_MAPINDEX )
  6249. continue;// invalid mapindex
  6250. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6251. if( users_all < INT_MAX ) ++users_all;
  6252. }
  6253. mapit_free(iter);
  6254. // display results for each map
  6255. for( i = 0; i < MAX_MAPINDEX; ++i )
  6256. {
  6257. if( users[i] == 0 )
  6258. continue;// empty
  6259. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6260. clif_displaymessage(sd->fd, buf);
  6261. }
  6262. // display overall count
  6263. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6264. clif_displaymessage(sd->fd, buf);
  6265. return 0;
  6266. }
  6267. /*==========================================
  6268. *
  6269. *------------------------------------------*/
  6270. ACMD_FUNC(reset)
  6271. {
  6272. pc_resetstate(sd);
  6273. pc_resetskill(sd,1);
  6274. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6275. clif_displaymessage(fd, atcmd_output);
  6276. return 0;
  6277. }
  6278. /*==========================================
  6279. *
  6280. *------------------------------------------*/
  6281. ACMD_FUNC(summon)
  6282. {
  6283. char name[NAME_LENGTH];
  6284. int mob_id = 0;
  6285. int duration = 0;
  6286. struct mob_data *md;
  6287. t_tick tick=gettick();
  6288. nullpo_retr(-1, sd);
  6289. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6290. {
  6291. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6292. return -1;
  6293. }
  6294. if (duration < 1)
  6295. duration =1;
  6296. else if (duration > 60)
  6297. duration =60;
  6298. if ((mob_id = atoi(name)) == 0)
  6299. mob_id = mobdb_searchname(name);
  6300. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6301. {
  6302. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6303. return -1;
  6304. }
  6305. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6306. if(!md)
  6307. return -1;
  6308. md->master_id=sd->bl.id;
  6309. md->special_state.ai=AI_ATTACK;
  6310. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6311. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6312. mob_spawn(md);
  6313. sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6314. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  6315. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6316. return 0;
  6317. }
  6318. /*==========================================
  6319. * @adjgroup
  6320. * Temporarily move player to another group
  6321. * Useful during beta testing to allow players to use GM commands for short periods of time
  6322. *------------------------------------------*/
  6323. ACMD_FUNC(adjgroup)
  6324. {
  6325. int new_group = 0;
  6326. nullpo_retr(-1, sd);
  6327. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6328. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6329. return -1;
  6330. }
  6331. if (!player_group_db.exists(new_group)) {
  6332. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6333. return -1;
  6334. }
  6335. sd->group_id = new_group;
  6336. pc_group_pc_load(sd);/* update cache */
  6337. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6338. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6339. return 0;
  6340. }
  6341. /*==========================================
  6342. * @trade by [MouseJstr]
  6343. * Open a trade window with a remote player
  6344. *------------------------------------------*/
  6345. ACMD_FUNC(trade)
  6346. {
  6347. map_session_data* pl_sd = nullptr;;
  6348. nullpo_retr(-1, sd);
  6349. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6350. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6351. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6352. return -1;
  6353. }
  6354. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  6355. {
  6356. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6357. return -1;
  6358. }
  6359. trade_traderequest(sd, pl_sd);
  6360. return 0;
  6361. }
  6362. /*==========================================
  6363. * @setbattleflag by [MouseJstr]
  6364. * set a battle_config flag without having to reboot
  6365. *------------------------------------------*/
  6366. ACMD_FUNC(setbattleflag)
  6367. {
  6368. char flag[128], value[128];
  6369. int reload = 0;
  6370. nullpo_retr(-1, sd);
  6371. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) < 2) {
  6372. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6373. return -1;
  6374. }
  6375. if (battle_set_value(flag, value) == 0)
  6376. {
  6377. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6378. return -1;
  6379. }
  6380. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6381. if (reload)
  6382. mob_reload();
  6383. return 0;
  6384. }
  6385. /*==========================================
  6386. * @unmute [Valaris]
  6387. *------------------------------------------*/
  6388. ACMD_FUNC(unmute)
  6389. {
  6390. map_session_data* pl_sd = nullptr;;
  6391. nullpo_retr(-1, sd);
  6392. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6393. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6394. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6395. return -1;
  6396. }
  6397. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6398. {
  6399. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6400. return -1;
  6401. }
  6402. if(!pl_sd->sc.getSCE(SC_NOCHAT)) {
  6403. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6404. return -1;
  6405. }
  6406. pl_sd->status.manner = 0;
  6407. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6408. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6409. return 0;
  6410. }
  6411. /*==========================================
  6412. * @uptime by MC Cameri
  6413. *------------------------------------------*/
  6414. ACMD_FUNC(uptime)
  6415. {
  6416. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6417. minute = 60, days = 0, hours = 0, minutes = 0;
  6418. nullpo_retr(-1, sd);
  6419. seconds = get_uptime();
  6420. days = seconds/day;
  6421. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6422. hours = seconds/hour;
  6423. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6424. minutes = seconds/minute;
  6425. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6426. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6427. clif_displaymessage(fd, atcmd_output);
  6428. return 0;
  6429. }
  6430. /*==========================================
  6431. * @changesex
  6432. * => Changes one's account sex. Switch from male to female or visversa
  6433. *------------------------------------------*/
  6434. ACMD_FUNC(changesex)
  6435. {
  6436. int i;
  6437. nullpo_retr(-1, sd);
  6438. pc_resetskill(sd,4);
  6439. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6440. for (i = 0; i < EQI_MAX; i++) {
  6441. if (sd->equip_index[i] >= 0)
  6442. pc_unequipitem(sd, sd->equip_index[i], 3);
  6443. }
  6444. chrif_changesex(sd, true);
  6445. return 0;
  6446. }
  6447. /*==========================================
  6448. * @changecharsex
  6449. * => Changes one's character sex. Switch from male to female or visversa.
  6450. *------------------------------------------*/
  6451. ACMD_FUNC(changecharsex)
  6452. {
  6453. int i;
  6454. nullpo_retr(-1, sd);
  6455. pc_resetskill(sd,4);
  6456. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6457. for (i = 0; i < EQI_MAX; i++) {
  6458. if (sd->equip_index[i] >= 0)
  6459. pc_unequipitem(sd, sd->equip_index[i], 3);
  6460. }
  6461. chrif_changesex(sd, false);
  6462. return 0;
  6463. }
  6464. /*================================================
  6465. * @mute - Mutes a player for a set amount of time
  6466. *------------------------------------------------*/
  6467. ACMD_FUNC(mute)
  6468. {
  6469. map_session_data* pl_sd = nullptr;;
  6470. int manner;
  6471. nullpo_retr(-1, sd);
  6472. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6473. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6474. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6475. return -1;
  6476. }
  6477. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6478. {
  6479. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6480. return -1;
  6481. }
  6482. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6483. {
  6484. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6485. return -1;
  6486. }
  6487. clif_manner_message(sd, 0);
  6488. clif_manner_message(pl_sd, 5);
  6489. if( pl_sd->status.manner < manner ) {
  6490. pl_sd->status.manner -= manner;
  6491. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6492. } else {
  6493. pl_sd->status.manner = 0;
  6494. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6495. }
  6496. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6497. return 0;
  6498. }
  6499. /*==========================================
  6500. * @refresh (like @jumpto <<yourself>>)
  6501. *------------------------------------------*/
  6502. ACMD_FUNC(refresh)
  6503. {
  6504. nullpo_retr(-1, sd);
  6505. clif_refresh(sd);
  6506. return 0;
  6507. }
  6508. ACMD_FUNC(refreshall)
  6509. {
  6510. map_session_data* iter_sd;
  6511. struct s_mapiterator* iter;
  6512. nullpo_retr(-1, sd);
  6513. iter = mapit_getallusers();
  6514. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6515. clif_refresh(iter_sd);
  6516. mapit_free(iter);
  6517. return 0;
  6518. }
  6519. /*==========================================
  6520. * @identify
  6521. * => GM's magnifier.
  6522. *------------------------------------------*/
  6523. ACMD_FUNC(identify)
  6524. {
  6525. int i,num;
  6526. nullpo_retr(-1, sd);
  6527. for(i=num=0;i<MAX_INVENTORY;i++){
  6528. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6529. num++;
  6530. }
  6531. }
  6532. if (num > 0) {
  6533. clif_item_identify_list(sd);
  6534. } else {
  6535. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6536. }
  6537. return 0;
  6538. }
  6539. /*===============================================
  6540. * @identifyall
  6541. * => Indentify all items in inventory - Akinari
  6542. *-----------------------------------------------*/
  6543. ACMD_FUNC(identifyall)
  6544. {
  6545. nullpo_retr(-1, sd);
  6546. pc_identifyall(sd, true);
  6547. return 0;
  6548. }
  6549. /*==========================================
  6550. * @gmotd (Global MOTD)
  6551. * by davidsiaw :P
  6552. *------------------------------------------*/
  6553. ACMD_FUNC(gmotd)
  6554. {
  6555. FILE* fp;
  6556. if( ( fp = fopen(motd_txt, "r") ) != nullptr )
  6557. {
  6558. char buf[CHAT_SIZE_MAX];
  6559. size_t len;
  6560. while( fgets(buf, sizeof(buf), fp) )
  6561. {
  6562. if( buf[0] == '/' && buf[1] == '/' )
  6563. {
  6564. continue;
  6565. }
  6566. len = strlen(buf);
  6567. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6568. {// strip trailing EOL characters
  6569. len--;
  6570. }
  6571. if( len )
  6572. {
  6573. buf[len] = 0;
  6574. intif_broadcast(buf, len+1, 0);
  6575. }
  6576. }
  6577. fclose(fp);
  6578. }
  6579. return 0;
  6580. }
  6581. ACMD_FUNC(misceffect)
  6582. {
  6583. int effect = 0;
  6584. nullpo_retr(-1, sd);
  6585. if (!message || !*message)
  6586. return -1;
  6587. if (sscanf(message, "%11d", &effect) < 1)
  6588. return -1;
  6589. if (effect < NOTIFYEFFECT_BASE_LEVEL_UP || effect > NOTIFYEFFECT_TAEKWON_BASE_LEVEL_UP)
  6590. return -1;
  6591. clif_misceffect( sd->bl, static_cast<e_notify_effect>(effect) );
  6592. return 0;
  6593. }
  6594. /*==========================================
  6595. * MAIL SYSTEM
  6596. *------------------------------------------*/
  6597. ACMD_FUNC(mail)
  6598. {
  6599. nullpo_ret(sd);
  6600. mail_openmail(sd);
  6601. return 0;
  6602. }
  6603. /*==========================================
  6604. * Show Monster DB Info v 1.0
  6605. * originally by [Lupus]
  6606. *------------------------------------------*/
  6607. ACMD_FUNC(mobinfo)
  6608. {
  6609. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6610. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6611. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6612. char atcmd_output2[CHAT_SIZE_MAX];
  6613. uint16 mob_ids[MAX_SEARCH], count;
  6614. uint16 i;
  6615. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6616. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6617. if (!message || !*message) {
  6618. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6619. return -1;
  6620. }
  6621. // If monster identifier/name argument is a name
  6622. if ((i = mobdb_checkid(strtoul(message, nullptr, 10))))
  6623. {
  6624. mob_ids[0] = i;
  6625. count = 1;
  6626. } else
  6627. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6628. if (!count) {
  6629. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6630. return -1;
  6631. }
  6632. if (count >= MAX_SEARCH) {
  6633. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6634. clif_displaymessage(fd, atcmd_output);
  6635. count = MAX_SEARCH;
  6636. }
  6637. for (uint16 k = 0; k < count; k++) {
  6638. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6639. if (mob == nullptr)
  6640. continue;
  6641. t_exp base_exp = mob->base_exp;
  6642. t_exp job_exp = mob->job_exp;
  6643. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6644. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6645. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6646. }
  6647. #ifdef RENEWAL_EXP
  6648. if( battle_config.atcommand_mobinfo_type ) {
  6649. int penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6650. base_exp = base_exp * penalty / 100;
  6651. job_exp = job_exp * penalty / 100;
  6652. }
  6653. #endif
  6654. // stats
  6655. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6656. sprintf(atcmd_output, msg_txt(sd,1240), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6657. else
  6658. sprintf(atcmd_output, msg_txt(sd,1241), mob->name.c_str(), mob->jname.c_str(), mob->sprite.c_str(), mob->id); // Monster: '%s'/'%s'/'%s' (%d)
  6659. clif_displaymessage(fd, atcmd_output);
  6660. sprintf(atcmd_output, msg_txt(sd,1242), mob->lv, mob->status.max_hp, base_exp, job_exp, MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%llu Job EXP:%llu HIT:%d FLEE:%d
  6661. clif_displaymessage(fd, atcmd_output);
  6662. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6663. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6664. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6665. clif_displaymessage(fd, atcmd_output);
  6666. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6667. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6668. mob->range2 , mob->range3, msize[mob->status.size],
  6669. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6670. clif_displaymessage(fd, atcmd_output);
  6671. #ifdef RENEWAL
  6672. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6673. clif_displaymessage(fd, atcmd_output);
  6674. #endif
  6675. // drops
  6676. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6677. strcpy(atcmd_output, " ");
  6678. unsigned int j = 0;
  6679. int drop_modifier = 100;
  6680. #ifdef RENEWAL_DROP
  6681. if( battle_config.atcommand_mobinfo_type ){
  6682. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6683. }
  6684. #endif
  6685. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6686. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1)
  6687. continue;
  6688. std::shared_ptr<item_data> id = item_db.find(mob->dropitem[i].nameid);
  6689. if (id == nullptr)
  6690. continue;
  6691. int droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6692. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
  6693. strcat(atcmd_output, atcmd_output2);
  6694. if (++j % 3 == 0) {
  6695. clif_displaymessage(fd, atcmd_output);
  6696. strcpy(atcmd_output, " ");
  6697. }
  6698. }
  6699. if (j == 0)
  6700. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6701. else if (j % 3 != 0)
  6702. clif_displaymessage(fd, atcmd_output);
  6703. // mvp
  6704. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6705. float mvppercent, mvpremain;
  6706. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6707. clif_displaymessage(fd, atcmd_output);
  6708. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6709. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6710. j = 0;
  6711. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6712. if (mob->mvpitem[i].nameid == 0)
  6713. continue;
  6714. std::shared_ptr<item_data> id = item_db.find(mob->mvpitem[i].nameid);
  6715. if (id == nullptr)
  6716. continue;
  6717. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6718. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6719. if(battle_config.item_drop_mvp_mode == 0) {
  6720. mvpremain -= mvppercent;
  6721. }
  6722. if (mvppercent > 0) {
  6723. j++;
  6724. if (j == 1) {
  6725. sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6726. } else {
  6727. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6728. }
  6729. strcat(atcmd_output, atcmd_output2);
  6730. }
  6731. }
  6732. if (j == 0)
  6733. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6734. else
  6735. clif_displaymessage(fd, atcmd_output);
  6736. }
  6737. }
  6738. return 0;
  6739. }
  6740. /*=========================================
  6741. * @showmobs by KarLaeda
  6742. * => For 15 sec displays the mobs on minimap
  6743. *------------------------------------------*/
  6744. ACMD_FUNC(showmobs)
  6745. {
  6746. char mob_name[100];
  6747. int mob_id;
  6748. int number = 0;
  6749. struct s_mapiterator* it;
  6750. nullpo_retr(-1, sd);
  6751. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6752. return -1;
  6753. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6754. mob_id = mobdb_searchname(mob_name);
  6755. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6756. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6757. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6758. clif_displaymessage(fd, atcmd_output);
  6759. return 0;
  6760. }
  6761. if(status_has_mode(&mob->status,MD_STATUSIMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6762. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6763. return 0;
  6764. }
  6765. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6766. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6767. //strcpy(mob_name, mob->name.c_str()); // --en--
  6768. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6769. mob_name, mapindex_id2name(sd->mapindex));
  6770. clif_displaymessage(fd, atcmd_output);
  6771. it = mapit_geteachmob();
  6772. for(;;)
  6773. {
  6774. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6775. if( md == nullptr )
  6776. break;// no more mobs
  6777. if( md->bl.m != sd->bl.m )
  6778. continue;
  6779. if( mob_id != -1 && md->mob_id != mob_id )
  6780. continue;
  6781. if( md->special_state.ai || md->master_id )
  6782. continue; // hide slaves and player summoned mobs
  6783. if( md->spawn_timer != INVALID_TIMER )
  6784. continue; // hide mobs waiting for respawn
  6785. ++number;
  6786. clif_viewpoint( *sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF );
  6787. }
  6788. mapit_free(it);
  6789. return 0;
  6790. }
  6791. /*==========================================
  6792. * homunculus level up [orn]
  6793. *------------------------------------------*/
  6794. ACMD_FUNC(homlevel)
  6795. {
  6796. TBL_HOM * hd;
  6797. int level = 0, i = 0;
  6798. nullpo_retr(-1, sd);
  6799. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6800. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6801. return -1;
  6802. }
  6803. if ( !hom_is_active(sd->hd) ) {
  6804. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6805. return -1;
  6806. }
  6807. hd = sd->hd;
  6808. for (i = 1; i <= level && hd->exp_next; i++){
  6809. hd->homunculus.exp += hd->exp_next;
  6810. if( !hom_levelup(hd) )
  6811. break;
  6812. }
  6813. status_calc_homunculus(hd, SCO_NONE);
  6814. status_percent_heal(&hd->bl, 100, 100);
  6815. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6816. return 0;
  6817. }
  6818. /*==========================================
  6819. * homunculus evolution H [orn]
  6820. *------------------------------------------*/
  6821. ACMD_FUNC(homevolution)
  6822. {
  6823. nullpo_retr(-1, sd);
  6824. if ( !hom_is_active(sd->hd) ) {
  6825. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6826. return -1;
  6827. }
  6828. if ( !hom_evolution(sd->hd) ) {
  6829. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6830. return -1;
  6831. }
  6832. clif_homskillinfoblock( *sd->hd );
  6833. return 0;
  6834. }
  6835. ACMD_FUNC(hommutate)
  6836. {
  6837. int homun_id, m_class = 0, m_id;
  6838. nullpo_retr(-1, sd);
  6839. if (!hom_is_active(sd->hd)) {
  6840. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6841. return -1;
  6842. }
  6843. if (!message || !*message) {
  6844. homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
  6845. } else {
  6846. homun_id = atoi(message);
  6847. }
  6848. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6849. m_id = hom_class2mapid(homun_id);
  6850. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6851. hom_mutate(sd->hd, homun_id);
  6852. } else {
  6853. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6854. }
  6855. return 0;
  6856. }
  6857. /*==========================================
  6858. * call choosen homunculus [orn]
  6859. *------------------------------------------*/
  6860. ACMD_FUNC(makehomun)
  6861. {
  6862. int homunid;
  6863. nullpo_retr(-1, sd);
  6864. if ( sd->status.hom_id ) {
  6865. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6866. return -1;
  6867. }
  6868. if (!message || !*message) {
  6869. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6870. return -1;
  6871. }
  6872. homunid = atoi(message);
  6873. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6874. {
  6875. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6876. return -1;
  6877. }
  6878. hom_create_request(sd,homunid);
  6879. return 0;
  6880. }
  6881. /*==========================================
  6882. * modify homunculus intimacy [orn]
  6883. *------------------------------------------*/
  6884. ACMD_FUNC(homfriendly)
  6885. {
  6886. int friendly = 0;
  6887. nullpo_retr(-1, sd);
  6888. if ( !hom_is_active(sd->hd) ) {
  6889. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6890. return -1;
  6891. }
  6892. if (!message || !*message) {
  6893. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6894. return -1;
  6895. }
  6896. friendly = atoi(message);
  6897. friendly = cap_value(friendly, 0, 1000);
  6898. sd->hd->homunculus.intimacy = friendly * 100 ;
  6899. clif_send_homdata( *sd->hd, SP_INTIMATE );
  6900. return 0;
  6901. }
  6902. /*==========================================
  6903. * modify homunculus hunger [orn]
  6904. *------------------------------------------*/
  6905. ACMD_FUNC(homhungry)
  6906. {
  6907. int hungry = 0;
  6908. nullpo_retr(-1, sd);
  6909. if ( !hom_is_active(sd->hd) ) {
  6910. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6911. return -1;
  6912. }
  6913. if (!message || !*message) {
  6914. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6915. return -1;
  6916. }
  6917. hungry = atoi(message);
  6918. hungry = cap_value(hungry, 0, 100);
  6919. sd->hd->homunculus.hunger = hungry;
  6920. clif_send_homdata( *sd->hd, SP_HUNGRY );
  6921. return 0;
  6922. }
  6923. /*==========================================
  6924. * make the homunculus speak [orn]
  6925. *------------------------------------------*/
  6926. ACMD_FUNC(homtalk)
  6927. {
  6928. char mes[100],temp[CHAT_SIZE_MAX];
  6929. nullpo_retr(-1, sd);
  6930. if ( battle_config.min_chat_delay ) {
  6931. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6932. return 0;
  6933. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6934. }
  6935. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6936. return -1; //no "chatting" while muted.
  6937. if ( !hom_is_active(sd->hd) ) {
  6938. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6939. return -1;
  6940. }
  6941. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6942. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6943. return -1;
  6944. }
  6945. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6946. clif_disp_overhead(&sd->hd->bl, temp);
  6947. return 0;
  6948. }
  6949. /*==========================================
  6950. * Show homunculus stats
  6951. *------------------------------------------*/
  6952. ACMD_FUNC(hominfo)
  6953. {
  6954. struct homun_data *hd;
  6955. nullpo_retr(-1, sd);
  6956. if ( !hom_is_active(sd->hd) ) {
  6957. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6958. return -1;
  6959. }
  6960. hd = sd->hd;
  6961. status_data* status = status_get_status_data(hd->bl);
  6962. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6963. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6964. status->hp, status->max_hp, status->sp, status->max_sp);
  6965. clif_displaymessage(fd, atcmd_output);
  6966. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6967. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6968. clif_displaymessage(fd, atcmd_output);
  6969. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6970. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6971. clif_displaymessage(fd, atcmd_output);
  6972. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6973. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6974. status->str, status->agi, status->vit,
  6975. status->int_, status->dex, status->luk);
  6976. clif_displaymessage(fd, atcmd_output);
  6977. return 0;
  6978. }
  6979. ACMD_FUNC(homstats)
  6980. {
  6981. struct homun_data *hd;
  6982. std::shared_ptr<s_homunculus_db> db;
  6983. struct s_homunculus *hom;
  6984. int lv, min, max, evo;
  6985. nullpo_retr(-1, sd);
  6986. if ( !hom_is_active(sd->hd) ) {
  6987. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6988. return -1;
  6989. }
  6990. hd = sd->hd;
  6991. hom = &hd->homunculus;
  6992. db = hd->homunculusDB;
  6993. lv = hom->level;
  6994. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6995. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6996. clif_displaymessage(fd, atcmd_output);
  6997. lv--; //Since the first increase is at level 2.
  6998. evo = (hom->class_ == db->evo_class);
  6999. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7000. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7001. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  7002. clif_displaymessage(fd, atcmd_output);
  7003. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7004. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7005. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  7006. clif_displaymessage(fd, atcmd_output);
  7007. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7008. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7009. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  7010. clif_displaymessage(fd, atcmd_output);
  7011. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7012. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7013. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  7014. clif_displaymessage(fd, atcmd_output);
  7015. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7016. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7017. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  7018. clif_displaymessage(fd, atcmd_output);
  7019. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7020. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7021. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  7022. clif_displaymessage(fd, atcmd_output);
  7023. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7024. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7025. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  7026. clif_displaymessage(fd, atcmd_output);
  7027. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7028. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7029. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  7030. clif_displaymessage(fd, atcmd_output);
  7031. return 0;
  7032. }
  7033. ACMD_FUNC(homshuffle)
  7034. {
  7035. nullpo_retr(-1, sd);
  7036. if(!sd->hd)
  7037. return -1; // nothing to do
  7038. if(!hom_shuffle(sd->hd))
  7039. return -1;
  7040. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7041. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7042. return 0;
  7043. }
  7044. /*==========================================
  7045. * Show Items DB Info v 1.0
  7046. * originally by [Lupus]
  7047. *------------------------------------------*/
  7048. ACMD_FUNC(iteminfo)
  7049. {
  7050. if (!message || !*message) {
  7051. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7052. return -1;
  7053. }
  7054. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7055. uint16 count = 1;
  7056. t_itemid itemid = strtoul(message, nullptr, 10);
  7057. if (itemid == 0) // Entered a string
  7058. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7059. else {
  7060. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7061. count = 0;
  7062. }
  7063. if (!count) {
  7064. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7065. return -1;
  7066. }
  7067. if (count == MAX_SEARCH) {
  7068. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7069. clif_displaymessage(fd, atcmd_output);
  7070. }
  7071. for (const auto &result : item_array) {
  7072. std::shared_ptr<item_data> item_data = result.second;
  7073. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
  7074. item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
  7075. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  7076. (item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7077. );
  7078. clif_displaymessage(fd, atcmd_output);
  7079. sprintf(atcmd_output, msg_txt(sd,1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f
  7080. clif_displaymessage(fd, atcmd_output);
  7081. if (item_data->maxchance == -1) {
  7082. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7083. clif_displaymessage(fd, atcmd_output);
  7084. }
  7085. else if (!battle_config.atcommand_mobinfo_type) {
  7086. if (item_data->maxchance)
  7087. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7088. else
  7089. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7090. clif_displaymessage(fd, atcmd_output);
  7091. }
  7092. }
  7093. return 0;
  7094. }
  7095. /*==========================================
  7096. * Show who drops the item.
  7097. *------------------------------------------*/
  7098. ACMD_FUNC(whodrops)
  7099. {
  7100. if (!message || !*message) {
  7101. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7102. return -1;
  7103. }
  7104. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7105. uint16 count = 1;
  7106. t_itemid itemid = strtoul(message, nullptr, 10);
  7107. if (itemid == 0) // Entered a string
  7108. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7109. else {
  7110. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7111. count = 0;
  7112. }
  7113. if (!count) {
  7114. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7115. return -1;
  7116. }
  7117. if (count == MAX_SEARCH) {
  7118. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7119. clif_displaymessage(fd, atcmd_output);
  7120. }
  7121. for (const auto &result : item_array) {
  7122. std::shared_ptr<item_data> id = result.second;
  7123. sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
  7124. clif_displaymessage(fd, atcmd_output);
  7125. if (id->mob[0].chance == 0) {
  7126. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7127. clif_displaymessage(fd, atcmd_output);
  7128. } else {
  7129. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7130. clif_displaymessage(fd, atcmd_output);
  7131. for (uint16 j=0; j < MAX_SEARCH && id->mob[j].chance > 0; j++)
  7132. {
  7133. int dropchance = id->mob[j].chance;
  7134. std::shared_ptr<s_mob_db> mob = mob_db.find(id->mob[j].id);
  7135. if(!mob) continue;
  7136. #ifdef RENEWAL_DROP
  7137. if( battle_config.atcommand_mobinfo_type ) {
  7138. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  7139. if (dropchance <= 0 && !battle_config.drop_rate0item)
  7140. dropchance = 1;
  7141. }
  7142. #endif
  7143. if (pc_isvip(sd)) // Display item rate increase for VIP
  7144. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  7145. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), id->mob[j].id, dropchance/100.);
  7146. clif_displaymessage(fd, atcmd_output);
  7147. }
  7148. }
  7149. }
  7150. return 0;
  7151. }
  7152. ACMD_FUNC(whereis)
  7153. {
  7154. uint16 mob_ids[MAX_SEARCH] = {0}, count;
  7155. if (!message || !*message) {
  7156. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7157. return -1;
  7158. }
  7159. int i_message = atoi(message);
  7160. if (mobdb_checkid(i_message)) {
  7161. // ID given
  7162. mob_ids[0] = i_message;
  7163. count = 1;
  7164. } else {
  7165. // Name given, get all monster associated whith this name
  7166. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7167. }
  7168. if (count <= 0) {
  7169. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7170. return -1;
  7171. }
  7172. if (count >= MAX_SEARCH) {
  7173. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7174. clif_displaymessage(fd, atcmd_output);
  7175. count = MAX_SEARCH;
  7176. }
  7177. for (int i = 0; i < count; i++) {
  7178. uint16 mob_id = mob_ids[i];
  7179. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7180. if(!mob) continue;
  7181. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7182. clif_displaymessage(fd, atcmd_output);
  7183. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7184. if (spawns.size() <= 0) {
  7185. // This monster does not spawn normally.
  7186. clif_displaymessage(fd, msg_txt(sd,1290));
  7187. } else {
  7188. for(auto& spawn : spawns)
  7189. {
  7190. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7191. if (mapid < 0)
  7192. continue;
  7193. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7194. clif_displaymessage(fd, atcmd_output);
  7195. }
  7196. }
  7197. }
  7198. return 0;
  7199. }
  7200. ACMD_FUNC(version)
  7201. {
  7202. pc_show_version(sd);
  7203. return 0;
  7204. }
  7205. /*==========================================
  7206. * @mutearea by MouseJstr
  7207. *------------------------------------------*/
  7208. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7209. {
  7210. int time, id;
  7211. map_session_data *pl_sd = (map_session_data *)bl;
  7212. if (pl_sd == nullptr)
  7213. return 0;
  7214. id = va_arg(ap, int);
  7215. time = va_arg(ap, int);
  7216. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7217. pl_sd->status.manner -= time;
  7218. if (pl_sd->status.manner < 0)
  7219. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7220. else
  7221. status_change_end(&pl_sd->bl, SC_NOCHAT);
  7222. }
  7223. return 0;
  7224. }
  7225. ACMD_FUNC(mutearea)
  7226. {
  7227. int time;
  7228. nullpo_ret(sd);
  7229. if (!message || !*message) {
  7230. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7231. return -1;
  7232. }
  7233. time = atoi(message);
  7234. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7235. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7236. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7237. return 0;
  7238. }
  7239. ACMD_FUNC(rates)
  7240. {
  7241. char buf[CHAT_SIZE_MAX];
  7242. nullpo_ret(sd);
  7243. memset(buf, '\0', sizeof(buf));
  7244. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7245. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7246. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7247. clif_displaymessage(fd, buf);
  7248. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7249. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7250. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7251. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7252. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7253. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7254. clif_displaymessage(fd, buf);
  7255. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7256. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7257. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7258. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7259. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7260. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7261. clif_displaymessage(fd, buf);
  7262. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7263. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7264. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7265. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7266. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7267. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7268. clif_displaymessage(fd, buf);
  7269. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7270. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7271. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7272. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7273. clif_displaymessage(fd, buf);
  7274. return 0;
  7275. }
  7276. /*==========================================
  7277. * @me by lordalfa
  7278. * => Displays the OUTPUT string on top of the Visible players Heads.
  7279. *------------------------------------------*/
  7280. ACMD_FUNC(me)
  7281. {
  7282. char tempmes[CHAT_SIZE_MAX];
  7283. nullpo_retr(-1, sd);
  7284. memset(tempmes, '\0', sizeof(tempmes));
  7285. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7286. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7287. return -1; //no "chatting" while muted.
  7288. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7289. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7290. return -1;
  7291. }
  7292. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7293. clif_disp_overhead(&sd->bl, atcmd_output);
  7294. return 0;
  7295. }
  7296. /*==========================================
  7297. * @size
  7298. * => Resize your character sprite. [Valaris]
  7299. *------------------------------------------*/
  7300. ACMD_FUNC(size)
  7301. {
  7302. int size = SZ_SMALL;
  7303. nullpo_retr(-1, sd);
  7304. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7305. if(sd->state.size) {
  7306. sd->state.size = SZ_SMALL;
  7307. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7308. }
  7309. sd->state.size = size;
  7310. if( size == SZ_MEDIUM )
  7311. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7312. else if( size == SZ_BIG )
  7313. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7314. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7315. return 0;
  7316. }
  7317. ACMD_FUNC(sizeall)
  7318. {
  7319. int size;
  7320. map_session_data *pl_sd;
  7321. struct s_mapiterator* iter;
  7322. size = atoi(message);
  7323. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7324. iter = mapit_getallusers();
  7325. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7326. if( pl_sd->state.size != size ) {
  7327. if( pl_sd->state.size ) {
  7328. pl_sd->state.size = SZ_SMALL;
  7329. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7330. }
  7331. pl_sd->state.size = size;
  7332. if( size == SZ_MEDIUM )
  7333. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7334. else if( size == SZ_BIG )
  7335. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7336. }
  7337. }
  7338. mapit_free(iter);
  7339. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7340. return 0;
  7341. }
  7342. ACMD_FUNC(sizeguild)
  7343. {
  7344. int size = SZ_SMALL, i;
  7345. char guild[NAME_LENGTH];
  7346. map_session_data *pl_sd;
  7347. nullpo_retr(-1, sd);
  7348. memset(guild, '\0', sizeof(guild));
  7349. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7350. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7351. return -1;
  7352. }
  7353. auto g = guild_searchnameid(guild);
  7354. if (!g) {
  7355. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7356. return -1;
  7357. }
  7358. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7359. for( i = 0; i < g->guild.max_member; i++ ) {
  7360. if( (pl_sd = g->guild.member[i].sd) && pl_sd->state.size != size ) {
  7361. if( pl_sd->state.size ) {
  7362. pl_sd->state.size = SZ_SMALL;
  7363. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7364. }
  7365. pl_sd->state.size = size;
  7366. if( size == SZ_MEDIUM )
  7367. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7368. else if( size == SZ_BIG )
  7369. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7370. }
  7371. }
  7372. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7373. return 0;
  7374. }
  7375. /*==========================================
  7376. * @monsterignore
  7377. * => Makes monsters ignore you. [Valaris]
  7378. *------------------------------------------*/
  7379. ACMD_FUNC(monsterignore)
  7380. {
  7381. nullpo_retr(-1, sd);
  7382. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7383. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7384. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7385. } else {
  7386. sd->state.block_action |= PCBLOCK_IMMUNE;
  7387. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7388. }
  7389. return 0;
  7390. }
  7391. /*==========================================
  7392. * @fakename
  7393. * => Gives your character a fake name. [Valaris]
  7394. *------------------------------------------*/
  7395. ACMD_FUNC(fakename)
  7396. {
  7397. nullpo_retr(-1, sd);
  7398. if( !message || !*message )
  7399. {
  7400. if( sd->fakename[0] )
  7401. {
  7402. sd->fakename[0] = '\0';
  7403. clif_name_area(&sd->bl);
  7404. if (sd->disguise)
  7405. clif_name_self(&sd->bl);
  7406. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7407. return 0;
  7408. }
  7409. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7410. return -1;
  7411. }
  7412. if( strlen(message) < 2 )
  7413. {
  7414. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7415. return -1;
  7416. }
  7417. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7418. clif_name_area(&sd->bl);
  7419. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7420. clif_name_self(&sd->bl);
  7421. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7422. return 0;
  7423. }
  7424. /*==========================================
  7425. * Ragnarok Resources
  7426. *------------------------------------------*/
  7427. ACMD_FUNC(mapflag) {
  7428. char flag_name[50];
  7429. short flag = 0, i, j;
  7430. std::string buf;
  7431. nullpo_retr(-1, sd);
  7432. memset(flag_name, '\0', sizeof(flag_name));
  7433. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7434. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7435. clif_displaymessage(sd->fd,"----------------------------------");
  7436. for( i = MF_MIN; i < MF_MAX; i++ ){
  7437. union u_mapflag_args args = {};
  7438. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7439. clif_displaymessage(sd->fd, flag_name);
  7440. }
  7441. }
  7442. clif_displaymessage(sd->fd," ");
  7443. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7444. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7445. return 1;
  7446. }
  7447. // Check if the list of mapflags was requested
  7448. if( strcasecmp(flag_name,"available") ){
  7449. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7450. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7451. if( mapflag != MF_INVALID ){
  7452. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7453. MF_PVP_NIGHTMAREDROP,
  7454. MF_RESTRICTED,
  7455. MF_NOCOMMAND,
  7456. MF_BEXP,
  7457. MF_JEXP,
  7458. MF_BATTLEGROUND,
  7459. MF_SKILL_DAMAGE,
  7460. MF_SKILL_DURATION };
  7461. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7462. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7463. clif_displaymessage(sd->fd,atcmd_output);
  7464. } else {
  7465. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7466. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7467. clif_displaymessage(sd->fd,atcmd_output);
  7468. }
  7469. return 0;
  7470. }else{
  7471. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7472. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7473. return 1;
  7474. }
  7475. }
  7476. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7477. clif_displaymessage(sd->fd,"----------------------------------");
  7478. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7479. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7480. buf.append(flag_name);
  7481. if( (i + 1) < MF_MAX )
  7482. buf.append(", ");
  7483. j++;
  7484. }
  7485. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7486. clif_displaymessage(sd->fd, buf.c_str() );
  7487. buf.clear();
  7488. j = 0;
  7489. }
  7490. }
  7491. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7492. return 0;
  7493. }
  7494. /*===================================
  7495. * Remove some messages
  7496. *-----------------------------------*/
  7497. ACMD_FUNC(showexp)
  7498. {
  7499. if (sd->state.showexp) {
  7500. sd->state.showexp = 0;
  7501. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7502. return 0;
  7503. }
  7504. sd->state.showexp = 1;
  7505. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7506. return 0;
  7507. }
  7508. ACMD_FUNC(showzeny)
  7509. {
  7510. if (sd->state.showzeny) {
  7511. sd->state.showzeny = 0;
  7512. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7513. return 0;
  7514. }
  7515. sd->state.showzeny = 1;
  7516. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7517. return 0;
  7518. }
  7519. ACMD_FUNC(showdelay)
  7520. {
  7521. if (sd->state.showdelay) {
  7522. sd->state.showdelay = 0;
  7523. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7524. return 0;
  7525. }
  7526. sd->state.showdelay = 1;
  7527. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7528. return 0;
  7529. }
  7530. /*==========================================
  7531. * Duel organizing functions [LuzZza]
  7532. *
  7533. * @duel [limit|nick] - create a duel
  7534. * @invite <nick> - invite player
  7535. * @accept - accept invitation
  7536. * @reject - reject invitation
  7537. * @leave - leave duel
  7538. *------------------------------------------*/
  7539. ACMD_FUNC(invite)
  7540. {
  7541. size_t did = sd->duel_group;
  7542. map_session_data *target_sd = nullptr;
  7543. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7544. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7545. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7546. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7547. clif_displaymessage(fd, atcmd_output);
  7548. return -1;
  7549. }
  7550. if(did == 0 || !duel_exist(did) ) {
  7551. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7552. return 0;
  7553. }
  7554. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7555. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7556. return 0;
  7557. }
  7558. if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
  7559. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7560. return 0;
  7561. }
  7562. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7563. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7564. return 0;
  7565. }
  7566. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7567. {
  7568. sprintf(atcmd_output, msg_txt(sd,364), atcmd_player_name); // Duel: You can't invite %s because he/she isn't on the same map.
  7569. clif_displaymessage(fd, atcmd_output);
  7570. return 0;
  7571. }
  7572. duel_invite(did, sd, target_sd);
  7573. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7574. return 0;
  7575. }
  7576. ACMD_FUNC(duel)
  7577. {
  7578. unsigned int maxpl = 0;
  7579. if(sd->duel_group > 0) {
  7580. duel_showinfo(sd->duel_group, sd);
  7581. return 0;
  7582. }
  7583. if(sd->duel_invite > 0) {
  7584. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7585. return 0;
  7586. }
  7587. if(!duel_checktime(sd)) {
  7588. char output[CHAT_SIZE_MAX];
  7589. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7590. clif_displaymessage(fd, output);
  7591. return 0;
  7592. }
  7593. if( message[0] ) {
  7594. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7595. if(maxpl < 2 || maxpl > 65535) {
  7596. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7597. return 0;
  7598. }
  7599. duel_create(sd, maxpl);
  7600. } else {
  7601. map_session_data *target_sd = nullptr;
  7602. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7603. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7604. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7605. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7606. clif_displaymessage(fd, atcmd_output);
  7607. return -1;
  7608. }
  7609. target_sd = map_nick2sd(atcmd_player_name,true);
  7610. if(target_sd != nullptr) {
  7611. size_t newduel;
  7612. if((newduel = duel_create(sd, 2)) != -1) {
  7613. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7614. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7615. return 0;
  7616. }
  7617. duel_invite(newduel, sd, target_sd);
  7618. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7619. }
  7620. } else {
  7621. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7622. return 0;
  7623. }
  7624. }
  7625. } else
  7626. duel_create(sd, 0);
  7627. return 0;
  7628. }
  7629. ACMD_FUNC(leave)
  7630. {
  7631. if(sd->duel_group <= 0) {
  7632. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7633. return 0;
  7634. }
  7635. duel_leave(sd->duel_group, sd);
  7636. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7637. return 0;
  7638. }
  7639. ACMD_FUNC(accept)
  7640. {
  7641. if(!duel_checktime(sd)) {
  7642. char output[CHAT_SIZE_MAX];
  7643. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7644. clif_displaymessage(fd, output);
  7645. return 0;
  7646. }
  7647. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7648. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7649. return 0;
  7650. }
  7651. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7652. {
  7653. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7654. return 0;
  7655. }
  7656. duel_accept(sd->duel_invite, sd);
  7657. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7658. return 0;
  7659. }
  7660. ACMD_FUNC(reject)
  7661. {
  7662. if(sd->duel_invite <= 0) {
  7663. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7664. return 0;
  7665. }
  7666. duel_reject(sd->duel_invite, sd);
  7667. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7668. return 0;
  7669. }
  7670. /*===================================
  7671. * Cash Points
  7672. *-----------------------------------*/
  7673. ACMD_FUNC(cash)
  7674. {
  7675. char output[128];
  7676. int value;
  7677. int ret=0;
  7678. nullpo_retr(-1, sd);
  7679. // Since there is no cashpoint update packet we need to force updating like this
  7680. if( sd->state.cashshop_open ){
  7681. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7682. return -1;
  7683. }
  7684. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7685. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7686. return -1;
  7687. }
  7688. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7689. if( !strcmpi(parent_cmd,"cash") )
  7690. {
  7691. if( value > 0 ) {
  7692. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7693. // If this option is set, the message is already sent by pc function
  7694. if( !battle_config.cashshop_show_points ){
  7695. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7696. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7697. }
  7698. }
  7699. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7700. } else {
  7701. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7702. value = -sd->cashPoints;
  7703. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7704. // If this option is set, the message is already sent by pc function
  7705. if( !battle_config.cashshop_show_points ){
  7706. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7707. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7708. }
  7709. }
  7710. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7711. }
  7712. }
  7713. else
  7714. { // @points
  7715. if( value > 0 ) {
  7716. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7717. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7718. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7719. }
  7720. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7721. } else {
  7722. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7723. value = -sd->kafraPoints;
  7724. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7725. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7726. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7727. }
  7728. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7729. }
  7730. }
  7731. return 0;
  7732. }
  7733. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7734. ACMD_FUNC(clone)
  7735. {
  7736. int x=0,y=0,flag=0,master=0,i=0;
  7737. map_session_data *pl_sd=nullptr;
  7738. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7739. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7740. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7741. return 0;
  7742. }
  7743. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
  7744. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7745. return 0;
  7746. }
  7747. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7748. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7749. return 0;
  7750. }
  7751. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7752. if (strcmpi(parent_cmd, "clone") == 0)
  7753. flag = 1;
  7754. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7755. flag = 2;
  7756. if(pc_isdead(sd)){
  7757. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7758. return 0;
  7759. }
  7760. master = sd->bl.id;
  7761. if (battle_config.atc_slave_clone_limit
  7762. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7763. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7764. return 0;
  7765. }
  7766. }
  7767. do {
  7768. x = sd->bl.x + rnd_value(-5, 5);
  7769. y = sd->bl.y + rnd_value(-5, 5);
  7770. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7771. if (i >= 10) {
  7772. x = sd->bl.x;
  7773. y = sd->bl.y;
  7774. }
  7775. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7776. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7777. return 0;
  7778. }
  7779. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7780. return 0;
  7781. }
  7782. /*=====================================
  7783. * Autorejecting Invites/Deals [LuzZza]
  7784. * Usage: @noask
  7785. *-------------------------------------*/
  7786. ACMD_FUNC(noask)
  7787. {
  7788. if(sd->state.noask) {
  7789. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7790. sd->state.noask = 0;
  7791. } else {
  7792. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7793. sd->state.noask = 1;
  7794. }
  7795. return 0;
  7796. }
  7797. /*=====================================
  7798. * Send a @request message to all GMs of lowest_gm_level.
  7799. * Usage: @request <petition>
  7800. *-------------------------------------*/
  7801. ACMD_FUNC(request)
  7802. {
  7803. if (!message || !*message) {
  7804. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7805. return -1;
  7806. }
  7807. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7808. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7809. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7810. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7811. return 0;
  7812. }
  7813. /*==========================================
  7814. * Feel (SG designated maps) Reset [HiddenDragon]
  7815. *------------------------------------------*/
  7816. ACMD_FUNC(feelreset)
  7817. {
  7818. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7819. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7820. return -1;
  7821. }
  7822. pc_resetfeel(sd);
  7823. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7824. return 0;
  7825. }
  7826. /*==========================================
  7827. * Hate (SG designated monsters) Reset
  7828. *------------------------------------------*/
  7829. ACMD_FUNC(hatereset)
  7830. {
  7831. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7832. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7833. return -1;
  7834. }
  7835. pc_resethate(sd);
  7836. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7837. return 0;
  7838. }
  7839. /*==========================================
  7840. * AUCTION SYSTEM
  7841. *------------------------------------------*/
  7842. ACMD_FUNC(auction)
  7843. {
  7844. nullpo_ret(sd);
  7845. if (!battle_config.feature_auction) {
  7846. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7847. return 0;
  7848. }
  7849. clif_Auction_openwindow(sd);
  7850. return 0;
  7851. }
  7852. /*==========================================
  7853. * Kill Steal Protection
  7854. *------------------------------------------*/
  7855. ACMD_FUNC(ksprotection)
  7856. {
  7857. nullpo_retr(-1,sd);
  7858. if( sd->state.noks ) {
  7859. sd->state.noks = 0;
  7860. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7861. }
  7862. else
  7863. {
  7864. if( !message || !*message || !strcmpi(message, "party") )
  7865. { // Default is Party
  7866. sd->state.noks = 2;
  7867. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7868. }
  7869. else if( !strcmpi(message, "self") )
  7870. {
  7871. sd->state.noks = 1;
  7872. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7873. }
  7874. else if( !strcmpi(message, "guild") )
  7875. {
  7876. sd->state.noks = 3;
  7877. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7878. }
  7879. else
  7880. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7881. }
  7882. return 0;
  7883. }
  7884. /*==========================================
  7885. * Map Kill Steal Protection Setting
  7886. *------------------------------------------*/
  7887. ACMD_FUNC(allowks)
  7888. {
  7889. nullpo_retr(-1,sd);
  7890. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7891. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7892. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7893. } else {
  7894. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7895. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7896. }
  7897. return 0;
  7898. }
  7899. ACMD_FUNC(resetstat)
  7900. {
  7901. nullpo_retr(-1, sd);
  7902. pc_resetstate(sd);
  7903. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7904. clif_displaymessage(fd, atcmd_output);
  7905. return 0;
  7906. }
  7907. ACMD_FUNC(resetskill)
  7908. {
  7909. nullpo_retr(-1,sd);
  7910. pc_resetskill(sd,1);
  7911. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7912. clif_displaymessage(fd, atcmd_output);
  7913. return 0;
  7914. }
  7915. /*==========================================
  7916. * #storagelist: Displays the items list of a player's storage.
  7917. * #cartlist: Displays contents of target's cart.
  7918. * #itemlist: Displays contents of target's inventory.
  7919. *------------------------------------------*/
  7920. ACMD_FUNC(itemlist)
  7921. {
  7922. int i, j, count, counter;
  7923. const char* location;
  7924. struct item* items;
  7925. int size;
  7926. StringBuf buf;
  7927. nullpo_retr(-1, sd);
  7928. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7929. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7930. location = "storage";
  7931. items = sd->storage.u.items_storage;
  7932. size = sd->storage.max_amount;
  7933. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7934. location = "cart";
  7935. items = sd->cart.u.items_cart;
  7936. size = MAX_CART;
  7937. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7938. location = "inventory";
  7939. items = sd->inventory.u.items_inventory;
  7940. size = MAX_INVENTORY;
  7941. } else
  7942. return 1;
  7943. StringBuf_Init(&buf);
  7944. count = 0; // total slots occupied
  7945. counter = 0; // total items found
  7946. for( i = 0; i < size; ++i ) {
  7947. struct item* it = &items[i];
  7948. if( it->nameid == 0 )
  7949. continue;
  7950. std::shared_ptr<item_data> itd = item_db.find(it->nameid);
  7951. if (itd == nullptr)
  7952. continue;
  7953. counter += it->amount;
  7954. count++;
  7955. if( count == 1 ) {
  7956. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7957. clif_displaymessage(fd, StringBuf_Value(&buf));
  7958. StringBuf_Clear(&buf);
  7959. }
  7960. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
  7961. if( it->equip ) {
  7962. char equipstr[CHAT_SIZE_MAX];
  7963. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7964. if( it->equip&EQP_GARMENT )
  7965. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7966. if( it->equip&EQP_ACC_L )
  7967. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7968. if( it->equip&EQP_ARMOR )
  7969. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7970. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7971. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7972. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7973. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7974. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7975. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7976. if( it->equip&EQP_SHOES )
  7977. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7978. if( it->equip&EQP_ACC_R )
  7979. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7980. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7981. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7982. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7983. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7984. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7985. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7986. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7987. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7988. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7989. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7990. if( (it->equip&EQP_HELM) == EQP_HELM )
  7991. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7992. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7993. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7994. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7995. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7996. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7997. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7998. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7999. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  8000. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  8001. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  8002. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  8003. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  8004. if( it->equip&EQP_COSTUME_GARMENT )
  8005. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  8006. //if( it->equip&EQP_COSTUME_FLOOR )
  8007. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  8008. if( it->equip&EQP_AMMO )
  8009. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  8010. if( it->equip&EQP_SHADOW_ARMOR )
  8011. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  8012. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  8013. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  8014. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  8015. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  8016. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  8017. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  8018. if( it->equip&EQP_SHADOW_SHOES )
  8019. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  8020. if( it->equip&EQP_SHADOW_ACC_R )
  8021. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  8022. if( it->equip&EQP_SHADOW_ACC_L )
  8023. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  8024. // remove final ', '
  8025. equipstr[strlen(equipstr) - 2] = '\0';
  8026. StringBuf_AppendStr(&buf, equipstr);
  8027. }
  8028. clif_displaymessage(fd, StringBuf_Value(&buf));
  8029. StringBuf_Clear(&buf);
  8030. if( it->card[0] == CARD0_PET ) { // pet egg
  8031. if (it->card[3]&1)
  8032. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  8033. else
  8034. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  8035. } else if(it->card[0] == CARD0_FORGE) { // forged item
  8036. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  8037. } else if(it->card[0] == CARD0_CREATE) { // created item
  8038. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8039. } else { // normal item
  8040. int counter2 = 0;
  8041. for( j = 0; j < itd->slots; ++j ) {
  8042. if( it->card[j] == 0 )
  8043. continue;
  8044. std::shared_ptr<item_data> card = item_db.find(it->card[j]);
  8045. if (card == nullptr)
  8046. continue;
  8047. counter2++;
  8048. if( counter2 == 1 )
  8049. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8050. if( counter2 != 1 )
  8051. StringBuf_AppendStr(&buf, ", ");
  8052. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
  8053. }
  8054. if( counter2 > 0 )
  8055. StringBuf_AppendStr(&buf, ")");
  8056. }
  8057. if( StringBuf_Length(&buf) > 0 )
  8058. clif_displaymessage(fd, StringBuf_Value(&buf));
  8059. StringBuf_Clear(&buf);
  8060. }
  8061. if( count == 0 )
  8062. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8063. else
  8064. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8065. clif_displaymessage(fd, StringBuf_Value(&buf));
  8066. StringBuf_Destroy(&buf);
  8067. return 0;
  8068. }
  8069. ACMD_FUNC(stats)
  8070. {
  8071. char job_jobname[100];
  8072. char output[CHAT_SIZE_MAX];
  8073. int i;
  8074. struct {
  8075. const char* format;
  8076. int value;
  8077. } output_table[] = {
  8078. { "Base Level - %d", 0 },
  8079. { nullptr, 0 },
  8080. { "Hp - %d", 0 },
  8081. { "MaxHp - %d", 0 },
  8082. { "Sp - %d", 0 },
  8083. { "MaxSp - %d", 0 },
  8084. { "Ap - %d", 0 },
  8085. { "MaxAp - %d", 0 },
  8086. { "Str - %3d", 0 },
  8087. { "Agi - %3d", 0 },
  8088. { "Vit - %3d", 0 },
  8089. { "Int - %3d", 0 },
  8090. { "Dex - %3d", 0 },
  8091. { "Luk - %3d", 0 },
  8092. { "Pow - %3d", 0 },
  8093. { "Sta - %3d", 0 },
  8094. { "Wis - %3d", 0 },
  8095. { "Spl - %3d", 0 },
  8096. { "Con - %3d", 0 },
  8097. { "Crt - %3d", 0 },
  8098. { "Zeny - %d", 0 },
  8099. { "Free Status Points - %d", 0 },
  8100. { "Free Trait Points - %d", 0 },
  8101. { "Free Skill Points - %d", 0 },
  8102. { "JobChangeLvl (2nd) - %d", 0 },
  8103. { "JobChangeLvl (3rd) - %d", 0 },
  8104. { "JobChangeLvl (4th) - %d", 0 },
  8105. { nullptr, 0 }
  8106. };
  8107. memset(job_jobname, '\0', sizeof(job_jobname));
  8108. memset(output, '\0', sizeof(output));
  8109. //direct array initialization with variables is not standard C compliant.
  8110. output_table[0].value = sd->status.base_level;
  8111. output_table[1].format = job_jobname;
  8112. output_table[1].value = sd->status.job_level;
  8113. output_table[2].value = sd->status.hp;
  8114. output_table[3].value = sd->status.max_hp;
  8115. output_table[4].value = sd->status.sp;
  8116. output_table[5].value = sd->status.max_sp;
  8117. output_table[6].value = sd->status.ap;
  8118. output_table[7].value = sd->status.max_ap;
  8119. output_table[8].value = sd->status.str;
  8120. output_table[9].value = sd->status.agi;
  8121. output_table[10].value = sd->status.vit;
  8122. output_table[11].value = sd->status.int_;
  8123. output_table[12].value = sd->status.dex;
  8124. output_table[13].value = sd->status.luk;
  8125. output_table[14].value = sd->status.pow;
  8126. output_table[15].value = sd->status.sta;
  8127. output_table[16].value = sd->status.wis;
  8128. output_table[17].value = sd->status.spl;
  8129. output_table[18].value = sd->status.con;
  8130. output_table[19].value = sd->status.crt;
  8131. output_table[20].value = sd->status.zeny;
  8132. output_table[21].value = sd->status.status_point;
  8133. output_table[22].value = sd->status.trait_point;
  8134. output_table[23].value = sd->status.skill_point;
  8135. output_table[24].value = sd->change_level_2nd;
  8136. output_table[25].value = sd->change_level_3rd;
  8137. output_table[26].value = sd->change_level_4th;
  8138. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8139. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8140. clif_displaymessage(fd, output);
  8141. for (i = 0; output_table[i].format != nullptr; i++) {
  8142. sprintf(output, output_table[i].format, output_table[i].value);
  8143. clif_displaymessage(fd, output);
  8144. }
  8145. return 0;
  8146. }
  8147. ACMD_FUNC(delitem)
  8148. {
  8149. char item_name[100];
  8150. int amount = 0, idx;
  8151. nullpo_retr(-1, sd);
  8152. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  8153. {
  8154. clif_displaymessage(fd, msg_txt(sd,1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>).
  8155. return -1;
  8156. }
  8157. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  8158. if( id == nullptr ){
  8159. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8160. }
  8161. if( id == nullptr ){
  8162. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8163. return -1;
  8164. }
  8165. t_itemid nameid = id->nameid;
  8166. int total = amount;
  8167. // delete items
  8168. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8169. {
  8170. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8171. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8172. {// delete pet
  8173. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8174. }
  8175. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8176. amount-= delamount;
  8177. }
  8178. // notify target
  8179. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8180. clif_displaymessage(sd->fd, atcmd_output);
  8181. // notify source
  8182. if( amount == total )
  8183. {
  8184. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8185. }
  8186. else if( amount )
  8187. {
  8188. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8189. clif_displaymessage(fd, atcmd_output);
  8190. }
  8191. else
  8192. {
  8193. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8194. clif_displaymessage(fd, atcmd_output);
  8195. }
  8196. return 0;
  8197. }
  8198. /*==========================================
  8199. * Custom Fonts
  8200. *------------------------------------------*/
  8201. ACMD_FUNC(font)
  8202. {
  8203. int font_id;
  8204. nullpo_retr(-1,sd);
  8205. font_id = atoi(message);
  8206. if( font_id == 0 ) {
  8207. if( sd->status.font ) {
  8208. sd->status.font = 0;
  8209. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8210. clif_font(sd);
  8211. } else {
  8212. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8213. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8214. }
  8215. } else if( font_id < 0 || font_id > 9 )
  8216. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8217. else if( font_id != sd->status.font ) {
  8218. sd->status.font = font_id;
  8219. clif_font(sd);
  8220. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8221. } else
  8222. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8223. return 0;
  8224. }
  8225. /*==========================================
  8226. * type: 1 = commands (@), 2 = charcommands (#)
  8227. *------------------------------------------*/
  8228. static void atcommand_commands_sub(map_session_data* sd, const int fd, AtCommandType type)
  8229. {
  8230. char line_buff[CHATBOX_SIZE];
  8231. char* cur = line_buff;
  8232. AtCommandInfo* cmd;
  8233. DBIterator *iter = db_iterator(atcommand_db);
  8234. int count = 0;
  8235. memset(line_buff,' ',CHATBOX_SIZE);
  8236. line_buff[CHATBOX_SIZE-1] = 0;
  8237. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8238. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8239. switch( type ) {
  8240. case COMMAND_CHARCOMMAND:
  8241. if( cmd->char_groups[sd->group->index] == 0 )
  8242. continue;
  8243. break;
  8244. case COMMAND_ATCOMMAND:
  8245. if( cmd->at_groups[sd->group->index] == 0 )
  8246. continue;
  8247. break;
  8248. default:
  8249. continue;
  8250. }
  8251. size_t slen = strlen( cmd->command );
  8252. // flush the text buffer if this command won't fit into it
  8253. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8254. clif_displaymessage(fd,line_buff);
  8255. cur = line_buff;
  8256. memset(line_buff,' ',CHATBOX_SIZE);
  8257. line_buff[CHATBOX_SIZE-1] = 0;
  8258. }
  8259. memcpy(cur,cmd->command,slen);
  8260. cur += slen+(10-slen%10);
  8261. count++;
  8262. }
  8263. dbi_destroy(iter);
  8264. clif_displaymessage(fd,line_buff);
  8265. if ( atcmd_binding_count ) {
  8266. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  8267. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8268. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8269. size_t slen = strlen( atcmd_binding[i]->command );
  8270. if ( count_bind == 0 ) {
  8271. cur = line_buff;
  8272. memset(line_buff,' ',CHATBOX_SIZE);
  8273. line_buff[CHATBOX_SIZE-1] = 0;
  8274. clif_displaymessage(fd, "-----------------");
  8275. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8276. }
  8277. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8278. clif_displaymessage(fd,line_buff);
  8279. cur = line_buff;
  8280. memset(line_buff,' ',CHATBOX_SIZE);
  8281. line_buff[CHATBOX_SIZE-1] = 0;
  8282. }
  8283. memcpy(cur,atcmd_binding[i]->command,slen);
  8284. cur += slen+(10-slen%10);
  8285. count_bind++;
  8286. }
  8287. }
  8288. if ( count_bind )
  8289. clif_displaymessage(fd,line_buff);// last one
  8290. count += count_bind;
  8291. }
  8292. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8293. clif_displaymessage(fd, atcmd_output);
  8294. return;
  8295. }
  8296. /*==========================================
  8297. * @commands Lists available @ commands to you
  8298. *------------------------------------------*/
  8299. ACMD_FUNC(commands)
  8300. {
  8301. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8302. return 0;
  8303. }
  8304. /*==========================================
  8305. * @charcommands Lists available # commands to you
  8306. *------------------------------------------*/
  8307. ACMD_FUNC(charcommands) {
  8308. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8309. return 0;
  8310. }
  8311. /* for new mounts */
  8312. ACMD_FUNC(mount2) {
  8313. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8314. if (!sd->sc.getSCE(SC_ALL_RIDING)) {
  8315. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8316. sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8317. } else {
  8318. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8319. status_change_end(&sd->bl, SC_ALL_RIDING);
  8320. }
  8321. return 0;
  8322. }
  8323. ACMD_FUNC(accinfo) {
  8324. char query[NAME_LENGTH];
  8325. char type = 0; // type = 1, get only account name
  8326. if (!message || !*message || strlen(message) > NAME_LENGTH
  8327. || ( sscanf(message, "%23s %c", query, &type) < 1))
  8328. {
  8329. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8330. clif_displaymessage(fd, msg_txt(sd,1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
  8331. return -1;
  8332. } else if (type != 0) {
  8333. type = type-'0'; //make it int
  8334. if (type != 1) {
  8335. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  8336. return -1;
  8337. }
  8338. }
  8339. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  8340. return 0;
  8341. }
  8342. /**
  8343. * @set <variable name{[index]}>{ <value>}
  8344. *
  8345. * Gets or sets a value of a non server variable.
  8346. * If a value is specified it is used to set the variable's value,
  8347. * if not the variable's value is read.
  8348. * In any case it reads and displays the variable's value.
  8349. *
  8350. * Original implementation by Ind
  8351. */
  8352. ACMD_FUNC(set) {
  8353. char reg[46], val[128], name[32];
  8354. int toset = 0;
  8355. size_t len;
  8356. uint32 index;
  8357. bool is_str = false;
  8358. int64 uid;
  8359. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8360. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8361. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8362. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8363. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8364. return -1;
  8365. }
  8366. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8367. if( reg[0] == '.' ) {
  8368. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8369. return -1;
  8370. } else if( reg[0] == '\'' ) {
  8371. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8372. return -1;
  8373. }
  8374. // Check if the user wanted to set an array
  8375. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8376. // The user did not specify array brackets, so we set the index to zero
  8377. index = 0;
  8378. }
  8379. is_str = is_string_variable(name);
  8380. if( ( len = strlen(val) ) > 1 ) {
  8381. if( val[0] == '"' && val[len-1] == '"') {
  8382. val[len-1] = '\0'; //Strip quotes.
  8383. memmove(val, val+1, len-1);
  8384. }
  8385. }
  8386. // Only set the variable if there is a value for it
  8387. if( toset >= 2 ){
  8388. if( is_str ){
  8389. setd_sub_str( nullptr, sd, name, index, val, nullptr );
  8390. }else{
  8391. setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
  8392. }
  8393. }
  8394. uid = reference_uid( add_str( name ), index );
  8395. if( is_str ) {// string variable
  8396. char* value;
  8397. switch( reg[0] ) {
  8398. case '@':
  8399. value = pc_readregstr(sd, uid);
  8400. break;
  8401. case '$':
  8402. value = mapreg_readregstr(uid);
  8403. break;
  8404. case '#':
  8405. if( reg[1] == '#' )
  8406. value = pc_readaccountreg2str(sd, uid);// global
  8407. else
  8408. value = pc_readaccountregstr(sd, uid);// local
  8409. break;
  8410. default:
  8411. value = pc_readglobalreg_str(sd, uid);
  8412. break;
  8413. }
  8414. if( value == nullptr || *value == '\0' ){// empty string
  8415. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8416. }else{
  8417. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8418. }
  8419. } else {// integer variable
  8420. int64 value;
  8421. switch( reg[0] ) {
  8422. case '@':
  8423. value = pc_readreg(sd, uid);
  8424. break;
  8425. case '$':
  8426. value = mapreg_readreg(uid);
  8427. break;
  8428. case '#':
  8429. if( reg[1] == '#' )
  8430. value = pc_readaccountreg2(sd, uid);// global
  8431. else
  8432. value = pc_readaccountreg(sd, uid);// local
  8433. break;
  8434. default:
  8435. value = pc_readglobalreg(sd, uid);
  8436. break;
  8437. }
  8438. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8439. }
  8440. clif_displaymessage(fd, atcmd_output);
  8441. return 0;
  8442. }
  8443. ACMD_FUNC(addperm) {
  8444. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  8445. bool add;
  8446. int i;
  8447. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8448. add = (strcmpi(parent_cmd, "addperm") == 0);
  8449. if( !message || !*message ) {
  8450. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8451. clif_displaymessage(fd, atcmd_output);
  8452. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8453. for( i = 0; i < perm_size; i++ ) {
  8454. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8455. clif_displaymessage(fd, atcmd_output);
  8456. }
  8457. return -1;
  8458. }
  8459. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8460. if( i == perm_size ) {
  8461. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8462. clif_displaymessage(fd, atcmd_output);
  8463. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8464. for( i = 0; i < perm_size; i++ ) {
  8465. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8466. clif_displaymessage(fd, atcmd_output);
  8467. }
  8468. return -1;
  8469. }
  8470. if( add && pc_has_permission( sd, pc_g_permission_name[i].permission) ){
  8471. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8472. clif_displaymessage(fd, atcmd_output);
  8473. return -1;
  8474. }else if( !add && !pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8475. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8476. clif_displaymessage(fd, atcmd_output);
  8477. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8478. clif_displaymessage(fd, atcmd_output);
  8479. for( i = 0; i < perm_size; i++ ) {
  8480. if( pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8481. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8482. clif_displaymessage(fd, atcmd_output);
  8483. }
  8484. }
  8485. return -1;
  8486. }
  8487. if( add ){
  8488. sd->permissions.set( pc_g_permission_name[i].permission );
  8489. }else{
  8490. sd->permissions.reset( pc_g_permission_name[i].permission );
  8491. }
  8492. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8493. clif_displaymessage(fd, atcmd_output);
  8494. return 0;
  8495. }
  8496. ACMD_FUNC(unloadnpcfile) {
  8497. if( !message || !*message ) {
  8498. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8499. return -1;
  8500. }
  8501. if( npc_unloadfile(message) )
  8502. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8503. else {
  8504. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8505. return -1;
  8506. }
  8507. return 0;
  8508. }
  8509. ACMD_FUNC(cart) {
  8510. #define MC_CART_MDFY(idx, x) \
  8511. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8512. sd->status.skill[(idx)].lv = (x)?1:0; \
  8513. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8514. int val = atoi(message);
  8515. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8516. uint16 sk_idx = 0;
  8517. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8518. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8519. clif_displaymessage(fd, atcmd_output);
  8520. return -1;
  8521. }
  8522. if( val == 0 && !pc_iscarton(sd) ) {
  8523. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8524. return -1;
  8525. }
  8526. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8527. return -1;
  8528. if( need_skill ) {
  8529. MC_CART_MDFY(sk_idx,1);
  8530. }
  8531. if( !pc_setcart(sd, val) ) {
  8532. if( need_skill ) {
  8533. MC_CART_MDFY(sk_idx,0);
  8534. }
  8535. return -1;/* @cart failed */
  8536. }
  8537. if( need_skill ) {
  8538. MC_CART_MDFY(sk_idx,0);
  8539. }
  8540. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8541. return 0;
  8542. #undef MC_CART_MDFY
  8543. }
  8544. /* Channel System [Ind] */
  8545. ACMD_FUNC(join){
  8546. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8547. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8548. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8549. clif_displaymessage(fd, atcmd_output);
  8550. return -1;
  8551. }
  8552. return channel_pcjoin(sd, chname, pass);
  8553. }
  8554. /*
  8555. * Display available option for @channel command
  8556. * @command : the name of used command (for alias case)
  8557. */
  8558. static inline void atcmd_channel_help(map_session_data *sd, const char *command)
  8559. {
  8560. int fd = sd->fd;
  8561. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8562. bool can_create = (can_delete || channel_config.private_channel.allow);
  8563. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8564. //option create
  8565. if( can_create ) {
  8566. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8567. clif_displaymessage(fd, atcmd_output);
  8568. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8569. }
  8570. //option delete
  8571. if(can_delete){
  8572. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8573. clif_displaymessage(fd, atcmd_output);
  8574. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8575. }
  8576. //option list
  8577. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8578. clif_displaymessage(fd, atcmd_output);
  8579. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8580. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8581. clif_displaymessage(fd, atcmd_output);
  8582. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8583. if( can_create ) {
  8584. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8585. clif_displaymessage(fd, atcmd_output);
  8586. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8587. }
  8588. //option setcolor
  8589. if(can_create){
  8590. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8591. clif_displaymessage(fd, atcmd_output);
  8592. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8593. }
  8594. //option join
  8595. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8596. clif_displaymessage(fd, atcmd_output);
  8597. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8598. //option leave
  8599. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8600. clif_displaymessage(fd, atcmd_output);
  8601. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8602. //option bindto
  8603. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8604. clif_displaymessage(fd, atcmd_output);
  8605. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8606. //option unbind
  8607. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8608. clif_displaymessage(fd, atcmd_output);
  8609. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8610. //option ban/unban/banlist
  8611. if( can_create ) {
  8612. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8613. clif_displaymessage(fd, atcmd_output);
  8614. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8615. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8616. clif_displaymessage(fd, atcmd_output);
  8617. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8618. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8619. clif_displaymessage(fd, atcmd_output);
  8620. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8621. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8622. clif_displaymessage(fd, atcmd_output);
  8623. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8624. }
  8625. //option setopt
  8626. if(can_create){
  8627. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8628. clif_displaymessage(fd, atcmd_output);
  8629. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8630. }
  8631. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8632. clif_displaymessage(fd, atcmd_output);
  8633. }
  8634. ACMD_FUNC(channel) {
  8635. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8636. sub1[0] = sub2[0] = '\0';
  8637. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8638. atcmd_channel_help(sd,command);
  8639. return 0;
  8640. }
  8641. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8642. return channel_pcdelete(sd,sub1);
  8643. } else if ( strcmpi(key,"list") == 0 ) {
  8644. return channel_display_list(sd,sub1);
  8645. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8646. return channel_pccolor(sd, sub1, sub2);
  8647. } else if ( strcmpi(key,"join") == 0 ) {
  8648. return channel_pcjoin(sd, sub1, sub2);
  8649. }else if ( strcmpi(key,"leave") == 0 ) {
  8650. return channel_pcleave(sd, sub1);
  8651. } else if ( strcmpi(key,"bindto") == 0 ) {
  8652. return channel_pcbind(sd, sub1);
  8653. } else if ( strcmpi(key,"unbind") == 0 ) {
  8654. return channel_pcunbind(sd);
  8655. } else if ( strcmpi(key,"ban") == 0 ) {
  8656. return channel_pcban(sd,sub1,sub2,0);
  8657. } else if ( strcmpi(key,"kick") == 0 ) {
  8658. return channel_pckick(sd,sub1,sub2);
  8659. } else if ( strcmpi(key,"banlist") == 0 ) {
  8660. return channel_pcban(sd,sub1,nullptr,3);
  8661. } else if ( strcmpi(key,"unban") == 0 ) {
  8662. return channel_pcban(sd,sub1,sub2,1);
  8663. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8664. return channel_pcban(sd,sub1,nullptr,2);
  8665. } else {
  8666. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8667. sub3[0] = sub4[0] = '\0';
  8668. sscanf(sub2, "%19s %19s", sub3, sub4);
  8669. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8670. if (sub4[0] != '\0') {
  8671. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8672. return -1;
  8673. }
  8674. return channel_pccreate(sd,sub1,sub3);
  8675. } else if ( strcmpi(key,"setopt") == 0 ) {
  8676. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8677. }
  8678. atcmd_channel_help(sd,command);
  8679. }
  8680. return 0;
  8681. }
  8682. ACMD_FUNC(fontcolor)
  8683. {
  8684. if( !message || !*message ) {
  8685. channel_display_list(sd,"colors");
  8686. return -1;
  8687. }
  8688. if( strcmpi(message,"Normal") == 0 ) {
  8689. sd->fontcolor = 0;
  8690. } else {
  8691. unsigned char k;
  8692. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8693. if( k == channel_config.colors_count ) {
  8694. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8695. clif_displaymessage(fd, atcmd_output);
  8696. return -1;
  8697. }
  8698. sd->fontcolor = k;
  8699. }
  8700. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8701. clif_displaymessage(fd, atcmd_output);
  8702. return 0;
  8703. }
  8704. ACMD_FUNC(langtype)
  8705. {
  8706. char langstr[8];
  8707. int i=0, fail=0;
  8708. memset(langstr, '\0', sizeof(langstr));
  8709. if(sscanf(message, "%3s", langstr) >= 1){
  8710. int lang=0;
  8711. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8712. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8713. char output[100];
  8714. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8715. sd->langtype = lang;
  8716. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8717. clif_displaymessage(fd,output);
  8718. return 0;
  8719. } else if (lang != -1) { //defined langage but failed check
  8720. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8721. return -1;
  8722. }
  8723. }
  8724. //wrong or no entry
  8725. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8726. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8727. while(fail != -1){ //out of range
  8728. fail = msg_checklangtype(i,false);
  8729. if(fail == 1)
  8730. clif_displaymessage(fd,msg_langtype2langstr(i));
  8731. i++;
  8732. }
  8733. return -1;
  8734. }
  8735. #ifdef VIP_ENABLE
  8736. ACMD_FUNC(vip) {
  8737. map_session_data* pl_sd = nullptr;;
  8738. char * modif_p;
  8739. int32 vipdifftime = 0;
  8740. time_t now=time(nullptr);
  8741. nullpo_retr(-1, sd);
  8742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8743. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8744. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8745. return -1;
  8746. }
  8747. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8748. modif_p = atcmd_output;
  8749. vipdifftime = (int32)solve_time(modif_p);
  8750. if (vipdifftime == 0) {
  8751. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8752. clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
  8753. return -1;
  8754. }
  8755. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  8756. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8757. return -1;
  8758. }
  8759. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8760. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8761. return -1;
  8762. }
  8763. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8764. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8765. if (pl_sd->vip.time <= now) {
  8766. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8767. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8768. } else {
  8769. int year,month,day,hour,minute,second;
  8770. char timestr[21];
  8771. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8772. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute); // Your VIP status is valid for %d years, %d months, %d days, %d hours and %d minutes.
  8773. clif_displaymessage(pl_sd->fd,atcmd_output);
  8774. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8775. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8776. clif_displaymessage(pl_sd->fd,atcmd_output);
  8777. if (pl_sd != sd) {
  8778. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours and %d minutes.
  8779. clif_displaymessage(fd,atcmd_output);
  8780. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8781. clif_displaymessage(fd,atcmd_output);
  8782. }
  8783. }
  8784. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8785. return 0;
  8786. }
  8787. /** Enable/disable rate info */
  8788. ACMD_FUNC(showrate) {
  8789. nullpo_retr(-1,sd);
  8790. if (!sd->vip.disableshowrate) {
  8791. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8792. sd->vip.disableshowrate = 1;
  8793. } else {
  8794. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8795. sd->vip.disableshowrate = 0;
  8796. }
  8797. clif_displaymessage(fd,atcmd_output);
  8798. return 0;
  8799. }
  8800. #endif
  8801. ACMD_FUNC(fullstrip) {
  8802. int i;
  8803. TBL_PC *tsd;
  8804. nullpo_retr(-1,sd);
  8805. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8806. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8807. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8808. return -1;
  8809. }
  8810. if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
  8811. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8812. return -1;
  8813. }
  8814. for( i = 0; i < EQI_MAX; i++ ) {
  8815. if( tsd->equip_index[ i ] >= 0 )
  8816. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8817. }
  8818. return 0;
  8819. }
  8820. ACMD_FUNC(changedress){
  8821. sc_type name2id[] = {
  8822. SC_WEDDING,
  8823. SC_XMAS,
  8824. SC_SUMMER,
  8825. SC_DRESSUP,
  8826. SC_HANBOK,
  8827. SC_OKTOBERFEST
  8828. };
  8829. for( sc_type type : name2id ) {
  8830. if( sd->sc.getSCE(type) ) {
  8831. status_change_end( &sd->bl, type );
  8832. // You should only be able to have one - so we cancel here
  8833. break;
  8834. }
  8835. }
  8836. return 0;
  8837. }
  8838. ACMD_FUNC(costume) {
  8839. const char* names[] = {
  8840. "Wedding",
  8841. "Xmas",
  8842. "Summer",
  8843. "Summer2",
  8844. "Hanbok",
  8845. "Oktoberfest"
  8846. };
  8847. const int name2id[] = {
  8848. SC_WEDDING,
  8849. SC_XMAS,
  8850. SC_SUMMER,
  8851. SC_DRESSUP,
  8852. SC_HANBOK,
  8853. SC_OKTOBERFEST
  8854. };
  8855. unsigned short k = 0, len = ARRAYLENGTH(names);
  8856. if( !message || !*message ) {
  8857. for( k = 0; k < len; k++ ) {
  8858. if( sd->sc.getSCE(name2id[k]) ) {
  8859. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8860. clif_displaymessage(sd->fd, atcmd_output);
  8861. status_change_end(&sd->bl, (sc_type)name2id[k]);
  8862. return 0;
  8863. }
  8864. }
  8865. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8866. for( k = 0; k < len; k++ ) {
  8867. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8868. clif_displaymessage(sd->fd, atcmd_output);
  8869. }
  8870. return -1;
  8871. }
  8872. for( k = 0; k < len; k++ ) {
  8873. if( sd->sc.getSCE(name2id[k]) ) {
  8874. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8875. clif_displaymessage(sd->fd, atcmd_output);
  8876. return -1;
  8877. }
  8878. }
  8879. for( k = 0; k < len; k++ )
  8880. if( strcmpi(message, names[k]) == 0 )
  8881. break;
  8882. if( k == len ) {
  8883. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8884. clif_displaymessage(sd->fd, atcmd_output);
  8885. return -1;
  8886. }
  8887. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8888. return 0;
  8889. }
  8890. /**
  8891. * Clone other player's equipments
  8892. * Usage: @cloneequip <char name/ID>
  8893. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8894. * @author [Cydh], [Antares]
  8895. */
  8896. ACMD_FUNC(cloneequip) {
  8897. map_session_data *pl_sd;
  8898. nullpo_retr(-1, sd);
  8899. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8900. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8901. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8902. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8903. clif_displaymessage(fd, atcmd_output);
  8904. return -1;
  8905. }
  8906. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8907. clif_displaymessage(fd, msg_txt(sd, 3));
  8908. return -1;
  8909. }
  8910. if (sd == pl_sd) {
  8911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8912. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8913. clif_displaymessage(fd, atcmd_output);
  8914. return -1;
  8915. }
  8916. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8917. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8918. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8919. clif_displaymessage(fd, atcmd_output);
  8920. return -1;
  8921. }
  8922. else {
  8923. int8 i;
  8924. for (i = 0; i < EQI_MAX; i++) {
  8925. short idx;
  8926. char flag = 0;
  8927. struct item tmp_item;
  8928. if ((idx = pl_sd->equip_index[i]) < 0)
  8929. continue;
  8930. if (i == EQI_AMMO)
  8931. continue;
  8932. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8933. continue;
  8934. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8935. if (itemdb_isspecial(tmp_item.card[0]))
  8936. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8937. tmp_item.bound = 0;
  8938. tmp_item.expire_time = 0;
  8939. tmp_item.unique_id = 0;
  8940. tmp_item.favorite = 0;
  8941. tmp_item.amount = 1;
  8942. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8943. clif_additem(sd, 0, 0, flag);
  8944. else
  8945. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8946. }
  8947. }
  8948. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8949. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8950. clif_displaymessage(fd, atcmd_output);
  8951. return 0;
  8952. }
  8953. /**
  8954. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8955. * Usage: @clonestat <char name/ID>
  8956. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8957. * @author [Cydh], [Antares]
  8958. */
  8959. ACMD_FUNC(clonestat) {
  8960. map_session_data *pl_sd;
  8961. nullpo_retr(-1, sd);
  8962. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8963. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8964. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8965. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8966. clif_displaymessage(fd, atcmd_output);
  8967. return -1;
  8968. }
  8969. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8970. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8971. return -1;
  8972. }
  8973. if (sd == pl_sd) {
  8974. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8975. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8976. clif_displaymessage(fd, atcmd_output);
  8977. return -1;
  8978. }
  8979. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8980. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8981. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8982. clif_displaymessage(fd, atcmd_output);
  8983. return -1;
  8984. }
  8985. else {
  8986. uint8 i;
  8987. short max_status[PARAM_MAX] = {};
  8988. pc_resetstate(sd);
  8989. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  8990. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8991. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  8992. continue;
  8993. max_status[i] = SHRT_MAX;
  8994. }
  8995. } else {
  8996. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  8997. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  8998. continue;
  8999. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  9000. }
  9001. }
  9002. #define clonestat_check(cmd,stat)\
  9003. {\
  9004. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  9005. if (pl_sd->status.cmd > max_status[(stat)]) {\
  9006. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  9007. clif_displaymessage(fd, atcmd_output);\
  9008. sd->status.cmd = max_status[(stat)];\
  9009. }\
  9010. else\
  9011. sd->status.cmd = pl_sd->status.cmd;\
  9012. }
  9013. clonestat_check(str, PARAM_STR);
  9014. clonestat_check(agi, PARAM_AGI);
  9015. clonestat_check(vit, PARAM_VIT);
  9016. clonestat_check(int_, PARAM_INT);
  9017. clonestat_check(dex, PARAM_DEX);
  9018. clonestat_check(luk, PARAM_LUK);
  9019. for (i = PARAM_STR; i < PARAM_POW; i++) {
  9020. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  9021. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  9022. }
  9023. if (sd->class_ & JOBL_FOURTH) {
  9024. clonestat_check(pow, PARAM_POW);
  9025. clonestat_check(sta, PARAM_STA);
  9026. clonestat_check(wis, PARAM_WIS);
  9027. clonestat_check(spl, PARAM_SPL);
  9028. clonestat_check(con, PARAM_CON);
  9029. clonestat_check(crt, PARAM_CRT);
  9030. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  9031. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  9032. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  9033. }
  9034. }
  9035. status_calc_pc(sd, SCO_FORCE);
  9036. }
  9037. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9038. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  9039. clif_displaymessage(fd, atcmd_output);
  9040. #undef clonestat_check
  9041. return 0;
  9042. }
  9043. /**
  9044. * Adopt a character.
  9045. * Usage: @adopt <char name>
  9046. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  9047. */
  9048. ACMD_FUNC(adopt)
  9049. {
  9050. TBL_PC *b_sd;
  9051. enum adopt_responses response;
  9052. nullpo_retr(-1, sd);
  9053. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9054. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9055. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9056. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  9057. clif_displaymessage(fd, atcmd_output);
  9058. return -1;
  9059. }
  9060. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  9061. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9062. return -1;
  9063. }
  9064. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  9065. if (response == ADOPT_ALLOWED) {
  9066. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  9067. b_sd->adopt_invite = sd->status.account_id;
  9068. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  9069. return 0;
  9070. }
  9071. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  9072. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  9073. return -1;
  9074. }
  9075. /**
  9076. * Opens the limited sale window.
  9077. * Usage: @limitedsale or client command /limitedsale on supported clients
  9078. */
  9079. ACMD_FUNC(limitedsale){
  9080. nullpo_retr(-1, sd);
  9081. clif_sale_open(sd);
  9082. return 0;
  9083. }
  9084. /**
  9085. * Displays camera information from the client.
  9086. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  9087. */
  9088. ACMD_FUNC(camerainfo){
  9089. nullpo_retr(-1, sd);
  9090. if( message == nullptr || message[0] == '\0' ){
  9091. clif_camerainfo( sd, true );
  9092. return 0;
  9093. }
  9094. float range = 0;
  9095. float rotation = 0;
  9096. float latitude = 0;
  9097. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  9098. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  9099. return -1;
  9100. }
  9101. clif_camerainfo( sd, false, range, rotation, latitude );
  9102. return 0;
  9103. }
  9104. ACMD_FUNC(resurrect) {
  9105. nullpo_retr(-1, sd);
  9106. if (!pc_revive_item(sd))
  9107. return -1;
  9108. return 0;
  9109. }
  9110. ACMD_FUNC(quest) {
  9111. uint8 i;
  9112. int quest_id = 0;
  9113. nullpo_retr(-1, sd);
  9114. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9115. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9116. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9117. clif_displaymessage(fd, atcmd_output);
  9118. return -1;
  9119. }
  9120. if (!quest_search(quest_id)) {
  9121. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9122. clif_displaymessage(fd, atcmd_output);
  9123. return -1;
  9124. }
  9125. const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
  9126. ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
  9127. switch(i) {
  9128. case 0:
  9129. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  9130. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  9131. clif_displaymessage(fd, atcmd_output);
  9132. return -1;
  9133. }
  9134. quest_add(sd, quest_id);
  9135. pc_show_questinfo(sd);
  9136. break;
  9137. case 1:
  9138. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  9139. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  9140. clif_displaymessage(fd, atcmd_output);
  9141. return -1;
  9142. }
  9143. quest_delete(sd, quest_id);
  9144. pc_show_questinfo(sd);
  9145. break;
  9146. case 2:
  9147. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  9148. quest_add(sd, quest_id);
  9149. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  9150. quest_update_status(sd, quest_id, Q_COMPLETE);
  9151. pc_show_questinfo(sd);
  9152. break;
  9153. case 3:
  9154. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  9155. clif_displaymessage(fd, atcmd_output);
  9156. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  9157. clif_displaymessage(fd, atcmd_output);
  9158. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  9159. clif_displaymessage(fd, atcmd_output);
  9160. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9161. clif_displaymessage(fd, atcmd_output);
  9162. break;
  9163. }
  9164. return 0;
  9165. }
  9166. /**
  9167. * Opens the refineUI
  9168. * Usage: @refineui
  9169. */
  9170. ACMD_FUNC(refineui)
  9171. {
  9172. nullpo_retr(-1, sd);
  9173. #if PACKETVER < 20161012
  9174. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9175. return -1;
  9176. #else
  9177. if( !battle_config.feature_refineui ){
  9178. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9179. return -1;
  9180. }
  9181. if( sd->state.refineui_open ){
  9182. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9183. return -1;
  9184. }
  9185. clif_refineui_open(sd);
  9186. return 0;
  9187. #endif
  9188. }
  9189. ACMD_FUNC( stylist ){
  9190. nullpo_retr(-1, sd);
  9191. #if PACKETVER < 20151104
  9192. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9193. return -1;
  9194. #else
  9195. if( !battle_config.feature_stylist ){
  9196. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  9197. return -1;
  9198. }
  9199. if( sd->state.stylist_open ){
  9200. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9201. return -1;
  9202. }
  9203. clif_ui_open( *sd, OUT_UI_STYLIST, 0 );
  9204. return 0;
  9205. #endif
  9206. }
  9207. /**
  9208. * Add fame point(s) to a player
  9209. * Usage: @addfame <amount>
  9210. */
  9211. ACMD_FUNC(addfame)
  9212. {
  9213. nullpo_retr(-1, sd);
  9214. int famepoint = 0;
  9215. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9216. if (!message || !*message || sscanf(message, "%11d", &famepoint) < 1 || famepoint == 0) {
  9217. sprintf(atcmd_output, msg_txt(sd, 1516), command); // Usage: %s <fame points>.
  9218. clif_displaymessage(fd, atcmd_output);
  9219. return -1;
  9220. }
  9221. if (!pc_addfame(*sd, famepoint)) {
  9222. sprintf(atcmd_output, msg_txt(sd, 1517), job_name(sd->status.class_)); // Cannot add fame to class '%s'.
  9223. clif_displaymessage(fd, atcmd_output);
  9224. return -1;
  9225. }
  9226. sprintf(atcmd_output, msg_txt(sd, 1518), famepoint, sd->status.name); // %d points were added to '%s'.
  9227. clif_displaymessage(fd, atcmd_output);
  9228. return 0;
  9229. }
  9230. /**
  9231. * Opens the enchantgrade UI
  9232. * Usage: @enchantgradeui
  9233. */
  9234. ACMD_FUNC( enchantgradeui ){
  9235. nullpo_retr( -1, sd );
  9236. #if !( PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200724 )
  9237. sprintf( atcmd_output, msg_txt( sd, 798 ), "2020-07-24" ); // This command requires packet version %s or newer.
  9238. clif_displaymessage( fd, atcmd_output );
  9239. return -1;
  9240. #else
  9241. clif_ui_open( *sd, OUT_UI_ENCHANTGRADE, 0 );
  9242. return 0;
  9243. #endif
  9244. }
  9245. ACMD_FUNC( roulette ){
  9246. nullpo_retr( -1, sd );
  9247. #if PACKETVER < 20141022
  9248. sprintf( atcmd_output, msg_txt( sd, 798 ), "2014-10-22" ); // This command requires packet version %s or newer.
  9249. clif_displaymessage( fd, atcmd_output );
  9250. return -1;
  9251. #else
  9252. if( !battle_config.feature_roulette ){
  9253. clif_displaymessage( fd, msg_txt( sd, 1497 ) ); // Roulette is disabled
  9254. return -1;
  9255. }
  9256. clif_roulette_open( sd );
  9257. return 0;
  9258. #endif
  9259. }
  9260. /**
  9261. * Replaces a card ID in an equip
  9262. * Usage: @setcard <equip position> <slot> <card_id>
  9263. */
  9264. ACMD_FUNC(setcard)
  9265. {
  9266. nullpo_retr(-1, sd);
  9267. int position = 0, slot, card_id;
  9268. if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
  9269. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9270. clif_displaymessage(fd, msg_txt(sd,1527)); // Please enter the position, the slot number and the card ID (usage: @setcard <equip position> <slot> <card_id>).
  9271. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  9272. clif_displaymessage(fd, atcmd_output);
  9273. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  9274. clif_displaymessage(fd, atcmd_output);
  9275. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  9276. clif_displaymessage(fd, atcmd_output);
  9277. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  9278. clif_displaymessage(fd, atcmd_output);
  9279. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  9280. clif_displaymessage(fd, atcmd_output);
  9281. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  9282. clif_displaymessage(fd, atcmd_output);
  9283. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  9284. clif_displaymessage(fd, atcmd_output);
  9285. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  9286. clif_displaymessage(fd, atcmd_output);
  9287. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  9288. clif_displaymessage(fd, atcmd_output);
  9289. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  9290. return -1;
  9291. }
  9292. if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
  9293. clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
  9294. return -1;
  9295. }
  9296. if (slot < 0 || slot >= MAX_SLOTS) {
  9297. clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
  9298. return -1;
  9299. }
  9300. if (card_id != 0) {
  9301. std::shared_ptr<item_data> item_data = item_db.find( card_id );
  9302. if (item_data == nullptr) {
  9303. clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
  9304. return -1;
  9305. }
  9306. if (item_data->type != IT_CARD) {
  9307. clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
  9308. return -1;
  9309. }
  9310. }
  9311. int16 i = pc_checkequip(sd, position);
  9312. if (i < 0) {
  9313. clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
  9314. return -1;
  9315. }
  9316. int current_position = sd->inventory.u.items_inventory[i].equip;
  9317. pc_unequipitem(sd, i, 3);
  9318. log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
  9319. sd->inventory.u.items_inventory[i].card[slot] = card_id;
  9320. log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
  9321. clif_delitem( *sd, i, 1, 0 );
  9322. clif_additem(sd, i, 1, 0);
  9323. pc_equipitem(sd, i, current_position);
  9324. return 0;
  9325. }
  9326. #include <custom/atcommand.inc>
  9327. /**
  9328. * Fills the reference of available commands in atcommand DBMap
  9329. **/
  9330. #define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, 0 }
  9331. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, 0 }
  9332. // Define with restriction
  9333. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
  9334. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
  9335. void atcommand_basecommands(void) {
  9336. /**
  9337. * Command reference list, place the base of your commands here
  9338. * TODO: List all commands that causing crash
  9339. **/
  9340. AtCommandInfo atcommand_base[] = {
  9341. #include <custom/atcommand_def.inc>
  9342. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  9343. ACMD_DEF(where),
  9344. ACMD_DEF(jumpto),
  9345. ACMD_DEF(jump),
  9346. ACMD_DEF(who),
  9347. ACMD_DEF2("who2", who),
  9348. ACMD_DEF2("who3", who),
  9349. ACMD_DEF2("whomap", who),
  9350. ACMD_DEF2("whomap2", who),
  9351. ACMD_DEF2("whomap3", who),
  9352. ACMD_DEF(whogm),
  9353. ACMD_DEF(save),
  9354. ACMD_DEF(load),
  9355. ACMD_DEF(speed),
  9356. ACMD_DEF(storage),
  9357. ACMD_DEF(guildstorage),
  9358. ACMD_DEF(option),
  9359. ACMD_DEF(hide), // + /hide
  9360. ACMD_DEF(resetcooltime), // + /resetcooltime
  9361. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  9362. ACMD_DEF(kill),
  9363. ACMD_DEF(alive),
  9364. ACMD_DEF(kami),
  9365. ACMD_DEF2("kamib", kami),
  9366. ACMD_DEF2("kamic", kami),
  9367. ACMD_DEF2("lkami", kami),
  9368. ACMD_DEF(heal),
  9369. ACMD_DEF(healap),
  9370. ACMD_DEF(item),
  9371. ACMD_DEF(item2),
  9372. ACMD_DEF2("itembound",item),
  9373. ACMD_DEF2("itembound2",item2),
  9374. ACMD_DEF(itemreset),
  9375. ACMD_DEF(clearstorage),
  9376. ACMD_DEF(cleargstorage),
  9377. ACMD_DEF(clearcart),
  9378. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  9379. ACMD_DEF2("jlvl", joblevelup),
  9380. ACMD_DEF(help),
  9381. ACMD_DEF(pvpoff),
  9382. ACMD_DEF(pvpon),
  9383. ACMD_DEF(gvgoff),
  9384. ACMD_DEF(gvgon),
  9385. ACMD_DEF(model),
  9386. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  9387. ACMD_DEF(monster),
  9388. ACMD_DEF2("monstersmall", monster),
  9389. ACMD_DEF2("monsterbig", monster),
  9390. ACMD_DEF(killmonster),
  9391. ACMD_DEF2("killmonster2", killmonster),
  9392. ACMD_DEF(refine),
  9393. ACMD_DEF(grade),
  9394. ACMD_DEF(produce),
  9395. ACMD_DEF(memo),
  9396. ACMD_DEF(gat),
  9397. ACMD_DEF(displaystatus),
  9398. ACMD_DEF2("stpoint", statuspoint),
  9399. ACMD_DEF2("trpoint", traitpoint),
  9400. ACMD_DEF2("skpoint", skillpoint),
  9401. ACMD_DEF(zeny),
  9402. ACMD_DEF2("str", param),
  9403. ACMD_DEF2("agi", param),
  9404. ACMD_DEF2("vit", param),
  9405. ACMD_DEF2("int", param),
  9406. ACMD_DEF2("dex", param),
  9407. ACMD_DEF2("luk", param),
  9408. ACMD_DEF2("pow", param),
  9409. ACMD_DEF2("sta", param),
  9410. ACMD_DEF2("wis", param),
  9411. ACMD_DEF2("spl", param),
  9412. ACMD_DEF2("con", param),
  9413. ACMD_DEF2("crt", param),
  9414. ACMD_DEF2("glvl", guildlevelup),
  9415. ACMD_DEF(makeegg),
  9416. ACMD_DEF(hatch),
  9417. ACMD_DEF(petfriendly),
  9418. ACMD_DEF(pethungry),
  9419. ACMD_DEF(petrename),
  9420. ACMD_DEF(recall), // + /recall
  9421. ACMD_DEF(night),
  9422. ACMD_DEF(day),
  9423. ACMD_DEF(doom),
  9424. ACMD_DEF(doommap),
  9425. ACMD_DEF(raise),
  9426. ACMD_DEF(raisemap),
  9427. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  9428. ACMD_DEF(kickall),
  9429. ACMD_DEF(allskill),
  9430. ACMD_DEF(questskill),
  9431. ACMD_DEF(lostskill),
  9432. ACMD_DEF(spiritball),
  9433. ACMD_DEF(soulball),
  9434. ACMD_DEF(party),
  9435. ACMD_DEF(guild),
  9436. ACMD_DEF(breakguild),
  9437. ACMD_DEF(agitstart),
  9438. ACMD_DEF(agitend),
  9439. ACMD_DEF(mapexit),
  9440. ACMD_DEF(idsearch),
  9441. ACMD_DEF(broadcast), // + /b and /nb
  9442. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9443. ACMD_DEF(recallall),
  9444. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  9445. ACMD_DEF2("reloaditemdb", reload),
  9446. ACMD_DEF2("reloadcashdb", reload),
  9447. ACMD_DEF2("reloadmobdb", reload),
  9448. ACMD_DEF2("reloadskilldb", reload),
  9449. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  9450. ACMD_DEF2("reloadatcommand", reload),
  9451. ACMD_DEF2("reloadbattleconf", reload),
  9452. ACMD_DEF2("reloadstatusdb", reload),
  9453. ACMD_DEF2("reloadpcdb", reload),
  9454. ACMD_DEF2("reloadmotd", reload),
  9455. ACMD_DEF2("reloadquestdb", reload),
  9456. ACMD_DEF2("reloadmsgconf", reload),
  9457. ACMD_DEF2("reloadinstancedb", reload),
  9458. ACMD_DEF2("reloadachievementdb",reload),
  9459. ACMD_DEF2("reloadattendancedb",reload),
  9460. ACMD_DEF2("reloadbarterdb",reload),
  9461. ACMD_DEF(partysharelvl),
  9462. ACMD_DEF(mapinfo),
  9463. ACMD_DEF(dye),
  9464. ACMD_DEF2("hairstyle", hair_style),
  9465. ACMD_DEF2("haircolor", hair_color),
  9466. ACMD_DEF2("allstats", stat_all),
  9467. ACMD_DEF2("alltraits", trait_all),
  9468. ACMD_DEF2("block", char_block),
  9469. ACMD_DEF2("ban", char_ban),
  9470. ACMD_DEF2("unblock", char_unblock),
  9471. ACMD_DEF2("unban", char_unban),
  9472. ACMD_DEF2("charban", char_ban),
  9473. ACMD_DEF2("charunban", char_unban),
  9474. ACMD_DEF2("mount", mount_peco),
  9475. ACMD_DEF(guildspy),
  9476. ACMD_DEF(partyspy),
  9477. ACMD_DEF(clanspy),
  9478. ACMD_DEF(repairall),
  9479. ACMD_DEF(guildrecall),
  9480. ACMD_DEF(partyrecall),
  9481. ACMD_DEF(nuke),
  9482. ACMD_DEF(shownpc),
  9483. ACMD_DEF(hidenpc),
  9484. ACMD_DEF(loadnpc),
  9485. ACMD_DEF(unloadnpc),
  9486. ACMD_DEF(reloadnpcfile),
  9487. ACMD_DEF2("time", servertime),
  9488. ACMD_DEF(jail),
  9489. ACMD_DEF(unjail),
  9490. ACMD_DEF(jailfor),
  9491. ACMD_DEF(jailtime),
  9492. ACMD_DEF(disguise),
  9493. ACMD_DEF(undisguise),
  9494. ACMD_DEF(email),
  9495. ACMD_DEF(effect),
  9496. ACMD_DEF(follow),
  9497. ACMD_DEF(addwarp),
  9498. ACMD_DEF(skillon),
  9499. ACMD_DEF(skilloff),
  9500. ACMD_DEF(killer),
  9501. ACMD_DEF(npcmove),
  9502. ACMD_DEF(killable),
  9503. ACMD_DEF(dropall),
  9504. ACMD_DEF(stockall),
  9505. ACMD_DEF(storeall),
  9506. ACMD_DEF(skillid),
  9507. ACMD_DEF(useskill),
  9508. ACMD_DEF(displayskill),
  9509. ACMD_DEF(displayskillcast),
  9510. ACMD_DEF(displayskillunit),
  9511. ACMD_DEF(snow),
  9512. ACMD_DEF(sakura),
  9513. ACMD_DEF(clouds),
  9514. ACMD_DEF(clouds2),
  9515. ACMD_DEF(fog),
  9516. ACMD_DEF(fireworks),
  9517. ACMD_DEF(leaves),
  9518. ACMD_DEF(summon),
  9519. ACMD_DEF(adjgroup),
  9520. ACMD_DEF(trade),
  9521. ACMD_DEF(send),
  9522. ACMD_DEF(setbattleflag),
  9523. ACMD_DEF(unmute),
  9524. ACMD_DEF(clearweather),
  9525. ACMD_DEF(uptime),
  9526. ACMD_DEF(changesex),
  9527. ACMD_DEF(changecharsex),
  9528. ACMD_DEF(mute),
  9529. ACMD_DEF(refresh),
  9530. ACMD_DEF(refreshall),
  9531. ACMD_DEF(identify),
  9532. ACMD_DEF(identifyall),
  9533. ACMD_DEF(gmotd),
  9534. ACMD_DEF(misceffect),
  9535. ACMD_DEF(mobsearch),
  9536. ACMD_DEF(cleanmap),
  9537. ACMD_DEF(cleanarea),
  9538. ACMD_DEF(npctalk),
  9539. ACMD_DEF(pettalk),
  9540. ACMD_DEF(users),
  9541. ACMD_DEF(reset),
  9542. ACMD_DEF(skilltree),
  9543. ACMD_DEF(marry),
  9544. ACMD_DEF(divorce),
  9545. ACMD_DEF(sound),
  9546. ACMD_DEF(undisguiseall),
  9547. ACMD_DEF(disguiseall),
  9548. ACMD_DEF(changelook),
  9549. ACMD_DEF(autoloot),
  9550. ACMD_DEF2("alootid", autolootitem),
  9551. ACMD_DEF(autoloottype),
  9552. ACMD_DEF(mobinfo),
  9553. ACMD_DEF(exp),
  9554. ACMD_DEF(version),
  9555. ACMD_DEF(mutearea),
  9556. ACMD_DEF(rates),
  9557. ACMD_DEF(iteminfo),
  9558. ACMD_DEF(whodrops),
  9559. ACMD_DEF(whereis),
  9560. ACMD_DEF(mapflag),
  9561. ACMD_DEF(me),
  9562. ACMD_DEF(monsterignore),
  9563. ACMD_DEF(fakename),
  9564. ACMD_DEF(size),
  9565. ACMD_DEF(showexp),
  9566. ACMD_DEF(showzeny),
  9567. ACMD_DEF(showdelay),
  9568. ACMD_DEF(autotrade),
  9569. ACMD_DEF(changegm),
  9570. ACMD_DEF(changeleader),
  9571. ACMD_DEF(partyoption),
  9572. ACMD_DEF(invite),
  9573. ACMD_DEF(duel),
  9574. ACMD_DEF(leave),
  9575. ACMD_DEF(accept),
  9576. ACMD_DEF(reject),
  9577. ACMD_DEF(clone),
  9578. ACMD_DEF2("slaveclone", clone),
  9579. ACMD_DEF2("evilclone", clone),
  9580. ACMD_DEF(tonpc),
  9581. ACMD_DEF(commands),
  9582. ACMD_DEF(noask),
  9583. ACMD_DEF(request),
  9584. ACMD_DEF(homlevel),
  9585. ACMD_DEF(homevolution),
  9586. ACMD_DEF(hommutate),
  9587. ACMD_DEF(makehomun),
  9588. ACMD_DEF(homfriendly),
  9589. ACMD_DEF(homhungry),
  9590. ACMD_DEF(homtalk),
  9591. ACMD_DEF(hominfo),
  9592. ACMD_DEF(homstats),
  9593. ACMD_DEF(homshuffle),
  9594. ACMD_DEF(showmobs),
  9595. ACMD_DEF(feelreset),
  9596. ACMD_DEF(hatereset),
  9597. ACMD_DEF(auction),
  9598. ACMD_DEF(mail),
  9599. ACMD_DEF2("noks", ksprotection),
  9600. ACMD_DEF(allowks),
  9601. ACMD_DEF(cash),
  9602. ACMD_DEF2("points", cash),
  9603. ACMD_DEF(agitstart2),
  9604. ACMD_DEF(agitend2),
  9605. ACMD_DEF(resetskill),
  9606. ACMD_DEF(resetstat),
  9607. ACMD_DEF2("storagelist", itemlist),
  9608. ACMD_DEF2("cartlist", itemlist),
  9609. ACMD_DEF2("itemlist", itemlist),
  9610. ACMD_DEF(stats),
  9611. ACMD_DEF(delitem),
  9612. ACMD_DEF(charcommands),
  9613. ACMD_DEF(font),
  9614. ACMD_DEF(accinfo),
  9615. ACMD_DEF(set),
  9616. ACMD_DEF(undisguiseguild),
  9617. ACMD_DEF(disguiseguild),
  9618. ACMD_DEF(sizeall),
  9619. ACMD_DEF(sizeguild),
  9620. ACMD_DEF(addperm),
  9621. ACMD_DEF2("rmvperm", addperm),
  9622. ACMD_DEF(unloadnpcfile),
  9623. ACMD_DEF(cart),
  9624. ACMD_DEF(mount2),
  9625. ACMD_DEF(join),
  9626. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9627. ACMD_DEF(fontcolor),
  9628. ACMD_DEF(langtype),
  9629. #ifdef VIP_ENABLE
  9630. ACMD_DEF(vip),
  9631. ACMD_DEF(showrate),
  9632. #endif
  9633. ACMD_DEF(fullstrip),
  9634. ACMD_DEF(costume),
  9635. ACMD_DEF(cloneequip),
  9636. ACMD_DEF(clonestat),
  9637. ACMD_DEF(bodystyle),
  9638. ACMD_DEF(adopt),
  9639. ACMD_DEF(agitstart3),
  9640. ACMD_DEF(agitend3),
  9641. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9642. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9643. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9644. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9645. ACMD_DEF2("setquest", quest),
  9646. ACMD_DEF2("erasequest", quest),
  9647. ACMD_DEF2("completequest", quest),
  9648. ACMD_DEF2("checkquest", quest),
  9649. ACMD_DEF(refineui),
  9650. ACMD_DEFR(stylist, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9651. ACMD_DEF(addfame),
  9652. ACMD_DEFR(enchantgradeui, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9653. ACMD_DEFR(roulette, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9654. ACMD_DEF(setcard),
  9655. };
  9656. AtCommandInfo* atcommand;
  9657. int i;
  9658. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9659. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9660. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9661. continue;
  9662. }
  9663. CREATE(atcommand, AtCommandInfo, 1);
  9664. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9665. atcommand->func = atcommand_base[i].func;
  9666. atcommand->restriction = atcommand_base[i].restriction;
  9667. strdb_put(atcommand_db, atcommand->command, atcommand);
  9668. }
  9669. return;
  9670. }
  9671. /*==========================================
  9672. * Command lookup functions
  9673. *------------------------------------------*/
  9674. bool atcommand_exists(const char* name)
  9675. {
  9676. return strdb_exists(atcommand_db, name);
  9677. }
  9678. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9679. {
  9680. if (strdb_exists(atcommand_db, name))
  9681. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9682. return nullptr;
  9683. }
  9684. /// AtCommand suggestion
  9685. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
  9686. DBIterator* atcommand_iter;
  9687. AtCommandInfo* command_info = nullptr;
  9688. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9689. char* full_match[MAX_SUGGESTIONS];
  9690. char* suggestions[MAX_SUGGESTIONS];
  9691. char* match;
  9692. int prefix_count = 0, full_count = 0;
  9693. bool can_use;
  9694. if (!battle_config.atcommand_suggestions_enabled)
  9695. return;
  9696. atcommand_iter = db_iterator(atcommand_db);
  9697. // Build the matches
  9698. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9699. match = strstr(command_info->command, name);
  9700. can_use = pc_can_use_command(sd, command_info->command, type);
  9701. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9702. suggestions[prefix_count] = command_info->command;
  9703. ++prefix_count;
  9704. }
  9705. if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
  9706. full_match[full_count] = command_info->command;
  9707. ++full_count;
  9708. }
  9709. }
  9710. for( auto& pair : atcommand_alias_db ){
  9711. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9712. if( pc_can_use_command( sd, info->command->command, type ) ){
  9713. for( const std::string& alias_str : info->aliases ){
  9714. char* alias = const_cast<char *>(alias_str.c_str());
  9715. match = strstr( alias, name );
  9716. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9717. suggestions[prefix_count] = alias;
  9718. ++prefix_count;
  9719. }
  9720. if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
  9721. full_match[full_count] = alias;
  9722. ++full_count;
  9723. }
  9724. }
  9725. }
  9726. }
  9727. if ((full_count+prefix_count) > 0) {
  9728. char buffer[512];
  9729. int i;
  9730. // Merge full match and prefix match results
  9731. if (prefix_count < MAX_SUGGESTIONS) {
  9732. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9733. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9734. }
  9735. // Build the suggestion string
  9736. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9737. strcat(buffer,"\n");
  9738. for(i=0; i < prefix_count; ++i) {
  9739. strcat(buffer,suggestions[i]);
  9740. strcat(buffer," ");
  9741. }
  9742. clif_displaymessage(sd->fd, buffer);
  9743. }
  9744. dbi_destroy(atcommand_iter);
  9745. }
  9746. /**
  9747. * Executes an at-command
  9748. * @param fd
  9749. * @param sd
  9750. * @param message
  9751. * @param type
  9752. * 0 : script call (atcommand)
  9753. * 1 : normal player @atcommand
  9754. * 2 : console (admin:@atcommand)
  9755. * 3 : script call (useatcmd)
  9756. */
  9757. bool is_atcommand(const int fd, map_session_data* sd, const char* message, int type)
  9758. {
  9759. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9760. char output[CHAT_SIZE_MAX];
  9761. //Reconstructed message
  9762. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9763. TBL_PC * ssd = nullptr; //sd for target
  9764. AtCommandInfo * info;
  9765. bool is_atcommand = true; // false if it's a charcommand
  9766. nullpo_retr(false, sd);
  9767. //Shouldn't happen
  9768. if ( !message || !*message )
  9769. return false;
  9770. //If cannot use atcomamnd while talking with NPC [Kichi]
  9771. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9772. return false;
  9773. //Block NOCHAT but do not display it as a normal message
  9774. if ( sd->sc.getSCE(SC_NOCHAT) && sd->sc.getSCE(SC_NOCHAT)->val1&MANNER_NOCOMMAND )
  9775. return true;
  9776. // skip 10/11-langtype's codepage indicator, if detected
  9777. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9778. message += 3;
  9779. //Should display as a normal message
  9780. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9781. return false;
  9782. // type value 0|2 = script|console invoked: bypass restrictions
  9783. if ( type == 1 || type == 3) {
  9784. //Commands are disabled on maps flagged as 'nocommand'
  9785. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  9786. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  9787. return false;
  9788. }
  9789. }
  9790. if (*message == charcommand_symbol)
  9791. is_atcommand = false;
  9792. if (is_atcommand) { // @command
  9793. sprintf(atcmd_msg, "%s", message);
  9794. ssd = sd;
  9795. } else { // #command
  9796. char charname[NAME_LENGTH];
  9797. int n;
  9798. //Checks to see if #command has a name or a name + parameters.
  9799. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  9800. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  9801. ) {
  9802. if (pc_get_group_level(sd) == 0) {
  9803. if (n < 1)
  9804. return false; // No command found. Display as normal message.
  9805. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9806. if (!info || info->char_groups[sd->group->index] == 0) // If we can't use or doesn't exist: don't even display the command failed message
  9807. return false;
  9808. }
  9809. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9810. clif_displaymessage(fd, output);
  9811. return true;
  9812. }
  9813. ssd = map_nick2sd(charname,true);
  9814. if (ssd == nullptr) {
  9815. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9816. clif_displaymessage(fd, output);
  9817. return true;
  9818. }
  9819. if (n > 2)
  9820. sprintf(atcmd_msg, "%s %s", command, params);
  9821. else
  9822. sprintf(atcmd_msg, "%s", command);
  9823. }
  9824. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9825. sd->idletime = last_tick;
  9826. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  9827. sd->idletime_hom = last_tick;
  9828. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  9829. sd->idletime_mer = last_tick;
  9830. //Clearing these to be used once more.
  9831. memset(command, '\0', sizeof(command));
  9832. memset(params, '\0', sizeof(params));
  9833. //check to see if any params exist within this command
  9834. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9835. params[0] = '\0';
  9836. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  9837. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9838. clif_displaymessage(fd, output);
  9839. return true;
  9840. }
  9841. // @commands (script based)
  9842. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9843. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9844. // Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
  9845. if( binding != nullptr && binding->npc_event[0] &&
  9846. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9847. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9848. {
  9849. // Check if self or character invoking; if self == character invoked, then self invoke.
  9850. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9851. return true;
  9852. }
  9853. }
  9854. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9855. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  9856. if (info == nullptr) {
  9857. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9858. return false;
  9859. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9860. clif_displaymessage(fd, output);
  9861. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9862. return true;
  9863. }
  9864. //check restriction
  9865. if (info->restriction) {
  9866. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9867. return true;
  9868. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9869. return true;
  9870. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9871. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9872. return true;
  9873. }
  9874. // type == 1 : player invoked
  9875. if (type == 1) {
  9876. if ((is_atcommand && info->at_groups[sd->group->index] == 0) ||
  9877. (!is_atcommand && info->char_groups[sd->group->index] == 0) )
  9878. return false;
  9879. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9880. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9881. return true;
  9882. }
  9883. }
  9884. //Attempt to use the command
  9885. if ( (info->func(fd, ssd, command, params) != 0) )
  9886. {
  9887. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9888. clif_displaymessage(fd, output);
  9889. return true;
  9890. }
  9891. //Log only if successful.
  9892. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9893. return true;
  9894. }
  9895. void atcommand_db_load_groups(){
  9896. DBIterator *iter = db_iterator(atcommand_db);
  9897. AtCommandInfo* cmd;
  9898. size_t pc_group_max = player_group_db.size();
  9899. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9900. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9901. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9902. for( auto& it : player_group_db ){
  9903. cmd->at_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_ATCOMMAND );
  9904. cmd->char_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_CHARCOMMAND );
  9905. }
  9906. }
  9907. dbi_destroy(iter);
  9908. }
  9909. void atcommand_db_clear(void) {
  9910. if (atcommand_db != nullptr) {
  9911. DBIterator *iter = db_iterator(atcommand_db);
  9912. AtCommandInfo* cmd;
  9913. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9914. aFree(cmd->at_groups);
  9915. aFree(cmd->char_groups);
  9916. }
  9917. dbi_destroy(iter);
  9918. db_destroy(atcommand_db);
  9919. }
  9920. atcommand_alias_db.clear();
  9921. }
  9922. void atcommand_doload(void) {
  9923. atcommand_db_clear();
  9924. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9925. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9926. atcommand_alias_db.load();
  9927. }
  9928. void do_init_atcommand(void) {
  9929. atcommand_doload();
  9930. }
  9931. void do_final_atcommand(void) {
  9932. atcommand_db_clear();
  9933. }