atcommand.cpp 359 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068
  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 int32 atcommand_ ## x (const int32 fd, map_session_data* sd, const char* command, const char* message)
  56. typedef struct AtCommandInfo AtCommandInfo;
  57. int32 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. AtCommandInfo* parent_cmd = get_atcommandinfo_byname( alias.c_str() );
  132. if( parent_cmd != nullptr ){
  133. this->invalidWarning( subNode, "\"%s\" cannot be used as alias for \"%s\", since a command with this name exists.\n", alias.c_str(), command.c_str() );
  134. return 0;
  135. }
  136. info->aliases.insert( alias );
  137. this->aliases[alias] = command;
  138. }
  139. }
  140. if( !exists ){
  141. this->put( command, info );
  142. }
  143. return 1;
  144. }
  145. const char* AtcommandAliasDatabase::checkAlias( const char* alias ){
  146. std::string alias_str( alias );
  147. std::string* command = util::umap_find( this->aliases, alias_str );
  148. if( command == nullptr ){
  149. return alias;
  150. }else{
  151. return command->c_str();
  152. }
  153. }
  154. AtcommandAliasDatabase atcommand_alias_db;
  155. static char atcmd_output[CHAT_SIZE_MAX];
  156. static char atcmd_player_name[NAME_LENGTH];
  157. const char *parent_cmd;
  158. struct atcmd_binding_data** atcmd_binding;
  159. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  160. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand); // @help
  161. static void warp_get_suggestions(map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  162. // @commands (script-based)
  163. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  164. int32 i = 0;
  165. if( *name == atcommand_symbol || *name == charcommand_symbol )
  166. name++; // for backwards compatibility
  167. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  168. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
  169. }
  170. /**
  171. * retrieves the help string associated with a given command.
  172. *
  173. * @param name the name of the command to retrieve help information for
  174. * @return the string associated with the command, or nullptr
  175. */
  176. static const char* atcommand_help_string( const char* command ){
  177. // remove the prefix symbol for the raw name of the command
  178. if( *command == atcommand_symbol || *command == charcommand_symbol ){
  179. command++;
  180. }
  181. // convert alias to the real command name
  182. command = atcommand_alias_db.checkAlias( command );
  183. // attempt to find the first default help command
  184. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command );
  185. // failed to find the help property in the configuration file
  186. if( info == nullptr ){
  187. return nullptr;
  188. }
  189. // push the result from the method
  190. return info->help.c_str();
  191. }
  192. /*==========================================
  193. * @send (used for testing packet sends from the client)
  194. *------------------------------------------*/
  195. ACMD_FUNC(send)
  196. {
  197. int32 len=0,type;
  198. // read message type as hex number (without the 0x)
  199. if(!message || !*message ||
  200. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  201. || sscanf(message, "%8x", &type)==1) )
  202. {
  203. int32 i;
  204. for (i = 900; i <= 903; ++i)
  205. clif_displaymessage(fd, msg_txt(sd,i));
  206. return -1;
  207. }
  208. #define PARSE_ERROR(error,p) \
  209. {\
  210. clif_displaymessage(fd, (error));\
  211. sprintf(atcmd_output, ">%s", (p));\
  212. clif_displaymessage(fd, atcmd_output);\
  213. }
  214. //define PARSE_ERROR
  215. #define CHECK_EOS(p) \
  216. if(*(p) == 0){\
  217. clif_displaymessage(fd, "Unexpected end of string");\
  218. return -1;\
  219. }
  220. //define CHECK_EOS
  221. #define SKIP_VALUE(p) \
  222. {\
  223. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  224. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  225. }
  226. //define SKIP_VALUE
  227. #define GET_VALUE(p,num) \
  228. {\
  229. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  230. PARSE_ERROR("Invalid number in:",(p));\
  231. return -1;\
  232. }\
  233. }
  234. //define GET_VALUE
  235. if (type > 0 && type < MAX_PACKET_DB) {
  236. int32 off,end;
  237. long num;
  238. if(len)
  239. {// show packet length
  240. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  241. clif_displaymessage(fd, atcmd_output);
  242. return 0;
  243. }
  244. len=packet_db[type].len;
  245. off=2;
  246. if(len == 0)
  247. {// unknown packet - ERROR
  248. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  249. clif_displaymessage(fd, atcmd_output);
  250. return -1;
  251. } else if(len == -1)
  252. {// dynamic packet
  253. len=SHRT_MAX-4; // maximum length
  254. off=4;
  255. }
  256. WFIFOHEAD(fd, len);
  257. WFIFOW(fd,0)=TOW(type);
  258. // parse packet contents
  259. SKIP_VALUE(message);
  260. while(*message != 0 && off < len){
  261. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  262. {// default (byte)
  263. GET_VALUE(message,num);
  264. WFIFOB(fd,off)=TOB(num);
  265. ++off;
  266. } else if(TOUPPER(*message) == 'B')
  267. {// byte
  268. ++message;
  269. GET_VALUE(message,num);
  270. WFIFOB(fd,off)=TOB(num);
  271. ++off;
  272. } else if(TOUPPER(*message) == 'W')
  273. {// word (2 bytes)
  274. ++message;
  275. GET_VALUE(message,num);
  276. WFIFOW(fd,off)=TOW(num);
  277. off+=2;
  278. } else if(TOUPPER(*message) == 'L')
  279. {// long word (4 bytes)
  280. ++message;
  281. GET_VALUE(message,num);
  282. WFIFOL(fd,off)=TOL(num);
  283. off+=4;
  284. } else if(TOUPPER(*message) == 'S')
  285. {// string - escapes are valid
  286. // get string length - num <= 0 means not fixed length (default)
  287. ++message;
  288. if(*message == '"'){
  289. num=0;
  290. } else {
  291. GET_VALUE(message,num);
  292. while(*message != '"')
  293. {// find start of string
  294. if(*message == 0 || ISSPACE(*message)){
  295. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  296. return -1;
  297. }
  298. ++message;
  299. }
  300. }
  301. // parse string
  302. ++message;
  303. CHECK_EOS(message);
  304. end=(num<=0? 0: min(off+((int32)num),len));
  305. for(; *message != '"' && (off < end || end == 0); ++off){
  306. if(*message == '\\'){
  307. ++message;
  308. CHECK_EOS(message);
  309. switch(*message){
  310. case 'a': num=0x07; break; // Bell
  311. case 'b': num=0x08; break; // Backspace
  312. case 't': num=0x09; break; // Horizontal tab
  313. case 'n': num=0x0A; break; // Line feed
  314. case 'v': num=0x0B; break; // Vertical tab
  315. case 'f': num=0x0C; break; // Form feed
  316. case 'r': num=0x0D; break; // Carriage return
  317. case 'e': num=0x1B; break; // Escape
  318. default: num=*message; break;
  319. case 'x': // Hexadecimal
  320. {
  321. ++message;
  322. CHECK_EOS(message);
  323. if(!ISXDIGIT(*message)){
  324. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  325. return -1;
  326. }
  327. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  328. if(ISXDIGIT(*message)){
  329. ++message;
  330. CHECK_EOS(message);
  331. num<<=8;
  332. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  333. }
  334. WFIFOB(fd,off)=TOB(num);
  335. ++message;
  336. CHECK_EOS(message);
  337. continue;
  338. }
  339. case '0':
  340. case '1':
  341. case '2':
  342. case '3':
  343. case '4':
  344. case '5':
  345. case '6':
  346. case '7': // Octal
  347. {
  348. num=*message-'0'; // 1st octal digit
  349. ++message;
  350. CHECK_EOS(message);
  351. if(ISDIGIT(*message) && *message < '8'){
  352. num<<=3;
  353. num+=*message-'0'; // 2nd octal digit
  354. ++message;
  355. CHECK_EOS(message);
  356. if(ISDIGIT(*message) && *message < '8'){
  357. num<<=3;
  358. num+=*message-'0'; // 3rd octal digit
  359. ++message;
  360. CHECK_EOS(message);
  361. }
  362. }
  363. WFIFOB(fd,off)=TOB(num);
  364. continue;
  365. }
  366. }
  367. } else
  368. num=*message;
  369. WFIFOB(fd,off)=TOB(num);
  370. ++message;
  371. CHECK_EOS(message);
  372. }//for
  373. while(*message != '"')
  374. {// ignore extra characters
  375. ++message;
  376. CHECK_EOS(message);
  377. }
  378. // terminate the string
  379. if(off < end)
  380. {// fill the rest with 0's
  381. memset(WFIFOP(fd,off),0,end-off);
  382. off=end;
  383. }
  384. } else
  385. {// unknown
  386. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  387. return -1;
  388. }
  389. SKIP_VALUE(message);
  390. }
  391. if(packet_db[type].len == -1)
  392. {// send dynamic packet
  393. WFIFOW(fd,2)=TOW(off);
  394. WFIFOSET(fd,off);
  395. } else
  396. {// send static packet
  397. if(off < len)
  398. memset(WFIFOP(fd,off),0,len-off);
  399. WFIFOSET(fd,len);
  400. }
  401. } else {
  402. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  403. return -1;
  404. }
  405. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  406. clif_displaymessage(fd, atcmd_output);
  407. return 0;
  408. #undef PARSE_ERROR
  409. #undef CHECK_EOS
  410. #undef SKIP_VALUE
  411. #undef GET_VALUE
  412. }
  413. /**
  414. * Retrieves map name suggestions for a given string.
  415. * This will first check if any map names contain the given string, and will
  416. * print out MAX_SUGGESTIONS results if any maps are found.
  417. * Otherwise, suggestions will be calculated through Levenshtein distance,
  418. * and up to 5 of the closest matches will be printed.
  419. *
  420. * @author Euphy
  421. */
  422. static void warp_get_suggestions(map_session_data* sd, const char *name) {
  423. // Minimum length for suggestions is 2 characters
  424. if( strlen( name ) < 2 ){
  425. return;
  426. }
  427. std::vector<const char*> suggestions;
  428. suggestions.reserve( MAX_SUGGESTIONS );
  429. // check for maps that contain string
  430. for (int32 i = 0; i < map_num; i++) {
  431. struct map_data *mapdata = map_getmapdata(i);
  432. // Prevent suggestion of instance mapnames
  433. if( mapdata->instance_id != 0 ){
  434. continue;
  435. }
  436. if( strstr( mapdata->name, name ) != nullptr ){
  437. suggestions.push_back( mapdata->name );
  438. if( suggestions.size() == MAX_SUGGESTIONS ){
  439. break;
  440. }
  441. }
  442. }
  443. // if no maps found, search by edit distance
  444. if( suggestions.empty() ){
  445. // Levenshtein > 4 is bad
  446. const int32 LEVENSHTEIN_MAX = 4;
  447. std::unordered_map<int32, std::vector<const char*>> maps;
  448. for (int32 i = 0; i < map_num; i++) {
  449. struct map_data *mapdata = map_getmapdata(i);
  450. // Prevent suggestion of instance mapnames
  451. if(mapdata->instance_id != 0 ){
  452. continue;
  453. }
  454. // Calculate the levenshtein distance of the two strings
  455. int32 distance = levenshtein(mapdata->name, name);
  456. // Check if it is above the maximum defined distance
  457. if( distance > LEVENSHTEIN_MAX ){
  458. continue;
  459. }
  460. std::vector<const char*>& vector = maps[distance];
  461. // Do not add more entries than required
  462. if( vector.size() == MAX_SUGGESTIONS ){
  463. continue;
  464. }
  465. vector.push_back(mapdata->name);
  466. }
  467. for( int32 distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  468. std::vector<const char*>& vector = maps[distance];
  469. for( const char* found_map : vector ){
  470. suggestions.push_back( found_map );
  471. if( suggestions.size() == MAX_SUGGESTIONS ){
  472. break;
  473. }
  474. }
  475. if( suggestions.size() == MAX_SUGGESTIONS ){
  476. break;
  477. }
  478. }
  479. }
  480. // If no suggestion could be made, do not output anything at all
  481. if( suggestions.empty() ){
  482. return;
  483. }
  484. char buffer[CHAT_SIZE_MAX];
  485. // build the suggestion string
  486. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  487. strcat(buffer, "\n");
  488. for( const char* suggestion : suggestions ){
  489. strcat(buffer, suggestion);
  490. strcat(buffer, " ");
  491. }
  492. clif_displaymessage(sd->fd, buffer);
  493. }
  494. /*==========================================
  495. * @rura, @warp, @mapmove
  496. *------------------------------------------*/
  497. ACMD_FUNC(mapmove)
  498. {
  499. char map_name[MAP_NAME_LENGTH_EXT];
  500. uint16 mapindex;
  501. int16 x = 0, y = 0;
  502. int16 m = -1;
  503. nullpo_retr(-1, sd);
  504. memset(map_name, '\0', sizeof(map_name));
  505. if (!message || !*message ||
  506. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  507. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  508. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  509. return -1;
  510. }
  511. mapindex = mapindex_name2idx(map_name, nullptr);
  512. if (mapindex)
  513. m = map_mapindex2mapid(mapindex);
  514. if (m < 0) { // m < 0 means on different server! [Kevin]
  515. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  516. if (battle_config.warp_suggestions_enabled)
  517. warp_get_suggestions(sd, map_name);
  518. return -1;
  519. }
  520. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  521. { //This is to prevent the pc_setpos call from printing an error.
  522. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  523. if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
  524. x = y = 0; //Invalid cell, use random spot.
  525. }
  526. 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))) {
  527. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  528. return -1;
  529. }
  530. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  531. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  532. return -1;
  533. }
  534. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  535. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  536. return -1;
  537. }
  538. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  539. return 0;
  540. }
  541. /*==========================================
  542. * Displays where a character is. Corrected version by Silent. [Skotlex]
  543. *------------------------------------------*/
  544. ACMD_FUNC(where)
  545. {
  546. map_session_data* pl_sd;
  547. nullpo_retr(-1, sd);
  548. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  549. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  550. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  551. return -1;
  552. }
  553. pl_sd = map_nick2sd(atcmd_player_name,true);
  554. if (pl_sd == nullptr ||
  555. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  556. (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))
  557. ) {
  558. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  559. return -1;
  560. }
  561. 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);
  562. clif_displaymessage(fd, atcmd_output);
  563. return 0;
  564. }
  565. /*==========================================
  566. *
  567. *------------------------------------------*/
  568. ACMD_FUNC(jumpto)
  569. {
  570. map_session_data* pl_sd = nullptr;;
  571. nullpo_retr(-1, sd);
  572. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  573. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  574. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  575. return -1;
  576. }
  577. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  578. {
  579. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  580. return -1;
  581. }
  582. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  583. {
  584. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  585. return -1;
  586. }
  587. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  588. {
  589. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  590. return -1;
  591. }
  592. if( pc_isdead(sd) )
  593. {
  594. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  595. return -1;
  596. }
  597. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  598. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  599. clif_displaymessage(fd, atcmd_output);
  600. return 0;
  601. }
  602. /*==========================================
  603. *
  604. *------------------------------------------*/
  605. ACMD_FUNC(jump)
  606. {
  607. int16 x = 0, y = 0;
  608. nullpo_retr(-1, sd);
  609. memset(atcmd_output, '\0', sizeof(atcmd_output));
  610. sscanf(message, "%6hd %6hd", &x, &y);
  611. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  612. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  613. return -1;
  614. }
  615. if( pc_isdead(sd) )
  616. {
  617. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  618. return -1;
  619. }
  620. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  621. { //This is to prevent the pc_setpos call from printing an error.
  622. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  623. if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
  624. x = y = 0; //Invalid cell, use random spot.
  625. }
  626. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  627. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  628. clif_displaymessage(fd, atcmd_output);
  629. return 0;
  630. }
  631. /*==========================================
  632. * Display list of online characters with
  633. * various info.
  634. *------------------------------------------*/
  635. ACMD_FUNC(who) {
  636. map_session_data* pl_sd = nullptr;;
  637. struct s_mapiterator *iter = nullptr;
  638. char player_name[NAME_LENGTH] = "";
  639. int32 count = 0;
  640. int32 level = 0;
  641. StringBuf buf;
  642. /**
  643. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  644. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  645. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  646. */
  647. int32 display_type = 1;
  648. int32 map_id = -1;
  649. nullpo_retr(-1, sd);
  650. if (strstr(command, "map") != nullptr) {
  651. char map_name[MAP_NAME_LENGTH_EXT] = "";
  652. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  653. map_id = sd->bl.m;
  654. } else {
  655. sscanf(message, "%23s", player_name);
  656. }
  657. if (strstr(command, "2") != nullptr)
  658. display_type = 2;
  659. else if (strstr(command, "3") != nullptr)
  660. display_type = 3;
  661. level = pc_get_group_level(sd);
  662. StringBuf_Init(&buf);
  663. iter = mapit_getallusers();
  664. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  665. 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
  666. if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
  667. || (map_id >= 0 && pl_sd->bl.m != map_id))
  668. continue;
  669. switch (display_type) {
  670. case 2: {
  671. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  672. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  673. StringBuf_Printf(&buf, msg_txt(sd,344),pl_sd->group->name.c_str()); // "(%s) "
  674. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  675. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  676. break;
  677. }
  678. case 3: {
  679. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  680. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  681. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  682. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  683. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  684. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  685. break;
  686. }
  687. default: {
  688. struct party_data *p = party_search(pl_sd->status.party_id);
  689. auto &g = pl_sd->guild;
  690. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  691. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  692. StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
  693. if (p != nullptr)
  694. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  695. if (g != nullptr)
  696. StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
  697. break;
  698. }
  699. }
  700. clif_displaymessage(fd, StringBuf_Value(&buf));
  701. StringBuf_Clear(&buf);
  702. count++;
  703. }
  704. }
  705. mapit_free(iter);
  706. if (map_id < 0) {
  707. if (count == 0)
  708. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  709. else if (count == 1)
  710. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  711. else
  712. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  713. } else {
  714. struct map_data *mapdata = map_getmapdata(map_id);
  715. if (count == 0)
  716. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  717. else if (count == 1)
  718. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  719. else
  720. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  721. }
  722. clif_displaymessage(fd, StringBuf_Value(&buf));
  723. StringBuf_Destroy(&buf);
  724. return 0;
  725. }
  726. /*==========================================
  727. *
  728. *------------------------------------------*/
  729. ACMD_FUNC(whogm)
  730. {
  731. map_session_data* pl_sd;
  732. struct s_mapiterator* iter;
  733. int32 j, count;
  734. int32 level;
  735. char match_text[CHAT_SIZE_MAX];
  736. char player_name[NAME_LENGTH];
  737. struct party_data *p;
  738. nullpo_retr(-1, sd);
  739. memset(atcmd_output, '\0', sizeof(atcmd_output));
  740. memset(match_text, '\0', sizeof(match_text));
  741. memset(player_name, '\0', sizeof(player_name));
  742. if (sscanf(message, "%255[^\n]", match_text) < 1)
  743. strcpy(match_text, "");
  744. for (j = 0; match_text[j]; j++)
  745. match_text[j] = TOLOWER(match_text[j]);
  746. count = 0;
  747. level = pc_get_group_level(sd);
  748. iter = mapit_getallusers();
  749. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  750. {
  751. int32 pl_level = pc_get_group_level(pl_sd);
  752. if (!pl_level)
  753. continue;
  754. if (match_text[0])
  755. {
  756. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  757. for (j = 0; player_name[j]; j++)
  758. player_name[j] = TOLOWER(player_name[j]);
  759. // search with no case sensitive
  760. if (strstr(player_name, match_text) == nullptr)
  761. continue;
  762. }
  763. if (pl_level > level) {
  764. if (pc_isinvisible(pl_sd))
  765. continue;
  766. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  767. clif_displaymessage(fd, atcmd_output);
  768. count++;
  769. continue;
  770. }
  771. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  772. pl_sd->status.name, pl_level,
  773. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  774. clif_displaymessage(fd, atcmd_output);
  775. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  776. pl_sd->status.base_level,
  777. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  778. clif_displaymessage(fd, atcmd_output);
  779. p = party_search(pl_sd->status.party_id);
  780. auto &g = pl_sd->guild;
  781. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  782. p?p->party.name:msg_txt(sd,917), g?g->guild.name:msg_txt(sd,917)); // None.
  783. clif_displaymessage(fd, atcmd_output);
  784. count++;
  785. }
  786. mapit_free(iter);
  787. if (count == 0)
  788. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  789. else if (count == 1)
  790. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  791. else {
  792. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  793. clif_displaymessage(fd, atcmd_output);
  794. }
  795. return 0;
  796. }
  797. /*==========================================
  798. *
  799. *------------------------------------------*/
  800. ACMD_FUNC(save)
  801. {
  802. nullpo_retr(-1, sd);
  803. if( map_getmapdata(sd->bl.m)->instance_id ) {
  804. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  805. return 1;
  806. }
  807. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  808. if (sd->status.pet_id > 0 && sd->pd)
  809. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  810. chrif_save(sd, CSAVE_NORMAL);
  811. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  812. return 0;
  813. }
  814. /*==========================================
  815. *
  816. *------------------------------------------*/
  817. ACMD_FUNC(load){
  818. nullpo_retr(-1, sd);
  819. uint16 mapindex = mapindex_name2id( sd->status.save_point.map );
  820. int16 m = map_mapindex2mapid( mapindex );
  821. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  822. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  823. return -1;
  824. }
  825. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  826. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  827. return -1;
  828. }
  829. pc_setpos( sd, mapindex, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT );
  830. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  831. return 0;
  832. }
  833. /*==========================================
  834. *
  835. *------------------------------------------*/
  836. ACMD_FUNC(speed)
  837. {
  838. int16 speed;
  839. nullpo_retr(-1, sd);
  840. memset(atcmd_output, '\0', sizeof(atcmd_output));
  841. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  842. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  843. clif_displaymessage(fd, atcmd_output);
  844. return -1;
  845. }
  846. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  847. if (speed < 0)
  848. sd->base_status.speed = DEFAULT_WALK_SPEED;
  849. else
  850. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  851. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  852. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  853. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  854. } else
  855. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  856. status_calc_bl(&sd->bl, { SCB_SPEED });
  857. return 0;
  858. }
  859. /*==========================================
  860. *
  861. *------------------------------------------*/
  862. ACMD_FUNC(storage)
  863. {
  864. nullpo_retr(-1, sd);
  865. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  866. return -1;
  867. if (storage_storageopen(sd) == 1)
  868. { //Already open.
  869. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  870. return -1;
  871. }
  872. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  873. return 0;
  874. }
  875. /*==========================================
  876. *
  877. *------------------------------------------*/
  878. ACMD_FUNC(guildstorage)
  879. {
  880. nullpo_retr(-1, sd);
  881. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  882. return -1;
  883. switch (storage_guild_storageopen(sd)) {
  884. case GSTORAGE_OPEN:
  885. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  886. break;
  887. case GSTORAGE_STORAGE_ALREADY_OPEN:
  888. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  889. return -1;
  890. case GSTORAGE_ALREADY_OPEN:
  891. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  892. return -1;
  893. case GSTORAGE_NO_GUILD:
  894. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  895. return -1;
  896. case GSTORAGE_NO_STORAGE:
  897. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  898. return -1;
  899. case GSTORAGE_NO_PERMISSION:
  900. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  901. return -1;
  902. }
  903. return 0;
  904. }
  905. /*==========================================
  906. *
  907. *------------------------------------------*/
  908. ACMD_FUNC(option)
  909. {
  910. int32 param1 = 0, param2 = 0, param3 = 0;
  911. nullpo_retr(-1, sd);
  912. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  913. {// failed to match the parameters so inform the user of the options
  914. const char* text;
  915. // attempt to find the setting information for this command
  916. text = atcommand_help_string( command );
  917. // notify the user of the requirement to enter an option
  918. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  919. if( text )
  920. {// send the help text associated with this command
  921. clif_displaymessage( fd, text );
  922. }
  923. return -1;
  924. }
  925. sd->sc.opt1 = param1;
  926. sd->sc.opt2 = param2;
  927. pc_setoption(sd, param3);
  928. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  929. return 0;
  930. }
  931. /*==========================================
  932. *
  933. *------------------------------------------*/
  934. ACMD_FUNC(hide)
  935. {
  936. nullpo_retr(-1, sd);
  937. if (pc_isinvisible(sd)) {
  938. sd->sc.option &= ~OPTION_INVISIBLE;
  939. if (sd->disguise)
  940. status_set_viewdata(&sd->bl, sd->disguise);
  941. else
  942. status_set_viewdata(&sd->bl, sd->status.class_);
  943. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  944. // increment the number of pvp players on the map
  945. map_getmapdata(sd->bl.m)->users_pvp++;
  946. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  947. {// register the player for ranking calculations
  948. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  949. }
  950. //bugreport:2266
  951. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  952. } else {
  953. sd->sc.option |= OPTION_INVISIBLE;
  954. sd->vd.class_ = JT_INVISIBLE;
  955. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  956. // decrement the number of pvp players on the map
  957. map_getmapdata(sd->bl.m)->users_pvp--;
  958. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  959. {// unregister the player for ranking
  960. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  961. sd->pvp_timer = INVALID_TIMER;
  962. }
  963. }
  964. clif_changeoption(&sd->bl);
  965. return 0;
  966. }
  967. ACMD_FUNC(resetcooltime)
  968. {
  969. nullpo_retr(-1, sd);
  970. if (!sd->scd.empty()) {
  971. for (const auto &entry : sd->scd) {
  972. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  973. clif_displaymessage( sd->fd, atcmd_output );
  974. }
  975. skill_blockpc_clear(*sd);
  976. }
  977. if( sd->hd != nullptr && hom_is_active( sd->hd ) ){
  978. for (const auto &entry : sd->hd->scd) {
  979. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  980. clif_displaymessage( sd->fd, atcmd_output );
  981. }
  982. skill_blockhomun_clear(*sd->hd);
  983. }
  984. if( sd->md != nullptr ){
  985. for( const auto &entry : sd->md->scd ){
  986. sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( entry.first )->name ); // Found skill '%s', unblocking...
  987. clif_displaymessage( sd->fd, atcmd_output );
  988. }
  989. skill_blockmerc_clear(*sd->md);
  990. }
  991. return 0;
  992. }
  993. /*==========================================
  994. * Changes a character's class
  995. *------------------------------------------*/
  996. ACMD_FUNC(jobchange)
  997. {
  998. int32 job = 0, upper = 0;
  999. const char* text;
  1000. nullpo_retr(-1, sd);
  1001. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  1002. int32 i;
  1003. bool found = false;
  1004. upper = 0;
  1005. // Normal Jobs
  1006. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  1007. if (strncmpi(message, job_name(i), 16) == 0) {
  1008. job = i;
  1009. found = true;
  1010. }
  1011. }
  1012. // High Jobs, Babys, Third, and Fourth
  1013. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  1014. if (strncmpi(message, job_name(i), 16) == 0) {
  1015. job = i;
  1016. found = true;
  1017. }
  1018. }
  1019. if (!found) {
  1020. text = atcommand_help_string(command);
  1021. if (text)
  1022. clif_displaymessage(fd, text);
  1023. return -1;
  1024. }
  1025. }
  1026. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  1027. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  1028. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE_KNIGHT2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  1029. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2
  1030. || (job >= JOB_WINDHAWK2 && job <= JOB_IMPERIAL_GUARD2) || job == JOB_SKY_EMPEROR2)
  1031. { // Deny direct transformation into dummy jobs
  1032. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  1033. return 0;
  1034. }
  1035. if (pcdb_checkid(job))
  1036. {
  1037. if (pc_jobchange(sd, job, upper))
  1038. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  1039. else {
  1040. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  1041. return -1;
  1042. }
  1043. } else {
  1044. text = atcommand_help_string(command);
  1045. if (text)
  1046. clif_displaymessage(fd, text);
  1047. return -1;
  1048. }
  1049. return 0;
  1050. }
  1051. /*==========================================
  1052. *
  1053. *------------------------------------------*/
  1054. ACMD_FUNC(kill)
  1055. {
  1056. nullpo_retr(-1, sd);
  1057. status_kill(&sd->bl);
  1058. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  1059. if (fd != sd->fd)
  1060. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  1061. return 0;
  1062. }
  1063. /*==========================================
  1064. *
  1065. *------------------------------------------*/
  1066. ACMD_FUNC(alive)
  1067. {
  1068. nullpo_retr(-1, sd);
  1069. if (!status_revive(&sd->bl, 100, 100))
  1070. {
  1071. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  1072. return -1;
  1073. }
  1074. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  1075. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  1076. return 0;
  1077. }
  1078. ACMD_FUNC(kami){
  1079. nullpo_retr(-1, sd);
  1080. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1081. if (!message || !*message) {
  1082. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1083. return -1;
  1084. }
  1085. sscanf(message, "%255[^\n]", atcmd_output);
  1086. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  1087. return 0;
  1088. }
  1089. ACMD_FUNC(lkami){
  1090. nullpo_retr(-1, sd);
  1091. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1092. if (!message || !*message) {
  1093. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1094. return -1;
  1095. }
  1096. sscanf(message, "%255[^\n]", atcmd_output);
  1097. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  1098. return 0;
  1099. }
  1100. ACMD_FUNC(kamib){
  1101. nullpo_retr(-1, sd);
  1102. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1103. if (!message || !*message) {
  1104. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  1105. return -1;
  1106. }
  1107. sscanf(message, "%255[^\n]", atcmd_output);
  1108. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_BLUE);
  1109. return 0;
  1110. }
  1111. ACMD_FUNC(kamic){
  1112. unsigned long color=0;
  1113. nullpo_retr(-1, sd);
  1114. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1115. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1116. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1117. return -1;
  1118. }
  1119. if(color > 0xFFFFFF) {
  1120. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1121. return -1;
  1122. }
  1123. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1124. return 0;
  1125. }
  1126. /*==========================================
  1127. *
  1128. *------------------------------------------*/
  1129. ACMD_FUNC(heal)
  1130. {
  1131. int32 hp = 0, sp = 0; // [Valaris] thanks to fov
  1132. nullpo_retr(-1, sd);
  1133. sscanf(message, "%11d %11d", &hp, &sp);
  1134. // some overflow checks
  1135. if( hp == INT_MIN ) hp++;
  1136. if( sp == INT_MIN ) sp++;
  1137. if ( hp == 0 && sp == 0 ) {
  1138. if (!status_percent_heal(&sd->bl, 100, 100))
  1139. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1140. else
  1141. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1142. return 0;
  1143. }
  1144. if ( hp > 0 && sp >= 0 ) {
  1145. if(!status_heal(&sd->bl, hp, sp, 0))
  1146. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1147. else
  1148. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1149. return 0;
  1150. }
  1151. if ( hp < 0 && sp <= 0 ) {
  1152. status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
  1153. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1154. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1155. return 0;
  1156. }
  1157. //Opposing signs.
  1158. if ( hp ) {
  1159. if (hp > 0)
  1160. status_heal(&sd->bl, hp, 0, 0);
  1161. else {
  1162. status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
  1163. clif_damage(sd->bl,sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1164. }
  1165. }
  1166. if ( sp ) {
  1167. if (sp > 0)
  1168. status_heal(&sd->bl, 0, sp, 0);
  1169. else
  1170. status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
  1171. }
  1172. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1173. return 0;
  1174. }
  1175. /*==========================================
  1176. * Recover's AP and allows exact adjustments. [Rytech]
  1177. *------------------------------------------*/
  1178. ACMD_FUNC(healap)
  1179. {
  1180. int32 ap = 0;
  1181. nullpo_retr(-1, sd);
  1182. sscanf(message, "%11d", &ap);
  1183. // Overflow check.
  1184. if (ap == INT_MIN) ap++;
  1185. if (ap == 0) {
  1186. if (!status_percent_heal(&sd->bl, 0, 0, 100))
  1187. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1188. else
  1189. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1190. return 0;
  1191. }else if (ap > 0) {
  1192. if (!status_heal(&sd->bl, 0, 0, ap, 0))
  1193. clif_displaymessage(fd, msg_txt(sd, 823));// AP have already been recovered.
  1194. else
  1195. clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
  1196. return 0;
  1197. }else{
  1198. status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
  1199. clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
  1200. return 0;
  1201. }
  1202. }
  1203. /*==========================================
  1204. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1205. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1206. *------------------------------------------*/
  1207. ACMD_FUNC(item)
  1208. {
  1209. char item_name[100];
  1210. int32 number = 0, bound = BOUND_NONE;
  1211. char flag = 0;
  1212. char *itemlist;
  1213. nullpo_retr(-1, sd);
  1214. memset(item_name, '\0', sizeof(item_name));
  1215. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1216. if (!strcmpi(parent_cmd,"itembound")) {
  1217. if (!message || !*message || (
  1218. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1219. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1220. {
  1221. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1222. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1223. return -1;
  1224. }
  1225. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1226. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1227. return -1;
  1228. }
  1229. } else if (!message || !*message || (
  1230. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1231. sscanf(message, "%99s %11d", item_name, &number) < 1
  1232. )) {
  1233. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1234. return -1;
  1235. }
  1236. std::vector<std::shared_ptr<item_data>> items;
  1237. itemlist = strtok(item_name, ":");
  1238. while( itemlist != nullptr ){
  1239. std::shared_ptr<item_data> item = item_db.searchname( itemlist );
  1240. if( item == nullptr ){
  1241. item = item_db.find( strtoul( itemlist, nullptr, 10 ) );
  1242. }
  1243. if( item == nullptr ){
  1244. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1245. return -1;
  1246. }
  1247. items.push_back( item );
  1248. itemlist = strtok(nullptr, ":"); //next itemline
  1249. }
  1250. if (number <= 0)
  1251. number = 1;
  1252. int32 get_count = number;
  1253. // Produce items in list
  1254. for( const auto& item : items ){
  1255. t_itemid item_id = item->nameid;
  1256. //Check if it's stackable.
  1257. if( !itemdb_isstackable2( item.get() ) ){
  1258. get_count = 1;
  1259. }
  1260. for( int32 i = 0; i < number; i += get_count ){
  1261. // if not pet egg
  1262. if (!pet_create_egg(sd, item_id)) {
  1263. struct item item_tmp = {};
  1264. item_tmp.nameid = item_id;
  1265. item_tmp.identify = 1;
  1266. item_tmp.bound = bound;
  1267. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1268. clif_additem(sd, 0, 0, flag);
  1269. }
  1270. }
  1271. }
  1272. if (flag == 0)
  1273. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1274. return 0;
  1275. }
  1276. /*==========================================
  1277. *
  1278. *------------------------------------------*/
  1279. ACMD_FUNC(item2)
  1280. {
  1281. char item_name[100];
  1282. int32 number = 0, bound = BOUND_NONE;
  1283. int32 identify = 0, refine = 0, attr = 0;
  1284. int32 c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1285. nullpo_retr(-1, sd);
  1286. memset(item_name, '\0', sizeof(item_name));
  1287. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1288. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1289. if (!message || !*message || (
  1290. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1291. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1292. {
  1293. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1294. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1295. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1296. return -1;
  1297. }
  1298. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1299. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1300. return -1;
  1301. }
  1302. } else if ( !message || !*message || (
  1303. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1304. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1305. )) {
  1306. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1307. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1308. return -1;
  1309. }
  1310. if (number <= 0)
  1311. number = 1;
  1312. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  1313. if( item_data == nullptr ){
  1314. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  1315. }
  1316. if( item_data != nullptr ){
  1317. int32 loop, get_count, i;
  1318. char flag = 0;
  1319. //Check if it's stackable.
  1320. if( !itemdb_isstackable2( item_data.get() ) ){
  1321. loop = number;
  1322. get_count = 1;
  1323. }else{
  1324. loop = 1;
  1325. get_count = number;
  1326. }
  1327. if( itemdb_isequip2( item_data.get() ) ){
  1328. refine = cap_value( refine, 0, MAX_REFINE );
  1329. }else{
  1330. // All other items cannot be refined and are always identified
  1331. identify = 1;
  1332. refine = attr = 0;
  1333. }
  1334. for (i = 0; i < loop; i++) {
  1335. // if not pet egg
  1336. if (!pet_create_egg(sd, item_data->nameid)) {
  1337. struct item item_tmp = {};
  1338. item_tmp.nameid = item_data->nameid;
  1339. item_tmp.identify = identify;
  1340. item_tmp.refine = refine;
  1341. item_tmp.attribute = attr;
  1342. item_tmp.card[0] = c1;
  1343. item_tmp.card[1] = c2;
  1344. item_tmp.card[2] = c3;
  1345. item_tmp.card[3] = c4;
  1346. item_tmp.bound = bound;
  1347. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1348. clif_additem(sd, 0, 0, flag);
  1349. }
  1350. }
  1351. if (flag == 0)
  1352. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1353. } else {
  1354. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1355. return -1;
  1356. }
  1357. return 0;
  1358. }
  1359. /*==========================================
  1360. *
  1361. *------------------------------------------*/
  1362. ACMD_FUNC(itemreset)
  1363. {
  1364. int32 i;
  1365. nullpo_retr(-1, sd);
  1366. for (i = 0; i < MAX_INVENTORY; i++) {
  1367. 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])) {
  1368. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1369. }
  1370. }
  1371. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1372. return 0;
  1373. }
  1374. /*==========================================
  1375. * Atcommand @lvlup
  1376. *------------------------------------------*/
  1377. ACMD_FUNC(baselevelup)
  1378. {
  1379. int32 level=0, i=0, status_point=0, trait_point=0;
  1380. nullpo_retr(-1, sd);
  1381. level = atoi(message);
  1382. if (!message || !*message || !level) {
  1383. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1384. return -1;
  1385. }
  1386. if (level > 0) {
  1387. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1388. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1389. return -1;
  1390. } // End Addition
  1391. if ((uint32)level > pc_maxbaselv(sd) || (uint32)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1392. level = pc_maxbaselv(sd) - sd->status.base_level;
  1393. for (i = 0; i < level; i++)
  1394. {
  1395. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i);
  1396. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i);
  1397. }
  1398. sd->status.status_point += status_point;
  1399. sd->status.trait_point += trait_point;
  1400. sd->status.base_level += (uint32)level;
  1401. status_calc_pc(sd, SCO_FORCE);
  1402. status_percent_heal(&sd->bl, 100, 100);
  1403. clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
  1404. for (uint32 j = sd->status.base_level - level; j <= sd->status.base_level; j++) {
  1405. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, j);
  1406. achievement_update_objective(sd, AG_GOAL_STATUS, 2, j, sd->status.class_);
  1407. }
  1408. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1409. } else {
  1410. if (sd->status.base_level == 1) {
  1411. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1412. return -1;
  1413. }
  1414. level*=-1;
  1415. if ((uint32)level >= sd->status.base_level)
  1416. level = sd->status.base_level-1;
  1417. for (i = 0; i > -level; i--)
  1418. {
  1419. status_point += statpoint_db.pc_gets_status_point(sd->status.base_level + i - 1);
  1420. trait_point += statpoint_db.pc_gets_trait_point(sd->status.base_level + i - 1);
  1421. }
  1422. if (sd->status.status_point < status_point || sd->status.trait_point < trait_point)
  1423. pc_resetstate(sd);
  1424. if (sd->status.status_point < status_point)
  1425. sd->status.status_point = 0;
  1426. else
  1427. sd->status.status_point -= status_point;
  1428. if (sd->status.trait_point < trait_point)
  1429. sd->status.trait_point = 0;
  1430. else
  1431. sd->status.trait_point -= trait_point;
  1432. sd->status.base_level -= (uint32)level;
  1433. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1434. status_calc_pc(sd, SCO_FORCE);
  1435. level*=-1;
  1436. }
  1437. sd->status.base_exp = 0;
  1438. clif_updatestatus(*sd, SP_STATUSPOINT);
  1439. clif_updatestatus(*sd, SP_TRAITPOINT);
  1440. clif_updatestatus(*sd, SP_BASELEVEL);
  1441. clif_updatestatus(*sd, SP_BASEEXP);
  1442. clif_updatestatus(*sd, SP_NEXTBASEEXP);
  1443. pc_baselevelchanged(sd);
  1444. if(sd->status.party_id)
  1445. party_send_levelup(sd);
  1446. if( level > 0 && battle_config.atcommand_levelup_events )
  1447. npc_script_event( *sd, NPCE_BASELVUP );
  1448. return 0;
  1449. }
  1450. /*==========================================
  1451. *
  1452. *------------------------------------------*/
  1453. ACMD_FUNC(joblevelup)
  1454. {
  1455. int32 level=0;
  1456. nullpo_retr(-1, sd);
  1457. level = atoi(message);
  1458. if (!message || !*message || !level) {
  1459. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1460. return -1;
  1461. }
  1462. if (level > 0) {
  1463. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1464. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1465. return -1;
  1466. }
  1467. if ((uint32)level > pc_maxjoblv(sd) || (uint32)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1468. level = pc_maxjoblv(sd) - sd->status.job_level;
  1469. sd->status.job_level += (uint32)level;
  1470. sd->status.skill_point += level;
  1471. clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
  1472. for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
  1473. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, i);
  1474. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1475. } else {
  1476. if (sd->status.job_level == 1) {
  1477. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1478. return -1;
  1479. }
  1480. level *=-1;
  1481. if ((uint32)level >= sd->status.job_level) // fix negative overflow
  1482. level = sd->status.job_level-1;
  1483. sd->status.job_level -= (uint32)level;
  1484. if (sd->status.skill_point < level)
  1485. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1486. if (sd->status.skill_point < level)
  1487. sd->status.skill_point = 0;
  1488. else
  1489. sd->status.skill_point -= level;
  1490. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1491. level *=-1;
  1492. }
  1493. sd->status.job_exp = 0;
  1494. clif_updatestatus(*sd, SP_JOBLEVEL);
  1495. clif_updatestatus(*sd, SP_JOBEXP);
  1496. clif_updatestatus(*sd, SP_NEXTJOBEXP);
  1497. clif_updatestatus(*sd, SP_SKILLPOINT);
  1498. status_calc_pc(sd, SCO_FORCE);
  1499. if( level > 0 && battle_config.atcommand_levelup_events )
  1500. npc_script_event( *sd, NPCE_JOBLVUP );
  1501. return 0;
  1502. }
  1503. /*==========================================
  1504. * @help
  1505. *------------------------------------------*/
  1506. ACMD_FUNC(help){
  1507. const char *command_name = nullptr;
  1508. nullpo_retr(-1, sd);
  1509. if (!message || !*message) {
  1510. command_name = "help"; // If no command_name specified, display help for @help.
  1511. } else {
  1512. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1513. ++message;
  1514. command_name = atcommand_alias_db.checkAlias(message);
  1515. }
  1516. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1517. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1518. clif_displaymessage(fd, atcmd_output);
  1519. atcommand_get_suggestions(sd, command_name, true);
  1520. return -1;
  1521. }
  1522. // attempt to find the first default help command
  1523. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_name );
  1524. const char* text = info != nullptr ? info->help.c_str() : nullptr;
  1525. if( text == nullptr ){
  1526. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1527. clif_displaymessage(fd, atcmd_output);
  1528. atcommand_get_suggestions(sd, command_name, true);
  1529. return -1;
  1530. }
  1531. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1532. clif_displaymessage(fd, atcmd_output);
  1533. { // Display aliases
  1534. StringBuf buf;
  1535. bool has_aliases = false;
  1536. StringBuf_Init(&buf);
  1537. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1538. for( const std::string& alias : info->aliases ){
  1539. StringBuf_Printf( &buf, " %s", alias.c_str() );
  1540. has_aliases = true;
  1541. }
  1542. if (has_aliases)
  1543. clif_displaymessage(fd, StringBuf_Value(&buf));
  1544. StringBuf_Destroy(&buf);
  1545. }
  1546. // Display help contents
  1547. clif_displaymessage(fd, text);
  1548. return 0;
  1549. }
  1550. /*==========================================
  1551. *
  1552. *------------------------------------------*/
  1553. ACMD_FUNC(pvpoff)
  1554. {
  1555. nullpo_retr(-1, sd);
  1556. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1557. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1558. return -1;
  1559. }
  1560. map_setmapflag(sd->bl.m, MF_PVP, false);
  1561. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1562. return 0;
  1563. }
  1564. /*==========================================
  1565. *
  1566. *------------------------------------------*/
  1567. ACMD_FUNC(pvpon)
  1568. {
  1569. nullpo_retr(-1, sd);
  1570. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1571. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1572. return -1;
  1573. }
  1574. map_setmapflag(sd->bl.m, MF_PVP, true);
  1575. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1576. return 0;
  1577. }
  1578. /*==========================================
  1579. *
  1580. *------------------------------------------*/
  1581. ACMD_FUNC(gvgoff)
  1582. {
  1583. nullpo_retr(-1, sd);
  1584. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1585. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1586. return -1;
  1587. }
  1588. map_setmapflag(sd->bl.m, MF_GVG, false);
  1589. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1590. return 0;
  1591. }
  1592. /*==========================================
  1593. *
  1594. *------------------------------------------*/
  1595. ACMD_FUNC(gvgon)
  1596. {
  1597. nullpo_retr(-1, sd);
  1598. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1599. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1600. return -1;
  1601. }
  1602. map_setmapflag(sd->bl.m, MF_GVG, true);
  1603. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1604. return 0;
  1605. }
  1606. /*==========================================
  1607. *
  1608. *------------------------------------------*/
  1609. ACMD_FUNC(model)
  1610. {
  1611. int32 hair_style = 0, hair_color = 0, cloth_color = 0;
  1612. nullpo_retr(-1, sd);
  1613. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1614. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1615. 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>).
  1616. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1617. clif_displaymessage(fd, atcmd_output);
  1618. return -1;
  1619. }
  1620. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1621. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1622. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1623. pc_changelook(sd, LOOK_HAIR, hair_style);
  1624. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1625. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1626. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1627. } else {
  1628. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1629. return -1;
  1630. }
  1631. return 0;
  1632. }
  1633. /*==========================================
  1634. * @bodystyle [Rytech]
  1635. *------------------------------------------*/
  1636. ACMD_FUNC(bodystyle)
  1637. {
  1638. int32 body_style = 0;
  1639. nullpo_retr(-1, sd);
  1640. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1641. 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) {
  1642. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1643. return -1;
  1644. }
  1645. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1646. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1647. clif_displaymessage(fd, atcmd_output);
  1648. return -1;
  1649. }
  1650. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1651. pc_changelook(sd, LOOK_BODY2, body_style);
  1652. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1653. } else {
  1654. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1655. return -1;
  1656. }
  1657. return 0;
  1658. }
  1659. /*==========================================
  1660. * @dye && @ccolor
  1661. *------------------------------------------*/
  1662. ACMD_FUNC(dye)
  1663. {
  1664. int32 cloth_color = 0;
  1665. nullpo_retr(-1, sd);
  1666. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1667. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1668. 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>).
  1669. clif_displaymessage(fd, atcmd_output);
  1670. return -1;
  1671. }
  1672. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1673. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1674. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1675. } else {
  1676. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1677. return -1;
  1678. }
  1679. return 0;
  1680. }
  1681. /*==========================================
  1682. * @hairstyle && @hstyle
  1683. *------------------------------------------*/
  1684. ACMD_FUNC(hair_style)
  1685. {
  1686. int32 hair_style = 0;
  1687. nullpo_retr(-1, sd);
  1688. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1689. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1690. 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>).
  1691. clif_displaymessage(fd, atcmd_output);
  1692. return -1;
  1693. }
  1694. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1695. pc_changelook(sd, LOOK_HAIR, hair_style);
  1696. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1697. } else {
  1698. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1699. return -1;
  1700. }
  1701. return 0;
  1702. }
  1703. /*==========================================
  1704. * @haircolor && @hcolor
  1705. *------------------------------------------*/
  1706. ACMD_FUNC(hair_color)
  1707. {
  1708. int32 hair_color = 0;
  1709. nullpo_retr(-1, sd);
  1710. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1711. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1712. 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>).
  1713. clif_displaymessage(fd, atcmd_output);
  1714. return -1;
  1715. }
  1716. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1717. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1718. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1719. } else {
  1720. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1721. return -1;
  1722. }
  1723. return 0;
  1724. }
  1725. /*==========================================
  1726. * @go [city_number or city_name] - Updated by Harbin
  1727. *------------------------------------------*/
  1728. ACMD_FUNC(go)
  1729. {
  1730. int32 i;
  1731. int32 town;
  1732. char map_name[MAP_NAME_LENGTH];
  1733. const struct {
  1734. char map[MAP_NAME_LENGTH];
  1735. int32 x, y;
  1736. } data[] = {
  1737. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1738. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1739. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1740. { MAP_PAYON, 162, 233 }, // 3=Payon
  1741. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1742. #ifdef RENEWAL
  1743. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1744. #else
  1745. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1746. #endif
  1747. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1748. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1749. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1750. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1751. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1752. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1753. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1754. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1755. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1756. #ifdef RENEWAL
  1757. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1758. #else
  1759. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1760. #endif
  1761. { MAP_JAIL, 23, 61 }, // 16=Prison
  1762. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1763. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1764. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1765. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1766. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1767. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1768. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1769. { MAP_VEINS, 216, 123 }, // 24=Veins
  1770. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1771. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1772. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1773. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1774. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1775. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1776. { MAP_MORA, 44, 151 }, // 31=Mora
  1777. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1778. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1779. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1780. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1781. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1782. };
  1783. nullpo_retr(-1, sd);
  1784. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1785. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1786. return 0;
  1787. }
  1788. memset(map_name, '\0', sizeof(map_name));
  1789. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1790. // get the number
  1791. town = atoi(message);
  1792. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1793. {// no value matched so send the list of locations
  1794. const char* text;
  1795. // attempt to find the text help string
  1796. text = atcommand_help_string( command );
  1797. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1798. if( text )
  1799. {// send the text to the client
  1800. clif_displaymessage( fd, text );
  1801. }
  1802. return -1;
  1803. }
  1804. // get possible name of the city
  1805. map_name[MAP_NAME_LENGTH-1] = '\0';
  1806. for (i = 0; map_name[i]; i++)
  1807. map_name[i] = TOLOWER(map_name[i]);
  1808. // try to identify the map name
  1809. if (strncmp(map_name, "prontera", 3) == 0) {
  1810. town = 0;
  1811. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1812. strncmp(map_name, "morroc", 4) == 0) {
  1813. town = 1;
  1814. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1815. town = 2;
  1816. } else if (strncmp(map_name, "payon", 3) == 0) {
  1817. town = 3;
  1818. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1819. town = 4;
  1820. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1821. town = 5;
  1822. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1823. town = 6;
  1824. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1825. strcmp(map_name, "christmas") == 0 ||
  1826. strncmp(map_name, "xmas", 3) == 0 ||
  1827. strncmp(map_name, "x-mas", 3) == 0) {
  1828. town = 7;
  1829. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1830. town = 8;
  1831. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1832. strncmp(map_name, "yuno", 3) == 0) {
  1833. town = 9;
  1834. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1835. town = 10;
  1836. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1837. strncmp(map_name, "gonryun", 3) == 0) {
  1838. town = 11;
  1839. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1840. town = 12;
  1841. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1842. town = 13;
  1843. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1844. town = 14;
  1845. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1846. strncmp(map_name, "startpoint", 3) == 0 ||
  1847. strncmp(map_name, "beginning", 3) == 0) {
  1848. town = 15;
  1849. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1850. strncmp(map_name, "prison", 3) == 0 ||
  1851. strncmp(map_name, "jail", 3) == 0) {
  1852. town = 16;
  1853. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1854. town = 17;
  1855. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1856. town = 18;
  1857. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1858. town = 19;
  1859. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1860. town = 20;
  1861. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1862. town = 21;
  1863. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1864. town = 22;
  1865. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1866. town = 23;
  1867. } else if (strncmp(map_name, "veins", 3) == 0) {
  1868. town = 24;
  1869. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1870. town = 25;
  1871. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1872. town = 26;
  1873. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1874. town = 27;
  1875. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1876. town = 28;
  1877. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1878. town = 29;
  1879. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1880. town = 30;
  1881. } else if (strcmp(map_name, "mora") == 0) {
  1882. town = 31;
  1883. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1884. town = 32;
  1885. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1886. town = 33;
  1887. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1888. town = 34;
  1889. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1890. town = 35;
  1891. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1892. town = 36;
  1893. }
  1894. if (town >= 0 && town < ARRAYLENGTH(data))
  1895. {
  1896. int16 m = map_mapname2mapid(data[town].map);
  1897. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1898. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1899. return -1;
  1900. }
  1901. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1902. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1903. return -1;
  1904. }
  1905. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1906. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1907. } else {
  1908. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1909. return -1;
  1910. }
  1911. } else { // if you arrive here, you have an error in town variable when reading of names
  1912. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1913. return -1;
  1914. }
  1915. return 0;
  1916. }
  1917. /*==========================================
  1918. *
  1919. *------------------------------------------*/
  1920. ACMD_FUNC(monster)
  1921. {
  1922. char name[NAME_LENGTH];
  1923. char monster[NAME_LENGTH];
  1924. char eventname[EVENT_NAME_LENGTH] = "";
  1925. int32 mob_id;
  1926. int32 number = 0;
  1927. int32 count;
  1928. int32 i, range;
  1929. int16 mx, my;
  1930. uint32 size;
  1931. nullpo_retr(-1, sd);
  1932. memset(name, '\0', sizeof(name));
  1933. memset(monster, '\0', sizeof(monster));
  1934. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1935. if (!message || !*message) {
  1936. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1937. return -1;
  1938. }
  1939. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1940. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1941. //All data can be left as it is.
  1942. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1943. //Here, it is possible name was not given and we are using monster for it.
  1944. if (count < 3) //Blank mob's name.
  1945. name[0] = '\0';
  1946. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1947. //All data can be left as it is.
  1948. } else if (sscanf(message, "%23s", monster) > 0) {
  1949. //As before, name may be already filled.
  1950. name[0] = '\0';
  1951. } else {
  1952. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1953. return -1;
  1954. }
  1955. // If AegisName matches exactly, summon that monster
  1956. std::shared_ptr<s_mob_db> mob = mobdb_search_aegisname(monster);
  1957. if (mob != nullptr)
  1958. mob_id = mob->id;
  1959. else {
  1960. // Otherwise, search for monster with that ID or name
  1961. // Check for ID first as this is faster; if search string is not a number it will return 0
  1962. mob_id = util::strtoint32def(monster);
  1963. if (mob_id == 0 || mobdb_checkid(mob_id) == 0)
  1964. mob_id = mobdb_searchname(monster);
  1965. }
  1966. if (mob_id == 0) {
  1967. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1968. return -1;
  1969. }
  1970. if (mob_id == MOBID_EMPERIUM) {
  1971. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1972. return -1;
  1973. }
  1974. if (number <= 0)
  1975. number = 1;
  1976. if( !name[0] )
  1977. strcpy(name, "--ja--");
  1978. // 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
  1979. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1980. number = battle_config.atc_spawn_quantity_limit;
  1981. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  1982. if (strcmp(parent_cmd, "monstersmall") == 0)
  1983. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1984. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1985. size = SZ_BIG;
  1986. else
  1987. size = SZ_SMALL;
  1988. if (battle_config.etc_log)
  1989. 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);
  1990. count = 0;
  1991. range = (int32)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1992. for (i = 0; i < number; i++) {
  1993. int32 k;
  1994. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1995. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1996. if(k) {
  1997. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1998. count ++;
  1999. }
  2000. }
  2001. if (count != 0)
  2002. if (number == count)
  2003. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  2004. else {
  2005. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  2006. clif_displaymessage(fd, atcmd_output);
  2007. }
  2008. else {
  2009. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  2010. return -1;
  2011. }
  2012. return 0;
  2013. }
  2014. /*==========================================
  2015. *
  2016. *------------------------------------------*/
  2017. static int32 atkillmonster_sub(struct block_list *bl, va_list ap)
  2018. {
  2019. struct mob_data *md;
  2020. int32 flag;
  2021. nullpo_ret(md=(struct mob_data *)bl);
  2022. flag = va_arg(ap, int32);
  2023. if (md->guardian_data)
  2024. return 0; //Do not touch WoE mobs!
  2025. if (flag)
  2026. status_zap(bl,md->status.hp, 0);
  2027. else
  2028. status_kill(bl);
  2029. return 1;
  2030. }
  2031. ACMD_FUNC(killmonster)
  2032. {
  2033. int32 map_id, drop_flag;
  2034. char map_name[MAP_NAME_LENGTH_EXT];
  2035. nullpo_retr(-1, sd);
  2036. memset(map_name, '\0', sizeof(map_name));
  2037. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  2038. map_id = sd->bl.m;
  2039. else {
  2040. if ((map_id = map_mapname2mapid(map_name)) < 0)
  2041. map_id = sd->bl.m;
  2042. }
  2043. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  2044. drop_flag = strcmpi(parent_cmd, "killmonster2");
  2045. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  2046. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  2047. return 0;
  2048. }
  2049. /*==========================================
  2050. *
  2051. *------------------------------------------*/
  2052. ACMD_FUNC(refine)
  2053. {
  2054. int32 j, position = 0, refine = 0, current_position, final_refine;
  2055. int32 count;
  2056. nullpo_retr(-1, sd);
  2057. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2058. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  2059. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  2060. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2061. clif_displaymessage(fd, atcmd_output);
  2062. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2063. clif_displaymessage(fd, atcmd_output);
  2064. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2065. clif_displaymessage(fd, atcmd_output);
  2066. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2067. clif_displaymessage(fd, atcmd_output);
  2068. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2069. clif_displaymessage(fd, atcmd_output);
  2070. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2071. clif_displaymessage(fd, atcmd_output);
  2072. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2073. clif_displaymessage(fd, atcmd_output);
  2074. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2075. clif_displaymessage(fd, atcmd_output);
  2076. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2077. clif_displaymessage(fd, atcmd_output);
  2078. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2079. clif_displaymessage(fd, atcmd_output);
  2080. sprintf(atcmd_output, msg_txt(sd,1521), EQP_SHADOW_ARMOR); // %d: Shadow Armor
  2081. clif_displaymessage(fd, atcmd_output);
  2082. sprintf(atcmd_output, msg_txt(sd,1522), EQP_SHADOW_WEAPON); // %d: Shadow Weapon
  2083. clif_displaymessage(fd, atcmd_output);
  2084. sprintf(atcmd_output, msg_txt(sd,1523), EQP_SHADOW_SHIELD); // %d: Shadow Shield
  2085. clif_displaymessage(fd, atcmd_output);
  2086. sprintf(atcmd_output, msg_txt(sd,1524), EQP_SHADOW_SHOES); // %d: Shadow Shoes
  2087. clif_displaymessage(fd, atcmd_output);
  2088. sprintf(atcmd_output, msg_txt(sd,1525), EQP_SHADOW_ACC_R); // %d: Shadow Right Accessory
  2089. clif_displaymessage(fd, atcmd_output);
  2090. sprintf(atcmd_output, msg_txt(sd,1526), EQP_SHADOW_ACC_L); // %d: Shadow Left Accessory
  2091. clif_displaymessage(fd, atcmd_output);
  2092. return -1;
  2093. }
  2094. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  2095. count = 0;
  2096. for (j = 0; j < EQI_MAX; j++) {
  2097. int32 i;
  2098. if ((i = sd->equip_index[j]) < 0)
  2099. continue;
  2100. if(j == EQI_AMMO)
  2101. continue;
  2102. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2103. continue;
  2104. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2105. continue;
  2106. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  2107. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  2108. sd->inventory.u.items_inventory[i].refine = final_refine;
  2109. current_position = sd->inventory.u.items_inventory[i].equip;
  2110. pc_unequipitem(sd, i, 3);
  2111. clif_refine( *sd, i, ITEMREFINING_SUCCESS );
  2112. clif_delitem( *sd, i, 1, 3 );
  2113. clif_additem(sd, i, 1, 0);
  2114. pc_equipitem(sd, i, current_position);
  2115. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2116. if( sd->inventory_data[i]->type == IT_WEAPON ){
  2117. achievement_update_objective(sd, AG_ENCHANT_SUCCESS, 2, sd->inventory_data[i]->weapon_level, sd->inventory.u.items_inventory[i].refine);
  2118. }
  2119. count++;
  2120. }
  2121. }
  2122. if (count == 0)
  2123. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  2124. else if (count == 1)
  2125. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  2126. else {
  2127. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  2128. clif_displaymessage(fd, atcmd_output);
  2129. }
  2130. return 0;
  2131. }
  2132. /*==========================================
  2133. *
  2134. *------------------------------------------*/
  2135. ACMD_FUNC(grade)
  2136. {
  2137. int32 j, position = 0, grade = 0, current_position, final_grade;
  2138. int32 count;
  2139. nullpo_retr(-1, sd);
  2140. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2141. if (!message || !*message || sscanf(message, "%11d %11d", &position, &grade) < 2) {
  2142. clif_displaymessage(fd, msg_txt(sd,1519)); // Please enter a position and an amount (usage: @grade <equip position> <+/- amount>).
  2143. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  2144. clif_displaymessage(fd, atcmd_output);
  2145. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  2146. clif_displaymessage(fd, atcmd_output);
  2147. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  2148. clif_displaymessage(fd, atcmd_output);
  2149. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  2150. clif_displaymessage(fd, atcmd_output);
  2151. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  2152. clif_displaymessage(fd, atcmd_output);
  2153. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  2154. clif_displaymessage(fd, atcmd_output);
  2155. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  2156. clif_displaymessage(fd, atcmd_output);
  2157. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  2158. clif_displaymessage(fd, atcmd_output);
  2159. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  2160. clif_displaymessage(fd, atcmd_output);
  2161. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  2162. clif_displaymessage(fd, atcmd_output);
  2163. return -1;
  2164. }
  2165. grade = cap_value(grade, -MAX_ENCHANTGRADE, MAX_ENCHANTGRADE);
  2166. count = 0;
  2167. for (j = 0; j < EQI_MAX; j++) {
  2168. int32 i;
  2169. if ((i = sd->equip_index[j]) < 0)
  2170. continue;
  2171. if(j == EQI_AMMO)
  2172. continue;
  2173. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  2174. continue;
  2175. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  2176. continue;
  2177. final_grade = cap_value(sd->inventory.u.items_inventory[i].enchantgrade + grade, 0, MAX_ENCHANTGRADE);
  2178. if (sd->inventory.u.items_inventory[i].enchantgrade != final_grade) {
  2179. sd->inventory.u.items_inventory[i].enchantgrade = final_grade;
  2180. current_position = sd->inventory.u.items_inventory[i].equip;
  2181. pc_unequipitem(sd, i, 3);
  2182. clif_delitem( *sd, i, 1, 3 );
  2183. clif_additem(sd, i, 1, 0);
  2184. pc_equipitem(sd, i, current_position);
  2185. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2186. count++;
  2187. }
  2188. }
  2189. sprintf(atcmd_output, msg_txt(sd,1520), count); // %d items have been graded.
  2190. clif_displaymessage(fd, atcmd_output);
  2191. return 0;
  2192. }
  2193. /*==========================================
  2194. *
  2195. *------------------------------------------*/
  2196. ACMD_FUNC(produce)
  2197. {
  2198. char item_name[100];
  2199. t_itemid item_id;
  2200. int32 attribute = 0, star = 0;
  2201. nullpo_retr(-1, sd);
  2202. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2203. memset(item_name, '\0', sizeof(item_name));
  2204. if (!message || !*message || (
  2205. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2206. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2207. )) {
  2208. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2209. return -1;
  2210. }
  2211. std::shared_ptr<item_data> item_data = item_db.searchname( item_name );
  2212. if( item_data == nullptr ){
  2213. item_data = item_db.find( strtoul( item_name, nullptr, 10 ) );
  2214. }
  2215. if( item_data == nullptr ){
  2216. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2217. return -1;
  2218. }
  2219. item_id = item_data->nameid;
  2220. if( itemdb_isequip2( item_data.get() ) ){
  2221. char flag = 0;
  2222. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2223. attribute = ATTRIBUTE_NORMAL;
  2224. if (star < MIN_STAR || star > MAX_STAR)
  2225. star = 0;
  2226. struct item tmp_item = {};
  2227. tmp_item.nameid = item_id;
  2228. tmp_item.amount = 1;
  2229. tmp_item.identify = 1;
  2230. tmp_item.card[0] = CARD0_FORGE;
  2231. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2232. ((star*5) << 8) + attribute:0;
  2233. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2234. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2235. clif_produceeffect(sd, 0, item_id);
  2236. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  2237. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2238. clif_additem(sd, 0, 0, flag);
  2239. } else {
  2240. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name.c_str()); // The item (%u: '%s') is not equipable.
  2241. clif_displaymessage(fd, atcmd_output);
  2242. return -1;
  2243. }
  2244. return 0;
  2245. }
  2246. /*==========================================
  2247. *
  2248. *------------------------------------------*/
  2249. ACMD_FUNC(memo)
  2250. {
  2251. int32 position = 0;
  2252. nullpo_retr(-1, sd);
  2253. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2254. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2255. {
  2256. int32 i;
  2257. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2258. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2259. {
  2260. if( strcmp( "", sd->status.memo_point[i].map ) != 0 )
  2261. 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 );
  2262. else
  2263. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2264. clif_displaymessage(sd->fd, atcmd_output);
  2265. }
  2266. return 0;
  2267. }
  2268. if( position < 0 || position >= MAX_MEMOPOINTS )
  2269. {
  2270. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2271. clif_displaymessage(fd, atcmd_output);
  2272. return -1;
  2273. }
  2274. return !pc_memo( sd, position );
  2275. }
  2276. /*==========================================
  2277. *
  2278. *------------------------------------------*/
  2279. ACMD_FUNC(gat)
  2280. {
  2281. int32 y;
  2282. nullpo_retr(-1, sd);
  2283. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2284. for (y = 2; y >= -2; y--) {
  2285. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2286. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2287. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2288. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2289. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2290. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2291. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2292. clif_displaymessage(fd, atcmd_output);
  2293. }
  2294. return 0;
  2295. }
  2296. /*==========================================
  2297. *
  2298. *------------------------------------------*/
  2299. ACMD_FUNC(displaystatus)
  2300. {
  2301. int32 i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2302. nullpo_retr(-1, sd);
  2303. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2304. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2305. return -1;
  2306. }
  2307. if (i < 2) flag = 1;
  2308. if (i < 3) tick = 0;
  2309. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2310. return 0;
  2311. }
  2312. /*==========================================
  2313. * @stpoint (Rewritten by [Yor])
  2314. *------------------------------------------*/
  2315. ACMD_FUNC(statuspoint)
  2316. {
  2317. int32 point;
  2318. uint32 new_status_point;
  2319. if (!message || !*message || (point = atoi(message)) == 0) {
  2320. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2321. return -1;
  2322. }
  2323. if(point < 0)
  2324. {
  2325. if(sd->status.status_point < (uint32)(-point))
  2326. {
  2327. new_status_point = 0;
  2328. }
  2329. else
  2330. {
  2331. new_status_point = sd->status.status_point + point;
  2332. }
  2333. }
  2334. else if(UINT_MAX - sd->status.status_point < (uint32)point)
  2335. {
  2336. new_status_point = UINT_MAX;
  2337. }
  2338. else
  2339. {
  2340. new_status_point = sd->status.status_point + point;
  2341. }
  2342. if (new_status_point != sd->status.status_point) {
  2343. sd->status.status_point = new_status_point;
  2344. clif_updatestatus(*sd, SP_STATUSPOINT);
  2345. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2346. } else {
  2347. if (point < 0)
  2348. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2349. else
  2350. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2351. return -1;
  2352. }
  2353. return 0;
  2354. }
  2355. /*==========================================
  2356. * @trpoint
  2357. *------------------------------------------*/
  2358. ACMD_FUNC(traitpoint)
  2359. {
  2360. int32 point;
  2361. uint32 new_trait_point;
  2362. if (!message || !*message || (point = atoi(message)) == 0) {
  2363. clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
  2364. return -1;
  2365. }
  2366. if (point < 0)
  2367. {
  2368. if (sd->status.trait_point < (uint32)(-point))
  2369. {
  2370. new_trait_point = 0;
  2371. }
  2372. else
  2373. {
  2374. new_trait_point = sd->status.trait_point + point;
  2375. }
  2376. }
  2377. else if (UINT_MAX - sd->status.trait_point < (uint32)point)
  2378. {
  2379. new_trait_point = UINT_MAX;
  2380. }
  2381. else
  2382. {
  2383. new_trait_point = sd->status.trait_point + point;
  2384. }
  2385. if (new_trait_point != sd->status.trait_point) {
  2386. sd->status.trait_point = new_trait_point;
  2387. clif_updatestatus(*sd, SP_TRAITPOINT);
  2388. clif_displaymessage(fd, msg_txt(sd, 174)); // Number of status points changed.
  2389. }
  2390. else {
  2391. if (point < 0)
  2392. clif_displaymessage(fd, msg_txt(sd, 41)); // Unable to decrease the number/value.
  2393. else
  2394. clif_displaymessage(fd, msg_txt(sd, 149)); // Unable to increase the number/value.
  2395. return -1;
  2396. }
  2397. return 0;
  2398. }
  2399. /*==========================================
  2400. * @skpoint (Rewritten by [Yor])
  2401. *------------------------------------------*/
  2402. ACMD_FUNC(skillpoint)
  2403. {
  2404. int32 point;
  2405. uint32 new_skill_point;
  2406. nullpo_retr(-1, sd);
  2407. if (!message || !*message || (point = atoi(message)) == 0) {
  2408. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2409. return -1;
  2410. }
  2411. if(point < 0)
  2412. {
  2413. if(sd->status.skill_point < (uint32)(-point))
  2414. {
  2415. new_skill_point = 0;
  2416. }
  2417. else
  2418. {
  2419. new_skill_point = sd->status.skill_point + point;
  2420. }
  2421. }
  2422. else if(UINT_MAX - sd->status.skill_point < (uint32)point)
  2423. {
  2424. new_skill_point = UINT_MAX;
  2425. }
  2426. else
  2427. {
  2428. new_skill_point = sd->status.skill_point + point;
  2429. }
  2430. if (new_skill_point != sd->status.skill_point) {
  2431. sd->status.skill_point = new_skill_point;
  2432. clif_updatestatus(*sd, SP_SKILLPOINT);
  2433. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2434. } else {
  2435. if (point < 0)
  2436. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2437. else
  2438. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2439. return -1;
  2440. }
  2441. return 0;
  2442. }
  2443. /*==========================================
  2444. * @zeny
  2445. *------------------------------------------*/
  2446. ACMD_FUNC(zeny)
  2447. {
  2448. int32 zeny=0, ret=-1;
  2449. nullpo_retr(-1, sd);
  2450. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2451. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2452. return -1;
  2453. }
  2454. if(zeny > 0){
  2455. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
  2456. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2457. }
  2458. else {
  2459. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2460. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
  2461. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2462. }
  2463. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2464. return 0;
  2465. }
  2466. /*==========================================
  2467. *
  2468. *------------------------------------------*/
  2469. ACMD_FUNC(param)
  2470. {
  2471. nullpo_retr(-1, sd);
  2472. uint8 stat;
  2473. int32 value = 0;
  2474. uint16 new_value, status, max_status;
  2475. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2476. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2477. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2478. return -1;
  2479. }
  2480. ARR_FIND( 0, ARRAYLENGTH(parameter_names), stat, strcmpi(command + 1, parameter_names[stat]) == 0 );
  2481. if( stat == ARRAYLENGTH(parameter_names)) { // normally impossible...
  2482. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2483. return -1;
  2484. }
  2485. if( stat < PARAM_POW ){
  2486. status = pc_getstat( sd, SP_STR + stat - PARAM_STR );
  2487. }else{
  2488. if( !( sd->class_ & JOBL_FOURTH ) ){
  2489. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2490. return -1;
  2491. }
  2492. status = pc_getstat( sd, SP_POW + stat - PARAM_POW );
  2493. }
  2494. if( pc_has_permission( sd, PC_PERM_BYPASS_MAX_STAT ) ){
  2495. max_status = SHRT_MAX;
  2496. }else{
  2497. max_status = pc_maxparameter( sd, static_cast<e_params>( stat ) );
  2498. }
  2499. if( value > 0 && status + value >= max_status ){
  2500. new_value = max_status;
  2501. }else if( value < 0 && abs( value ) >= status ){
  2502. if( stat < PARAM_POW ){
  2503. new_value = 1;
  2504. }else{
  2505. new_value = 0;
  2506. }
  2507. }else{
  2508. new_value = status + value;
  2509. }
  2510. if( new_value != status ){
  2511. if (stat < PARAM_POW) {
  2512. pc_setstat( sd, SP_STR + stat - PARAM_STR, new_value );
  2513. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + stat ) );
  2514. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + stat ) );
  2515. } else {
  2516. pc_setstat( sd, SP_POW + stat - PARAM_POW, new_value );
  2517. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + stat - PARAM_POW ) );
  2518. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + stat - PARAM_POW ) );
  2519. }
  2520. status_calc_pc(sd, SCO_FORCE);
  2521. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2522. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2523. } else {
  2524. if (value < 0)
  2525. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2526. else
  2527. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2528. return -1;
  2529. }
  2530. return 0;
  2531. }
  2532. /*==========================================
  2533. * Stat all by fritz (rewritten by [Yor])
  2534. *------------------------------------------*/
  2535. ACMD_FUNC(stat_all)
  2536. {
  2537. nullpo_retr(-1, sd);
  2538. int32 value = 0;
  2539. uint8 count, i;
  2540. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2541. for (i = PARAM_STR; i < PARAM_POW; i++)
  2542. status[i] = pc_getstat(sd, SP_STR + i);
  2543. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2544. for (i = PARAM_STR; i < PARAM_POW; i++)
  2545. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2546. value = SHRT_MAX;
  2547. } else {
  2548. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2549. for (i = PARAM_STR; i < PARAM_POW; i++)
  2550. max_status[i] = SHRT_MAX;
  2551. } else {
  2552. for (i = PARAM_STR; i < PARAM_POW; i++)
  2553. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2554. }
  2555. }
  2556. count = 0;
  2557. for (i = PARAM_STR; i < PARAM_POW; i++) {
  2558. int16 new_value;
  2559. if (value > 0 && status[i] + value >= max_status[i])
  2560. new_value = max_status[i];
  2561. else if (value < 0 && abs(value) >= status[i])
  2562. new_value = 1;
  2563. else
  2564. new_value = status[i] + value;
  2565. if (new_value != status[i]) {
  2566. pc_setstat( sd, SP_STR + i, new_value );
  2567. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  2568. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  2569. count++;
  2570. }
  2571. }
  2572. if (count > 0) { // if at least 1 stat modified
  2573. status_calc_pc(sd, SCO_FORCE);
  2574. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2575. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2576. } else {
  2577. if (value < 0)
  2578. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2579. else
  2580. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2581. return -1;
  2582. }
  2583. return 0;
  2584. }
  2585. /*==========================================
  2586. * Traits
  2587. *------------------------------------------*/
  2588. ACMD_FUNC(trait_all) {
  2589. nullpo_retr(-1, sd);
  2590. #ifndef RENEWAL
  2591. sprintf(atcmd_output, msg_txt(sd, 154), command); // %s failed.
  2592. clif_displaymessage(fd, atcmd_output);
  2593. return -1;
  2594. #endif
  2595. if( !( sd->class_ & JOBL_FOURTH ) ){
  2596. clif_displaymessage(fd, msg_txt(sd, 797)); // This command is unavailable to non - 4th class.
  2597. return -1;
  2598. }
  2599. int32 value = 0;
  2600. uint8 i;
  2601. uint16 status[PARAM_MAX] = {}, max_status[PARAM_MAX] = {};
  2602. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2603. status[i] = pc_getstat(sd, SP_POW + i - PARAM_POW);
  2604. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2605. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2606. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2607. value = SHRT_MAX;
  2608. } else {
  2609. if (pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT)) {
  2610. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2611. max_status[i] = SHRT_MAX;
  2612. } else {
  2613. for (i = PARAM_POW; i < PARAM_MAX; i++)
  2614. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  2615. }
  2616. }
  2617. uint8 count = 0;
  2618. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  2619. int16 new_value;
  2620. if (value > 0 && status[i] + value >= max_status[i])
  2621. new_value = max_status[i];
  2622. else if (value < 0 && abs(value) >= status[i])
  2623. new_value = 0;
  2624. else
  2625. new_value = status[i] + value;
  2626. if (new_value != status[i]) {
  2627. pc_setstat( sd, SP_POW + i - PARAM_POW, new_value );
  2628. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  2629. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  2630. count++;
  2631. }
  2632. }
  2633. if (count > 0) { // if at least 1 stat modified
  2634. status_calc_pc(sd, SCO_FORCE);
  2635. clif_displaymessage(fd, msg_txt(sd, 84)); // All stats changed!
  2636. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2637. } else {
  2638. if (value < 0)
  2639. clif_displaymessage(fd, msg_txt(sd, 177)); // You cannot decrease that stat anymore.
  2640. else
  2641. clif_displaymessage(fd, msg_txt(sd, 178)); // You cannot increase that stat anymore.
  2642. return -1;
  2643. }
  2644. return 0;
  2645. }
  2646. /*==========================================
  2647. *
  2648. *------------------------------------------*/
  2649. ACMD_FUNC(guildlevelup) {
  2650. int32 level = 0;
  2651. int16 added_level;
  2652. nullpo_retr(-1, sd);
  2653. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2654. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2655. return -1;
  2656. }
  2657. auto &guild_info = sd->guild;
  2658. if (sd->status.guild_id <= 0 || guild_info == nullptr) {
  2659. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2660. return -1;
  2661. }
  2662. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2663. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2664. // return -1;
  2665. //}
  2666. added_level = (int16)level;
  2667. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((int16)MAX_GUILDLEVEL - guild_info->guild.guild_lv))) // fix positive overflow
  2668. added_level = (int16)MAX_GUILDLEVEL - guild_info->guild.guild_lv;
  2669. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild.guild_lv))) // fix negative overflow
  2670. added_level = 1 - guild_info->guild.guild_lv;
  2671. if (added_level != 0) {
  2672. intif_guild_change_basicinfo(guild_info->guild.guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2673. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2674. } else {
  2675. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2676. return -1;
  2677. }
  2678. return 0;
  2679. }
  2680. /*==========================================
  2681. *
  2682. *------------------------------------------*/
  2683. ACMD_FUNC(makeegg) {
  2684. int32 id;
  2685. nullpo_retr(-1, sd);
  2686. if (!message || !*message) {
  2687. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2688. return -1;
  2689. }
  2690. // for monster name
  2691. if ((id = mobdb_searchname(message)) != 0)
  2692. ;
  2693. else
  2694. id = atoi(message);
  2695. std::shared_ptr<s_pet_db> pet = pet_db.find(id);
  2696. if( pet == nullptr ){
  2697. t_itemid nameid;
  2698. // for egg name
  2699. std::shared_ptr<item_data> item_data = item_db.searchname( message );
  2700. if( item_data != nullptr ){
  2701. nameid = item_data->nameid;
  2702. }else{
  2703. nameid = strtoul( message, nullptr, 10 );
  2704. }
  2705. pet = pet_db_search( nameid, PET_EGG );
  2706. }
  2707. int32 res(-1);
  2708. if (pet != nullptr) {
  2709. std::shared_ptr<s_mob_db> mdb = mob_db.find(pet->class_);
  2710. if(mdb){
  2711. 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())){
  2712. res = 0;
  2713. } else {
  2714. res = -2; //char server down
  2715. }
  2716. }
  2717. }
  2718. switch(res){
  2719. case -1:
  2720. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2721. break;
  2722. case -2:
  2723. clif_displaymessage(fd, msg_txt(sd,407)); //charserver link broken
  2724. break;
  2725. }
  2726. return res;
  2727. }
  2728. /*==========================================
  2729. *
  2730. *------------------------------------------*/
  2731. ACMD_FUNC(hatch) {
  2732. nullpo_retr(-1, sd);
  2733. if (sd->status.pet_id <= 0)
  2734. clif_sendegg(sd);
  2735. else {
  2736. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2737. return -1;
  2738. }
  2739. return 0;
  2740. }
  2741. /*==========================================
  2742. *
  2743. *------------------------------------------*/
  2744. ACMD_FUNC(petfriendly) {
  2745. int32 friendly;
  2746. struct pet_data *pd;
  2747. nullpo_retr(-1, sd);
  2748. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2749. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2750. return -1;
  2751. }
  2752. pd = sd->pd;
  2753. if (!pd) {
  2754. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2755. return -1;
  2756. }
  2757. if (friendly < 0 || friendly > 1000)
  2758. {
  2759. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2760. return -1;
  2761. }
  2762. if (friendly == pd->pet.intimate) {
  2763. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2764. return -1;
  2765. }
  2766. pet_set_intimate(pd, friendly);
  2767. clif_send_petstatus( *sd, *pd );
  2768. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2769. return 0;
  2770. }
  2771. /*==========================================
  2772. *
  2773. *------------------------------------------*/
  2774. ACMD_FUNC(pethungry)
  2775. {
  2776. int32 hungry;
  2777. struct pet_data *pd;
  2778. nullpo_retr(-1, sd);
  2779. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2780. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2781. return -1;
  2782. }
  2783. pd = sd->pd;
  2784. if (!sd->status.pet_id || !pd) {
  2785. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2786. return -1;
  2787. }
  2788. if (hungry < 0 || hungry > 100) {
  2789. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2790. return -1;
  2791. }
  2792. if (hungry == pd->pet.hungry) {
  2793. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2794. return -1;
  2795. }
  2796. pd->pet.hungry = hungry;
  2797. clif_send_petstatus( *sd, *pd );
  2798. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2799. return 0;
  2800. }
  2801. /*==========================================
  2802. *
  2803. *------------------------------------------*/
  2804. ACMD_FUNC(petrename)
  2805. {
  2806. struct pet_data *pd;
  2807. nullpo_retr(-1, sd);
  2808. if (!sd->status.pet_id || !sd->pd) {
  2809. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2810. return -1;
  2811. }
  2812. pd = sd->pd;
  2813. if (!pd->pet.rename_flag) {
  2814. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2815. return -1;
  2816. }
  2817. pd->pet.rename_flag = 0;
  2818. intif_save_petdata(sd->status.account_id, &pd->pet);
  2819. clif_send_petstatus( *sd, *pd );
  2820. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2821. return 0;
  2822. }
  2823. /*==========================================
  2824. *
  2825. *------------------------------------------*/
  2826. ACMD_FUNC(recall) {
  2827. map_session_data* pl_sd = nullptr;;
  2828. nullpo_retr(-1, sd);
  2829. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2830. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2831. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2832. return -1;
  2833. }
  2834. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  2835. {
  2836. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2837. return -1;
  2838. }
  2839. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2840. {
  2841. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  2842. return -1;
  2843. }
  2844. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2845. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2846. return -1;
  2847. }
  2848. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2849. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2850. return -1;
  2851. }
  2852. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2853. return -1;
  2854. }
  2855. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2856. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2857. return -1;
  2858. }
  2859. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2860. clif_displaymessage(fd, atcmd_output);
  2861. return 0;
  2862. }
  2863. /*==========================================
  2864. * charblock command (usage: charblock <player_name>)
  2865. * This command do a definitiv ban on a player
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(char_block)
  2868. {
  2869. nullpo_retr(-1, sd);
  2870. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2871. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2872. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2873. clif_displaymessage(fd, atcmd_output);
  2874. return -1;
  2875. }
  2876. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2877. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2878. clif_displaymessage(fd, atcmd_output);
  2879. return 0;
  2880. }
  2881. /*==========================================
  2882. * accountban command (usage: ban <%time> <player_name>)
  2883. * %time see common/timer.cpp::solve_time()
  2884. *------------------------------------------*/
  2885. ACMD_FUNC(ban)
  2886. {
  2887. char *modif_p, output[CHAT_SIZE_MAX];
  2888. int32 timediff = 0; //don't set this as uint32 as we may want to decrease banned time
  2889. nullpo_retr(-1, sd);
  2890. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2891. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2892. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2893. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2894. clif_displaymessage(fd, output);
  2895. return -1;
  2896. }
  2897. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2898. modif_p = atcmd_output;
  2899. timediff = (int32)solve_time(modif_p); //discard seconds
  2900. if (timediff == 0) { //allow negative ?
  2901. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2902. clif_displaymessage(fd, output);
  2903. 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.
  2904. return -1;
  2905. }
  2906. if( timediff < 0 ){
  2907. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2908. return -1;
  2909. }
  2910. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BAN, timediff, 0, 0);
  2911. safesnprintf(output, sizeof(output), msg_txt(sd,88), "login"); // Sending request to %s server...
  2912. clif_displaymessage(fd, output);
  2913. return 0;
  2914. }
  2915. /*==========================================
  2916. * charban command (usage: charban <%time> <player_name>)
  2917. * %time see common/timer.cpp::solve_time()
  2918. *------------------------------------------*/
  2919. ACMD_FUNC(char_ban)
  2920. {
  2921. char *modif_p, output[CHAT_SIZE_MAX];
  2922. int32 timediff = 0; //don't set this as uint32 as we may want to decrease banned time
  2923. nullpo_retr(-1, sd);
  2924. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2925. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2926. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2927. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2928. clif_displaymessage(fd, output);
  2929. return -1;
  2930. }
  2931. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2932. modif_p = atcmd_output;
  2933. timediff = (int32)solve_time(modif_p); //discard seconds
  2934. if (timediff == 0) { //allow negative ?
  2935. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2936. clif_displaymessage(fd, output);
  2937. 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.
  2938. return -1;
  2939. }
  2940. if( timediff < 0 ){
  2941. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2942. return -1;
  2943. }
  2944. chrif_req_charban( sd->status.account_id, atcmd_player_name, timediff );
  2945. safesnprintf(output, sizeof(output), msg_txt(sd,88), "char"); // Sending request to %s server...
  2946. clif_displaymessage(fd, output);
  2947. return 0;
  2948. }
  2949. /*==========================================
  2950. * charunblock command (usage: charunblock <player_name>)
  2951. *------------------------------------------*/
  2952. ACMD_FUNC(char_unblock)
  2953. {
  2954. nullpo_retr(-1, sd);
  2955. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2956. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2957. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2958. clif_displaymessage(fd, atcmd_output);
  2959. return -1;
  2960. }
  2961. // send answer to login server via char-server
  2962. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2963. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2964. clif_displaymessage(fd, atcmd_output);
  2965. return 0;
  2966. }
  2967. /*==========================================
  2968. * acc unban command (usage: unban <player_name>)
  2969. *------------------------------------------*/
  2970. ACMD_FUNC(unban){
  2971. nullpo_retr(-1, sd);
  2972. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2973. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2974. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2975. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2976. clif_displaymessage(fd, atcmd_output);
  2977. return -1;
  2978. }
  2979. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBAN, 0, 0, 0);
  2980. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2981. clif_displaymessage(fd, atcmd_output);
  2982. return 0;
  2983. }
  2984. /*==========================================
  2985. * char unban command (usage: charunban <player_name>)
  2986. *------------------------------------------*/
  2987. ACMD_FUNC(char_unban){
  2988. nullpo_retr(-1, sd);
  2989. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2990. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2991. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2992. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2993. clif_displaymessage(fd, atcmd_output);
  2994. return -1;
  2995. }
  2996. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2997. sprintf(atcmd_output, msg_txt(sd,88), "char"); // Sending request to %s server...
  2998. clif_displaymessage(fd, atcmd_output);
  2999. return 0;
  3000. }
  3001. /*==========================================
  3002. *
  3003. *------------------------------------------*/
  3004. ACMD_FUNC(night)
  3005. {
  3006. nullpo_retr(-1, sd);
  3007. if (night_flag != 1) {
  3008. map_night_timer(night_timer_tid, 0, 0, 1);
  3009. } else {
  3010. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  3011. return -1;
  3012. }
  3013. return 0;
  3014. }
  3015. /*==========================================
  3016. *
  3017. *------------------------------------------*/
  3018. ACMD_FUNC(day)
  3019. {
  3020. nullpo_retr(-1, sd);
  3021. if (night_flag != 0) {
  3022. map_day_timer(day_timer_tid, 0, 0, 1);
  3023. } else {
  3024. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  3025. return -1;
  3026. }
  3027. return 0;
  3028. }
  3029. /*==========================================
  3030. *
  3031. *------------------------------------------*/
  3032. ACMD_FUNC(doom)
  3033. {
  3034. map_session_data* pl_sd;
  3035. struct s_mapiterator* iter;
  3036. nullpo_retr(-1, sd);
  3037. iter = mapit_getallusers();
  3038. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3039. {
  3040. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3041. {
  3042. status_kill(&pl_sd->bl);
  3043. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3044. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3045. }
  3046. }
  3047. mapit_free(iter);
  3048. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3049. return 0;
  3050. }
  3051. /*==========================================
  3052. *
  3053. *------------------------------------------*/
  3054. ACMD_FUNC(doommap)
  3055. {
  3056. map_session_data* pl_sd;
  3057. struct s_mapiterator* iter;
  3058. nullpo_retr(-1, sd);
  3059. iter = mapit_getallusers();
  3060. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3061. {
  3062. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3063. {
  3064. status_kill(&pl_sd->bl);
  3065. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  3066. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  3067. }
  3068. }
  3069. mapit_free(iter);
  3070. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  3071. return 0;
  3072. }
  3073. /*==========================================
  3074. *
  3075. *------------------------------------------*/
  3076. static void atcommand_raise_sub(map_session_data* sd) {
  3077. status_revive(&sd->bl, 100, 100);
  3078. clif_skill_nodamage(&sd->bl,sd->bl,ALL_RESURRECTION,4);
  3079. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  3080. }
  3081. /*==========================================
  3082. *
  3083. *------------------------------------------*/
  3084. ACMD_FUNC(raise)
  3085. {
  3086. map_session_data* pl_sd;
  3087. struct s_mapiterator* iter;
  3088. nullpo_retr(-1, sd);
  3089. iter = mapit_getallusers();
  3090. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3091. if( pc_isdead(pl_sd) )
  3092. atcommand_raise_sub(pl_sd);
  3093. mapit_free(iter);
  3094. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3095. return 0;
  3096. }
  3097. /*==========================================
  3098. *
  3099. *------------------------------------------*/
  3100. ACMD_FUNC(raisemap)
  3101. {
  3102. map_session_data* pl_sd;
  3103. struct s_mapiterator* iter;
  3104. nullpo_retr(-1, sd);
  3105. iter = mapit_getallusers();
  3106. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3107. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  3108. atcommand_raise_sub(pl_sd);
  3109. mapit_free(iter);
  3110. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  3111. return 0;
  3112. }
  3113. /*==========================================
  3114. *
  3115. *------------------------------------------*/
  3116. ACMD_FUNC(kick)
  3117. {
  3118. map_session_data *pl_sd;
  3119. nullpo_retr(-1, sd);
  3120. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3121. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3122. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  3123. return -1;
  3124. }
  3125. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
  3126. {
  3127. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3128. return -1;
  3129. }
  3130. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  3131. {
  3132. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3133. return -1;
  3134. }
  3135. clif_GM_kick(sd, pl_sd);
  3136. return 0;
  3137. }
  3138. /*==========================================
  3139. *
  3140. *------------------------------------------*/
  3141. ACMD_FUNC(kickall)
  3142. {
  3143. map_session_data* pl_sd;
  3144. struct s_mapiterator* iter;
  3145. nullpo_retr(-1, sd);
  3146. iter = mapit_getallusers();
  3147. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3148. {
  3149. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  3150. if (sd->status.account_id != pl_sd->status.account_id)
  3151. clif_GM_kick(nullptr, pl_sd);
  3152. }
  3153. }
  3154. mapit_free(iter);
  3155. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  3156. return 0;
  3157. }
  3158. /*==========================================
  3159. *
  3160. *------------------------------------------*/
  3161. ACMD_FUNC(allskill)
  3162. {
  3163. nullpo_retr(-1, sd);
  3164. pc_allskillup(sd); // all skills
  3165. sd->status.skill_point = 0; // 0 skill points
  3166. clif_updatestatus(*sd, SP_SKILLPOINT); // update
  3167. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  3168. return 0;
  3169. }
  3170. /*==========================================
  3171. *
  3172. *------------------------------------------*/
  3173. ACMD_FUNC(questskill)
  3174. {
  3175. uint16 skill_id;
  3176. nullpo_retr(-1, sd);
  3177. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3178. {// also send a list of skills applicable to this command
  3179. const char* text;
  3180. // attempt to find the text corresponding to this command
  3181. text = atcommand_help_string( command );
  3182. // send the error message as always
  3183. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3184. if( text )
  3185. {// send the skill ID list associated with this command
  3186. clif_displaymessage( fd, text );
  3187. }
  3188. return -1;
  3189. }
  3190. if (skill_id >= MAX_SKILL_ID) {
  3191. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3192. return -1;
  3193. }
  3194. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3195. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3196. return -1;
  3197. }
  3198. if (pc_checkskill(sd, skill_id) > 0) {
  3199. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  3200. return -1;
  3201. }
  3202. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  3203. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  3204. return 0;
  3205. }
  3206. /*==========================================
  3207. *
  3208. *------------------------------------------*/
  3209. ACMD_FUNC(lostskill)
  3210. {
  3211. uint16 skill_id = 0, sk_idx = 0;
  3212. nullpo_retr(-1, sd);
  3213. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  3214. {// also send a list of skills applicable to this command
  3215. const char* text;
  3216. // attempt to find the text corresponding to this command
  3217. text = atcommand_help_string( command );
  3218. // send the error message as always
  3219. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  3220. if( text )
  3221. {// send the skill ID list associated with this command
  3222. clif_displaymessage( fd, text );
  3223. }
  3224. return -1;
  3225. }
  3226. if (!(sk_idx = skill_get_index(skill_id))) {
  3227. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  3228. return -1;
  3229. }
  3230. if (!skill_get_inf2(skill_id, INF2_ISQUEST)) {
  3231. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  3232. return -1;
  3233. }
  3234. if (pc_checkskill(sd, skill_id) == 0) {
  3235. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  3236. return -1;
  3237. }
  3238. sd->status.skill[sk_idx].lv = 0;
  3239. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  3240. clif_deleteskill(*sd,skill_id);
  3241. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  3242. return 0;
  3243. }
  3244. /*==========================================
  3245. *
  3246. *------------------------------------------*/
  3247. ACMD_FUNC(spiritball)
  3248. {
  3249. int32 number;
  3250. nullpo_retr(-1, sd);
  3251. if( !message || !*message || ( number = atoi( message ) ) < 0 || number > MAX_SPIRITBALL ){
  3252. char msg[CHAT_SIZE_MAX];
  3253. safesnprintf( msg, sizeof( msg ), msg_txt( sd, 1028 ), MAX_SPIRITBALL ); // Please enter an amount (usage: @spiritball <number: 0-%d>).
  3254. clif_displaymessage(fd, msg);
  3255. return -1;
  3256. }
  3257. if( sd->spiritball > 0 )
  3258. pc_delspiritball(sd, sd->spiritball, 1);
  3259. sd->spiritball = number;
  3260. clif_spiritball(&sd->bl);
  3261. // no message, player can look the difference
  3262. return 0;
  3263. }
  3264. ACMD_FUNC(soulball)
  3265. {
  3266. int32 number;
  3267. nullpo_retr(-1, sd);
  3268. if (!message || !*message || (number = atoi(message)) < 0 || number > MAX_SOUL_BALL) {
  3269. char msg[CHAT_SIZE_MAX];
  3270. safesnprintf(msg, sizeof(msg), "Usage: @soulball <number: 0-%d>", MAX_SOUL_BALL);
  3271. clif_displaymessage(fd, msg);
  3272. return -1;
  3273. }
  3274. if (sd->soulball > 0)
  3275. pc_delsoulball( *sd, sd->soulball, true );
  3276. pc_addsoulball( *sd, number );
  3277. clif_soulball(sd);
  3278. return 0;
  3279. }
  3280. /*==========================================
  3281. *
  3282. *------------------------------------------*/
  3283. ACMD_FUNC(party)
  3284. {
  3285. char party[NAME_LENGTH];
  3286. nullpo_retr(-1, sd);
  3287. memset(party, '\0', sizeof(party));
  3288. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  3289. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  3290. return -1;
  3291. }
  3292. party_create( *sd, party, 0, 0 );
  3293. return 0;
  3294. }
  3295. /*==========================================
  3296. *
  3297. *------------------------------------------*/
  3298. ACMD_FUNC(guild)
  3299. {
  3300. char guild[NAME_LENGTH];
  3301. int32 prev;
  3302. nullpo_retr(-1, sd);
  3303. memset(guild, '\0', sizeof(guild));
  3304. if (sd->clan) {
  3305. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  3306. return -1;
  3307. }
  3308. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  3309. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  3310. return -1;
  3311. }
  3312. prev = battle_config.guild_emperium_check;
  3313. battle_config.guild_emperium_check = 0;
  3314. guild_create( *sd, guild );
  3315. battle_config.guild_emperium_check = prev;
  3316. return 0;
  3317. }
  3318. ACMD_FUNC(breakguild)
  3319. {
  3320. nullpo_retr(-1, sd);
  3321. if (sd->status.guild_id) { // Check if the player has a guild
  3322. if (sd->guild) { // Check if guild was found
  3323. if (sd->state.gmaster_flag) { // Check if player is guild master
  3324. // Break guild
  3325. int32 ret = guild_break( *sd, sd->guild->guild.name );
  3326. if (ret) { // Check if anything went wrong
  3327. return 0; // Guild was broken
  3328. } else {
  3329. return -1; // Something went wrong
  3330. }
  3331. } else { // Not guild master
  3332. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  3333. return -1;
  3334. }
  3335. } else { // Guild was not found. HOW?
  3336. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3337. return -1;
  3338. }
  3339. } else { // Player does not have a guild
  3340. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  3341. return -1;
  3342. }
  3343. }
  3344. /**
  3345. * Start WoE:FE
  3346. */
  3347. ACMD_FUNC(agitstart)
  3348. {
  3349. nullpo_retr(-1, sd);
  3350. if( guild_agit_start() ){
  3351. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  3352. return 0;
  3353. }else{
  3354. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  3355. return -1;
  3356. }
  3357. }
  3358. /**
  3359. * Start WoE:SE
  3360. */
  3361. ACMD_FUNC(agitstart2)
  3362. {
  3363. nullpo_retr(-1, sd);
  3364. if( guild_agit2_start() ){
  3365. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3366. return 0;
  3367. }else{
  3368. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3369. return -1;
  3370. }
  3371. }
  3372. /**
  3373. * Start WoE:TE
  3374. */
  3375. ACMD_FUNC(agitstart3)
  3376. {
  3377. nullpo_retr(-1, sd);
  3378. if( guild_agit3_start() ){
  3379. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3380. return 0;
  3381. }else{
  3382. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3383. return -1;
  3384. }
  3385. }
  3386. /**
  3387. * End WoE:FE
  3388. */
  3389. ACMD_FUNC(agitend)
  3390. {
  3391. nullpo_retr(-1, sd);
  3392. if( guild_agit_end() ){
  3393. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3394. return 0;
  3395. }else{
  3396. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3397. return -1;
  3398. }
  3399. }
  3400. /**
  3401. * End WoE:SE
  3402. */
  3403. ACMD_FUNC(agitend2)
  3404. {
  3405. nullpo_retr(-1, sd);
  3406. if( guild_agit2_end() ){
  3407. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3408. return 0;
  3409. }else{
  3410. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3411. return -1;
  3412. }
  3413. }
  3414. /**
  3415. * End WoE:TE
  3416. */
  3417. ACMD_FUNC(agitend3)
  3418. {
  3419. nullpo_retr(-1, sd);
  3420. if( guild_agit3_end() ){
  3421. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3422. return 0;
  3423. }else{
  3424. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3425. return -1;
  3426. }
  3427. }
  3428. /*==========================================
  3429. * @mapexit - shuts down the map server
  3430. *------------------------------------------*/
  3431. ACMD_FUNC(mapexit)
  3432. {
  3433. nullpo_retr(-1, sd);
  3434. global_core->signal_shutdown();
  3435. return 0;
  3436. }
  3437. /*==========================================
  3438. * idsearch <part_of_name>: revrited by [Yor]
  3439. *------------------------------------------*/
  3440. ACMD_FUNC(idsearch)
  3441. {
  3442. nullpo_retr(-1, sd);
  3443. char item_name[100];
  3444. memset(item_name, '\0', sizeof(item_name));
  3445. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3446. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3447. return -1;
  3448. }
  3449. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3450. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3451. clif_displaymessage(fd, atcmd_output);
  3452. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  3453. uint16 match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3454. if (match == MAX_SEARCH) {
  3455. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3456. clif_displaymessage(fd, atcmd_output);
  3457. }
  3458. for(const auto &result : item_array) {
  3459. std::shared_ptr<item_data> id = result.second;
  3460. sprintf(atcmd_output, msg_txt(sd,78), item_db.create_item_link( id ).c_str(), id->nameid); // %s: %u
  3461. clif_displaymessage(fd, atcmd_output);
  3462. }
  3463. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3464. clif_displaymessage(fd, atcmd_output);
  3465. return 0;
  3466. }
  3467. /*==========================================
  3468. * Recall All Characters Online To Your Location
  3469. *------------------------------------------*/
  3470. ACMD_FUNC(recallall)
  3471. {
  3472. map_session_data* pl_sd;
  3473. struct s_mapiterator* iter;
  3474. int32 count;
  3475. nullpo_retr(-1, sd);
  3476. memset(atcmd_output, '\0', sizeof(atcmd_output));
  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. count = 0;
  3482. iter = mapit_getallusers();
  3483. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3484. {
  3485. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3486. {
  3487. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3488. continue; // Don't waste time warping the character to the same place.
  3489. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3490. count++;
  3491. else {
  3492. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3493. count++;
  3494. }
  3495. }
  3496. }
  3497. }
  3498. mapit_free(iter);
  3499. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3500. if (count) {
  3501. 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.
  3502. clif_displaymessage(fd, atcmd_output);
  3503. }
  3504. return 0;
  3505. }
  3506. /*==========================================
  3507. * Recall online characters of a guild to your location
  3508. *------------------------------------------*/
  3509. ACMD_FUNC(guildrecall)
  3510. {
  3511. map_session_data* pl_sd;
  3512. struct s_mapiterator* iter;
  3513. int32 count;
  3514. char guild_name[NAME_LENGTH];
  3515. nullpo_retr(-1, sd);
  3516. memset(guild_name, '\0', sizeof(guild_name));
  3517. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3518. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3519. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3520. return -1;
  3521. }
  3522. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3523. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3524. return -1;
  3525. }
  3526. auto g = guild_searchnameid(guild_name);
  3527. if (!g) {
  3528. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3529. return -1;
  3530. }
  3531. count = 0;
  3532. iter = mapit_getallusers();
  3533. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3534. {
  3535. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild.guild_id)
  3536. {
  3537. 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))
  3538. continue; // Skip GMs greater than you... or chars already on the cell
  3539. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3540. count++;
  3541. else{
  3542. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3543. count++;
  3544. }
  3545. }
  3546. }
  3547. }
  3548. mapit_free(iter);
  3549. sprintf(atcmd_output, msg_txt(sd,93), g->guild.name); // All online characters of the %s guild have been recalled to your position.
  3550. clif_displaymessage(fd, atcmd_output);
  3551. if (count) {
  3552. 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.
  3553. clif_displaymessage(fd, atcmd_output);
  3554. }
  3555. return 0;
  3556. }
  3557. /*==========================================
  3558. * Recall online characters of a party to your location
  3559. *------------------------------------------*/
  3560. ACMD_FUNC(partyrecall)
  3561. {
  3562. map_session_data* pl_sd;
  3563. struct s_mapiterator* iter;
  3564. char party_name[NAME_LENGTH];
  3565. struct party_data *p;
  3566. int32 count;
  3567. nullpo_retr(-1, sd);
  3568. memset(party_name, '\0', sizeof(party_name));
  3569. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3570. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3571. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3572. return -1;
  3573. }
  3574. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3575. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3576. return -1;
  3577. }
  3578. if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
  3579. (p = party_search(atoi(message))) == nullptr)
  3580. {
  3581. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3582. return -1;
  3583. }
  3584. count = 0;
  3585. iter = mapit_getallusers();
  3586. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3587. {
  3588. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3589. {
  3590. 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))
  3591. continue; // Skip GMs greater than you... or chars already on the cell
  3592. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3593. count++;
  3594. else{
  3595. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3596. count++;
  3597. }
  3598. }
  3599. }
  3600. }
  3601. mapit_free(iter);
  3602. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3603. clif_displaymessage(fd, atcmd_output);
  3604. if (count) {
  3605. 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.
  3606. clif_displaymessage(fd, atcmd_output);
  3607. }
  3608. return 0;
  3609. }
  3610. /*==========================================
  3611. *
  3612. *------------------------------------------*/
  3613. void atcommand_doload();
  3614. ACMD_FUNC(reloadcashdb){
  3615. nullpo_retr(-1, sd);
  3616. cashshop_reloaddb();
  3617. clif_displaymessage( fd, msg_txt( sd, 832 ) ); // Cash shop database has been reloaded.
  3618. return 0;
  3619. }
  3620. ACMD_FUNC(reloaditemdb){
  3621. nullpo_retr(-1, sd);
  3622. itemdb_reload();
  3623. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3624. return 0;
  3625. }
  3626. ACMD_FUNC(reloadmobdb){
  3627. nullpo_retr(-1, sd);
  3628. mob_reload();
  3629. pet_db.reload();
  3630. hom_reload();
  3631. mercenary_db.reload();
  3632. elemental_db.reload();
  3633. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3634. return 0;
  3635. }
  3636. ACMD_FUNC(reloadskilldb){
  3637. nullpo_retr(-1, sd);
  3638. skill_reload();
  3639. homunculus_db.reload();
  3640. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3641. return 0;
  3642. }
  3643. ACMD_FUNC(reloadscript){
  3644. nullpo_retr(-1, sd);
  3645. struct s_mapiterator* iter;
  3646. map_session_data* pl_sd;
  3647. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3648. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3649. iter = mapit_getallusers();
  3650. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3651. pc_close_npc(pl_sd,1);
  3652. clif_cutin( *pl_sd, "", 255 );
  3653. pl_sd->state.block_action &= ~(PCBLOCK_ALL ^ PCBLOCK_IMMUNE);
  3654. bg_queue_leave(pl_sd);
  3655. }
  3656. mapit_free(iter);
  3657. for (auto &bg : bg_queues) {
  3658. for (auto &bg_sd : bg->teama_members)
  3659. bg_team_leave(bg_sd, false, false); // Kick Team A from battlegrounds
  3660. for (auto &bg_sd : bg->teamb_members)
  3661. bg_team_leave(bg_sd, false, false); // Kick Team B from battlegrounds
  3662. bg_queue_clear(bg, true);
  3663. }
  3664. flush_fifos();
  3665. map_reloadnpc(true); // reload config files seeking for npcs
  3666. script_reload();
  3667. npc_reload();
  3668. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3669. return 0;
  3670. }
  3671. ACMD_FUNC(reloadatcommand){
  3672. nullpo_retr(-1, sd);
  3673. atcommand_doload();
  3674. pc_groups_reload();
  3675. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3676. return 0;
  3677. }
  3678. ACMD_FUNC(reloadbattleconf){
  3679. nullpo_retr(-1, sd);
  3680. struct Battle_Config prev_config;
  3681. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3682. battle_config_read(BATTLE_CONF_FILENAME);
  3683. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3684. || prev_config.item_rate_common != battle_config.item_rate_common
  3685. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3686. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3687. || prev_config.item_rate_card != battle_config.item_rate_card
  3688. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3689. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3690. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3691. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3692. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3693. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3694. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3695. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3696. || prev_config.item_rate_use != battle_config.item_rate_use
  3697. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3698. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3699. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3700. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3701. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3702. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3703. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3704. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3705. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3706. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3707. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3708. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3709. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3710. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3711. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3712. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3713. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3714. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3715. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3716. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3717. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3718. )
  3719. { // Exp or Drop rates changed.
  3720. mob_reload(); //Needed as well so rate changes take effect.
  3721. }
  3722. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3723. return 0;
  3724. }
  3725. ACMD_FUNC(reloadstatusdb){
  3726. nullpo_retr(-1, sd);
  3727. status_readdb( true );
  3728. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3729. return 0;
  3730. }
  3731. ACMD_FUNC(reloadpcdb){
  3732. nullpo_retr(-1, sd);
  3733. pc_readdb();
  3734. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3735. return 0;
  3736. }
  3737. ACMD_FUNC(reloadmotd){
  3738. nullpo_retr(-1, sd);
  3739. pc_read_motd();
  3740. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3741. return 0;
  3742. }
  3743. ACMD_FUNC(reloadquestdb){
  3744. nullpo_retr(-1, sd);
  3745. if (quest_db.reload())
  3746. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3747. return 0;
  3748. }
  3749. ACMD_FUNC(reloadmsgconf){
  3750. nullpo_retr(-1, sd);
  3751. map_msg_reload();
  3752. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3753. return 0;
  3754. }
  3755. ACMD_FUNC(reloadinstancedb){
  3756. nullpo_retr(-1, sd);
  3757. if (instance_db.reload())
  3758. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3759. return 0;
  3760. }
  3761. ACMD_FUNC(reloadachievementdb){
  3762. nullpo_retr(-1, sd);
  3763. achievement_db_reload();
  3764. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3765. return 0;
  3766. }
  3767. ACMD_FUNC(reloadattendancedb){
  3768. nullpo_retr(-1, sd);
  3769. attendance_db.reload();
  3770. clif_displaymessage(fd, msg_txt(sd, 795)); // Attendance database has been reloaded.
  3771. return 0;
  3772. }
  3773. ACMD_FUNC(reloadbarterdb){
  3774. nullpo_retr(-1, sd);
  3775. barter_db.reload();
  3776. clif_displaymessage(fd, msg_txt(sd, 830)); // Barter database has been reloaded.
  3777. return 0;
  3778. }
  3779. ACMD_FUNC(reloadlogconf){
  3780. nullpo_retr(-1, sd);
  3781. log_config_read(LOG_CONF_NAME);
  3782. clif_displaymessage(fd, msg_txt(sd,1536)); // Log configuration has been reloaded.
  3783. return 0;
  3784. }
  3785. /*==========================================
  3786. * @partysharelvl <share_range> [Akinari]
  3787. * Updates char server party share level range in runtime
  3788. * Temporary - Permanent update in inter_athena.conf
  3789. *------------------------------------------*/
  3790. ACMD_FUNC(partysharelvl) {
  3791. uint32 share_lvl;
  3792. nullpo_retr(-1, sd);
  3793. if(!message || !*message) {
  3794. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3795. return -1;
  3796. } else {
  3797. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3798. }
  3799. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3800. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3801. else //Char server offline
  3802. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3803. return 0;
  3804. }
  3805. /*==========================================
  3806. * @mapinfo [0-3] <map name> by MC_Cameri
  3807. * => Shows information about the map [map name]
  3808. * 0 = no additional information
  3809. * 1 = Show users in that map and their location
  3810. * 2 = Shows NPCs in that map
  3811. * 3 = Shows the chats in that map
  3812. *------------------------------------------*/
  3813. ACMD_FUNC(mapinfo) {
  3814. map_session_data* pl_sd;
  3815. struct s_mapiterator* iter;
  3816. struct chat_data *cd = nullptr;
  3817. char direction[12];
  3818. int32 i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3819. uint16 m_index;
  3820. char mapname[MAP_NAME_LENGTH];
  3821. nullpo_retr(-1, sd);
  3822. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3823. memset(mapname, '\0', sizeof(mapname));
  3824. memset(direction, '\0', sizeof(direction));
  3825. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3826. if (list < 0 || list > 3) {
  3827. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3828. return -1;
  3829. }
  3830. if (mapname[0] == '\0') {
  3831. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3832. m_id = map_mapindex2mapid(sd->mapindex);
  3833. } else {
  3834. m_id = map_mapname2mapid(mapname);
  3835. }
  3836. if (m_id < 0) {
  3837. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3838. return -1;
  3839. }
  3840. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3841. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3842. // count chats (for initial message)
  3843. chat_num = 0;
  3844. iter = mapit_getallusers();
  3845. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3846. if( pl_sd->mapindex == m_index ) {
  3847. if( pl_sd->state.vending )
  3848. vend_num++;
  3849. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
  3850. chat_num++;
  3851. }
  3852. }
  3853. mapit_free(iter);
  3854. struct map_data *mapdata = map_getmapdata(m_id);
  3855. 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
  3856. clif_displaymessage(fd, atcmd_output);
  3857. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3858. if (map_getmapflag(m_id, MF_TOWN))
  3859. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3860. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3861. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3862. clif_displaymessage(fd, atcmd_output);
  3863. }
  3864. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3865. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3866. else
  3867. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3868. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3869. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3870. clif_displaymessage(fd, atcmd_output);
  3871. }
  3872. /* Skill damage adjustment info [Cydh] */
  3873. if (mapdata->getMapFlag(MF_SKILL_DAMAGE)) {
  3874. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3875. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3876. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3877. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3878. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3879. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3880. mapdata->damage_adjust.caster);
  3881. clif_displaymessage(fd, atcmd_output);
  3882. if (!mapdata->skill_damage.empty()) {
  3883. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3884. for (const auto& skilldmg : mapdata->skill_damage) {
  3885. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3886. skill_get_name(skilldmg.first),
  3887. skilldmg.second.rate[SKILLDMG_PC],
  3888. skilldmg.second.rate[SKILLDMG_MOB],
  3889. skilldmg.second.rate[SKILLDMG_BOSS],
  3890. skilldmg.second.rate[SKILLDMG_OTHER],
  3891. skilldmg.second.caster);
  3892. clif_displaymessage(fd,atcmd_output);
  3893. }
  3894. }
  3895. }
  3896. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3897. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3898. for (const auto &it : mapdata->skill_duration) {
  3899. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3900. clif_displaymessage(fd, atcmd_output);
  3901. }
  3902. }
  3903. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3904. if (map_getmapflag(m_id, MF_PVP))
  3905. strcat(atcmd_output, " Pvp ON |");
  3906. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3907. strcat(atcmd_output, " NoGuild |");
  3908. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3909. strcat(atcmd_output, " NoParty |");
  3910. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3911. strcat(atcmd_output, " NightmareDrop |");
  3912. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3913. strcat(atcmd_output, " NoCalcRank |");
  3914. clif_displaymessage(fd, atcmd_output);
  3915. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3916. if (map_getmapflag(m_id, MF_GVG))
  3917. strcat(atcmd_output, " GvG ON |");
  3918. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3919. strcat(atcmd_output, " GvG Dungeon |");
  3920. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3921. strcat(atcmd_output, " GvG Castle |");
  3922. if (map_getmapflag(m_id, MF_GVG_TE))
  3923. strcat(atcmd_output, " GvG TE |");
  3924. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3925. strcat(atcmd_output, " GvG TE Castle |");
  3926. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3927. strcat(atcmd_output, " NoParty |");
  3928. clif_displaymessage(fd, atcmd_output);
  3929. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3930. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3931. strcat(atcmd_output, " NoTeleport |");
  3932. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3933. strcat(atcmd_output, " Monster NoTeleport |");
  3934. if (map_getmapflag(m_id, MF_NOWARP))
  3935. strcat(atcmd_output, " NoWarp |");
  3936. if (map_getmapflag(m_id, MF_NOWARPTO))
  3937. strcat(atcmd_output, " NoWarpTo |");
  3938. if (map_getmapflag(m_id, MF_NORETURN))
  3939. strcat(atcmd_output, " NoReturn |");
  3940. if (map_getmapflag(m_id, MF_NOGO))
  3941. strcat(atcmd_output, " NoGo |"); //
  3942. if (map_getmapflag(m_id, MF_NOMEMO))
  3943. strcat(atcmd_output, " NoMemo |");
  3944. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_SOURCE))
  3945. strcat(atcmd_output, " PrivateAirship_Source |");
  3946. if (map_getmapflag(m_id, MF_PRIVATEAIRSHIP_DESTINATION))
  3947. strcat(atcmd_output, " PrivateAirship_Destination |");
  3948. clif_displaymessage(fd, atcmd_output);
  3949. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3950. (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
  3951. clif_displaymessage(fd, atcmd_output);
  3952. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3953. if (!mapdata->save.map)
  3954. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3955. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3956. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3957. clif_displaymessage(fd, atcmd_output);
  3958. }
  3959. else {
  3960. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3961. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3962. clif_displaymessage(fd, atcmd_output);
  3963. }
  3964. }
  3965. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3966. if (map_getmapflag(m_id, MF_SNOW))
  3967. strcat(atcmd_output, " Snow |");
  3968. if (map_getmapflag(m_id, MF_FOG))
  3969. strcat(atcmd_output, " Fog |");
  3970. if (map_getmapflag(m_id, MF_SAKURA))
  3971. strcat(atcmd_output, " Sakura |");
  3972. if (map_getmapflag(m_id, MF_CLOUDS))
  3973. strcat(atcmd_output, " Clouds |");
  3974. if (map_getmapflag(m_id, MF_CLOUDS2))
  3975. strcat(atcmd_output, " Clouds2 |");
  3976. if (map_getmapflag(m_id, MF_FIREWORKS))
  3977. strcat(atcmd_output, " Fireworks |");
  3978. if (map_getmapflag(m_id, MF_LEAVES))
  3979. strcat(atcmd_output, " Leaves |");
  3980. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3981. strcat(atcmd_output, " Displays Night |");
  3982. clif_displaymessage(fd, atcmd_output);
  3983. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3984. if (map_getmapflag(m_id, MF_NOBRANCH))
  3985. strcat(atcmd_output, " NoBranch |");
  3986. if (map_getmapflag(m_id, MF_NOTRADE))
  3987. strcat(atcmd_output, " NoTrade |");
  3988. if (map_getmapflag(m_id, MF_NOVENDING))
  3989. strcat(atcmd_output, " NoVending |");
  3990. if (map_getmapflag(m_id, MF_NOBUYINGSTORE))
  3991. strcat(atcmd_output, " NoBuyingstore |");
  3992. if (map_getmapflag(m_id, MF_NODROP))
  3993. strcat(atcmd_output, " NoDrop |");
  3994. if (map_getmapflag(m_id, MF_NOSKILL))
  3995. strcat(atcmd_output, " NoSkill |");
  3996. if (map_getmapflag(m_id, MF_NOICEWALL))
  3997. strcat(atcmd_output, " NoIcewall |");
  3998. if (map_getmapflag(m_id, MF_ALLOWKS))
  3999. strcat(atcmd_output, " AllowKS |");
  4000. if (map_getmapflag(m_id, MF_RESET))
  4001. strcat(atcmd_output, " Reset |");
  4002. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  4003. strcat(atcmd_output, " HideMobHPBar |");
  4004. if (map_getmapflag(m_id, MF_NOCOMMAND))
  4005. strcat(atcmd_output, " NoCommand |");
  4006. if (map_getmapflag(m_id, MF_NOBASEEXP))
  4007. strcat(atcmd_output, " NoBaseEXP |");
  4008. if (map_getmapflag(m_id, MF_NOJOBEXP))
  4009. strcat(atcmd_output, " NoJobEXP |");
  4010. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  4011. strcat(atcmd_output, " NoMobLoot |");
  4012. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  4013. strcat(atcmd_output, " NoMVPLoot |");
  4014. if (map_getmapflag(m_id, MF_NORENEWALEXPPENALTY))
  4015. strcat(atcmd_output, " NoRenewalExpPenalty |");
  4016. if (map_getmapflag(m_id, MF_NORENEWALDROPPENALTY))
  4017. strcat(atcmd_output, " NoRenewalDropPenalty |");
  4018. if (map_getmapflag(m_id, MF_PARTYLOCK))
  4019. strcat(atcmd_output, " PartyLock |");
  4020. if (map_getmapflag(m_id, MF_GUILDLOCK))
  4021. strcat(atcmd_output, " GuildLock |");
  4022. if (map_getmapflag(m_id, MF_LOADEVENT))
  4023. strcat(atcmd_output, " Loadevent |");
  4024. if (map_getmapflag(m_id, MF_NODYNAMICNPC))
  4025. strcat(atcmd_output, " NoDynamicNPC |");
  4026. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  4027. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  4028. if (map_getmapflag(m_id, MF_NOUSECART))
  4029. strcat(atcmd_output, " NoUsecart |");
  4030. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  4031. strcat(atcmd_output, " NoItemConsumption |");
  4032. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  4033. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  4034. if (map_getmapflag(m_id, MF_FORCEMINEFFECT))
  4035. strcat(atcmd_output, " ForceMinEffect |");
  4036. if (map_getmapflag(m_id, MF_NOLOCKON))
  4037. strcat(atcmd_output, " NoLockOn |");
  4038. if (map_getmapflag(m_id, MF_NOTOMB))
  4039. strcat(atcmd_output, " NoTomb |");
  4040. if (map_getmapflag(m_id, MF_NOCOSTUME))
  4041. strcat(atcmd_output, " NoCostume |");
  4042. if (map_getmapflag(m_id, MF_NOBANK))
  4043. strcat(atcmd_output, " NoBank |");
  4044. if (map_getmapflag(m_id, MF_NOCASHSHOP))
  4045. strcat(atcmd_output, " NoCashShop |");
  4046. if (map_getmapflag(m_id, MF_NORODEX))
  4047. strcat(atcmd_output, " NoRODex |");
  4048. if (map_getmapflag(m_id, MF_NOPETCAPTURE))
  4049. strcat(atcmd_output, " NoPetCapture |");
  4050. clif_displaymessage(fd, atcmd_output);
  4051. switch (list) {
  4052. case 0:
  4053. // Do nothing. It's list 0, no additional display.
  4054. break;
  4055. case 1:
  4056. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  4057. iter = mapit_getallusers();
  4058. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4059. {
  4060. if (pl_sd->mapindex == m_index) {
  4061. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  4062. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  4063. clif_displaymessage(fd, atcmd_output);
  4064. }
  4065. }
  4066. mapit_free(iter);
  4067. break;
  4068. case 2:
  4069. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  4070. for (i = 0; i < mapdata->npc_num;)
  4071. {
  4072. struct npc_data *nd = mapdata->npc[i];
  4073. switch(nd->ud.dir) {
  4074. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  4075. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  4076. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  4077. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  4078. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  4079. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  4080. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  4081. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  4082. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  4083. }
  4084. if(strcmp(nd->name,nd->exname) == 0)
  4085. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  4086. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  4087. else
  4088. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  4089. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  4090. clif_displaymessage(fd, atcmd_output);
  4091. }
  4092. break;
  4093. case 3:
  4094. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  4095. iter = mapit_getallusers();
  4096. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4097. {
  4098. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
  4099. pl_sd->mapindex == m_index &&
  4100. cd->usersd[0] == pl_sd)
  4101. {
  4102. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  4103. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  4104. clif_displaymessage(fd, atcmd_output);
  4105. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  4106. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  4107. clif_displaymessage(fd, atcmd_output);
  4108. }
  4109. }
  4110. mapit_free(iter);
  4111. break;
  4112. default: // normally impossible to arrive here
  4113. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  4114. return -1;
  4115. break;
  4116. }
  4117. return 0;
  4118. }
  4119. /*==========================================
  4120. *
  4121. *------------------------------------------*/
  4122. ACMD_FUNC(mount_peco)
  4123. {
  4124. nullpo_retr(-1, sd);
  4125. if (sd->disguise) {
  4126. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  4127. return -1;
  4128. }
  4129. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  4130. if( !(sd->sc.option&OPTION_DRAGON) ) {
  4131. uint32 option = OPTION_DRAGON1;
  4132. if( message[0] ) {
  4133. int32 color = atoi(message);
  4134. option = ( color == 2 ? OPTION_DRAGON2 :
  4135. color == 3 ? OPTION_DRAGON3 :
  4136. color == 4 ? OPTION_DRAGON4 :
  4137. color == 5 ? OPTION_DRAGON5 :
  4138. OPTION_DRAGON1 );
  4139. }
  4140. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  4141. pc_setoption(sd, sd->sc.option|option);
  4142. } else {
  4143. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  4144. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  4145. }
  4146. return 0;
  4147. }
  4148. 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)) ) {
  4149. if( !pc_isridingwug(sd) ) {
  4150. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  4151. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  4152. } else {
  4153. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  4154. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  4155. }
  4156. return 0;
  4157. }
  4158. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  4159. if( !pc_ismadogear(sd) ) {
  4160. e_mado_type type = MADO_ROBOT;
  4161. if (message[0]) {
  4162. int32 tmp = strtol(message, nullptr, 10);
  4163. switch (tmp) {
  4164. case MADO_ROBOT:
  4165. case MADO_SUIT:
  4166. type = static_cast<e_mado_type>(tmp);
  4167. break;
  4168. default:
  4169. type = MADO_ROBOT;
  4170. break;
  4171. }
  4172. }
  4173. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  4174. pc_setmadogear(sd, true, type);
  4175. } else {
  4176. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  4177. pc_setmadogear(sd, false);
  4178. }
  4179. return 0;
  4180. }
  4181. if (!pc_isriding(sd)) { // if actually no peco
  4182. if (!pc_checkskill(sd, KN_RIDING)) {
  4183. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  4184. return -1;
  4185. }
  4186. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  4187. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  4188. } else {//Dismount
  4189. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  4190. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  4191. }
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. *Spy Commands by Syrus22
  4196. *------------------------------------------*/
  4197. ACMD_FUNC(guildspy)
  4198. {
  4199. char guild_name[NAME_LENGTH];
  4200. nullpo_retr(-1, sd);
  4201. memset(guild_name, '\0', sizeof(guild_name));
  4202. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4203. if (!enable_spy)
  4204. {
  4205. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4206. return -1;
  4207. }
  4208. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4209. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  4210. return -1;
  4211. }
  4212. auto g = guild_searchnameid(guild_name);
  4213. if (!g) {
  4214. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  4215. return -1;
  4216. }
  4217. if (sd->guildspy == g->guild.guild_id) {
  4218. sd->guildspy = 0;
  4219. sprintf(atcmd_output, msg_txt(sd,103), g->guild.name); // No longer spying on the %s guild.
  4220. clif_displaymessage(fd, atcmd_output);
  4221. } else {
  4222. sd->guildspy = g->guild.guild_id;
  4223. sprintf(atcmd_output, msg_txt(sd,104), g->guild.name); // Spying on the %s guild.
  4224. clif_displaymessage(fd, atcmd_output);
  4225. }
  4226. return 0;
  4227. }
  4228. /*==========================================
  4229. *
  4230. *------------------------------------------*/
  4231. ACMD_FUNC(partyspy)
  4232. {
  4233. char party_name[NAME_LENGTH];
  4234. struct party_data *p;
  4235. nullpo_retr(-1, sd);
  4236. memset(party_name, '\0', sizeof(party_name));
  4237. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4238. if (!enable_spy)
  4239. {
  4240. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  4241. return -1;
  4242. }
  4243. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  4244. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  4245. return -1;
  4246. }
  4247. if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
  4248. (p = party_search(atoi(message))) != nullptr) {
  4249. if (sd->partyspy == p->party.party_id) {
  4250. sd->partyspy = 0;
  4251. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  4252. clif_displaymessage(fd, atcmd_output);
  4253. } else {
  4254. sd->partyspy = p->party.party_id;
  4255. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  4256. clif_displaymessage(fd, atcmd_output);
  4257. }
  4258. } else {
  4259. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  4260. return -1;
  4261. }
  4262. return 0;
  4263. }
  4264. ACMD_FUNC(clanspy){
  4265. char clan_name[NAME_LENGTH];
  4266. struct clan* c;
  4267. nullpo_retr(-1, sd);
  4268. memset(clan_name, '\0', sizeof(clan_name));
  4269. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4270. if( !enable_spy ){
  4271. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  4272. return -1;
  4273. }
  4274. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  4275. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  4276. return -1;
  4277. }
  4278. if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
  4279. (c = clan_search(atoi(message))) != nullptr) {
  4280. if (sd->clanspy == c->id) {
  4281. sd->clanspy = 0;
  4282. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  4283. clif_displaymessage(fd, atcmd_output);
  4284. }
  4285. else {
  4286. sd->clanspy = c->id;
  4287. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  4288. clif_displaymessage(fd, atcmd_output);
  4289. }
  4290. }
  4291. else {
  4292. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  4293. return -1;
  4294. }
  4295. return 0;
  4296. }
  4297. /*==========================================
  4298. * @repairall [Valaris]
  4299. *------------------------------------------*/
  4300. ACMD_FUNC(repairall)
  4301. {
  4302. int32 count, i;
  4303. nullpo_retr(-1, sd);
  4304. count = 0;
  4305. for (i = 0; i < MAX_INVENTORY; i++) {
  4306. 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])) {
  4307. sd->inventory.u.items_inventory[i].attribute = 0;
  4308. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  4309. count++;
  4310. }
  4311. }
  4312. if (count > 0) {
  4313. clif_misceffect( sd->bl, NOTIFYEFFECT_REFINE_SUCCESS );
  4314. clif_equiplist(sd);
  4315. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  4316. } else {
  4317. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  4318. return -1;
  4319. }
  4320. return 0;
  4321. }
  4322. /*==========================================
  4323. * @nuke [Valaris]
  4324. *------------------------------------------*/
  4325. ACMD_FUNC(nuke)
  4326. {
  4327. map_session_data *pl_sd;
  4328. nullpo_retr(-1, sd);
  4329. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4330. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4331. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  4332. return -1;
  4333. }
  4334. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
  4335. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  4336. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  4337. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  4338. } else {
  4339. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4340. return -1;
  4341. }
  4342. } else {
  4343. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4344. return -1;
  4345. }
  4346. return 0;
  4347. }
  4348. /*==========================================
  4349. * @tonpc
  4350. *------------------------------------------*/
  4351. ACMD_FUNC(tonpc)
  4352. {
  4353. char npcname[NPC_NAME_LENGTH];
  4354. struct npc_data *nd;
  4355. nullpo_retr(-1, sd);
  4356. memset(npcname, 0, sizeof(npcname));
  4357. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  4358. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  4359. return -1;
  4360. }
  4361. if ((nd = npc_name2id(npcname)) != nullptr) {
  4362. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  4363. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  4364. else
  4365. return -1;
  4366. } else {
  4367. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4368. return -1;
  4369. }
  4370. return 0;
  4371. }
  4372. /*==========================================
  4373. *
  4374. *------------------------------------------*/
  4375. ACMD_FUNC(shownpc)
  4376. {
  4377. char NPCname[NPC_NAME_LENGTH];
  4378. nullpo_retr(-1, sd);
  4379. memset(NPCname, '\0', sizeof(NPCname));
  4380. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4381. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  4382. return -1;
  4383. }
  4384. npc_data* nd = npc_name2id(NPCname);
  4385. if (nd) {
  4386. npc_enable(*nd, NPCVIEW_ENABLE);
  4387. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  4388. } else {
  4389. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4390. return -1;
  4391. }
  4392. return 0;
  4393. }
  4394. /*==========================================
  4395. *
  4396. *------------------------------------------*/
  4397. ACMD_FUNC(hidenpc)
  4398. {
  4399. char NPCname[NPC_NAME_LENGTH];
  4400. nullpo_retr(-1, sd);
  4401. memset(NPCname, '\0', sizeof(NPCname));
  4402. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4403. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  4404. return -1;
  4405. }
  4406. npc_data* nd = npc_name2id(NPCname);
  4407. if (!nd) {
  4408. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4409. return -1;
  4410. }
  4411. npc_enable(*nd, NPCVIEW_DISABLE);
  4412. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4413. return 0;
  4414. }
  4415. ACMD_FUNC(loadnpc)
  4416. {
  4417. if (!message || !*message) {
  4418. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  4419. return -1;
  4420. }
  4421. if (!npc_addsrcfile(message, true)) {
  4422. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4423. return -1;
  4424. }
  4425. npc_read_event_script();
  4426. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was loaded.\n", message );
  4427. npc_event_doall_path( script_config.init_event_name, message );
  4428. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4429. return 0;
  4430. }
  4431. ACMD_FUNC(unloadnpc)
  4432. {
  4433. struct npc_data *nd;
  4434. char NPCname[NPC_NAME_LENGTH];
  4435. nullpo_retr(-1, sd);
  4436. memset(NPCname, '\0', sizeof(NPCname));
  4437. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  4438. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  4439. return -1;
  4440. }
  4441. if ((nd = npc_name2id(NPCname)) == nullptr) {
  4442. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4443. return -1;
  4444. }
  4445. npc_unload_duplicates(nd);
  4446. npc_unload(nd,true);
  4447. npc_read_event_script();
  4448. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4449. return 0;
  4450. }
  4451. ACMD_FUNC(reloadnpcfile) {
  4452. if (!message || !*message) {
  4453. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4454. return -1;
  4455. }
  4456. if (npc_unloadfile(message))
  4457. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4458. if (!npc_addsrcfile(message, true)) {
  4459. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4460. return -1;
  4461. }
  4462. npc_read_event_script();
  4463. ShowStatus( "NPC file '" CL_WHITE "%s" CL_RESET "' was reloaded.\n", message );
  4464. npc_event_doall_path( script_config.init_event_name, message );
  4465. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4466. return 0;
  4467. }
  4468. /*==========================================
  4469. * time in txt for time command (by [Yor])
  4470. *------------------------------------------*/
  4471. char* txt_time(t_tick duration_)
  4472. {
  4473. int32 days, hours, minutes, seconds;
  4474. char temp[CHAT_SIZE_MAX];
  4475. static char temp1[CHAT_SIZE_MAX];
  4476. memset(temp, '\0', sizeof(temp));
  4477. memset(temp1, '\0', sizeof(temp1));
  4478. // Cap it
  4479. int32 duration = (int32)duration_;
  4480. days = duration / (60 * 60 * 24);
  4481. duration = duration - (60 * 60 * 24 * days);
  4482. hours = duration / (60 * 60);
  4483. duration = duration - (60 * 60 * hours);
  4484. minutes = duration / 60;
  4485. seconds = duration - (60 * minutes);
  4486. if (days == 1)
  4487. sprintf(temp, msg_txt(nullptr,219), days); // %d day
  4488. else if (days > 1)
  4489. sprintf(temp, msg_txt(nullptr,220), days); // %d days
  4490. if (hours == 1)
  4491. sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
  4492. else if (hours > 1)
  4493. sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
  4494. if (minutes < 2)
  4495. sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
  4496. else
  4497. sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
  4498. if (seconds == 1)
  4499. sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
  4500. else if (seconds > 1)
  4501. sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
  4502. return temp1;
  4503. }
  4504. /*==========================================
  4505. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4506. * Calculation management of GM modification (@day/@night GM commands) is done
  4507. *------------------------------------------*/
  4508. ACMD_FUNC(servertime)
  4509. {
  4510. const struct TimerData * timer_data;
  4511. time_t time_server; // variable for number of seconds (used with time() function)
  4512. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4513. char temp[CHAT_SIZE_MAX];
  4514. nullpo_retr(-1, sd);
  4515. memset(temp, '\0', sizeof(temp));
  4516. time(&time_server); // get time in seconds since 1/1/1970
  4517. datetime = localtime(&time_server); // convert seconds in structure
  4518. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4519. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4520. clif_displaymessage(fd, temp);
  4521. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4522. if (night_flag == 0)
  4523. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4524. else
  4525. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4526. } else if (battle_config.night_duration == 0)
  4527. if (night_flag == 1) { // we start with night
  4528. if ((timer_data = get_timer(day_timer_tid)) != nullptr) {
  4529. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4530. clif_displaymessage(fd, temp);
  4531. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4532. } else
  4533. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4534. } else
  4535. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4536. else if (battle_config.day_duration == 0)
  4537. if (night_flag == 0) { // we start with day
  4538. if ((timer_data = get_timer(night_timer_tid)) != nullptr) {
  4539. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4540. clif_displaymessage(fd, temp);
  4541. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4542. } else
  4543. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4544. } else
  4545. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4546. else {
  4547. const struct TimerData * timer_data2;
  4548. if (night_flag == 0) {
  4549. if ((timer_data = get_timer(night_timer_tid)) != nullptr && (timer_data2 = get_timer(day_timer_tid)) != nullptr) {
  4550. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4551. clif_displaymessage(fd, temp);
  4552. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4553. 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.
  4554. else
  4555. 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.
  4556. clif_displaymessage(fd, temp);
  4557. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4558. clif_displaymessage(fd, temp);
  4559. } else
  4560. clif_displaymessage(fd, msg_txt(sd, 231)); // Game time: The game is in permanent daylight.
  4561. } else {
  4562. if ((timer_data = get_timer(day_timer_tid)) != nullptr && (timer_data2 = get_timer(night_timer_tid)) != nullptr) {
  4563. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4564. clif_displaymessage(fd, temp);
  4565. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4566. 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.
  4567. else
  4568. 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.
  4569. clif_displaymessage(fd, temp);
  4570. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4571. clif_displaymessage(fd, temp);
  4572. } else
  4573. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4574. }
  4575. }
  4576. return 0;
  4577. }
  4578. /*==========================================
  4579. * @jail <char_name> by [Yor]
  4580. * Special warp! No check with nowarp and nowarpto flag
  4581. *------------------------------------------*/
  4582. ACMD_FUNC(jail)
  4583. {
  4584. map_session_data *pl_sd;
  4585. nullpo_retr(-1, sd);
  4586. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4587. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4588. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4589. return -1;
  4590. }
  4591. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4592. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4593. return -1;
  4594. }
  4595. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4596. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4597. return -1;
  4598. }
  4599. if (pl_sd->sc.getSCE(SC_JAILED)) {
  4600. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4601. return -1;
  4602. }
  4603. pc_jail(*pl_sd);
  4604. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4605. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4606. return 0;
  4607. }
  4608. /*==========================================
  4609. * @unjail/@discharge <char_name> by [Yor]
  4610. * Special warp! No check with nowarp and nowarpto flag
  4611. *------------------------------------------*/
  4612. ACMD_FUNC(unjail)
  4613. {
  4614. map_session_data *pl_sd;
  4615. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4616. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4617. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4618. return -1;
  4619. }
  4620. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4621. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4622. return -1;
  4623. }
  4624. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4625. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4626. return -1;
  4627. }
  4628. if (!pl_sd->sc.getSCE(SC_JAILED)) {
  4629. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4630. return -1;
  4631. }
  4632. //Reset jail time to 1 sec.
  4633. pc_jail(*pl_sd, 0);
  4634. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4635. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4636. return 0;
  4637. }
  4638. ACMD_FUNC(jailfor) {
  4639. map_session_data* pl_sd = nullptr;;
  4640. char * modif_p;
  4641. int32 jailtime = 0;
  4642. nullpo_retr(-1, sd);
  4643. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4644. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4645. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4646. return -1;
  4647. }
  4648. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4649. modif_p = atcmd_output;
  4650. jailtime = (int32)solve_time(modif_p)/60; // Change to minutes
  4651. if (jailtime == 0) {
  4652. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4653. 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.
  4654. return -1;
  4655. }
  4656. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  4657. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4658. return -1;
  4659. }
  4660. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4661. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4662. return -1;
  4663. }
  4664. // Added by Coltaro
  4665. if(pl_sd->sc.getSCE(SC_JAILED) && pl_sd->sc.getSCE(SC_JAILED)->val1 != INT_MAX) { // Update the player's jail time
  4666. jailtime += pl_sd->sc.getSCE(SC_JAILED)->val1;
  4667. if (jailtime <= 0) {
  4668. jailtime = 0;
  4669. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4670. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4671. } else {
  4672. int32 year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4673. char timestr[21];
  4674. time_t now=time(nullptr);
  4675. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4676. 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
  4677. clif_displaymessage(pl_sd->fd, atcmd_output);
  4678. 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
  4679. clif_displaymessage(fd, atcmd_output);
  4680. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4681. sprintf(atcmd_output,"Release date is: %s",timestr);
  4682. clif_displaymessage(pl_sd->fd, atcmd_output);
  4683. clif_displaymessage(fd, atcmd_output);
  4684. }
  4685. } else if (jailtime < 0) {
  4686. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4687. return -1;
  4688. }
  4689. pc_jail(*pl_sd, jailtime);
  4690. return 0;
  4691. }
  4692. //By Coltaro
  4693. ACMD_FUNC(jailtime){
  4694. int32 year, month, day, hour, minute, second;
  4695. char timestr[21];
  4696. time_t now = time(nullptr);
  4697. nullpo_retr(-1, sd);
  4698. if (!sd->sc.getSCE(SC_JAILED)) {
  4699. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4700. return -1;
  4701. }
  4702. if (sd->sc.getSCE(SC_JAILED)->val1 == INT_MAX) {
  4703. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4704. return 0;
  4705. }
  4706. if (sd->sc.getSCE(SC_JAILED)->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4707. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4708. return -1;
  4709. }
  4710. // Get remaining jail time
  4711. split_time(sd->sc.getSCE(SC_JAILED)->val1*60,&year,&month,&day,&hour,&minute,&second);
  4712. 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
  4713. clif_displaymessage(fd, atcmd_output);
  4714. timestamp2string(timestr,20,now+sd->sc.getSCE(SC_JAILED)->val1*60,"%Y-%m-%d %H:%M");
  4715. sprintf(atcmd_output,"Release date is: %s",timestr);
  4716. clif_displaymessage(fd, atcmd_output);
  4717. return 0;
  4718. }
  4719. /*==========================================
  4720. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4721. *------------------------------------------*/
  4722. ACMD_FUNC(disguise)
  4723. {
  4724. int32 id = 0;
  4725. nullpo_retr(-1, sd);
  4726. if (!message || !*message) {
  4727. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4728. return -1;
  4729. }
  4730. if ((id = atoi(message)) > 0)
  4731. { //Acquired an ID
  4732. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4733. id = 0; //Invalid id for either mobs or npcs.
  4734. } else { //Acquired a Name
  4735. if ((id = mobdb_searchname(message)) == 0)
  4736. {
  4737. struct npc_data* nd = npc_name2id(message);
  4738. if (nd != nullptr)
  4739. id = nd->class_;
  4740. }
  4741. }
  4742. if (id == 0)
  4743. {
  4744. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4745. return -1;
  4746. }
  4747. if(pc_isriding(sd))
  4748. {
  4749. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4750. return -1;
  4751. }
  4752. if (sd->sc.getSCE(SC_MONSTER_TRANSFORM) || sd->sc.getSCE(SC_ACTIVE_MONSTER_TRANSFORM)) {
  4753. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4754. return -1;
  4755. }
  4756. pc_disguise(sd, id);
  4757. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4758. return 0;
  4759. }
  4760. /*==========================================
  4761. * DisguiseAll
  4762. *------------------------------------------*/
  4763. ACMD_FUNC(disguiseall)
  4764. {
  4765. int32 mob_id=0;
  4766. map_session_data *pl_sd;
  4767. struct s_mapiterator* iter;
  4768. nullpo_retr(-1, sd);
  4769. if (!message || !*message) {
  4770. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4771. return -1;
  4772. }
  4773. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4774. mob_id = atoi(message);
  4775. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4776. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4777. return -1;
  4778. }
  4779. iter = mapit_getallusers();
  4780. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4781. pc_disguise(pl_sd, mob_id);
  4782. mapit_free(iter);
  4783. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4784. return 0;
  4785. }
  4786. /*==========================================
  4787. * DisguiseGuild
  4788. *------------------------------------------*/
  4789. ACMD_FUNC(disguiseguild)
  4790. {
  4791. int32 id = 0, i;
  4792. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4793. memset(monster, '\0', sizeof(monster));
  4794. memset(guild, '\0', sizeof(guild));
  4795. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4796. 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>).
  4797. return -1;
  4798. }
  4799. if( (id = atoi(monster)) > 0 ) {
  4800. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4801. id = 0;
  4802. } else {
  4803. if( (id = mobdb_searchname(monster)) == 0 ) {
  4804. struct npc_data* nd = npc_name2id(monster);
  4805. if( nd != nullptr )
  4806. id = nd->class_;
  4807. }
  4808. }
  4809. if( id == 0 ) {
  4810. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4811. return -1;
  4812. }
  4813. auto g = guild_searchnameid(guild);
  4814. if (!g) {
  4815. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4816. return -1;
  4817. }
  4818. for( i = 0; i < g->guild.max_member; i++ ){
  4819. map_session_data *pl_sd;
  4820. if( (pl_sd = g->guild.member[i].sd) && !pc_isriding(pl_sd) )
  4821. pc_disguise(pl_sd, id);
  4822. }
  4823. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4824. return 0;
  4825. }
  4826. /*==========================================
  4827. * @undisguise by [Yor]
  4828. *------------------------------------------*/
  4829. ACMD_FUNC(undisguise)
  4830. {
  4831. nullpo_retr(-1, sd);
  4832. if (sd->disguise) {
  4833. pc_disguise(sd, 0);
  4834. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4835. } else {
  4836. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4837. return -1;
  4838. }
  4839. return 0;
  4840. }
  4841. /*==========================================
  4842. * UndisguiseAll
  4843. *------------------------------------------*/
  4844. ACMD_FUNC(undisguiseall)
  4845. {
  4846. map_session_data *pl_sd;
  4847. struct s_mapiterator* iter;
  4848. nullpo_retr(-1, sd);
  4849. iter = mapit_getallusers();
  4850. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4851. if( pl_sd->disguise )
  4852. pc_disguise(pl_sd, 0);
  4853. mapit_free(iter);
  4854. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4855. return 0;
  4856. }
  4857. /*==========================================
  4858. * UndisguiseGuild
  4859. *------------------------------------------*/
  4860. ACMD_FUNC(undisguiseguild)
  4861. {
  4862. char guild_name[NAME_LENGTH];
  4863. int32 i;
  4864. nullpo_retr(-1, sd);
  4865. memset(guild_name, '\0', sizeof(guild_name));
  4866. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4867. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4868. return -1;
  4869. }
  4870. auto g = guild_searchnameid(guild_name);
  4871. if (!g) {
  4872. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4873. return -1;
  4874. }
  4875. for(i = 0; i < g->guild.max_member; i++){
  4876. map_session_data *pl_sd;
  4877. if( (pl_sd = g->guild.member[i].sd) && pl_sd->disguise )
  4878. pc_disguise(pl_sd, 0);
  4879. }
  4880. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4881. return 0;
  4882. }
  4883. /*==========================================
  4884. * @exp by [Skotlex]
  4885. *------------------------------------------*/
  4886. ACMD_FUNC(exp)
  4887. {
  4888. char output[CHAT_SIZE_MAX];
  4889. double nextb, nextj;
  4890. nullpo_retr(-1, sd);
  4891. memset(output, '\0', sizeof(output));
  4892. nextb = (double)pc_nextbaseexp(sd);
  4893. if (nextb)
  4894. nextb = sd->status.base_exp*100.0/nextb;
  4895. nextj = (double)pc_nextjobexp(sd);
  4896. if (nextj)
  4897. nextj = sd->status.job_exp*100.0/nextj;
  4898. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4899. clif_displaymessage(fd, output);
  4900. return 0;
  4901. }
  4902. /*==========================================
  4903. * @broadcast by [Valaris]
  4904. *------------------------------------------*/
  4905. ACMD_FUNC(broadcast)
  4906. {
  4907. nullpo_retr(-1, sd);
  4908. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4909. if (!message || !*message) {
  4910. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4911. return -1;
  4912. }
  4913. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4914. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4915. return 0;
  4916. }
  4917. /*==========================================
  4918. * @localbroadcast by [Valaris]
  4919. *------------------------------------------*/
  4920. ACMD_FUNC(localbroadcast)
  4921. {
  4922. nullpo_retr(-1, sd);
  4923. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4924. if (!message || !*message) {
  4925. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4926. return -1;
  4927. }
  4928. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4929. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4930. return 0;
  4931. }
  4932. /*==========================================
  4933. * @email <actual@email> <new@email> by [Yor]
  4934. *------------------------------------------*/
  4935. ACMD_FUNC(email)
  4936. {
  4937. char actual_email[100];
  4938. char new_email[100];
  4939. nullpo_retr(-1, sd);
  4940. memset(actual_email, '\0', sizeof(actual_email));
  4941. memset(new_email, '\0', sizeof(new_email));
  4942. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4943. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4944. return -1;
  4945. }
  4946. if (e_mail_check(actual_email) == 0) {
  4947. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4948. return -1;
  4949. } else if (e_mail_check(new_email) == 0) {
  4950. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4951. return -1;
  4952. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4953. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4954. return -1;
  4955. } else if (strcmpi(actual_email, new_email) == 0) {
  4956. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4957. return -1;
  4958. }
  4959. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4960. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4961. return 0;
  4962. }
  4963. /*==========================================
  4964. *@effect
  4965. *------------------------------------------*/
  4966. ACMD_FUNC(effect)
  4967. {
  4968. int32 type = EF_NONE;
  4969. nullpo_retr(-1, sd);
  4970. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4971. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4972. return -1;
  4973. }
  4974. if( type <= EF_NONE || type >= EF_MAX ){
  4975. 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.
  4976. clif_displaymessage(fd, atcmd_output);
  4977. return -1;
  4978. }
  4979. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4980. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4981. return 0;
  4982. }
  4983. /*==========================================
  4984. * @killer by MouseJstr
  4985. * enable killing players even when not in pvp
  4986. *------------------------------------------*/
  4987. ACMD_FUNC(killer)
  4988. {
  4989. nullpo_retr(-1, sd);
  4990. sd->state.killer = !sd->state.killer;
  4991. if(sd->state.killer)
  4992. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4993. else {
  4994. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4995. unit_stop_attack( &sd->bl );
  4996. }
  4997. return 0;
  4998. }
  4999. /*==========================================
  5000. * @killable by MouseJstr
  5001. * enable other people killing you
  5002. *------------------------------------------*/
  5003. ACMD_FUNC(killable)
  5004. {
  5005. nullpo_retr(-1, sd);
  5006. sd->state.killable = !sd->state.killable;
  5007. if(sd->state.killable)
  5008. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  5009. else {
  5010. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  5011. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  5012. }
  5013. return 0;
  5014. }
  5015. /*==========================================
  5016. * @skillon by MouseJstr
  5017. * turn skills on for the map
  5018. *------------------------------------------*/
  5019. ACMD_FUNC(skillon)
  5020. {
  5021. nullpo_retr(-1, sd);
  5022. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  5023. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  5024. return 0;
  5025. }
  5026. /*==========================================
  5027. * @skilloff by MouseJstr
  5028. * Turn skills off on the map
  5029. *------------------------------------------*/
  5030. ACMD_FUNC(skilloff)
  5031. {
  5032. nullpo_retr(-1, sd);
  5033. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  5034. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  5035. return 0;
  5036. }
  5037. /*==========================================
  5038. * @npcmove by MouseJstr
  5039. * move a npc
  5040. *------------------------------------------*/
  5041. ACMD_FUNC(npcmove)
  5042. {
  5043. int16 x = 0, y = 0;
  5044. struct npc_data *nd = 0;
  5045. char npc_name[NPC_NAME_LENGTH];
  5046. nullpo_retr(-1, sd);
  5047. memset(npc_name, '\0', sizeof npc_name);
  5048. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  5049. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  5050. return -1;
  5051. }
  5052. if ((nd = npc_name2id(npc_name)) == nullptr)
  5053. {
  5054. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  5055. return -1;
  5056. }
  5057. if ( npc_movenpc( nd, x, y ) )
  5058. { //actually failed to move
  5059. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  5060. return -1; //Not on a map.
  5061. } else
  5062. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  5063. return 0;
  5064. }
  5065. /*==========================================
  5066. * @addwarp by MouseJstr
  5067. * Create a new static warp point.
  5068. *------------------------------------------*/
  5069. ACMD_FUNC(addwarp)
  5070. {
  5071. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  5072. int16 x,y;
  5073. uint16 m;
  5074. struct npc_data* nd;
  5075. nullpo_retr(-1, sd);
  5076. memset(warpname, '\0', sizeof(warpname));
  5077. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  5078. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  5079. return -1;
  5080. }
  5081. m = mapindex_name2id(mapname);
  5082. if( m == 0 )
  5083. {
  5084. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  5085. clif_displaymessage(fd, atcmd_output);
  5086. return -1;
  5087. }
  5088. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  5089. if( nd == nullptr )
  5090. return -1;
  5091. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  5092. clif_displaymessage(fd, atcmd_output);
  5093. return 0;
  5094. }
  5095. /*==========================================
  5096. * @follow by [MouseJstr]
  5097. * Follow a player .. staying no more then 5 spaces away
  5098. *------------------------------------------*/
  5099. ACMD_FUNC(follow)
  5100. {
  5101. map_session_data* pl_sd = nullptr;;
  5102. nullpo_retr(-1, sd);
  5103. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5104. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5105. if (sd->followtarget == -1)
  5106. return -1;
  5107. pc_stop_following (sd);
  5108. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5109. return 0;
  5110. }
  5111. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5112. {
  5113. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5114. return -1;
  5115. }
  5116. if (sd->followtarget == pl_sd->bl.id) {
  5117. pc_stop_following (sd);
  5118. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  5119. } else {
  5120. pc_follow(sd, pl_sd->bl.id);
  5121. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  5122. }
  5123. return 0;
  5124. }
  5125. /*==========================================
  5126. * @dropall by [MouseJstr] and [Xantara]
  5127. * Drops all your possession on the ground based on item type
  5128. *------------------------------------------*/
  5129. ACMD_FUNC(dropall)
  5130. {
  5131. int8 type = -1;
  5132. uint16 i, count = 0, count2 = 0;
  5133. nullpo_retr(-1, sd);
  5134. if( message[0] ) {
  5135. type = atoi(message);
  5136. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  5137. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  5138. {
  5139. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  5140. 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
  5141. return -1;
  5142. }
  5143. }
  5144. for( i = 0; i < MAX_INVENTORY; i++ ) {
  5145. if( sd->inventory.u.items_inventory[i].amount ) {
  5146. std::shared_ptr<item_data> id = item_db.find(sd->inventory.u.items_inventory[i].nameid);
  5147. if( id == nullptr ) {
  5148. 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);
  5149. continue;
  5150. }
  5151. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  5152. continue;
  5153. if( type == -1 || type == (uint8)id->type ) {
  5154. if( sd->inventory.u.items_inventory[i].equip != 0 )
  5155. pc_unequipitem(sd, i, 3);
  5156. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5157. pet_return_egg( sd, sd->pd );
  5158. }
  5159. pc_equipswitch_remove(sd, i);
  5160. int32 amount = sd->inventory.u.items_inventory[i].amount;
  5161. if(pc_dropitem(sd, i, amount))
  5162. count += amount;
  5163. else count2 += amount;
  5164. }
  5165. }
  5166. }
  5167. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  5168. clif_displaymessage(fd, atcmd_output);
  5169. return 0;
  5170. }
  5171. /*==========================================
  5172. * @stockall by [Hanashi]
  5173. * transfer items from cart to inventory
  5174. *------------------------------------------*/
  5175. ACMD_FUNC(stockall)
  5176. {
  5177. nullpo_retr(-1, sd);
  5178. if (!pc_iscarton(sd)) {
  5179. clif_displaymessage(fd, msg_txt(sd,1533)); // You do not have a cart.
  5180. return -1;
  5181. }
  5182. int8 type = -1;
  5183. if ( message[0] ) {
  5184. type = atoi(message);
  5185. switch (type) {
  5186. case -1:
  5187. case IT_HEALING:
  5188. case IT_USABLE:
  5189. case IT_ETC:
  5190. case IT_WEAPON:
  5191. case IT_ARMOR:
  5192. case IT_CARD:
  5193. case IT_PETEGG:
  5194. case IT_PETARMOR:
  5195. case IT_AMMO:
  5196. break;
  5197. default:
  5198. clif_displaymessage(fd, msg_txt(sd, 1534)); // Usage: @stockall {<type>}
  5199. 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
  5200. return -1;
  5201. }
  5202. }
  5203. int32 count = 0, count2 = 0;
  5204. for ( uint16 i = 0; i < MAX_CART; i++ ) {
  5205. if ( sd->cart.u.items_cart[i].amount > 0 ) {
  5206. std::shared_ptr<item_data> id = item_db.find(sd->cart.u.items_cart[i].nameid);
  5207. if ( id == nullptr ) {
  5208. 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);
  5209. continue;
  5210. }
  5211. if ( type == -1 || static_cast<item_types>(type) == id->type ) {
  5212. int32 amount = sd->cart.u.items_cart[i].amount;
  5213. if( pc_getitemfromcart( sd, i, amount ) ){
  5214. count += amount;
  5215. }else{
  5216. count2 += amount;
  5217. }
  5218. }
  5219. }
  5220. }
  5221. sprintf(atcmd_output, msg_txt(sd,1535), count,count2); // %d items are transferred (%d skipped)!
  5222. clif_displaymessage(fd, atcmd_output);
  5223. return 0;
  5224. }
  5225. /*==========================================
  5226. * @storeall by [MouseJstr]
  5227. * Put everything into storage
  5228. *------------------------------------------*/
  5229. ACMD_FUNC(storeall)
  5230. {
  5231. int32 i;
  5232. nullpo_retr(-1, sd);
  5233. if (sd->state.storage_flag != 1)
  5234. { //Open storage.
  5235. if( storage_storageopen(sd) == 1 ) {
  5236. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  5237. return -1;
  5238. }
  5239. }
  5240. for (i = 0; i < MAX_INVENTORY; i++) {
  5241. if (sd->inventory.u.items_inventory[i].amount) {
  5242. if(sd->inventory.u.items_inventory[i].equip != 0)
  5243. pc_unequipitem(sd, i, 3);
  5244. if( itemdb_ishatched_egg( &sd->inventory.u.items_inventory[i] ) ){
  5245. pet_return_egg( sd, sd->pd );
  5246. }
  5247. pc_equipswitch_remove(sd, i);
  5248. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  5249. }
  5250. }
  5251. storage_storageclose(sd);
  5252. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  5253. return 0;
  5254. }
  5255. ACMD_FUNC(clearstorage)
  5256. {
  5257. int32 i, j;
  5258. nullpo_retr(-1, sd);
  5259. if (sd->state.storage_flag == 1) {
  5260. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5261. return -1;
  5262. }
  5263. if (sd->state.storage_flag == 3) {
  5264. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5265. return -1;
  5266. }
  5267. j = sd->storage.amount;
  5268. for (i = 0; i < j; ++i) {
  5269. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  5270. }
  5271. sd->state.storage_flag = 1;
  5272. storage_storageclose(sd);
  5273. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  5274. return 0;
  5275. }
  5276. ACMD_FUNC(cleargstorage)
  5277. {
  5278. int32 i, j;
  5279. struct s_storage *gstorage;
  5280. nullpo_retr(-1, sd);
  5281. if (!sd->guild) {
  5282. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  5283. return -1;
  5284. }
  5285. if (sd->state.storage_flag == 1) {
  5286. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5287. return -1;
  5288. }
  5289. if (sd->state.storage_flag == 2) {
  5290. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  5291. return -1;
  5292. }
  5293. if (sd->state.storage_flag == 3) {
  5294. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  5295. return -1;
  5296. }
  5297. gstorage = guild2storage2(sd->status.guild_id);
  5298. if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  5299. return -1;
  5300. }
  5301. j = gstorage->amount;
  5302. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  5303. for (i = 0; i < j; ++i) {
  5304. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  5305. }
  5306. storage_guild_storageclose(sd);
  5307. gstorage->lock = false; // Cleaning done, release lock
  5308. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  5309. return 0;
  5310. }
  5311. ACMD_FUNC(clearcart)
  5312. {
  5313. int32 i;
  5314. nullpo_retr(-1, sd);
  5315. if (pc_iscarton(sd) == 0) {
  5316. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  5317. return -1;
  5318. }
  5319. if (sd->state.vending == 1) { //Somehow...
  5320. return -1;
  5321. }
  5322. for (i = 0; i < MAX_CART; i++) {
  5323. if (sd->cart.u.items_cart[i].nameid > 0)
  5324. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  5325. }
  5326. clif_clearcart(fd);
  5327. clif_updatestatus(*sd,SP_CARTINFO);
  5328. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  5329. return 0;
  5330. }
  5331. /*==========================================
  5332. * @skillid by [MouseJstr]
  5333. * lookup a skill by name
  5334. *------------------------------------------*/
  5335. #define MAX_SKILLID_PARTIAL_RESULTS 5
  5336. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  5337. ACMD_FUNC(skillid) {
  5338. int32 i, found = 0;
  5339. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  5340. nullpo_retr(-1, sd);
  5341. if (!message || !*message) {
  5342. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  5343. return -1;
  5344. }
  5345. size_t skillen = strlen( message );
  5346. for(const auto & skill : skill_db) {
  5347. uint16 skill_id = skill.second->nameid;
  5348. uint16 idx = skill_get_index(skill_id);
  5349. const char *name = skill.second->name;
  5350. const char *desc = skill.second->desc;
  5351. if (strnicmp(name, message, skillen) == 0 || strnicmp(desc, message, skillen) == 0) {
  5352. sprintf(atcmd_output, msg_txt(sd,1164), skill_id, desc, name); // skill %d: %s (%s)
  5353. clif_displaymessage(fd, atcmd_output);
  5354. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(name,message) || stristr(desc,message) ) ) {
  5355. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), skill_id, desc, name); // // skill %d: %s (%s)
  5356. }
  5357. }
  5358. if( found ) {
  5359. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  5360. clif_displaymessage(fd, atcmd_output);
  5361. }
  5362. for(i = 0; i < found; i++) { /* partials */
  5363. clif_displaymessage(fd, partials[i]);
  5364. }
  5365. return 0;
  5366. }
  5367. /*==========================================
  5368. * @useskill by [MouseJstr]
  5369. * A way of using skills without having to find them in the skills menu
  5370. *------------------------------------------*/
  5371. ACMD_FUNC(useskill)
  5372. {
  5373. map_session_data* pl_sd = nullptr;;
  5374. struct block_list *bl;
  5375. uint16 skill_id;
  5376. uint16 skill_lv;
  5377. nullpo_retr(-1, sd);
  5378. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5379. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  5380. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  5381. return -1;
  5382. }
  5383. if (!skill_id || !skill_db.find(skill_id)) {
  5384. clif_displaymessage(fd, msg_txt(sd, 198)); // This skill number doesn't exist.
  5385. return -1;
  5386. }
  5387. if (!skill_lv)
  5388. skill_lv = 1;
  5389. if(!strcmp(atcmd_player_name,"self"))
  5390. pl_sd = sd; //quick keyword
  5391. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
  5392. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5393. return -1;
  5394. }
  5395. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5396. {
  5397. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5398. return -1;
  5399. }
  5400. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  5401. bl = &sd->hd->bl;
  5402. else
  5403. bl = &sd->bl;
  5404. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  5405. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  5406. else
  5407. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  5408. return 0;
  5409. }
  5410. /*==========================================
  5411. * @displayskill by [Skotlex]
  5412. * Debug command to locate new skill IDs. It sends the
  5413. * three possible skill-effect packets to the area.
  5414. *------------------------------------------*/
  5415. ACMD_FUNC(displayskill)
  5416. {
  5417. t_tick tick;
  5418. uint16 skill_id;
  5419. uint16 skill_lv = 1;
  5420. uint16 type = 0;
  5421. nullpo_retr(-1, sd);
  5422. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &skill_id, &skill_lv, &type) < 1)
  5423. {
  5424. clif_displaymessage(fd, msg_txt(sd,1166));// Usage: @displayskill <skill ID> {<skill level> <type>}
  5425. clif_displaymessage(fd, msg_txt(sd,825));// Effect Types: 0: All, 1: Damage, 2: Splash Dmg, 3: No Damage, 4: Ground
  5426. return -1;
  5427. }
  5428. status_data* status = status_get_status_data(sd->bl);
  5429. tick = gettick();
  5430. if (type == 0 || type == 1)
  5431. clif_skill_damage( sd->bl, sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SINGLE );
  5432. if (type == 0 || type == 2)
  5433. clif_skill_damage( sd->bl, sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH );
  5434. if (type == 0 || type == 3)
  5435. clif_skill_nodamage(&sd->bl, sd->bl, skill_id, skill_lv);
  5436. if (type == 0 || type == 4)
  5437. clif_skill_poseffect( sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick );
  5438. return 0;
  5439. }
  5440. /*==========================================
  5441. * @displayskillcast by [Rytech]
  5442. * Debug command to view casting animations for skills.
  5443. * Can target self or the ground. Ground target can be
  5444. * useful for seeing casting circle size.
  5445. *------------------------------------------*/
  5446. ACMD_FUNC(displayskillcast)
  5447. {
  5448. uint16 skill_id;
  5449. uint16 skill_lv = 1;
  5450. uint16 cast_time = 5000;
  5451. uint16 target_type = 0;
  5452. nullpo_retr(-1, sd);
  5453. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu %6hu", &skill_id, &skill_lv, &target_type, &cast_time) < 1)
  5454. {
  5455. clif_displaymessage(fd, msg_txt(sd, 824));// Usage: @displayskillcast <skill ID> {<skill level> <ground target flag> <cast time>}
  5456. return -1;
  5457. }
  5458. if ( target_type == 1)
  5459. clif_skillcasting(&sd->bl, sd->bl.id, 0, sd->bl.x, sd->bl.y, skill_id, skill_lv, 0, cast_time);
  5460. else
  5461. clif_skillcasting(&sd->bl, sd->bl.id, sd->bl.id, 0, 0, skill_id, skill_lv, 0, cast_time);
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * @displayskillunit by [Rytech]
  5466. * Debug command to view unit animations for skills.
  5467. *------------------------------------------*/
  5468. ACMD_FUNC(displayskillunit)
  5469. {
  5470. uint16 unit_id;
  5471. uint16 range = 0;
  5472. uint16 skill_lv = 1;
  5473. nullpo_retr(-1, sd);
  5474. if (!message || !*message || sscanf(message, "%6hu %6hu %6hu", &unit_id, &skill_lv, &range) < 1)
  5475. {
  5476. clif_displaymessage(fd, msg_txt(sd, 826));// Usage: @displayskillunit <unit ID> {<skill level> <range>}
  5477. return -1;
  5478. }
  5479. clif_skill_unit_test(&sd->bl, sd->bl.x, sd->bl.y, unit_id, range, skill_lv);
  5480. return 0;
  5481. }
  5482. /*==========================================
  5483. * @skilltree by [MouseJstr]
  5484. * prints the skill tree for a player required to get to a skill
  5485. *------------------------------------------*/
  5486. ACMD_FUNC(skilltree)
  5487. {
  5488. map_session_data* pl_sd = nullptr;;
  5489. uint16 skill_id;
  5490. nullpo_retr(-1, sd);
  5491. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5492. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  5493. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  5494. return -1;
  5495. }
  5496. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  5497. {
  5498. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5499. return -1;
  5500. }
  5501. int32 c = pc_mapid2jobid( pc_calc_skilltree_normalize_job( pl_sd ), pl_sd->status.sex );
  5502. 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).
  5503. clif_displaymessage(fd, atcmd_output);
  5504. auto entry = skill_tree_db.get_skill_data(c, skill_id);
  5505. if (entry == nullptr) {
  5506. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  5507. return 0;
  5508. }
  5509. bool meets = true;
  5510. for (const auto &it : entry->need) {
  5511. if (pc_checkskill(sd, it.first) < it.second) {
  5512. sprintf(atcmd_output, msg_txt(sd,1170), it.second, skill_get_desc(it.first)); // Player requires level %d of skill %s.
  5513. clif_displaymessage(fd, atcmd_output);
  5514. meets = false;
  5515. }
  5516. }
  5517. if (meets) {
  5518. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  5519. }
  5520. return 0;
  5521. }
  5522. // Hand a ring with partners name on it to this char
  5523. void getring (map_session_data* sd)
  5524. {
  5525. char flag = 0;
  5526. t_itemid item_id;
  5527. struct item item_tmp;
  5528. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5529. memset(&item_tmp, 0, sizeof(item_tmp));
  5530. item_tmp.nameid = item_id;
  5531. item_tmp.identify = 1;
  5532. item_tmp.card[0] = CARD0_FORGE;
  5533. item_tmp.card[2] = GetWord(sd->status.partner_id,0);
  5534. item_tmp.card[3] = GetWord(sd->status.partner_id,1);
  5535. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5536. clif_additem(sd,0,0,flag);
  5537. }
  5538. }
  5539. /*==========================================
  5540. * @marry by [MouseJstr], fixed by Lupus
  5541. * Marry two players
  5542. *------------------------------------------*/
  5543. ACMD_FUNC(marry)
  5544. {
  5545. map_session_data* pl_sd = nullptr;;
  5546. nullpo_retr(-1, sd);
  5547. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5548. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5549. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5550. return -1;
  5551. }
  5552. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  5553. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5554. return -1;
  5555. }
  5556. if (!pc_inventoryblank(sd)) {
  5557. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5558. return -1;
  5559. }
  5560. if (!pc_inventoryblank(pl_sd)) {
  5561. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_COUNT, color_table[COLOR_RED]);
  5562. return -1;
  5563. }
  5564. uint32 w = 0;
  5565. if (w = itemdb_weight((sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + sd->weight > sd->max_weight) {
  5566. clif_msg_color(sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5567. return -1;
  5568. }
  5569. if (w = itemdb_weight((pl_sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F) && w + pl_sd->weight > pl_sd->max_weight) {
  5570. clif_msg_color(pl_sd, MSI_CANT_GET_ITEM_BECAUSE_WEIGHT, color_table[COLOR_RED]);
  5571. return -1;
  5572. }
  5573. if (pc_marriage(sd, pl_sd)) {
  5574. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5575. clif_wedding_effect( pl_sd->bl );
  5576. if( pl_sd->bl.m != sd->bl.m )
  5577. clif_wedding_effect( sd->bl );
  5578. getring(sd); // Auto-give named rings (Aru)
  5579. getring(pl_sd);
  5580. return 0;
  5581. }
  5582. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5583. return -1;
  5584. }
  5585. /*==========================================
  5586. * @divorce by [MouseJstr], fixed by [Lupus]
  5587. * divorce two players
  5588. *------------------------------------------*/
  5589. ACMD_FUNC(divorce)
  5590. {
  5591. nullpo_retr(-1, sd);
  5592. if (!pc_divorce(sd)) {
  5593. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5594. clif_displaymessage(fd, atcmd_output);
  5595. return -1;
  5596. }
  5597. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5598. clif_displaymessage(fd, atcmd_output);
  5599. return 0;
  5600. }
  5601. /*==========================================
  5602. * @changelook by [Celest]
  5603. *------------------------------------------*/
  5604. ACMD_FUNC(changelook)
  5605. {
  5606. int32 i, j = 0, k = 0;
  5607. int32 pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5608. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5609. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5610. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5611. return -1;
  5612. } else if ( i == 2 ) {
  5613. if (j < 1 || j > 8)
  5614. j = 1;
  5615. j = pos[j - 1];
  5616. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5617. k = j; // swap
  5618. j = LOOK_HEAD_TOP;
  5619. }
  5620. clif_changelook(&sd->bl,j,k);
  5621. return 0;
  5622. }
  5623. /*==========================================
  5624. * @autotrade by durf [Lupus] [Paradox924X]
  5625. * Turns on/off Autotrade for a specific player
  5626. *------------------------------------------*/
  5627. ACMD_FUNC(autotrade) {
  5628. nullpo_retr(-1, sd);
  5629. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5630. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5631. return -1;
  5632. }
  5633. if( pc_isdead(sd) ) {
  5634. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5635. return -1;
  5636. }
  5637. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5638. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5639. return -1;
  5640. }
  5641. sd->state.autotrade = 1;
  5642. if (battle_config.autotrade_monsterignore)
  5643. sd->state.block_action |= PCBLOCK_IMMUNE;
  5644. if( sd->state.vending ){
  5645. vending_update(*sd);
  5646. }else if( sd->state.buyingstore ){
  5647. buyingstore_update(*sd);
  5648. }
  5649. if( battle_config.at_timeout ) {
  5650. int32 timeout = atoi(message);
  5651. 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);
  5652. }
  5653. if (battle_config.at_logout_event)
  5654. npc_script_event( *sd, NPCE_LOGOUT );
  5655. channel_pcquit(sd,0xF); //leave all chan
  5656. clif_authfail_fd(sd->fd, 15);
  5657. chrif_save(sd, CSAVE_AUTOTRADE);
  5658. return 0;
  5659. }
  5660. /*==========================================
  5661. * @changegm by durf (changed by Lupus)
  5662. * Changes Master of your Guild to a specified guild member
  5663. *------------------------------------------*/
  5664. ACMD_FUNC(changegm)
  5665. {
  5666. map_session_data *pl_sd;
  5667. nullpo_retr(-1, sd);
  5668. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5669. if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
  5670. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5671. return -1;
  5672. }
  5673. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5674. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5675. return -1;
  5676. }
  5677. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5678. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5679. return -1;
  5680. }
  5681. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
  5682. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5683. return -1;
  5684. }
  5685. if( !battle_config.guild_leaderchange_woe && is_agit_start() ){
  5686. #if PACKETVER >= 20151001
  5687. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_IN_SIEGE_TIME);
  5688. #else
  5689. clif_displaymessage(fd, msg_txt(sd,1513)); // Currently in WoE hours, unable to delegate Guild leader
  5690. #endif
  5691. return -1;
  5692. }
  5693. if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
  5694. #if PACKETVER >= 20151001
  5695. clif_msg(sd, MSI_IMPOSSIBLE_CHANGE_GUILD_MASTER_NOT_TIME);
  5696. #else
  5697. clif_displaymessage(fd, msg_txt(sd,1514)); // You have to wait for a while before delegating a new Guild leader
  5698. #endif
  5699. return -1;
  5700. }
  5701. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5702. return 0;
  5703. }
  5704. /*==========================================
  5705. * @changeleader by Skotlex
  5706. * Changes the leader of a party.
  5707. *------------------------------------------*/
  5708. ACMD_FUNC(changeleader)
  5709. {
  5710. nullpo_retr(-1, sd);
  5711. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5712. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5713. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5714. return -1;
  5715. }
  5716. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
  5717. return 0;
  5718. }
  5719. /*==========================================
  5720. * @partyoption by Skotlex
  5721. * Used to change the item share setting of a party.
  5722. *------------------------------------------*/
  5723. ACMD_FUNC(partyoption)
  5724. {
  5725. struct party_data *p;
  5726. int32 mi, option;
  5727. char w1[16], w2[16];
  5728. nullpo_retr(-1, sd);
  5729. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
  5730. {
  5731. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5732. return -1;
  5733. }
  5734. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5735. if (mi == MAX_PARTY)
  5736. return -1; //Shouldn't happen
  5737. if (!p->party.member[mi].leader)
  5738. {
  5739. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5740. return -1;
  5741. }
  5742. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5743. {
  5744. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5745. return -1;
  5746. }
  5747. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5748. //Change item share type.
  5749. if (option != p->party.item)
  5750. party_changeoption(sd, p->party.exp, option);
  5751. else
  5752. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5753. return 0;
  5754. }
  5755. /*==========================================
  5756. * @autoloot by Upa-Kun
  5757. * Turns on/off AutoLoot for a specific player
  5758. *------------------------------------------*/
  5759. ACMD_FUNC(autoloot)
  5760. {
  5761. int32 rate;
  5762. nullpo_retr(-1, sd);
  5763. // autoloot command without value
  5764. if(!message || !*message)
  5765. {
  5766. if (sd->state.autoloot)
  5767. rate = 0;
  5768. else
  5769. rate = 10000;
  5770. } else {
  5771. double drate;
  5772. drate = atof(message);
  5773. rate = (int32)(drate*100);
  5774. }
  5775. if (rate < 0) rate = 0;
  5776. if (rate > 10000) rate = 10000;
  5777. sd->state.autoloot = rate;
  5778. if (sd->state.autoloot) {
  5779. 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.
  5780. clif_displaymessage(fd, atcmd_output);
  5781. }else
  5782. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5783. return 0;
  5784. }
  5785. /*==========================================
  5786. * @alootid
  5787. *------------------------------------------*/
  5788. ACMD_FUNC(autolootitem)
  5789. {
  5790. std::shared_ptr<item_data> item_data;
  5791. int32 i;
  5792. int32 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5793. nullpo_retr(-1, sd);
  5794. if (message && *message) {
  5795. if (message[0] == '+') {
  5796. message++;
  5797. action = 1;
  5798. }
  5799. else if (message[0] == '-') {
  5800. message++;
  5801. action = 2;
  5802. }
  5803. else if (!strcmp(message,"reset"))
  5804. action = 4;
  5805. }
  5806. if (action < 3) // add or remove
  5807. {
  5808. item_data = item_db.find( strtoul( message, nullptr, 10 ) );
  5809. if( item_data == nullptr ){
  5810. item_data = item_db.searchname( message );
  5811. }
  5812. if( item_data == nullptr ){
  5813. // No items founds in the DB with Id or Name
  5814. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5815. return -1;
  5816. }
  5817. }
  5818. switch(action) {
  5819. case 1:
  5820. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5821. if (i != AUTOLOOTITEM_SIZE) {
  5822. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5823. return -1;
  5824. }
  5825. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5826. if (i == AUTOLOOTITEM_SIZE) {
  5827. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5828. return -1;
  5829. }
  5830. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5831. 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}
  5832. clif_displaymessage(fd, atcmd_output);
  5833. sd->state.autolooting = 1;
  5834. break;
  5835. case 2:
  5836. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5837. if (i == AUTOLOOTITEM_SIZE) {
  5838. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5839. return -1;
  5840. }
  5841. sd->state.autolootid[i] = 0;
  5842. 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.
  5843. clif_displaymessage(fd, atcmd_output);
  5844. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5845. if (i == AUTOLOOTITEM_SIZE) {
  5846. sd->state.autolooting = 0;
  5847. }
  5848. break;
  5849. case 3:
  5850. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5851. clif_displaymessage(fd, atcmd_output);
  5852. 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>".
  5853. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5854. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5855. if (i == AUTOLOOTITEM_SIZE) {
  5856. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5857. } else {
  5858. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5859. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5860. {
  5861. if (sd->state.autolootid[i] == 0)
  5862. continue;
  5863. item_data = item_db.find( sd->state.autolootid[i] );
  5864. if( item_data == nullptr ){
  5865. 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);
  5866. continue;
  5867. }
  5868. sprintf(atcmd_output, "'%s'/'%s' {%u}", item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(), item_data->nameid);
  5869. clif_displaymessage(fd, atcmd_output);
  5870. }
  5871. }
  5872. break;
  5873. case 4:
  5874. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5875. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5876. sd->state.autolooting = 0;
  5877. break;
  5878. }
  5879. return 0;
  5880. }
  5881. /*==========================================
  5882. * @autoloottype
  5883. * Flags:
  5884. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5885. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5886. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5887. * 262144: IT_CASH
  5888. *------------------------------------------
  5889. * Credits:
  5890. * chriser
  5891. * Aleos
  5892. *------------------------------------------*/
  5893. ACMD_FUNC(autoloottype)
  5894. {
  5895. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5896. enum item_types type= IT_UNKNOWN;
  5897. int32 ITEM_MAX = 1533;
  5898. nullpo_retr(-1, sd);
  5899. if (message && *message) {
  5900. if (message[0] == '+') {
  5901. message++;
  5902. action = 1;
  5903. }
  5904. else if (message[0] == '-') {
  5905. message++;
  5906. action = 2;
  5907. }
  5908. else if (!strcmp(message,"reset"))
  5909. action = 4;
  5910. }
  5911. if (action < 3) { // add or remove
  5912. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5913. type = IT_HEALING;
  5914. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5915. type = IT_USABLE;
  5916. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5917. type = IT_ETC;
  5918. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5919. type = IT_ARMOR;
  5920. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5921. type = IT_WEAPON;
  5922. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5923. type = IT_CARD;
  5924. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5925. type = IT_PETEGG;
  5926. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5927. type = IT_PETARMOR;
  5928. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5929. type = IT_AMMO;
  5930. else {
  5931. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5932. return -1;
  5933. }
  5934. }
  5935. switch (action) {
  5936. case 1:
  5937. if (sd->state.autoloottype&(1<<type)) {
  5938. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5939. return -1;
  5940. }
  5941. if (sd->state.autoloottype == ITEM_MAX) {
  5942. 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>.
  5943. return -1;
  5944. }
  5945. sd->state.autoloottype |= (1<<type); // Stores the type
  5946. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%u}
  5947. clif_displaymessage(fd, atcmd_output);
  5948. break;
  5949. case 2:
  5950. if (!(sd->state.autoloottype&(1<<type))) {
  5951. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5952. return -1;
  5953. }
  5954. sd->state.autoloottype &= ~(1<<type);
  5955. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%u} from your autoloottype list.
  5956. clif_displaymessage(fd, atcmd_output);
  5957. break;
  5958. case 3:
  5959. 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>".
  5960. 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
  5961. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5962. if (sd->state.autoloottype == 0)
  5963. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5964. else {
  5965. uint8 i = 0;
  5966. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5967. while (i < IT_MAX) {
  5968. if (sd->state.autoloottype&(1<<i)) {
  5969. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5970. clif_displaymessage(fd, atcmd_output);
  5971. }
  5972. i++;
  5973. }
  5974. }
  5975. break;
  5976. case 4:
  5977. sd->state.autoloottype = 0;
  5978. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5979. break;
  5980. }
  5981. return 0;
  5982. }
  5983. /*==========================================
  5984. * It is made to rain.
  5985. * No longer available, keeping here just in case it's back someday. [Ind]
  5986. *------------------------------------------*/
  5987. //ACMD_FUNC(rain)
  5988. //{
  5989. // nullpo_retr(-1, sd);
  5990. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5991. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5992. // clif_weather(sd->bl.m);
  5993. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5994. // } else {
  5995. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5996. // clif_weather(sd->bl.m);
  5997. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5998. // }
  5999. // return 0;
  6000. //}
  6001. /*==========================================
  6002. * It is made to snow.
  6003. *------------------------------------------*/
  6004. ACMD_FUNC(snow)
  6005. {
  6006. nullpo_retr(-1, sd);
  6007. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  6008. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6009. clif_weather(sd->bl.m);
  6010. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  6011. } else {
  6012. map_setmapflag(sd->bl.m, MF_SNOW, true);
  6013. clif_weather(sd->bl.m);
  6014. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  6015. }
  6016. return 0;
  6017. }
  6018. /*==========================================
  6019. * Cherry tree snowstorm is made to fall. (Sakura)
  6020. *------------------------------------------*/
  6021. ACMD_FUNC(sakura)
  6022. {
  6023. nullpo_retr(-1, sd);
  6024. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  6025. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6026. clif_weather(sd->bl.m);
  6027. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  6028. } else {
  6029. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  6030. clif_weather(sd->bl.m);
  6031. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  6032. }
  6033. return 0;
  6034. }
  6035. /*==========================================
  6036. * Clouds appear.
  6037. *------------------------------------------*/
  6038. ACMD_FUNC(clouds)
  6039. {
  6040. nullpo_retr(-1, sd);
  6041. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  6042. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6043. clif_weather(sd->bl.m);
  6044. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  6045. } else {
  6046. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  6047. clif_weather(sd->bl.m);
  6048. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  6049. }
  6050. return 0;
  6051. }
  6052. /*==========================================
  6053. * Different type of clouds using effect 516
  6054. *------------------------------------------*/
  6055. ACMD_FUNC(clouds2)
  6056. {
  6057. nullpo_retr(-1, sd);
  6058. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  6059. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6060. clif_weather(sd->bl.m);
  6061. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  6062. } else {
  6063. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  6064. clif_weather(sd->bl.m);
  6065. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  6066. }
  6067. return 0;
  6068. }
  6069. /*==========================================
  6070. * Fog hangs over.
  6071. *------------------------------------------*/
  6072. ACMD_FUNC(fog)
  6073. {
  6074. nullpo_retr(-1, sd);
  6075. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  6076. map_setmapflag(sd->bl.m, MF_FOG, false);
  6077. clif_weather(sd->bl.m);
  6078. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  6079. } else {
  6080. map_setmapflag(sd->bl.m, MF_FOG, true);
  6081. clif_weather(sd->bl.m);
  6082. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  6083. }
  6084. return 0;
  6085. }
  6086. /*==========================================
  6087. * Fallen leaves fall.
  6088. *------------------------------------------*/
  6089. ACMD_FUNC(leaves)
  6090. {
  6091. nullpo_retr(-1, sd);
  6092. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  6093. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6094. clif_weather(sd->bl.m);
  6095. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  6096. } else {
  6097. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  6098. clif_weather(sd->bl.m);
  6099. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  6100. }
  6101. return 0;
  6102. }
  6103. /*==========================================
  6104. * Fireworks appear.
  6105. *------------------------------------------*/
  6106. ACMD_FUNC(fireworks)
  6107. {
  6108. nullpo_retr(-1, sd);
  6109. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  6110. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6111. clif_weather(sd->bl.m);
  6112. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  6113. } else {
  6114. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  6115. clif_weather(sd->bl.m);
  6116. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  6117. }
  6118. return 0;
  6119. }
  6120. /*==========================================
  6121. * Clearing Weather Effects by Dexity
  6122. *------------------------------------------*/
  6123. ACMD_FUNC(clearweather)
  6124. {
  6125. nullpo_retr(-1, sd);
  6126. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  6127. map_setmapflag(sd->bl.m, MF_SNOW, false);
  6128. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  6129. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  6130. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  6131. map_setmapflag(sd->bl.m, MF_FOG, false);
  6132. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  6133. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  6134. clif_weather(sd->bl.m);
  6135. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  6136. return 0;
  6137. }
  6138. /*===============================================================
  6139. * Sound Command - plays a sound for everyone around! [Codemaster]
  6140. *---------------------------------------------------------------*/
  6141. ACMD_FUNC(sound)
  6142. {
  6143. char sound_file[100];
  6144. memset(sound_file, '\0', sizeof(sound_file));
  6145. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  6146. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  6147. return -1;
  6148. }
  6149. if(strstr(sound_file, ".wav") == nullptr)
  6150. strcat(sound_file, ".wav");
  6151. clif_soundeffect( sd->bl, sound_file, 0, AREA );
  6152. return 0;
  6153. }
  6154. /*==========================================
  6155. * MOB Search
  6156. *------------------------------------------*/
  6157. ACMD_FUNC(mobsearch)
  6158. {
  6159. nullpo_retr(-1, sd);
  6160. char mob_name[100]={0};
  6161. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  6162. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  6163. return -1;
  6164. }
  6165. int32 mob_id = strtol(mob_name, nullptr, 10);
  6166. if (mob_id == 0)
  6167. mob_id = mobdb_searchname(mob_name);
  6168. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6169. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6170. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  6171. clif_displaymessage(fd, atcmd_output);
  6172. return -1;
  6173. }
  6174. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6175. // strcpy(mob_name, mob->name.c_str()); // --en--
  6176. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  6177. clif_displaymessage(fd, atcmd_output);
  6178. s_mapiterator* it = mapit_geteachmob();
  6179. int32 number = 0;
  6180. for(;;)
  6181. {
  6182. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6183. if( md == nullptr )
  6184. break;// no more mobs
  6185. if( md->bl.m != sd->bl.m )
  6186. continue;
  6187. if( md->mob_id != mob_id )
  6188. continue;
  6189. ++number;
  6190. if( md->spawn_timer == INVALID_TIMER )
  6191. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  6192. else
  6193. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  6194. clif_displaymessage(fd, atcmd_output);
  6195. }
  6196. mapit_free(it);
  6197. return 0;
  6198. }
  6199. /*==========================================
  6200. * @cleanmap - cleans items on the ground
  6201. * @cleanarea - cleans items on the ground within an specified area
  6202. *------------------------------------------*/
  6203. static int32 atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  6204. {
  6205. nullpo_ret(bl);
  6206. map_clearflooritem(bl);
  6207. return 0;
  6208. }
  6209. ACMD_FUNC(cleanmap)
  6210. {
  6211. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  6212. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6213. return 0;
  6214. }
  6215. ACMD_FUNC(cleanarea)
  6216. {
  6217. int16 x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  6218. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  6219. 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);
  6220. }
  6221. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  6222. 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);
  6223. }
  6224. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  6225. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  6226. }
  6227. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  6228. return 0;
  6229. }
  6230. /*==========================================
  6231. * make a NPC/PET talk
  6232. * @npctalkc [SnakeDrak]
  6233. *------------------------------------------*/
  6234. ACMD_FUNC(npctalk)
  6235. {
  6236. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  6237. struct npc_data *nd;
  6238. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  6239. unsigned long color=0;
  6240. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6241. return -1; //no "chatting" while muted.
  6242. if(!ifcolor) {
  6243. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  6244. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  6245. return -1;
  6246. }
  6247. }
  6248. else {
  6249. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  6250. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  6251. return -1;
  6252. }
  6253. }
  6254. if (!(nd = npc_name2id(name))) {
  6255. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  6256. return -1;
  6257. }
  6258. strtok(name, "#"); // discard extra name identifier if present
  6259. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  6260. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  6261. else clif_disp_overhead(&nd->bl, temp);
  6262. return 0;
  6263. }
  6264. ACMD_FUNC(pettalk)
  6265. {
  6266. char mes[100],temp[CHAT_SIZE_MAX];
  6267. struct pet_data *pd;
  6268. nullpo_retr(-1, sd);
  6269. if ( battle_config.min_chat_delay ) {
  6270. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6271. return 0;
  6272. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6273. }
  6274. if(!sd->status.pet_id || !(pd=sd->pd))
  6275. {
  6276. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  6277. return -1;
  6278. }
  6279. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  6280. return -1; //no "chatting" while muted.
  6281. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6282. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  6283. return -1;
  6284. }
  6285. if (message[0] == '/')
  6286. {// pet emotion processing
  6287. const char* emo[] = {
  6288. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  6289. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  6290. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  6291. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  6292. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  6293. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  6294. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  6295. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  6296. "/whisp"
  6297. };
  6298. int32 i;
  6299. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  6300. if( i == ET_DICE1 ) i = rnd_value<int32>(ET_DICE1, ET_DICE6); // randomize /dice
  6301. if( i < ARRAYLENGTH(emo) )
  6302. {
  6303. if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
  6304. sd->emotionlasttime = time(nullptr);
  6305. return 0;
  6306. }
  6307. sd->emotionlasttime = time(nullptr);
  6308. clif_emotion( pd->bl, static_cast<emotion_type>( i ) );
  6309. return 0;
  6310. }
  6311. }
  6312. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  6313. clif_disp_overhead(&pd->bl, temp);
  6314. return 0;
  6315. }
  6316. /// @users - displays the number of players present on each map (and percentage)
  6317. /// #users displays on the target user instead of self
  6318. ACMD_FUNC(users)
  6319. {
  6320. char buf[CHAT_SIZE_MAX];
  6321. int32 i;
  6322. int32 users[MAX_MAPINDEX];
  6323. int32 users_all;
  6324. struct s_mapiterator* iter;
  6325. memset(users, 0, sizeof(users));
  6326. users_all = 0;
  6327. // count users on each map
  6328. iter = mapit_getallusers();
  6329. for(;;)
  6330. {
  6331. map_session_data* sd2 = (map_session_data*)mapit_next(iter);
  6332. if( sd2 == nullptr )
  6333. break;// no more users
  6334. if( sd2->mapindex >= MAX_MAPINDEX )
  6335. continue;// invalid mapindex
  6336. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  6337. if( users_all < INT_MAX ) ++users_all;
  6338. }
  6339. mapit_free(iter);
  6340. // display results for each map
  6341. for( i = 0; i < MAX_MAPINDEX; ++i )
  6342. {
  6343. if( users[i] == 0 )
  6344. continue;// empty
  6345. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  6346. clif_displaymessage(sd->fd, buf);
  6347. }
  6348. // display overall count
  6349. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  6350. clif_displaymessage(sd->fd, buf);
  6351. return 0;
  6352. }
  6353. /*==========================================
  6354. *
  6355. *------------------------------------------*/
  6356. ACMD_FUNC(reset)
  6357. {
  6358. pc_resetstate(sd);
  6359. pc_resetskill(sd,1);
  6360. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  6361. clif_displaymessage(fd, atcmd_output);
  6362. return 0;
  6363. }
  6364. /*==========================================
  6365. *
  6366. *------------------------------------------*/
  6367. ACMD_FUNC(summon)
  6368. {
  6369. char name[NAME_LENGTH];
  6370. int32 mob_id = 0;
  6371. int32 duration = 0;
  6372. struct mob_data *md;
  6373. t_tick tick=gettick();
  6374. nullpo_retr(-1, sd);
  6375. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  6376. {
  6377. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  6378. return -1;
  6379. }
  6380. if (duration < 1)
  6381. duration =1;
  6382. else if (duration > 60)
  6383. duration =60;
  6384. if ((mob_id = atoi(name)) == 0)
  6385. mob_id = mobdb_searchname(name);
  6386. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  6387. {
  6388. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6389. return -1;
  6390. }
  6391. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  6392. if(!md)
  6393. return -1;
  6394. md->master_id=sd->bl.id;
  6395. md->special_state.ai=AI_ATTACK;
  6396. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  6397. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  6398. mob_spawn(md);
  6399. sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  6400. clif_skill_poseffect( sd->bl, AM_CALLHOMUN, 1, md->bl.x, md->bl.y, tick );
  6401. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  6402. return 0;
  6403. }
  6404. /*==========================================
  6405. * @adjgroup
  6406. * Temporarily move player to another group
  6407. * Useful during beta testing to allow players to use GM commands for short periods of time
  6408. *------------------------------------------*/
  6409. ACMD_FUNC(adjgroup)
  6410. {
  6411. int32 new_group = 0;
  6412. nullpo_retr(-1, sd);
  6413. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  6414. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  6415. return -1;
  6416. }
  6417. if (!player_group_db.exists(new_group)) {
  6418. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  6419. return -1;
  6420. }
  6421. sd->group_id = new_group;
  6422. pc_group_pc_load(sd);/* update cache */
  6423. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  6424. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  6425. return 0;
  6426. }
  6427. /*==========================================
  6428. * @trade by [MouseJstr]
  6429. * Open a trade window with a remote player
  6430. *------------------------------------------*/
  6431. ACMD_FUNC(trade)
  6432. {
  6433. map_session_data* pl_sd = nullptr;;
  6434. nullpo_retr(-1, sd);
  6435. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6436. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6437. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  6438. return -1;
  6439. }
  6440. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
  6441. {
  6442. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6443. return -1;
  6444. }
  6445. trade_traderequest(sd, pl_sd);
  6446. return 0;
  6447. }
  6448. /*==========================================
  6449. * @setbattleflag by [MouseJstr]
  6450. * set a battle_config flag without having to reboot
  6451. *------------------------------------------*/
  6452. ACMD_FUNC(setbattleflag)
  6453. {
  6454. char flag[128], value[128];
  6455. int32 reload = 0;
  6456. nullpo_retr(-1, sd);
  6457. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) < 2) {
  6458. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  6459. return -1;
  6460. }
  6461. if (battle_set_value(flag, value) == 0)
  6462. {
  6463. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  6464. return -1;
  6465. }
  6466. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  6467. if (reload)
  6468. mob_reload();
  6469. return 0;
  6470. }
  6471. /*==========================================
  6472. * @unmute [Valaris]
  6473. *------------------------------------------*/
  6474. ACMD_FUNC(unmute)
  6475. {
  6476. map_session_data* pl_sd = nullptr;;
  6477. nullpo_retr(-1, sd);
  6478. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6479. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  6480. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  6481. return -1;
  6482. }
  6483. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6484. {
  6485. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6486. return -1;
  6487. }
  6488. if(!pl_sd->sc.getSCE(SC_NOCHAT)) {
  6489. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  6490. return -1;
  6491. }
  6492. pl_sd->status.manner = 0;
  6493. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6494. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  6495. return 0;
  6496. }
  6497. /*==========================================
  6498. * @uptime by MC Cameri
  6499. *------------------------------------------*/
  6500. ACMD_FUNC(uptime)
  6501. {
  6502. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  6503. minute = 60, days = 0, hours = 0, minutes = 0;
  6504. nullpo_retr(-1, sd);
  6505. seconds = get_uptime();
  6506. days = seconds/day;
  6507. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  6508. hours = seconds/hour;
  6509. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  6510. minutes = seconds/minute;
  6511. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  6512. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  6513. clif_displaymessage(fd, atcmd_output);
  6514. return 0;
  6515. }
  6516. /*==========================================
  6517. * @changesex
  6518. * => Changes one's account sex. Switch from male to female or visversa
  6519. *------------------------------------------*/
  6520. ACMD_FUNC(changesex)
  6521. {
  6522. int32 i;
  6523. nullpo_retr(-1, sd);
  6524. pc_resetskill(sd,4);
  6525. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6526. for (i = 0; i < EQI_MAX; i++) {
  6527. if (sd->equip_index[i] >= 0)
  6528. pc_unequipitem(sd, sd->equip_index[i], 3);
  6529. }
  6530. chrif_changesex(sd, true);
  6531. return 0;
  6532. }
  6533. /*==========================================
  6534. * @changecharsex
  6535. * => Changes one's character sex. Switch from male to female or visversa.
  6536. *------------------------------------------*/
  6537. ACMD_FUNC(changecharsex)
  6538. {
  6539. int32 i;
  6540. nullpo_retr(-1, sd);
  6541. pc_resetskill(sd,4);
  6542. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  6543. for (i = 0; i < EQI_MAX; i++) {
  6544. if (sd->equip_index[i] >= 0)
  6545. pc_unequipitem(sd, sd->equip_index[i], 3);
  6546. }
  6547. chrif_changesex(sd, false);
  6548. return 0;
  6549. }
  6550. /*================================================
  6551. * @mute - Mutes a player for a set amount of time
  6552. *------------------------------------------------*/
  6553. ACMD_FUNC(mute)
  6554. {
  6555. map_session_data* pl_sd = nullptr;;
  6556. int32 manner;
  6557. nullpo_retr(-1, sd);
  6558. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6559. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6560. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6561. return -1;
  6562. }
  6563. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
  6564. {
  6565. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6566. return -1;
  6567. }
  6568. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6569. {
  6570. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6571. return -1;
  6572. }
  6573. clif_manner_message(sd, 0);
  6574. clif_manner_message(pl_sd, 5);
  6575. if( pl_sd->status.manner < manner ) {
  6576. pl_sd->status.manner -= manner;
  6577. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6578. } else {
  6579. pl_sd->status.manner = 0;
  6580. status_change_end(&pl_sd->bl, SC_NOCHAT);
  6581. }
  6582. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6583. return 0;
  6584. }
  6585. /*==========================================
  6586. * @refresh (like @jumpto <<yourself>>)
  6587. *------------------------------------------*/
  6588. ACMD_FUNC(refresh)
  6589. {
  6590. nullpo_retr(-1, sd);
  6591. clif_refresh(sd);
  6592. return 0;
  6593. }
  6594. ACMD_FUNC(refreshall)
  6595. {
  6596. map_session_data* iter_sd;
  6597. struct s_mapiterator* iter;
  6598. nullpo_retr(-1, sd);
  6599. iter = mapit_getallusers();
  6600. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6601. clif_refresh(iter_sd);
  6602. mapit_free(iter);
  6603. return 0;
  6604. }
  6605. /*==========================================
  6606. * @identify
  6607. * => GM's magnifier.
  6608. *------------------------------------------*/
  6609. ACMD_FUNC(identify)
  6610. {
  6611. int32 i,num;
  6612. nullpo_retr(-1, sd);
  6613. for(i=num=0;i<MAX_INVENTORY;i++){
  6614. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6615. num++;
  6616. }
  6617. }
  6618. if (num > 0) {
  6619. clif_item_identify_list(sd);
  6620. } else {
  6621. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6622. }
  6623. return 0;
  6624. }
  6625. /*===============================================
  6626. * @identifyall
  6627. * => Indentify all items in inventory - Akinari
  6628. *-----------------------------------------------*/
  6629. ACMD_FUNC(identifyall)
  6630. {
  6631. nullpo_retr(-1, sd);
  6632. pc_identifyall(sd, true);
  6633. return 0;
  6634. }
  6635. /*==========================================
  6636. * @gmotd (Global MOTD)
  6637. * by davidsiaw :P
  6638. *------------------------------------------*/
  6639. ACMD_FUNC(gmotd)
  6640. {
  6641. FILE* fp;
  6642. if( ( fp = fopen(motd_txt, "r") ) != nullptr )
  6643. {
  6644. char buf[CHAT_SIZE_MAX];
  6645. size_t len;
  6646. while( fgets(buf, sizeof(buf), fp) )
  6647. {
  6648. if( buf[0] == '/' && buf[1] == '/' )
  6649. {
  6650. continue;
  6651. }
  6652. len = strlen(buf);
  6653. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6654. {// strip trailing EOL characters
  6655. len--;
  6656. }
  6657. if( len )
  6658. {
  6659. buf[len] = 0;
  6660. intif_broadcast(buf, len+1, 0);
  6661. }
  6662. }
  6663. fclose(fp);
  6664. }
  6665. return 0;
  6666. }
  6667. ACMD_FUNC(misceffect)
  6668. {
  6669. int32 effect = 0;
  6670. nullpo_retr(-1, sd);
  6671. if (!message || !*message)
  6672. return -1;
  6673. if (sscanf(message, "%11d", &effect) < 1)
  6674. return -1;
  6675. if (effect < NOTIFYEFFECT_BASE_LEVEL_UP || effect > NOTIFYEFFECT_TAEKWON_BASE_LEVEL_UP)
  6676. return -1;
  6677. clif_misceffect( sd->bl, static_cast<e_notify_effect>(effect) );
  6678. return 0;
  6679. }
  6680. /*==========================================
  6681. * MAIL SYSTEM
  6682. *------------------------------------------*/
  6683. ACMD_FUNC(mail)
  6684. {
  6685. nullpo_ret(sd);
  6686. mail_openmail(sd);
  6687. return 0;
  6688. }
  6689. /*==========================================
  6690. * Show Monster DB Info v 1.0
  6691. * originally by [Lupus]
  6692. *------------------------------------------*/
  6693. ACMD_FUNC(mobinfo)
  6694. {
  6695. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6696. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6697. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6698. char atcmd_output2[CHAT_SIZE_MAX];
  6699. uint16 mob_ids[MAX_SEARCH], count;
  6700. uint16 i;
  6701. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6702. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6703. if (!message || !*message) {
  6704. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6705. return -1;
  6706. }
  6707. // If monster identifier/name argument is a name
  6708. i = util::strtoint32def(message);
  6709. if (i != 0 && (i = mobdb_checkid(i)))
  6710. {
  6711. mob_ids[0] = i;
  6712. count = 1;
  6713. } else
  6714. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6715. if (!count) {
  6716. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6717. return -1;
  6718. }
  6719. if (count >= MAX_SEARCH) {
  6720. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6721. clif_displaymessage(fd, atcmd_output);
  6722. count = MAX_SEARCH;
  6723. }
  6724. for (uint16 k = 0; k < count; k++) {
  6725. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_ids[k]);
  6726. if (mob == nullptr)
  6727. continue;
  6728. t_exp base_exp = mob->base_exp;
  6729. t_exp job_exp = mob->job_exp;
  6730. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6731. base_exp += (base_exp * battle_config.vip_base_exp_increase) / 100;
  6732. job_exp += (job_exp * battle_config.vip_job_exp_increase) / 100;
  6733. }
  6734. #ifdef RENEWAL_EXP
  6735. if( battle_config.atcommand_mobinfo_type ) {
  6736. int32 penalty = pc_level_penalty_mod( sd, PENALTY_EXP, mob );
  6737. base_exp = base_exp * penalty / 100;
  6738. job_exp = job_exp * penalty / 100;
  6739. }
  6740. #endif
  6741. // stats
  6742. if( mob->get_bosstype() == BOSSTYPE_MVP )
  6743. 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)
  6744. else
  6745. 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)
  6746. clif_displaymessage(fd, atcmd_output);
  6747. 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
  6748. clif_displaymessage(fd, atcmd_output);
  6749. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6750. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6751. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6752. clif_displaymessage(fd, atcmd_output);
  6753. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6754. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6755. mob->range2 , mob->range3, msize[mob->status.size],
  6756. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6757. clif_displaymessage(fd, atcmd_output);
  6758. #ifdef RENEWAL
  6759. sprintf(atcmd_output, msg_txt(sd, 827), mob->status.res, mob->status.mres);// MDEF:%d RES:%d MRES:%d
  6760. clif_displaymessage(fd, atcmd_output);
  6761. #endif
  6762. // drops
  6763. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6764. strcpy(atcmd_output, " ");
  6765. uint32 j = 0;
  6766. int32 drop_modifier = 100;
  6767. #ifdef RENEWAL_DROP
  6768. if( battle_config.atcommand_mobinfo_type ){
  6769. drop_modifier = pc_level_penalty_mod( sd, PENALTY_DROP, mob );
  6770. }
  6771. #endif
  6772. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6773. if (mob->dropitem[i].nameid == 0 || mob->dropitem[i].rate < 1)
  6774. continue;
  6775. std::shared_ptr<item_data> id = item_db.find(mob->dropitem[i].nameid);
  6776. if (id == nullptr)
  6777. continue;
  6778. int32 droprate = mob_getdroprate( &sd->bl, mob, mob->dropitem[i].rate, drop_modifier );
  6779. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), (float)droprate / 100);
  6780. strcat(atcmd_output, atcmd_output2);
  6781. if (++j % 3 == 0) {
  6782. clif_displaymessage(fd, atcmd_output);
  6783. strcpy(atcmd_output, " ");
  6784. }
  6785. }
  6786. if (j == 0)
  6787. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6788. else if (j % 3 != 0)
  6789. clif_displaymessage(fd, atcmd_output);
  6790. // mvp
  6791. if( mob->get_bosstype() == BOSSTYPE_MVP ){
  6792. float mvppercent, mvpremain;
  6793. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%llu
  6794. clif_displaymessage(fd, atcmd_output);
  6795. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6796. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6797. j = 0;
  6798. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6799. if (mob->mvpitem[i].nameid == 0)
  6800. continue;
  6801. std::shared_ptr<item_data> id = item_db.find(mob->mvpitem[i].nameid);
  6802. if (id == nullptr)
  6803. continue;
  6804. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6805. mvppercent = (float)mob->mvpitem[i].rate * mvpremain / 10000.0f;
  6806. if(battle_config.item_drop_mvp_mode == 0) {
  6807. mvpremain -= mvppercent;
  6808. }
  6809. if (mvppercent > 0) {
  6810. j++;
  6811. if (j == 1) {
  6812. sprintf(atcmd_output2, " %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6813. } else {
  6814. sprintf(atcmd_output2, " - %s %02.02f%%", item_db.create_item_link( id ).c_str(), mvppercent);
  6815. }
  6816. strcat(atcmd_output, atcmd_output2);
  6817. }
  6818. }
  6819. if (j == 0)
  6820. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6821. else
  6822. clif_displaymessage(fd, atcmd_output);
  6823. }
  6824. }
  6825. return 0;
  6826. }
  6827. /*=========================================
  6828. * @showmobs by KarLaeda
  6829. * => For 15 sec displays the mobs on minimap
  6830. *------------------------------------------*/
  6831. ACMD_FUNC(showmobs)
  6832. {
  6833. char mob_name[100];
  6834. int32 mob_id;
  6835. int32 number = 0;
  6836. struct s_mapiterator* it;
  6837. nullpo_retr(-1, sd);
  6838. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6839. return -1;
  6840. if((mob_id = strtol(mob_name, nullptr, 10)) == 0)
  6841. mob_id = mobdb_searchname(mob_name);
  6842. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  6843. if (mob == nullptr || mobdb_checkid(mob_id) == 0) {
  6844. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6845. clif_displaymessage(fd, atcmd_output);
  6846. return 0;
  6847. }
  6848. 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.
  6849. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6850. return 0;
  6851. }
  6852. if(mob_id == strtol(mob_name, nullptr, 10) && !mob->jname.empty())
  6853. strcpy(mob_name, mob->jname.c_str()); // --ja--
  6854. //strcpy(mob_name, mob->name.c_str()); // --en--
  6855. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6856. mob_name, mapindex_id2name(sd->mapindex));
  6857. clif_displaymessage(fd, atcmd_output);
  6858. it = mapit_geteachmob();
  6859. for(;;)
  6860. {
  6861. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6862. if( md == nullptr )
  6863. break;// no more mobs
  6864. if( md->bl.m != sd->bl.m )
  6865. continue;
  6866. if( mob_id != -1 && md->mob_id != mob_id )
  6867. continue;
  6868. if( md->special_state.ai || md->master_id )
  6869. continue; // hide slaves and player summoned mobs
  6870. if( md->spawn_timer != INVALID_TIMER )
  6871. continue; // hide mobs waiting for respawn
  6872. ++number;
  6873. clif_viewpoint( *sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF );
  6874. }
  6875. mapit_free(it);
  6876. return 0;
  6877. }
  6878. /*==========================================
  6879. * homunculus level up [orn]
  6880. *------------------------------------------*/
  6881. ACMD_FUNC(homlevel)
  6882. {
  6883. TBL_HOM * hd;
  6884. int32 level = 0, i = 0;
  6885. nullpo_retr(-1, sd);
  6886. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6887. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6888. return -1;
  6889. }
  6890. if ( !hom_is_active(sd->hd) ) {
  6891. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6892. return -1;
  6893. }
  6894. hd = sd->hd;
  6895. for (i = 1; i <= level && hd->exp_next; i++){
  6896. hd->homunculus.exp += hd->exp_next;
  6897. if( !hom_levelup(hd) )
  6898. break;
  6899. }
  6900. status_calc_homunculus(hd, SCO_NONE);
  6901. status_percent_heal(&hd->bl, 100, 100);
  6902. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6903. return 0;
  6904. }
  6905. /*==========================================
  6906. * homunculus evolution H [orn]
  6907. *------------------------------------------*/
  6908. ACMD_FUNC(homevolution)
  6909. {
  6910. nullpo_retr(-1, sd);
  6911. if ( !hom_is_active(sd->hd) ) {
  6912. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6913. return -1;
  6914. }
  6915. if ( !hom_evolution(sd->hd) ) {
  6916. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6917. return -1;
  6918. }
  6919. clif_homskillinfoblock( *sd->hd );
  6920. return 0;
  6921. }
  6922. ACMD_FUNC(hommutate)
  6923. {
  6924. int32 homun_id, m_class = 0, m_id;
  6925. nullpo_retr(-1, sd);
  6926. if (!hom_is_active(sd->hd)) {
  6927. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6928. return -1;
  6929. }
  6930. if (!message || !*message) {
  6931. homun_id = rnd_value<uint16>(MER_EIRA, MER_ELEANOR);
  6932. } else {
  6933. homun_id = atoi(message);
  6934. }
  6935. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6936. m_id = hom_class2mapid(homun_id);
  6937. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6938. hom_mutate(sd->hd, homun_id);
  6939. } else {
  6940. clif_emotion( sd->hd->bl, ET_SWEAT );
  6941. }
  6942. return 0;
  6943. }
  6944. /*==========================================
  6945. * call choosen homunculus [orn]
  6946. *------------------------------------------*/
  6947. ACMD_FUNC(makehomun)
  6948. {
  6949. int32 homunid;
  6950. nullpo_retr(-1, sd);
  6951. if ( sd->status.hom_id ) {
  6952. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6953. return -1;
  6954. }
  6955. if (!message || !*message) {
  6956. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6957. return -1;
  6958. }
  6959. homunid = atoi(message);
  6960. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6961. {
  6962. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6963. return -1;
  6964. }
  6965. hom_create_request(sd,homunid);
  6966. return 0;
  6967. }
  6968. /*==========================================
  6969. * modify homunculus intimacy [orn]
  6970. *------------------------------------------*/
  6971. ACMD_FUNC(homfriendly)
  6972. {
  6973. int32 friendly = 0;
  6974. nullpo_retr(-1, sd);
  6975. if ( !hom_is_active(sd->hd) ) {
  6976. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6977. return -1;
  6978. }
  6979. if (!message || !*message) {
  6980. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6981. return -1;
  6982. }
  6983. friendly = atoi(message);
  6984. friendly = cap_value(friendly, 0, 1000);
  6985. sd->hd->homunculus.intimacy = friendly * 100 ;
  6986. clif_send_homdata( *sd->hd, SP_INTIMATE );
  6987. return 0;
  6988. }
  6989. /*==========================================
  6990. * modify homunculus hunger [orn]
  6991. *------------------------------------------*/
  6992. ACMD_FUNC(homhungry)
  6993. {
  6994. int32 hungry = 0;
  6995. nullpo_retr(-1, sd);
  6996. if ( !hom_is_active(sd->hd) ) {
  6997. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6998. return -1;
  6999. }
  7000. if (!message || !*message) {
  7001. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  7002. return -1;
  7003. }
  7004. hungry = atoi(message);
  7005. hungry = cap_value(hungry, 0, 100);
  7006. sd->hd->homunculus.hunger = hungry;
  7007. clif_send_homdata( *sd->hd, SP_HUNGRY );
  7008. return 0;
  7009. }
  7010. /*==========================================
  7011. * make the homunculus speak [orn]
  7012. *------------------------------------------*/
  7013. ACMD_FUNC(homtalk)
  7014. {
  7015. char mes[100],temp[CHAT_SIZE_MAX];
  7016. nullpo_retr(-1, sd);
  7017. if ( battle_config.min_chat_delay ) {
  7018. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  7019. return 0;
  7020. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  7021. }
  7022. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7023. return -1; //no "chatting" while muted.
  7024. if ( !hom_is_active(sd->hd) ) {
  7025. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7026. return -1;
  7027. }
  7028. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  7029. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  7030. return -1;
  7031. }
  7032. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  7033. clif_disp_overhead(&sd->hd->bl, temp);
  7034. return 0;
  7035. }
  7036. /*==========================================
  7037. * Show homunculus stats
  7038. *------------------------------------------*/
  7039. ACMD_FUNC(hominfo)
  7040. {
  7041. struct homun_data *hd;
  7042. nullpo_retr(-1, sd);
  7043. if ( !hom_is_active(sd->hd) ) {
  7044. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7045. return -1;
  7046. }
  7047. hd = sd->hd;
  7048. status_data* status = status_get_status_data(hd->bl);
  7049. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  7050. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  7051. status->hp, status->max_hp, status->sp, status->max_sp);
  7052. clif_displaymessage(fd, atcmd_output);
  7053. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  7054. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  7055. clif_displaymessage(fd, atcmd_output);
  7056. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  7057. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  7058. clif_displaymessage(fd, atcmd_output);
  7059. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7060. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  7061. status->str, status->agi, status->vit,
  7062. status->int_, status->dex, status->luk);
  7063. clif_displaymessage(fd, atcmd_output);
  7064. return 0;
  7065. }
  7066. ACMD_FUNC(homstats)
  7067. {
  7068. struct homun_data *hd;
  7069. std::shared_ptr<s_homunculus_db> db;
  7070. struct s_homunculus *hom;
  7071. int32 lv, min, max, evo;
  7072. nullpo_retr(-1, sd);
  7073. if ( !hom_is_active(sd->hd) ) {
  7074. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  7075. return -1;
  7076. }
  7077. hd = sd->hd;
  7078. hom = &hd->homunculus;
  7079. db = hd->homunculusDB;
  7080. lv = hom->level;
  7081. snprintf(atcmd_output, sizeof(atcmd_output) ,
  7082. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  7083. clif_displaymessage(fd, atcmd_output);
  7084. lv--; //Since the first increase is at level 2.
  7085. evo = (hom->class_ == db->evo_class);
  7086. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  7087. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  7088. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  7089. clif_displaymessage(fd, atcmd_output);
  7090. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  7091. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  7092. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  7093. clif_displaymessage(fd, atcmd_output);
  7094. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  7095. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  7096. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  7097. clif_displaymessage(fd, atcmd_output);
  7098. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  7099. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  7100. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  7101. clif_displaymessage(fd, atcmd_output);
  7102. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  7103. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  7104. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  7105. clif_displaymessage(fd, atcmd_output);
  7106. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  7107. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  7108. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  7109. clif_displaymessage(fd, atcmd_output);
  7110. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  7111. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  7112. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  7113. clif_displaymessage(fd, atcmd_output);
  7114. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  7115. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  7116. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  7117. clif_displaymessage(fd, atcmd_output);
  7118. return 0;
  7119. }
  7120. ACMD_FUNC(homshuffle)
  7121. {
  7122. nullpo_retr(-1, sd);
  7123. if(!sd->hd)
  7124. return -1; // nothing to do
  7125. if(!hom_shuffle(sd->hd))
  7126. return -1;
  7127. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  7128. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  7129. return 0;
  7130. }
  7131. /*==========================================
  7132. * Show Items DB Info v 1.0
  7133. * originally by [Lupus]
  7134. *------------------------------------------*/
  7135. ACMD_FUNC(iteminfo)
  7136. {
  7137. if (!message || !*message) {
  7138. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  7139. return -1;
  7140. }
  7141. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7142. uint16 count = 1;
  7143. t_itemid itemid = strtoul(message, nullptr, 10);
  7144. if (itemid == 0) // Entered a string
  7145. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7146. else {
  7147. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7148. count = 0;
  7149. }
  7150. if (!count) {
  7151. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7152. return -1;
  7153. }
  7154. if (count == MAX_SEARCH) {
  7155. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7156. clif_displaymessage(fd, atcmd_output);
  7157. }
  7158. for (const auto &result : item_array) {
  7159. std::shared_ptr<item_data> item_data = result.second;
  7160. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
  7161. item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
  7162. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
  7163. (item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  7164. );
  7165. clif_displaymessage(fd, atcmd_output);
  7166. 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
  7167. clif_displaymessage(fd, atcmd_output);
  7168. if (item_data->maxchance == -1) {
  7169. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  7170. clif_displaymessage(fd, atcmd_output);
  7171. }
  7172. else if (!battle_config.atcommand_mobinfo_type) {
  7173. if (item_data->maxchance)
  7174. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  7175. else
  7176. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  7177. clif_displaymessage(fd, atcmd_output);
  7178. }
  7179. }
  7180. return 0;
  7181. }
  7182. /*==========================================
  7183. * Show who drops the item.
  7184. *------------------------------------------*/
  7185. ACMD_FUNC(whodrops)
  7186. {
  7187. if (!message || !*message) {
  7188. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  7189. return -1;
  7190. }
  7191. std::map<t_itemid, std::shared_ptr<item_data>> item_array = {};
  7192. uint16 count = 1;
  7193. t_itemid itemid = strtoul(message, nullptr, 10);
  7194. if (itemid == 0) // Entered a string
  7195. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  7196. else {
  7197. if ((item_array[0] = item_db.find(itemid)) == nullptr)
  7198. count = 0;
  7199. }
  7200. if (!count) {
  7201. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7202. return -1;
  7203. }
  7204. if (count == MAX_SEARCH) {
  7205. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7206. clif_displaymessage(fd, atcmd_output);
  7207. }
  7208. for (const auto &result : item_array) {
  7209. std::shared_ptr<item_data> id = result.second;
  7210. sprintf(atcmd_output, msg_txt(sd,1285), item_db.create_item_link( id ).c_str(), id->nameid); // Item: '%s' (ID:%u)
  7211. clif_displaymessage(fd, atcmd_output);
  7212. if (id->mob[0].chance == 0) {
  7213. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  7214. clif_displaymessage(fd, atcmd_output);
  7215. } else {
  7216. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  7217. clif_displaymessage(fd, atcmd_output);
  7218. for (uint16 j=0; j < MAX_SEARCH && id->mob[j].chance > 0; j++)
  7219. {
  7220. int32 dropchance = id->mob[j].chance;
  7221. std::shared_ptr<s_mob_db> mob = mob_db.find(id->mob[j].id);
  7222. if(!mob) continue;
  7223. #ifdef RENEWAL_DROP
  7224. if( battle_config.atcommand_mobinfo_type ) {
  7225. dropchance = dropchance * pc_level_penalty_mod( sd, PENALTY_DROP, mob ) / 100;
  7226. if (dropchance <= 0 && !battle_config.drop_rate0item)
  7227. dropchance = 1;
  7228. }
  7229. #endif
  7230. if (pc_isvip(sd)) // Display item rate increase for VIP
  7231. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  7232. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob->jname.c_str(), id->mob[j].id, dropchance/100.);
  7233. clif_displaymessage(fd, atcmd_output);
  7234. }
  7235. }
  7236. }
  7237. return 0;
  7238. }
  7239. ACMD_FUNC(whereis)
  7240. {
  7241. uint16 mob_ids[MAX_SEARCH] = {0}, count;
  7242. if (!message || !*message) {
  7243. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  7244. return -1;
  7245. }
  7246. int32 i_message = atoi(message);
  7247. if (mobdb_checkid(i_message)) {
  7248. // ID given
  7249. mob_ids[0] = i_message;
  7250. count = 1;
  7251. } else {
  7252. // Name given, get all monster associated whith this name
  7253. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  7254. }
  7255. if (count <= 0) {
  7256. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  7257. return -1;
  7258. }
  7259. if (count >= MAX_SEARCH) {
  7260. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  7261. clif_displaymessage(fd, atcmd_output);
  7262. count = MAX_SEARCH;
  7263. }
  7264. for (int32 i = 0; i < count; i++) {
  7265. uint16 mob_id = mob_ids[i];
  7266. std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id);
  7267. if(!mob) continue;
  7268. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname.c_str()); // %s spawns in:
  7269. clif_displaymessage(fd, atcmd_output);
  7270. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  7271. if (spawns.size() <= 0) {
  7272. // This monster does not spawn normally.
  7273. clif_displaymessage(fd, msg_txt(sd,1290));
  7274. } else {
  7275. for(auto& spawn : spawns)
  7276. {
  7277. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  7278. if (mapid < 0)
  7279. continue;
  7280. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  7281. clif_displaymessage(fd, atcmd_output);
  7282. }
  7283. }
  7284. }
  7285. return 0;
  7286. }
  7287. ACMD_FUNC(version)
  7288. {
  7289. pc_show_version(sd);
  7290. return 0;
  7291. }
  7292. /*==========================================
  7293. * @mutearea by MouseJstr
  7294. *------------------------------------------*/
  7295. static int32 atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  7296. {
  7297. int32 time, id;
  7298. map_session_data *pl_sd = (map_session_data *)bl;
  7299. if (pl_sd == nullptr)
  7300. return 0;
  7301. id = va_arg(ap, int32);
  7302. time = va_arg(ap, int32);
  7303. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  7304. pl_sd->status.manner -= time;
  7305. if (pl_sd->status.manner < 0)
  7306. sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
  7307. else
  7308. status_change_end(&pl_sd->bl, SC_NOCHAT);
  7309. }
  7310. return 0;
  7311. }
  7312. ACMD_FUNC(mutearea)
  7313. {
  7314. int32 time;
  7315. nullpo_ret(sd);
  7316. if (!message || !*message) {
  7317. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  7318. return -1;
  7319. }
  7320. time = atoi(message);
  7321. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  7322. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  7323. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  7324. return 0;
  7325. }
  7326. ACMD_FUNC(rates)
  7327. {
  7328. char buf[CHAT_SIZE_MAX];
  7329. nullpo_ret(sd);
  7330. memset(buf, '\0', sizeof(buf));
  7331. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  7332. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  7333. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  7334. clif_displaymessage(fd, buf);
  7335. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7336. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  7337. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  7338. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  7339. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  7340. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  7341. clif_displaymessage(fd, buf);
  7342. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7343. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  7344. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  7345. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  7346. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  7347. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  7348. clif_displaymessage(fd, buf);
  7349. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  7350. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  7351. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  7352. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  7353. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  7354. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  7355. clif_displaymessage(fd, buf);
  7356. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  7357. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  7358. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  7359. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  7360. clif_displaymessage(fd, buf);
  7361. return 0;
  7362. }
  7363. /*==========================================
  7364. * @me by lordalfa
  7365. * => Displays the OUTPUT string on top of the Visible players Heads.
  7366. *------------------------------------------*/
  7367. ACMD_FUNC(me)
  7368. {
  7369. char tempmes[CHAT_SIZE_MAX];
  7370. nullpo_retr(-1, sd);
  7371. memset(tempmes, '\0', sizeof(tempmes));
  7372. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7373. if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
  7374. return -1; //no "chatting" while muted.
  7375. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  7376. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  7377. return -1;
  7378. }
  7379. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  7380. clif_disp_overhead(&sd->bl, atcmd_output);
  7381. return 0;
  7382. }
  7383. /*==========================================
  7384. * @size
  7385. * => Resize your character sprite. [Valaris]
  7386. *------------------------------------------*/
  7387. ACMD_FUNC(size)
  7388. {
  7389. int32 size = SZ_SMALL;
  7390. nullpo_retr(-1, sd);
  7391. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  7392. if(sd->state.size) {
  7393. sd->state.size = SZ_SMALL;
  7394. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  7395. }
  7396. sd->state.size = size;
  7397. if( size == SZ_MEDIUM )
  7398. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  7399. else if( size == SZ_BIG )
  7400. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  7401. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7402. return 0;
  7403. }
  7404. ACMD_FUNC(sizeall)
  7405. {
  7406. int32 size;
  7407. map_session_data *pl_sd;
  7408. struct s_mapiterator* iter;
  7409. size = atoi(message);
  7410. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7411. iter = mapit_getallusers();
  7412. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  7413. if( pl_sd->state.size != size ) {
  7414. if( pl_sd->state.size ) {
  7415. pl_sd->state.size = SZ_SMALL;
  7416. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7417. }
  7418. pl_sd->state.size = size;
  7419. if( size == SZ_MEDIUM )
  7420. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7421. else if( size == SZ_BIG )
  7422. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7423. }
  7424. }
  7425. mapit_free(iter);
  7426. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7427. return 0;
  7428. }
  7429. ACMD_FUNC(sizeguild)
  7430. {
  7431. int32 size = SZ_SMALL, i;
  7432. char guild[NAME_LENGTH];
  7433. map_session_data *pl_sd;
  7434. nullpo_retr(-1, sd);
  7435. memset(guild, '\0', sizeof(guild));
  7436. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  7437. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  7438. return -1;
  7439. }
  7440. auto g = guild_searchnameid(guild);
  7441. if (!g) {
  7442. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  7443. return -1;
  7444. }
  7445. size = cap_value(size,SZ_SMALL,SZ_BIG);
  7446. for( i = 0; i < g->guild.max_member; i++ ) {
  7447. if( (pl_sd = g->guild.member[i].sd) && pl_sd->state.size != size ) {
  7448. if( pl_sd->state.size ) {
  7449. pl_sd->state.size = SZ_SMALL;
  7450. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  7451. }
  7452. pl_sd->state.size = size;
  7453. if( size == SZ_MEDIUM )
  7454. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  7455. else if( size == SZ_BIG )
  7456. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  7457. }
  7458. }
  7459. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  7460. return 0;
  7461. }
  7462. /*==========================================
  7463. * @monsterignore
  7464. * => Makes monsters ignore you. [Valaris]
  7465. *------------------------------------------*/
  7466. ACMD_FUNC(monsterignore)
  7467. {
  7468. nullpo_retr(-1, sd);
  7469. if (sd->state.block_action & PCBLOCK_IMMUNE) {
  7470. sd->state.block_action &= ~PCBLOCK_IMMUNE;
  7471. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  7472. } else {
  7473. sd->state.block_action |= PCBLOCK_IMMUNE;
  7474. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  7475. }
  7476. return 0;
  7477. }
  7478. /*==========================================
  7479. * @fakename
  7480. * => Gives your character a fake name. [Valaris]
  7481. *------------------------------------------*/
  7482. ACMD_FUNC(fakename)
  7483. {
  7484. nullpo_retr(-1, sd);
  7485. if( !message || !*message )
  7486. {
  7487. if( sd->fakename[0] )
  7488. {
  7489. sd->fakename[0] = '\0';
  7490. clif_name_area(&sd->bl);
  7491. if (sd->disguise)
  7492. clif_name_self(&sd->bl);
  7493. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  7494. return 0;
  7495. }
  7496. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  7497. return -1;
  7498. }
  7499. if( strlen(message) < 2 )
  7500. {
  7501. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  7502. return -1;
  7503. }
  7504. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  7505. clif_name_area(&sd->bl);
  7506. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  7507. clif_name_self(&sd->bl);
  7508. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  7509. return 0;
  7510. }
  7511. /*==========================================
  7512. * Ragnarok Resources
  7513. *------------------------------------------*/
  7514. ACMD_FUNC(mapflag) {
  7515. char flag_name[50];
  7516. int16 flag = 0, i, j;
  7517. std::string buf;
  7518. nullpo_retr(-1, sd);
  7519. memset(flag_name, '\0', sizeof(flag_name));
  7520. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  7521. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  7522. clif_displaymessage(sd->fd,"----------------------------------");
  7523. for( i = MF_MIN; i < MF_MAX; i++ ){
  7524. union u_mapflag_args args = {};
  7525. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  7526. clif_displaymessage(sd->fd, flag_name);
  7527. }
  7528. }
  7529. clif_displaymessage(sd->fd," ");
  7530. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7531. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  7532. return 1;
  7533. }
  7534. // Check if the list of mapflags was requested
  7535. if( strcasecmp(flag_name,"available") ){
  7536. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  7537. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  7538. if( mapflag != MF_INVALID ){
  7539. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  7540. MF_PVP_NIGHTMAREDROP,
  7541. MF_RESTRICTED,
  7542. MF_NOCOMMAND,
  7543. MF_BEXP,
  7544. MF_JEXP,
  7545. MF_BATTLEGROUND,
  7546. MF_SKILL_DAMAGE,
  7547. MF_SKILL_DURATION };
  7548. if (flag > 0 && util::vector_exists(disabled_mf, mapflag)) {
  7549. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  7550. clif_displaymessage(sd->fd,atcmd_output);
  7551. } else {
  7552. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  7553. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  7554. clif_displaymessage(sd->fd,atcmd_output);
  7555. }
  7556. return 0;
  7557. }else{
  7558. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  7559. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  7560. return 1;
  7561. }
  7562. }
  7563. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7564. clif_displaymessage(sd->fd,"----------------------------------");
  7565. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  7566. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  7567. buf.append(flag_name);
  7568. if( (i + 1) < MF_MAX )
  7569. buf.append(", ");
  7570. j++;
  7571. }
  7572. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  7573. clif_displaymessage(sd->fd, buf.c_str() );
  7574. buf.clear();
  7575. j = 0;
  7576. }
  7577. }
  7578. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7579. return 0;
  7580. }
  7581. /*===================================
  7582. * Remove some messages
  7583. *-----------------------------------*/
  7584. ACMD_FUNC(showexp)
  7585. {
  7586. if (sd->state.showexp) {
  7587. sd->state.showexp = 0;
  7588. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7589. return 0;
  7590. }
  7591. sd->state.showexp = 1;
  7592. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7593. return 0;
  7594. }
  7595. ACMD_FUNC(showzeny)
  7596. {
  7597. if (sd->state.showzeny) {
  7598. sd->state.showzeny = 0;
  7599. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7600. return 0;
  7601. }
  7602. sd->state.showzeny = 1;
  7603. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7604. return 0;
  7605. }
  7606. ACMD_FUNC(showdelay)
  7607. {
  7608. if (sd->state.showdelay) {
  7609. sd->state.showdelay = 0;
  7610. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7611. return 0;
  7612. }
  7613. sd->state.showdelay = 1;
  7614. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7615. return 0;
  7616. }
  7617. /*==========================================
  7618. * Duel organizing functions [LuzZza]
  7619. *
  7620. * @duel [limit|nick] - create a duel
  7621. * @invite <nick> - invite player
  7622. * @accept - accept invitation
  7623. * @reject - reject invitation
  7624. * @leave - leave duel
  7625. *------------------------------------------*/
  7626. ACMD_FUNC(invite)
  7627. {
  7628. size_t did = sd->duel_group;
  7629. map_session_data *target_sd = nullptr;
  7630. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7631. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7632. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7633. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7634. clif_displaymessage(fd, atcmd_output);
  7635. return -1;
  7636. }
  7637. if(did == 0 || !duel_exist(did) ) {
  7638. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7639. return 0;
  7640. }
  7641. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7642. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7643. return 0;
  7644. }
  7645. if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
  7646. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7647. return 0;
  7648. }
  7649. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7650. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7651. return 0;
  7652. }
  7653. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7654. {
  7655. 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.
  7656. clif_displaymessage(fd, atcmd_output);
  7657. return 0;
  7658. }
  7659. duel_invite(did, sd, target_sd);
  7660. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7661. return 0;
  7662. }
  7663. ACMD_FUNC(duel)
  7664. {
  7665. uint32 maxpl = 0;
  7666. if(sd->duel_group > 0) {
  7667. duel_showinfo(sd->duel_group, sd);
  7668. return 0;
  7669. }
  7670. if(sd->duel_invite > 0) {
  7671. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7672. return 0;
  7673. }
  7674. if(!duel_checktime(sd)) {
  7675. char output[CHAT_SIZE_MAX];
  7676. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7677. clif_displaymessage(fd, output);
  7678. return 0;
  7679. }
  7680. if( message[0] ) {
  7681. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7682. if(maxpl < 2 || maxpl > 65535) {
  7683. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7684. return 0;
  7685. }
  7686. duel_create(sd, maxpl);
  7687. } else {
  7688. map_session_data *target_sd = nullptr;
  7689. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7690. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7691. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7692. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7693. clif_displaymessage(fd, atcmd_output);
  7694. return -1;
  7695. }
  7696. target_sd = map_nick2sd(atcmd_player_name,true);
  7697. if(target_sd != nullptr) {
  7698. size_t newduel;
  7699. if((newduel = duel_create(sd, 2)) != -1) {
  7700. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7701. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7702. return 0;
  7703. }
  7704. duel_invite(newduel, sd, target_sd);
  7705. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7706. }
  7707. } else {
  7708. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7709. return 0;
  7710. }
  7711. }
  7712. } else
  7713. duel_create(sd, 0);
  7714. return 0;
  7715. }
  7716. ACMD_FUNC(leave)
  7717. {
  7718. if(sd->duel_group <= 0) {
  7719. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7720. return 0;
  7721. }
  7722. duel_leave(sd->duel_group, sd);
  7723. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7724. return 0;
  7725. }
  7726. ACMD_FUNC(accept)
  7727. {
  7728. if(!duel_checktime(sd)) {
  7729. char output[CHAT_SIZE_MAX];
  7730. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7731. clif_displaymessage(fd, output);
  7732. return 0;
  7733. }
  7734. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7735. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7736. return 0;
  7737. }
  7738. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7739. {
  7740. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7741. return 0;
  7742. }
  7743. duel_accept(sd->duel_invite, sd);
  7744. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7745. return 0;
  7746. }
  7747. ACMD_FUNC(reject)
  7748. {
  7749. if(sd->duel_invite <= 0) {
  7750. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7751. return 0;
  7752. }
  7753. duel_reject(sd->duel_invite, sd);
  7754. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7755. return 0;
  7756. }
  7757. /*===================================
  7758. * Cash Points
  7759. *-----------------------------------*/
  7760. ACMD_FUNC(cash)
  7761. {
  7762. char output[128];
  7763. int32 value;
  7764. int32 ret=0;
  7765. nullpo_retr(-1, sd);
  7766. // Since there is no cashpoint update packet we need to force updating like this
  7767. if( sd->state.cashshop_open ){
  7768. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7769. return -1;
  7770. }
  7771. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7772. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7773. return -1;
  7774. }
  7775. if( value > 0 ) {
  7776. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7777. // If this option is set, the message is already sent by pc function
  7778. if( !battle_config.cashshop_show_points ){
  7779. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7780. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7781. }
  7782. }
  7783. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7784. } else {
  7785. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7786. value = -sd->cashPoints;
  7787. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7788. // If this option is set, the message is already sent by pc function
  7789. if( !battle_config.cashshop_show_points ){
  7790. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7791. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7792. }
  7793. }
  7794. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7795. }
  7796. return 0;
  7797. }
  7798. ACMD_FUNC(points){
  7799. char output[128];
  7800. int32 value;
  7801. int32 ret=0;
  7802. nullpo_retr(-1, sd);
  7803. // Since there is no cashpoint update packet we need to force updating like this
  7804. if( sd->state.cashshop_open ){
  7805. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7806. return -1;
  7807. }
  7808. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7809. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7810. return -1;
  7811. }
  7812. if( value > 0 ) {
  7813. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7814. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7815. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7816. }
  7817. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7818. } else {
  7819. if (-value > sd->kafraPoints) //By command, if cash < value, force it to remove all
  7820. value = -sd->kafraPoints;
  7821. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7822. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7823. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7824. }
  7825. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7826. }
  7827. return 0;
  7828. }
  7829. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7830. ACMD_FUNC(clone)
  7831. {
  7832. int32 x=0,y=0,flag=0,master=0,i=0;
  7833. map_session_data *pl_sd=nullptr;
  7834. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7835. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7836. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7837. return 0;
  7838. }
  7839. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
  7840. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7841. return 0;
  7842. }
  7843. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7844. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7845. return 0;
  7846. }
  7847. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  7848. if (strcmpi(parent_cmd, "clone") == 0)
  7849. flag = 1;
  7850. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7851. flag = 2;
  7852. if(pc_isdead(sd)){
  7853. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7854. return 0;
  7855. }
  7856. master = sd->bl.id;
  7857. if (battle_config.atc_slave_clone_limit
  7858. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7859. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7860. return 0;
  7861. }
  7862. }
  7863. do {
  7864. x = sd->bl.x + rnd_value(-5, 5);
  7865. y = sd->bl.y + rnd_value(-5, 5);
  7866. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7867. if (i >= 10) {
  7868. x = sd->bl.x;
  7869. y = sd->bl.y;
  7870. }
  7871. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7872. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7873. return 0;
  7874. }
  7875. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7876. return 0;
  7877. }
  7878. /*=====================================
  7879. * Autorejecting Invites/Deals [LuzZza]
  7880. * Usage: @noask
  7881. *-------------------------------------*/
  7882. ACMD_FUNC(noask)
  7883. {
  7884. if(sd->state.noask) {
  7885. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7886. sd->state.noask = 0;
  7887. } else {
  7888. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7889. sd->state.noask = 1;
  7890. }
  7891. return 0;
  7892. }
  7893. /*=====================================
  7894. * Send a @request message to all GMs of lowest_gm_level.
  7895. * Usage: @request <petition>
  7896. *-------------------------------------*/
  7897. ACMD_FUNC(request)
  7898. {
  7899. if (!message || !*message) {
  7900. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7901. return -1;
  7902. }
  7903. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7904. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7905. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7906. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7907. return 0;
  7908. }
  7909. /*==========================================
  7910. * Feel (SG designated maps) Reset [HiddenDragon]
  7911. *------------------------------------------*/
  7912. ACMD_FUNC(feelreset)
  7913. {
  7914. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7915. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7916. return -1;
  7917. }
  7918. pc_resetfeel(sd);
  7919. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7920. return 0;
  7921. }
  7922. /*==========================================
  7923. * Hate (SG designated monsters) Reset
  7924. *------------------------------------------*/
  7925. ACMD_FUNC(hatereset)
  7926. {
  7927. if ((sd->class_&MAPID_UPPERMASK) != MAPID_STAR_GLADIATOR) {
  7928. clif_displaymessage(sd->fd,msg_txt(sd,35)); // You can't use this command with this class.
  7929. return -1;
  7930. }
  7931. pc_resethate(sd);
  7932. clif_displaymessage(fd, msg_txt(sd,1515)); // Reset 'Hatred' monsters.
  7933. return 0;
  7934. }
  7935. /*==========================================
  7936. * AUCTION SYSTEM
  7937. *------------------------------------------*/
  7938. ACMD_FUNC(auction)
  7939. {
  7940. nullpo_ret(sd);
  7941. if (!battle_config.feature_auction) {
  7942. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7943. return 0;
  7944. }
  7945. clif_Auction_openwindow(sd);
  7946. return 0;
  7947. }
  7948. /*==========================================
  7949. * Kill Steal Protection
  7950. *------------------------------------------*/
  7951. ACMD_FUNC(ksprotection)
  7952. {
  7953. nullpo_retr(-1,sd);
  7954. if( sd->state.noks ) {
  7955. sd->state.noks = 0;
  7956. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7957. }
  7958. else
  7959. {
  7960. if( !message || !*message || !strcmpi(message, "party") )
  7961. { // Default is Party
  7962. sd->state.noks = 2;
  7963. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7964. }
  7965. else if( !strcmpi(message, "self") )
  7966. {
  7967. sd->state.noks = 1;
  7968. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7969. }
  7970. else if( !strcmpi(message, "guild") )
  7971. {
  7972. sd->state.noks = 3;
  7973. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7974. }
  7975. else
  7976. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7977. }
  7978. return 0;
  7979. }
  7980. /*==========================================
  7981. * Map Kill Steal Protection Setting
  7982. *------------------------------------------*/
  7983. ACMD_FUNC(allowks)
  7984. {
  7985. nullpo_retr(-1,sd);
  7986. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7987. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7988. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7989. } else {
  7990. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7991. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7992. }
  7993. return 0;
  7994. }
  7995. ACMD_FUNC(resetstat)
  7996. {
  7997. nullpo_retr(-1, sd);
  7998. pc_resetstate(sd);
  7999. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  8000. clif_displaymessage(fd, atcmd_output);
  8001. return 0;
  8002. }
  8003. ACMD_FUNC(resetskill)
  8004. {
  8005. nullpo_retr(-1,sd);
  8006. pc_resetskill(sd,1);
  8007. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  8008. clif_displaymessage(fd, atcmd_output);
  8009. return 0;
  8010. }
  8011. /*==========================================
  8012. * #storagelist: Displays the items list of a player's storage.
  8013. * #cartlist: Displays contents of target's cart.
  8014. * #itemlist: Displays contents of target's inventory.
  8015. *------------------------------------------*/
  8016. ACMD_FUNC(itemlist)
  8017. {
  8018. int32 i, j, count, counter;
  8019. const char* location;
  8020. struct item* items;
  8021. int32 size;
  8022. StringBuf buf;
  8023. nullpo_retr(-1, sd);
  8024. parent_cmd = atcommand_alias_db.checkAlias(command+1);
  8025. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  8026. location = "storage";
  8027. items = sd->storage.u.items_storage;
  8028. size = sd->storage.max_amount;
  8029. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  8030. location = "cart";
  8031. items = sd->cart.u.items_cart;
  8032. size = MAX_CART;
  8033. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  8034. location = "inventory";
  8035. items = sd->inventory.u.items_inventory;
  8036. size = MAX_INVENTORY;
  8037. } else
  8038. return 1;
  8039. StringBuf_Init(&buf);
  8040. count = 0; // total slots occupied
  8041. counter = 0; // total items found
  8042. for( i = 0; i < size; ++i ) {
  8043. struct item* it = &items[i];
  8044. if( it->nameid == 0 )
  8045. continue;
  8046. std::shared_ptr<item_data> itd = item_db.find(it->nameid);
  8047. if (itd == nullptr)
  8048. continue;
  8049. counter += it->amount;
  8050. count++;
  8051. if( count == 1 ) {
  8052. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  8053. clif_displaymessage(fd, StringBuf_Value(&buf));
  8054. StringBuf_Clear(&buf);
  8055. }
  8056. StringBuf_Printf(&buf, "%d %s (%s, id: %u)", it->amount, item_db.create_item_link( *it ).c_str(), itd->name.c_str(), it->nameid);
  8057. if( it->equip ) {
  8058. char equipstr[CHAT_SIZE_MAX];
  8059. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  8060. if( it->equip&EQP_GARMENT )
  8061. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  8062. if( it->equip&EQP_ACC_L )
  8063. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  8064. if( it->equip&EQP_ARMOR )
  8065. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  8066. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  8067. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  8068. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  8069. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  8070. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  8071. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  8072. if( it->equip&EQP_SHOES )
  8073. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  8074. if( it->equip&EQP_ACC_R )
  8075. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  8076. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  8077. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  8078. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  8079. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  8080. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  8081. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  8082. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  8083. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  8084. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  8085. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  8086. if( (it->equip&EQP_HELM) == EQP_HELM )
  8087. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  8088. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  8089. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  8090. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  8091. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  8092. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  8093. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  8094. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  8095. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  8096. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  8097. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  8098. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  8099. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  8100. if( it->equip&EQP_COSTUME_GARMENT )
  8101. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  8102. //if( it->equip&EQP_COSTUME_FLOOR )
  8103. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  8104. if( it->equip&EQP_AMMO )
  8105. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  8106. if( it->equip&EQP_SHADOW_ARMOR )
  8107. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  8108. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  8109. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  8110. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  8111. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  8112. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  8113. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  8114. if( it->equip&EQP_SHADOW_SHOES )
  8115. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  8116. if( it->equip&EQP_SHADOW_ACC_R )
  8117. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  8118. if( it->equip&EQP_SHADOW_ACC_L )
  8119. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  8120. // remove final ', '
  8121. equipstr[strlen(equipstr) - 2] = '\0';
  8122. StringBuf_AppendStr(&buf, equipstr);
  8123. }
  8124. clif_displaymessage(fd, StringBuf_Value(&buf));
  8125. StringBuf_Clear(&buf);
  8126. if( it->card[0] == CARD0_PET ) { // pet egg
  8127. if (it->card[3]&1)
  8128. StringBuf_Printf(&buf, msg_txt(sd,1348), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  8129. else
  8130. StringBuf_Printf(&buf, msg_txt(sd,1349), (uint32)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  8131. } else if(it->card[0] == CARD0_FORGE) { // forged item
  8132. StringBuf_Printf(&buf, msg_txt(sd,1350), (uint32)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)
  8133. } else if(it->card[0] == CARD0_CREATE) { // created item
  8134. StringBuf_Printf(&buf, msg_txt(sd,1351), (uint32)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  8135. } else { // normal item
  8136. int32 counter2 = 0;
  8137. for( j = 0; j < itd->slots; ++j ) {
  8138. if( it->card[j] == 0 )
  8139. continue;
  8140. std::shared_ptr<item_data> card = item_db.find(it->card[j]);
  8141. if (card == nullptr)
  8142. continue;
  8143. counter2++;
  8144. if( counter2 == 1 )
  8145. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  8146. if( counter2 != 1 )
  8147. StringBuf_AppendStr(&buf, ", ");
  8148. StringBuf_Printf(&buf, "#%d %s (id: %u)", counter2, item_db.create_item_link( card ).c_str(), card->nameid);
  8149. }
  8150. if( counter2 > 0 )
  8151. StringBuf_AppendStr(&buf, ")");
  8152. }
  8153. if( StringBuf_Length(&buf) > 0 )
  8154. clif_displaymessage(fd, StringBuf_Value(&buf));
  8155. StringBuf_Clear(&buf);
  8156. }
  8157. if( count == 0 )
  8158. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  8159. else
  8160. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  8161. clif_displaymessage(fd, StringBuf_Value(&buf));
  8162. StringBuf_Destroy(&buf);
  8163. return 0;
  8164. }
  8165. ACMD_FUNC(stats)
  8166. {
  8167. char job_jobname[100];
  8168. char output[CHAT_SIZE_MAX];
  8169. int32 i;
  8170. struct {
  8171. const char* format;
  8172. int32 value;
  8173. } output_table[] = {
  8174. { "Base Level - %d", 0 },
  8175. { nullptr, 0 },
  8176. { "Hp - %d", 0 },
  8177. { "MaxHp - %d", 0 },
  8178. { "Sp - %d", 0 },
  8179. { "MaxSp - %d", 0 },
  8180. { "Ap - %d", 0 },
  8181. { "MaxAp - %d", 0 },
  8182. { "Str - %3d", 0 },
  8183. { "Agi - %3d", 0 },
  8184. { "Vit - %3d", 0 },
  8185. { "Int - %3d", 0 },
  8186. { "Dex - %3d", 0 },
  8187. { "Luk - %3d", 0 },
  8188. { "Pow - %3d", 0 },
  8189. { "Sta - %3d", 0 },
  8190. { "Wis - %3d", 0 },
  8191. { "Spl - %3d", 0 },
  8192. { "Con - %3d", 0 },
  8193. { "Crt - %3d", 0 },
  8194. { "Zeny - %d", 0 },
  8195. { "Free Status Points - %d", 0 },
  8196. { "Free Trait Points - %d", 0 },
  8197. { "Free Skill Points - %d", 0 },
  8198. { "JobChangeLvl (2nd) - %d", 0 },
  8199. { "JobChangeLvl (3rd) - %d", 0 },
  8200. { "JobChangeLvl (4th) - %d", 0 },
  8201. { nullptr, 0 }
  8202. };
  8203. memset(job_jobname, '\0', sizeof(job_jobname));
  8204. memset(output, '\0', sizeof(output));
  8205. //direct array initialization with variables is not standard C compliant.
  8206. output_table[0].value = sd->status.base_level;
  8207. output_table[1].format = job_jobname;
  8208. output_table[1].value = sd->status.job_level;
  8209. output_table[2].value = sd->status.hp;
  8210. output_table[3].value = sd->status.max_hp;
  8211. output_table[4].value = sd->status.sp;
  8212. output_table[5].value = sd->status.max_sp;
  8213. output_table[6].value = sd->status.ap;
  8214. output_table[7].value = sd->status.max_ap;
  8215. output_table[8].value = sd->status.str;
  8216. output_table[9].value = sd->status.agi;
  8217. output_table[10].value = sd->status.vit;
  8218. output_table[11].value = sd->status.int_;
  8219. output_table[12].value = sd->status.dex;
  8220. output_table[13].value = sd->status.luk;
  8221. output_table[14].value = sd->status.pow;
  8222. output_table[15].value = sd->status.sta;
  8223. output_table[16].value = sd->status.wis;
  8224. output_table[17].value = sd->status.spl;
  8225. output_table[18].value = sd->status.con;
  8226. output_table[19].value = sd->status.crt;
  8227. output_table[20].value = sd->status.zeny;
  8228. output_table[21].value = sd->status.status_point;
  8229. output_table[22].value = sd->status.trait_point;
  8230. output_table[23].value = sd->status.skill_point;
  8231. output_table[24].value = sd->change_level_2nd;
  8232. output_table[25].value = sd->change_level_3rd;
  8233. output_table[26].value = sd->change_level_4th;
  8234. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  8235. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  8236. clif_displaymessage(fd, output);
  8237. for (i = 0; output_table[i].format != nullptr; i++) {
  8238. sprintf(output, output_table[i].format, output_table[i].value);
  8239. clif_displaymessage(fd, output);
  8240. }
  8241. return 0;
  8242. }
  8243. ACMD_FUNC(delitem)
  8244. {
  8245. char item_name[100];
  8246. int32 amount = 0, idx;
  8247. nullpo_retr(-1, sd);
  8248. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  8249. {
  8250. 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>).
  8251. return -1;
  8252. }
  8253. std::shared_ptr<item_data> id = item_db.searchname( item_name );
  8254. if( id == nullptr ){
  8255. id = item_db.find( strtoul( item_name, nullptr, 10 ) );
  8256. }
  8257. if( id == nullptr ){
  8258. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  8259. return -1;
  8260. }
  8261. t_itemid nameid = id->nameid;
  8262. int32 total = amount;
  8263. // delete items
  8264. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  8265. {
  8266. int32 delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  8267. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  8268. {// delete pet
  8269. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  8270. }
  8271. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  8272. amount-= delamount;
  8273. }
  8274. // notify target
  8275. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  8276. clif_displaymessage(sd->fd, atcmd_output);
  8277. // notify source
  8278. if( amount == total )
  8279. {
  8280. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  8281. }
  8282. else if( amount )
  8283. {
  8284. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  8285. clif_displaymessage(fd, atcmd_output);
  8286. }
  8287. else
  8288. {
  8289. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  8290. clif_displaymessage(fd, atcmd_output);
  8291. }
  8292. return 0;
  8293. }
  8294. /*==========================================
  8295. * Custom Fonts
  8296. *------------------------------------------*/
  8297. ACMD_FUNC(font)
  8298. {
  8299. int32 font_id;
  8300. nullpo_retr(-1,sd);
  8301. font_id = atoi(message);
  8302. if( font_id == 0 ) {
  8303. if( sd->status.font ) {
  8304. sd->status.font = 0;
  8305. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  8306. clif_font(sd);
  8307. } else {
  8308. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  8309. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  8310. }
  8311. } else if( font_id < 0 || font_id > 9 )
  8312. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  8313. else if( font_id != sd->status.font ) {
  8314. sd->status.font = font_id;
  8315. clif_font(sd);
  8316. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  8317. } else
  8318. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  8319. return 0;
  8320. }
  8321. /*==========================================
  8322. * type: 1 = commands (@), 2 = charcommands (#)
  8323. *------------------------------------------*/
  8324. static void atcommand_commands_sub(map_session_data* sd, const int32 fd, AtCommandType type)
  8325. {
  8326. char line_buff[CHATBOX_SIZE];
  8327. char* cur = line_buff;
  8328. AtCommandInfo* cmd;
  8329. DBIterator *iter = db_iterator(atcommand_db);
  8330. int32 count = 0;
  8331. memset(line_buff,' ',CHATBOX_SIZE);
  8332. line_buff[CHATBOX_SIZE-1] = 0;
  8333. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  8334. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8335. switch( type ) {
  8336. case COMMAND_CHARCOMMAND:
  8337. if( cmd->char_groups[sd->group->index] == 0 )
  8338. continue;
  8339. break;
  8340. case COMMAND_ATCOMMAND:
  8341. if( cmd->at_groups[sd->group->index] == 0 )
  8342. continue;
  8343. break;
  8344. default:
  8345. continue;
  8346. }
  8347. size_t slen = strlen( cmd->command );
  8348. // flush the text buffer if this command won't fit into it
  8349. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8350. clif_displaymessage(fd,line_buff);
  8351. cur = line_buff;
  8352. memset(line_buff,' ',CHATBOX_SIZE);
  8353. line_buff[CHATBOX_SIZE-1] = 0;
  8354. }
  8355. memcpy(cur,cmd->command,slen);
  8356. cur += slen+(10-slen%10);
  8357. count++;
  8358. }
  8359. dbi_destroy(iter);
  8360. clif_displaymessage(fd,line_buff);
  8361. if ( atcmd_binding_count ) {
  8362. int32 i, count_bind, gm_lvl = pc_get_group_level(sd);
  8363. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  8364. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  8365. size_t slen = strlen( atcmd_binding[i]->command );
  8366. if ( count_bind == 0 ) {
  8367. cur = line_buff;
  8368. memset(line_buff,' ',CHATBOX_SIZE);
  8369. line_buff[CHATBOX_SIZE-1] = 0;
  8370. clif_displaymessage(fd, "-----------------");
  8371. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  8372. }
  8373. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  8374. clif_displaymessage(fd,line_buff);
  8375. cur = line_buff;
  8376. memset(line_buff,' ',CHATBOX_SIZE);
  8377. line_buff[CHATBOX_SIZE-1] = 0;
  8378. }
  8379. memcpy(cur,atcmd_binding[i]->command,slen);
  8380. cur += slen+(10-slen%10);
  8381. count_bind++;
  8382. }
  8383. }
  8384. if ( count_bind )
  8385. clif_displaymessage(fd,line_buff);// last one
  8386. count += count_bind;
  8387. }
  8388. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  8389. clif_displaymessage(fd, atcmd_output);
  8390. return;
  8391. }
  8392. /*==========================================
  8393. * @commands Lists available @ commands to you
  8394. *------------------------------------------*/
  8395. ACMD_FUNC(commands)
  8396. {
  8397. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  8398. return 0;
  8399. }
  8400. /*==========================================
  8401. * @charcommands Lists available # commands to you
  8402. *------------------------------------------*/
  8403. ACMD_FUNC(charcommands) {
  8404. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  8405. return 0;
  8406. }
  8407. /* for new mounts */
  8408. ACMD_FUNC(mount2) {
  8409. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  8410. if (!sd->sc.getSCE(SC_ALL_RIDING)) {
  8411. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  8412. sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  8413. } else {
  8414. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  8415. status_change_end(&sd->bl, SC_ALL_RIDING);
  8416. }
  8417. return 0;
  8418. }
  8419. ACMD_FUNC(accinfo) {
  8420. char query[NAME_LENGTH];
  8421. if (!message || !*message || strlen(message) > NAME_LENGTH
  8422. || ( sscanf(message, "%23s", query) < 1))
  8423. {
  8424. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  8425. 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".
  8426. return -1;
  8427. }
  8428. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query);
  8429. return 0;
  8430. }
  8431. /**
  8432. * @set <variable name{[index]}>{ <value>}
  8433. *
  8434. * Gets or sets a value of a non server variable.
  8435. * If a value is specified it is used to set the variable's value,
  8436. * if not the variable's value is read.
  8437. * In any case it reads and displays the variable's value.
  8438. *
  8439. * Original implementation by Ind
  8440. */
  8441. ACMD_FUNC(set) {
  8442. char reg[46], val[128], name[32];
  8443. int32 toset = 0;
  8444. size_t len;
  8445. uint32 index;
  8446. bool is_str = false;
  8447. int64 uid;
  8448. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  8449. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  8450. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  8451. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  8452. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  8453. return -1;
  8454. }
  8455. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  8456. if( reg[0] == '.' ) {
  8457. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  8458. return -1;
  8459. } else if( reg[0] == '\'' ) {
  8460. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  8461. return -1;
  8462. }
  8463. // Check if the user wanted to set an array
  8464. if( sscanf( reg, "%31[^[][%" PRIu32 "]", name, &index ) < 2 ){
  8465. // The user did not specify array brackets, so we set the index to zero
  8466. index = 0;
  8467. }
  8468. is_str = is_string_variable(name);
  8469. if( ( len = strlen(val) ) > 1 ) {
  8470. if( val[0] == '"' && val[len-1] == '"') {
  8471. val[len-1] = '\0'; //Strip quotes.
  8472. memmove(val, val+1, len-1);
  8473. }
  8474. }
  8475. // Only set the variable if there is a value for it
  8476. if( toset >= 2 ){
  8477. if( is_str ){
  8478. setd_sub_str( nullptr, sd, name, index, val, nullptr );
  8479. }else{
  8480. setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
  8481. }
  8482. }
  8483. uid = reference_uid( add_str( name ), index );
  8484. if( is_str ) {// string variable
  8485. char* value;
  8486. switch( reg[0] ) {
  8487. case '@':
  8488. value = pc_readregstr(sd, uid);
  8489. break;
  8490. case '$':
  8491. value = mapreg_readregstr(uid);
  8492. break;
  8493. case '#':
  8494. if( reg[1] == '#' )
  8495. value = pc_readaccountreg2str(sd, uid);// global
  8496. else
  8497. value = pc_readaccountregstr(sd, uid);// local
  8498. break;
  8499. default:
  8500. value = pc_readglobalreg_str(sd, uid);
  8501. break;
  8502. }
  8503. if( value == nullptr || *value == '\0' ){// empty string
  8504. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  8505. }else{
  8506. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
  8507. }
  8508. } else {// integer variable
  8509. int64 value;
  8510. switch( reg[0] ) {
  8511. case '@':
  8512. value = pc_readreg(sd, uid);
  8513. break;
  8514. case '$':
  8515. value = mapreg_readreg(uid);
  8516. break;
  8517. case '#':
  8518. if( reg[1] == '#' )
  8519. value = pc_readaccountreg2(sd, uid);// global
  8520. else
  8521. value = pc_readaccountreg(sd, uid);// local
  8522. break;
  8523. default:
  8524. value = pc_readglobalreg(sd, uid);
  8525. break;
  8526. }
  8527. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now: %lld
  8528. }
  8529. clif_displaymessage(fd, atcmd_output);
  8530. return 0;
  8531. }
  8532. ACMD_FUNC(addperm) {
  8533. int32 perm_size = ARRAYLENGTH(pc_g_permission_name);
  8534. int32 i;
  8535. if( !message || !*message ) {
  8536. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8537. clif_displaymessage(fd, atcmd_output);
  8538. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8539. for( i = 0; i < perm_size; i++ ) {
  8540. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8541. clif_displaymessage(fd, atcmd_output);
  8542. }
  8543. return -1;
  8544. }
  8545. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8546. if( i == perm_size ) {
  8547. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8548. clif_displaymessage(fd, atcmd_output);
  8549. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8550. for( i = 0; i < perm_size; i++ ) {
  8551. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8552. clif_displaymessage(fd, atcmd_output);
  8553. }
  8554. return -1;
  8555. }
  8556. if( pc_has_permission( sd, pc_g_permission_name[i].permission) ){
  8557. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  8558. clif_displaymessage(fd, atcmd_output);
  8559. return -1;
  8560. }
  8561. sd->permissions.set( pc_g_permission_name[i].permission );
  8562. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8563. clif_displaymessage(fd, atcmd_output);
  8564. return 0;
  8565. }
  8566. ACMD_FUNC(rmvperm) {
  8567. int32 perm_size = ARRAYLENGTH(pc_g_permission_name);
  8568. int32 i;
  8569. if( !message || !*message ) {
  8570. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  8571. clif_displaymessage(fd, atcmd_output);
  8572. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8573. for( i = 0; i < perm_size; i++ ) {
  8574. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8575. clif_displaymessage(fd, atcmd_output);
  8576. }
  8577. return -1;
  8578. }
  8579. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  8580. if( i == perm_size ) {
  8581. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  8582. clif_displaymessage(fd, atcmd_output);
  8583. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  8584. for( i = 0; i < perm_size; i++ ) {
  8585. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8586. clif_displaymessage(fd, atcmd_output);
  8587. }
  8588. return -1;
  8589. }
  8590. if( !pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8591. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  8592. clif_displaymessage(fd, atcmd_output);
  8593. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  8594. clif_displaymessage(fd, atcmd_output);
  8595. for( i = 0; i < perm_size; i++ ) {
  8596. if( pc_has_permission( sd, pc_g_permission_name[i].permission ) ){
  8597. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  8598. clif_displaymessage(fd, atcmd_output);
  8599. }
  8600. }
  8601. return -1;
  8602. }
  8603. sd->permissions.reset( pc_g_permission_name[i].permission );
  8604. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  8605. clif_displaymessage(fd, atcmd_output);
  8606. return 0;
  8607. }
  8608. ACMD_FUNC(unloadnpcfile) {
  8609. if( !message || !*message ) {
  8610. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  8611. return -1;
  8612. }
  8613. if( npc_unloadfile(message) )
  8614. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  8615. else {
  8616. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  8617. return -1;
  8618. }
  8619. return 0;
  8620. }
  8621. ACMD_FUNC(cart) {
  8622. #define MC_CART_MDFY(idx, x) \
  8623. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8624. sd->status.skill[(idx)].lv = (x)?1:0; \
  8625. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8626. int32 val = atoi(message);
  8627. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8628. uint16 sk_idx = 0;
  8629. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8630. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8631. clif_displaymessage(fd, atcmd_output);
  8632. return -1;
  8633. }
  8634. if( val == 0 && !pc_iscarton(sd) ) {
  8635. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8636. return -1;
  8637. }
  8638. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8639. return -1;
  8640. if( need_skill ) {
  8641. MC_CART_MDFY(sk_idx,1);
  8642. }
  8643. if( !pc_setcart(sd, val) ) {
  8644. if( need_skill ) {
  8645. MC_CART_MDFY(sk_idx,0);
  8646. }
  8647. return -1;/* @cart failed */
  8648. }
  8649. if( need_skill ) {
  8650. MC_CART_MDFY(sk_idx,0);
  8651. }
  8652. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8653. return 0;
  8654. #undef MC_CART_MDFY
  8655. }
  8656. /* Channel System [Ind] */
  8657. ACMD_FUNC(join){
  8658. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8659. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8660. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8661. clif_displaymessage(fd, atcmd_output);
  8662. return -1;
  8663. }
  8664. return channel_pcjoin(sd, chname, pass);
  8665. }
  8666. /*
  8667. * Display available option for @channel command
  8668. * @command : the name of used command (for alias case)
  8669. */
  8670. static inline void atcmd_channel_help(map_session_data *sd, const char *command)
  8671. {
  8672. int32 fd = sd->fd;
  8673. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8674. bool can_create = (can_delete || channel_config.private_channel.allow);
  8675. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8676. //option create
  8677. if( can_create ) {
  8678. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8679. clif_displaymessage(fd, atcmd_output);
  8680. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8681. }
  8682. //option delete
  8683. if(can_delete){
  8684. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8685. clif_displaymessage(fd, atcmd_output);
  8686. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8687. }
  8688. //option list
  8689. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8690. clif_displaymessage(fd, atcmd_output);
  8691. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8692. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8693. clif_displaymessage(fd, atcmd_output);
  8694. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8695. if( can_create ) {
  8696. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8697. clif_displaymessage(fd, atcmd_output);
  8698. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8699. }
  8700. //option setcolor
  8701. if(can_create){
  8702. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8703. clif_displaymessage(fd, atcmd_output);
  8704. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8705. }
  8706. //option join
  8707. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8708. clif_displaymessage(fd, atcmd_output);
  8709. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8710. //option leave
  8711. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8712. clif_displaymessage(fd, atcmd_output);
  8713. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8714. //option bindto
  8715. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8716. clif_displaymessage(fd, atcmd_output);
  8717. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8718. //option unbind
  8719. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8720. clif_displaymessage(fd, atcmd_output);
  8721. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8722. //option ban/unban/banlist
  8723. if( can_create ) {
  8724. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8725. clif_displaymessage(fd, atcmd_output);
  8726. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8727. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8728. clif_displaymessage(fd, atcmd_output);
  8729. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8730. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8731. clif_displaymessage(fd, atcmd_output);
  8732. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8733. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8734. clif_displaymessage(fd, atcmd_output);
  8735. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8736. }
  8737. //option setopt
  8738. if(can_create){
  8739. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8740. clif_displaymessage(fd, atcmd_output);
  8741. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8742. }
  8743. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8744. clif_displaymessage(fd, atcmd_output);
  8745. }
  8746. ACMD_FUNC(channel) {
  8747. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8748. sub1[0] = sub2[0] = '\0';
  8749. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8750. atcmd_channel_help(sd,command);
  8751. return 0;
  8752. }
  8753. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8754. return channel_pcdelete(sd,sub1);
  8755. } else if ( strcmpi(key,"list") == 0 ) {
  8756. return channel_display_list(sd,sub1);
  8757. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8758. return channel_pccolor(sd, sub1, sub2);
  8759. } else if ( strcmpi(key,"join") == 0 ) {
  8760. return channel_pcjoin(sd, sub1, sub2);
  8761. }else if ( strcmpi(key,"leave") == 0 ) {
  8762. return channel_pcleave(sd, sub1);
  8763. } else if ( strcmpi(key,"bindto") == 0 ) {
  8764. return channel_pcbind(sd, sub1);
  8765. } else if ( strcmpi(key,"unbind") == 0 ) {
  8766. return channel_pcunbind(sd);
  8767. } else if ( strcmpi(key,"ban") == 0 ) {
  8768. return channel_pcban(sd,sub1,sub2,0);
  8769. } else if ( strcmpi(key,"kick") == 0 ) {
  8770. return channel_pckick(sd,sub1,sub2);
  8771. } else if ( strcmpi(key,"banlist") == 0 ) {
  8772. return channel_pcban(sd,sub1,nullptr,3);
  8773. } else if ( strcmpi(key,"unban") == 0 ) {
  8774. return channel_pcban(sd,sub1,sub2,1);
  8775. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8776. return channel_pcban(sd,sub1,nullptr,2);
  8777. } else {
  8778. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8779. sub3[0] = sub4[0] = '\0';
  8780. sscanf(sub2, "%19s %19s", sub3, sub4);
  8781. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8782. if (sub4[0] != '\0') {
  8783. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8784. return -1;
  8785. }
  8786. return channel_pccreate(sd,sub1,sub3);
  8787. } else if ( strcmpi(key,"setopt") == 0 ) {
  8788. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8789. }
  8790. atcmd_channel_help(sd,command);
  8791. }
  8792. return 0;
  8793. }
  8794. ACMD_FUNC(fontcolor)
  8795. {
  8796. if( !message || !*message ) {
  8797. channel_display_list(sd,"colors");
  8798. return -1;
  8799. }
  8800. if( strcmpi(message,"Normal") == 0 ) {
  8801. sd->fontcolor = 0;
  8802. } else {
  8803. unsigned char k;
  8804. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8805. if( k == channel_config.colors_count ) {
  8806. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8807. clif_displaymessage(fd, atcmd_output);
  8808. return -1;
  8809. }
  8810. sd->fontcolor = k;
  8811. }
  8812. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8813. clif_displaymessage(fd, atcmd_output);
  8814. return 0;
  8815. }
  8816. ACMD_FUNC(langtype)
  8817. {
  8818. char langstr[8];
  8819. int32 i=0, fail=0;
  8820. memset(langstr, '\0', sizeof(langstr));
  8821. if(sscanf(message, "%3s", langstr) >= 1){
  8822. int32 lang=0;
  8823. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8824. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8825. char output[100];
  8826. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8827. sd->langtype = lang;
  8828. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8829. clif_displaymessage(fd,output);
  8830. return 0;
  8831. } else if (lang != -1) { //defined langage but failed check
  8832. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8833. return -1;
  8834. }
  8835. }
  8836. //wrong or no entry
  8837. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8838. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8839. while(fail != -1){ //out of range
  8840. fail = msg_checklangtype(i,false);
  8841. if(fail == 1)
  8842. clif_displaymessage(fd,msg_langtype2langstr(i));
  8843. i++;
  8844. }
  8845. return -1;
  8846. }
  8847. ACMD_FUNC(vip) {
  8848. #ifdef VIP_ENABLE
  8849. map_session_data* pl_sd = nullptr;;
  8850. char * modif_p;
  8851. int32 vipdifftime = 0;
  8852. time_t now=time(nullptr);
  8853. nullpo_retr(-1, sd);
  8854. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8855. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8856. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8857. return -1;
  8858. }
  8859. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8860. modif_p = atcmd_output;
  8861. vipdifftime = (int32)solve_time(modif_p);
  8862. if (vipdifftime == 0) {
  8863. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8864. 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.
  8865. return -1;
  8866. }
  8867. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  8868. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8869. return -1;
  8870. }
  8871. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8872. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
  8873. return -1;
  8874. }
  8875. if( pc_get_group_level( pl_sd ) > 0 ){
  8876. clif_displaymessage( sd->fd, msg_txt( sd, 437 ) ); // GM's cannot become a VIP.
  8877. return -1;
  8878. }
  8879. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8880. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8881. if (pl_sd->vip.time <= now) {
  8882. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8883. if( pl_sd != sd ){
  8884. sprintf( atcmd_output, msg_txt( sd, 704 ), pl_sd->status.name ); // Player '%s' is no longer VIP.
  8885. clif_displaymessage( fd, atcmd_output );
  8886. }
  8887. } else {
  8888. int32 year,month,day,hour,minute,second;
  8889. char timestr[21];
  8890. split_time((int32)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8891. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute,second); // Your VIP status is valid for %d years, %d months, %d days, %d hours, %d minutes and %d seconds.
  8892. clif_displaymessage(pl_sd->fd,atcmd_output);
  8893. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M:%S");
  8894. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until: %s
  8895. clif_displaymessage(pl_sd->fd,atcmd_output);
  8896. if (pl_sd != sd) {
  8897. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute,second); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours, %d minutes and %d seconds.
  8898. clif_displaymessage(fd,atcmd_output);
  8899. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until: %s
  8900. clif_displaymessage(fd,atcmd_output);
  8901. }
  8902. }
  8903. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8904. return 0;
  8905. #else
  8906. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  8907. return -1;
  8908. #endif
  8909. }
  8910. /** Enable/disable rate info */
  8911. ACMD_FUNC(showrate) {
  8912. #ifdef VIP_ENABLE
  8913. nullpo_retr(-1,sd);
  8914. if (!sd->vip.disableshowrate) {
  8915. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8916. sd->vip.disableshowrate = 1;
  8917. } else {
  8918. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8919. sd->vip.disableshowrate = 0;
  8920. }
  8921. clif_displaymessage(fd,atcmd_output);
  8922. return 0;
  8923. #else
  8924. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  8925. return -1;
  8926. #endif
  8927. }
  8928. ACMD_FUNC(fullstrip) {
  8929. int32 i;
  8930. TBL_PC *tsd;
  8931. nullpo_retr(-1,sd);
  8932. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8933. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8934. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8935. return -1;
  8936. }
  8937. if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
  8938. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8939. return -1;
  8940. }
  8941. for( i = 0; i < EQI_MAX; i++ ) {
  8942. if( tsd->equip_index[ i ] >= 0 )
  8943. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8944. }
  8945. return 0;
  8946. }
  8947. ACMD_FUNC(changedress){
  8948. sc_type name2id[] = {
  8949. SC_WEDDING,
  8950. SC_XMAS,
  8951. SC_SUMMER,
  8952. SC_DRESSUP,
  8953. SC_HANBOK,
  8954. SC_OKTOBERFEST
  8955. };
  8956. for( sc_type type : name2id ) {
  8957. if( sd->sc.getSCE(type) ) {
  8958. status_change_end( &sd->bl, type );
  8959. // You should only be able to have one - so we cancel here
  8960. break;
  8961. }
  8962. }
  8963. return 0;
  8964. }
  8965. ACMD_FUNC(costume) {
  8966. const char* names[] = {
  8967. "Wedding",
  8968. "Xmas",
  8969. "Summer",
  8970. "Summer2",
  8971. "Hanbok",
  8972. "Oktoberfest"
  8973. };
  8974. const int32 name2id[] = {
  8975. SC_WEDDING,
  8976. SC_XMAS,
  8977. SC_SUMMER,
  8978. SC_DRESSUP,
  8979. SC_HANBOK,
  8980. SC_OKTOBERFEST
  8981. };
  8982. uint16 k = 0, len = ARRAYLENGTH(names);
  8983. if( !message || !*message ) {
  8984. for( k = 0; k < len; k++ ) {
  8985. if( sd->sc.getSCE(name2id[k]) ) {
  8986. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8987. clif_displaymessage(sd->fd, atcmd_output);
  8988. status_change_end(&sd->bl, (sc_type)name2id[k]);
  8989. return 0;
  8990. }
  8991. }
  8992. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8993. for( k = 0; k < len; k++ ) {
  8994. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8995. clif_displaymessage(sd->fd, atcmd_output);
  8996. }
  8997. return -1;
  8998. }
  8999. for( k = 0; k < len; k++ ) {
  9000. if( sd->sc.getSCE(name2id[k]) ) {
  9001. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  9002. clif_displaymessage(sd->fd, atcmd_output);
  9003. return -1;
  9004. }
  9005. }
  9006. for( k = 0; k < len; k++ )
  9007. if( strcmpi(message, names[k]) == 0 )
  9008. break;
  9009. if( k == len ) {
  9010. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  9011. clif_displaymessage(sd->fd, atcmd_output);
  9012. return -1;
  9013. }
  9014. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  9015. return 0;
  9016. }
  9017. /**
  9018. * Clone other player's equipments
  9019. * Usage: @cloneequip <char name/ID>
  9020. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  9021. * @author [Cydh], [Antares]
  9022. */
  9023. ACMD_FUNC(cloneequip) {
  9024. map_session_data *pl_sd;
  9025. nullpo_retr(-1, sd);
  9026. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9027. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9028. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9029. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  9030. clif_displaymessage(fd, atcmd_output);
  9031. return -1;
  9032. }
  9033. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  9034. clif_displaymessage(fd, msg_txt(sd, 3));
  9035. return -1;
  9036. }
  9037. if (sd == pl_sd) {
  9038. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9039. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  9040. clif_displaymessage(fd, atcmd_output);
  9041. return -1;
  9042. }
  9043. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  9044. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9045. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  9046. clif_displaymessage(fd, atcmd_output);
  9047. return -1;
  9048. }
  9049. else {
  9050. int8 i;
  9051. for (i = 0; i < EQI_MAX; i++) {
  9052. int16 idx;
  9053. char flag = 0;
  9054. struct item tmp_item;
  9055. if ((idx = pl_sd->equip_index[i]) < 0)
  9056. continue;
  9057. if (i == EQI_AMMO)
  9058. continue;
  9059. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  9060. continue;
  9061. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  9062. if (itemdb_isspecial(tmp_item.card[0]))
  9063. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  9064. tmp_item.bound = 0;
  9065. tmp_item.expire_time = 0;
  9066. tmp_item.unique_id = 0;
  9067. tmp_item.favorite = 0;
  9068. tmp_item.amount = 1;
  9069. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  9070. clif_additem(sd, 0, 0, flag);
  9071. else
  9072. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  9073. }
  9074. }
  9075. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9076. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  9077. clif_displaymessage(fd, atcmd_output);
  9078. return 0;
  9079. }
  9080. /**
  9081. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  9082. * Usage: @clonestat <char name/ID>
  9083. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  9084. * @author [Cydh], [Antares]
  9085. */
  9086. ACMD_FUNC(clonestat) {
  9087. map_session_data *pl_sd;
  9088. nullpo_retr(-1, sd);
  9089. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9090. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9091. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9092. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  9093. clif_displaymessage(fd, atcmd_output);
  9094. return -1;
  9095. }
  9096. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  9097. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9098. return -1;
  9099. }
  9100. if (sd == pl_sd) {
  9101. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9102. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  9103. clif_displaymessage(fd, atcmd_output);
  9104. return -1;
  9105. }
  9106. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  9107. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9108. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  9109. clif_displaymessage(fd, atcmd_output);
  9110. return -1;
  9111. }
  9112. else {
  9113. uint8 i;
  9114. int16 max_status[PARAM_MAX] = {};
  9115. pc_resetstate(sd);
  9116. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE)) {
  9117. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  9118. if (i >= PARAM_POW && !(sd->class_ & JOBL_FOURTH))
  9119. continue;
  9120. max_status[i] = SHRT_MAX;
  9121. }
  9122. } else {
  9123. for (i = PARAM_STR; i < PARAM_MAX; i++) {
  9124. if (i >= PARAM_POW && sd->class_ & JOBL_FOURTH)
  9125. continue;
  9126. max_status[i] = pc_maxparameter(sd, static_cast<e_params>(i));
  9127. }
  9128. }
  9129. #define clonestat_check(cmd,stat)\
  9130. {\
  9131. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  9132. if (pl_sd->status.cmd > max_status[(stat)]) {\
  9133. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  9134. clif_displaymessage(fd, atcmd_output);\
  9135. sd->status.cmd = max_status[(stat)];\
  9136. }\
  9137. else\
  9138. sd->status.cmd = pl_sd->status.cmd;\
  9139. }
  9140. clonestat_check(str, PARAM_STR);
  9141. clonestat_check(agi, PARAM_AGI);
  9142. clonestat_check(vit, PARAM_VIT);
  9143. clonestat_check(int_, PARAM_INT);
  9144. clonestat_check(dex, PARAM_DEX);
  9145. clonestat_check(luk, PARAM_LUK);
  9146. for (i = PARAM_STR; i < PARAM_POW; i++) {
  9147. clif_updatestatus(*sd, static_cast<_sp>( SP_STR + i ) );
  9148. clif_updatestatus(*sd, static_cast<_sp>( SP_USTR + i ) );
  9149. }
  9150. if (sd->class_ & JOBL_FOURTH) {
  9151. clonestat_check(pow, PARAM_POW);
  9152. clonestat_check(sta, PARAM_STA);
  9153. clonestat_check(wis, PARAM_WIS);
  9154. clonestat_check(spl, PARAM_SPL);
  9155. clonestat_check(con, PARAM_CON);
  9156. clonestat_check(crt, PARAM_CRT);
  9157. for (i = PARAM_POW; i < PARAM_MAX; i++) {
  9158. clif_updatestatus(*sd, static_cast<_sp>( SP_POW + i - PARAM_POW ) );
  9159. clif_updatestatus(*sd, static_cast<_sp>( SP_UPOW + i - PARAM_POW ) );
  9160. }
  9161. }
  9162. status_calc_pc(sd, SCO_FORCE);
  9163. }
  9164. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9165. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  9166. clif_displaymessage(fd, atcmd_output);
  9167. #undef clonestat_check
  9168. return 0;
  9169. }
  9170. /**
  9171. * Adopt a character.
  9172. * Usage: @adopt <char name>
  9173. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  9174. */
  9175. ACMD_FUNC(adopt)
  9176. {
  9177. TBL_PC *b_sd;
  9178. enum adopt_responses response;
  9179. nullpo_retr(-1, sd);
  9180. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9181. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  9182. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  9183. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  9184. clif_displaymessage(fd, atcmd_output);
  9185. return -1;
  9186. }
  9187. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
  9188. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  9189. return -1;
  9190. }
  9191. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  9192. if (response == ADOPT_ALLOWED) {
  9193. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  9194. b_sd->adopt_invite = sd->status.account_id;
  9195. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  9196. return 0;
  9197. }
  9198. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  9199. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  9200. return -1;
  9201. }
  9202. /**
  9203. * Opens the limited sale window.
  9204. * Usage: @limitedsale or client command /limitedsale on supported clients
  9205. */
  9206. ACMD_FUNC(limitedsale){
  9207. nullpo_retr(-1, sd);
  9208. clif_sale_open(sd);
  9209. return 0;
  9210. }
  9211. /**
  9212. * Displays camera information from the client.
  9213. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  9214. */
  9215. ACMD_FUNC(camerainfo){
  9216. nullpo_retr(-1, sd);
  9217. if( message == nullptr || message[0] == '\0' ){
  9218. clif_camerainfo( sd, true );
  9219. return 0;
  9220. }
  9221. float range = 0;
  9222. float rotation = 0;
  9223. float latitude = 0;
  9224. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  9225. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  9226. return -1;
  9227. }
  9228. clif_camerainfo( sd, false, range, rotation, latitude );
  9229. return 0;
  9230. }
  9231. ACMD_FUNC(resurrect) {
  9232. nullpo_retr(-1, sd);
  9233. if (!pc_revive_item(sd))
  9234. return -1;
  9235. return 0;
  9236. }
  9237. ACMD_FUNC(setquest){
  9238. int32 quest_id = 0;
  9239. nullpo_retr(-1, sd);
  9240. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9241. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9242. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9243. clif_displaymessage(fd, atcmd_output);
  9244. return -1;
  9245. }
  9246. if (!quest_search(quest_id)) {
  9247. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9248. clif_displaymessage(fd, atcmd_output);
  9249. return -1;
  9250. }
  9251. if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
  9252. sprintf(atcmd_output, msg_txt(sd,1507), quest_id); // Character already has quest %d.
  9253. clif_displaymessage(fd, atcmd_output);
  9254. return -1;
  9255. }
  9256. quest_add(sd, quest_id);
  9257. pc_show_questinfo(sd);
  9258. return 0;
  9259. }
  9260. ACMD_FUNC(erasequest) {
  9261. int32 quest_id = 0;
  9262. nullpo_retr(-1, sd);
  9263. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9264. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9265. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9266. clif_displaymessage(fd, atcmd_output);
  9267. return -1;
  9268. }
  9269. if (!quest_search(quest_id)) {
  9270. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9271. clif_displaymessage(fd, atcmd_output);
  9272. return -1;
  9273. }
  9274. if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
  9275. sprintf(atcmd_output, msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
  9276. clif_displaymessage(fd, atcmd_output);
  9277. return -1;
  9278. }
  9279. quest_delete(sd, quest_id);
  9280. pc_show_questinfo(sd);
  9281. return 0;
  9282. }
  9283. ACMD_FUNC(completequest){
  9284. int32 quest_id = 0;
  9285. nullpo_retr(-1, sd);
  9286. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9287. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9288. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9289. clif_displaymessage(fd, atcmd_output);
  9290. return -1;
  9291. }
  9292. if (!quest_search(quest_id)) {
  9293. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9294. clif_displaymessage(fd, atcmd_output);
  9295. return -1;
  9296. }
  9297. if (quest_check(sd, quest_id, HAVEQUEST) < 0)
  9298. quest_add(sd, quest_id);
  9299. if (quest_check(sd, quest_id, HAVEQUEST) < 2)
  9300. quest_update_status(sd, quest_id, Q_COMPLETE);
  9301. pc_show_questinfo(sd);
  9302. return 0;
  9303. }
  9304. ACMD_FUNC(checkquest){
  9305. int32 quest_id = 0;
  9306. nullpo_retr(-1, sd);
  9307. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9308. if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
  9309. sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
  9310. clif_displaymessage(fd, atcmd_output);
  9311. return -1;
  9312. }
  9313. if (!quest_search(quest_id)) {
  9314. sprintf(atcmd_output, msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
  9315. clif_displaymessage(fd, atcmd_output);
  9316. return -1;
  9317. }
  9318. sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
  9319. clif_displaymessage(fd, atcmd_output);
  9320. sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST)); // HAVEQUEST : %d
  9321. clif_displaymessage(fd, atcmd_output);
  9322. sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING)); // HUNTING : %d
  9323. clif_displaymessage(fd, atcmd_output);
  9324. sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME)); // PLAYTIME : %d
  9325. clif_displaymessage(fd, atcmd_output);
  9326. return 0;
  9327. }
  9328. /**
  9329. * Opens the refineUI
  9330. * Usage: @refineui
  9331. */
  9332. ACMD_FUNC(refineui)
  9333. {
  9334. nullpo_retr(-1, sd);
  9335. #if PACKETVER < 20161012
  9336. clif_displaymessage(fd, msg_txt(sd, 773)); // This command requires packet version 2016-10-12 or newer.
  9337. return -1;
  9338. #else
  9339. if( !battle_config.feature_refineui ){
  9340. clif_displaymessage(fd, msg_txt(sd, 774)); // This command is disabled via configuration.
  9341. return -1;
  9342. }
  9343. if( sd->state.refineui_open ){
  9344. clif_displaymessage(fd, msg_txt(sd, 775)); // You have already opened the refine UI.
  9345. return -1;
  9346. }
  9347. clif_refineui_open(sd);
  9348. return 0;
  9349. #endif
  9350. }
  9351. ACMD_FUNC( stylist ){
  9352. nullpo_retr(-1, sd);
  9353. #if PACKETVER < 20151104
  9354. clif_displaymessage( fd, msg_txt( sd, 798 ) ); // This command requires packet version 2015-11-04 or newer.
  9355. return -1;
  9356. #else
  9357. if( !battle_config.feature_stylist ){
  9358. clif_displaymessage( fd, msg_txt( sd, 774 ) ); // This command is disabled via configuration.
  9359. return -1;
  9360. }
  9361. if( sd->state.stylist_open ){
  9362. clif_displaymessage( fd, msg_txt( sd, 799 ) ); // You have already opened the stylist UI.
  9363. return -1;
  9364. }
  9365. clif_ui_open( *sd, OUT_UI_STYLIST, 0 );
  9366. return 0;
  9367. #endif
  9368. }
  9369. /**
  9370. * Add fame point(s) to a player
  9371. * Usage: @addfame <amount>
  9372. */
  9373. ACMD_FUNC(addfame)
  9374. {
  9375. nullpo_retr(-1, sd);
  9376. int32 famepoint = 0;
  9377. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9378. if (!message || !*message || sscanf(message, "%11d", &famepoint) < 1 || famepoint == 0) {
  9379. sprintf(atcmd_output, msg_txt(sd, 1516), command); // Usage: %s <fame points>.
  9380. clif_displaymessage(fd, atcmd_output);
  9381. return -1;
  9382. }
  9383. if (!pc_addfame(*sd, famepoint)) {
  9384. sprintf(atcmd_output, msg_txt(sd, 1517), job_name(sd->status.class_)); // Cannot add fame to class '%s'.
  9385. clif_displaymessage(fd, atcmd_output);
  9386. return -1;
  9387. }
  9388. sprintf(atcmd_output, msg_txt(sd, 1518), famepoint, sd->status.name); // %d points were added to '%s'.
  9389. clif_displaymessage(fd, atcmd_output);
  9390. return 0;
  9391. }
  9392. /**
  9393. * Opens the enchantgrade UI
  9394. * Usage: @enchantgradeui
  9395. */
  9396. ACMD_FUNC( enchantgradeui ){
  9397. nullpo_retr( -1, sd );
  9398. #if !( PACKETVER_MAIN_NUM >= 20200916 || PACKETVER_RE_NUM >= 20200724 )
  9399. sprintf( atcmd_output, msg_txt( sd, 798 ), "2020-07-24" ); // This command requires packet version %s or newer.
  9400. clif_displaymessage( fd, atcmd_output );
  9401. return -1;
  9402. #else
  9403. clif_ui_open( *sd, OUT_UI_ENCHANTGRADE, 0 );
  9404. return 0;
  9405. #endif
  9406. }
  9407. ACMD_FUNC( roulette ){
  9408. nullpo_retr( -1, sd );
  9409. #if PACKETVER < 20141022
  9410. sprintf( atcmd_output, msg_txt( sd, 798 ), "2014-10-22" ); // This command requires packet version %s or newer.
  9411. clif_displaymessage( fd, atcmd_output );
  9412. return -1;
  9413. #else
  9414. if( !battle_config.feature_roulette ){
  9415. clif_displaymessage( fd, msg_txt( sd, 1497 ) ); // Roulette is disabled
  9416. return -1;
  9417. }
  9418. clif_roulette_open( sd );
  9419. return 0;
  9420. #endif
  9421. }
  9422. /**
  9423. * Replaces a card ID in an equip
  9424. * Usage: @setcard <equip position> <slot> <card_id>
  9425. */
  9426. ACMD_FUNC(setcard)
  9427. {
  9428. nullpo_retr(-1, sd);
  9429. int32 position = 0, slot, card_id;
  9430. if (!message || !*message || sscanf(message, "%11d %11d %11d", &position, &slot, &card_id) < 3) {
  9431. memset(atcmd_output, '\0', sizeof(atcmd_output));
  9432. 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>).
  9433. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  9434. clif_displaymessage(fd, atcmd_output);
  9435. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  9436. clif_displaymessage(fd, atcmd_output);
  9437. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  9438. clif_displaymessage(fd, atcmd_output);
  9439. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  9440. clif_displaymessage(fd, atcmd_output);
  9441. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  9442. clif_displaymessage(fd, atcmd_output);
  9443. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  9444. clif_displaymessage(fd, atcmd_output);
  9445. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  9446. clif_displaymessage(fd, atcmd_output);
  9447. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  9448. clif_displaymessage(fd, atcmd_output);
  9449. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  9450. clif_displaymessage(fd, atcmd_output);
  9451. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  9452. clif_displaymessage(fd, atcmd_output);
  9453. return -1;
  9454. }
  9455. if (position < EQP_HEAD_LOW || position > EQP_HEAD_MID) {
  9456. clif_displaymessage(fd, msg_txt(sd,1531)); // Invalid position.
  9457. return -1;
  9458. }
  9459. if (slot < 0 || slot >= MAX_SLOTS) {
  9460. clif_displaymessage(fd, msg_txt(sd,1532)); // Invalid slot number.
  9461. return -1;
  9462. }
  9463. if (card_id != 0) {
  9464. std::shared_ptr<item_data> item_data = item_db.find( card_id );
  9465. if (item_data == nullptr) {
  9466. clif_displaymessage(fd, msg_txt(sd,1530)); // Invalid card ID.
  9467. return -1;
  9468. }
  9469. if (item_data->type != IT_CARD) {
  9470. clif_displaymessage(fd, msg_txt(sd,1529)); // The item type must be a card or enchant.
  9471. return -1;
  9472. }
  9473. }
  9474. int16 i = pc_checkequip(sd, position);
  9475. if (i < 0) {
  9476. clif_displaymessage(fd, msg_txt(sd,1528)); // You are not wearing any equipment in this position.
  9477. return -1;
  9478. }
  9479. int32 current_position = sd->inventory.u.items_inventory[i].equip;
  9480. pc_unequipitem(sd, i, 3);
  9481. log_pick_pc( sd, LOG_TYPE_COMMAND, -1, &sd->inventory.u.items_inventory[i] );
  9482. sd->inventory.u.items_inventory[i].card[slot] = card_id;
  9483. log_pick_pc( sd, LOG_TYPE_COMMAND, 1, &sd->inventory.u.items_inventory[i] );
  9484. clif_delitem( *sd, i, 1, 0 );
  9485. clif_additem(sd, i, 1, 0);
  9486. pc_equipitem(sd, i, current_position);
  9487. return 0;
  9488. }
  9489. int32 atcommand_macrochecker_sub( block_list* bl, va_list ap ){
  9490. uint32 reporter_aid = va_arg( ap, uint32 );
  9491. uint32 reporter_gmlv = va_arg( ap, uint32 );
  9492. map_session_data* tsd = reinterpret_cast<map_session_data*>( bl );
  9493. // Dont start the macro checking on self
  9494. if( tsd->status.account_id == reporter_aid ){
  9495. return 0;
  9496. }
  9497. // Dont start it on other GMs with same or higher level
  9498. if( pc_get_group_level( tsd ) >= reporter_gmlv ){
  9499. return 0;
  9500. }
  9501. // Dont start it on autotraders
  9502. if( !session_isActive( tsd->fd ) ){
  9503. return 0;
  9504. }
  9505. // Start the macro checking on the player
  9506. pc_macro_reporter_process( *tsd, reporter_aid );
  9507. return 1;
  9508. }
  9509. ACMD_FUNC(macrochecker){
  9510. int16 mapid;
  9511. if( !message || !*message ){
  9512. mapid = sd->bl.m;
  9513. }else{
  9514. mapid = map_mapname2mapid( message );
  9515. if( mapid < 0 ){
  9516. clif_macro_checker( *sd, MACROCHECKER_UNKNOWN_MAP );
  9517. return -1;
  9518. }
  9519. }
  9520. map_data* mapdata = map_getmapdata( mapid );
  9521. if( !mapdata ){
  9522. // Should not happen
  9523. return -1;
  9524. }
  9525. if( mapdata->getMapFlag( MF_NOMACROCHECKER ) ){
  9526. clif_macro_checker( *sd, MACROCHECKER_MAPFLAG );
  9527. return -1;
  9528. }
  9529. if( DIFF_TICK( gettick(), mapdata->last_macrocheck ) < battle_config.macrochecker_delay ){
  9530. clif_macro_checker( *sd, MACROCHECKER_COOLDOWN );
  9531. return -1;
  9532. }
  9533. int32 count = map_foreachinmap( atcommand_macrochecker_sub, mapid, BL_PC, sd->status.account_id, pc_get_group_level( sd ) );
  9534. clif_macro_checker( *sd, MACROCHECKER_SUCCESS );
  9535. sprintf( atcmd_output, msg_txt( sd, 1538 ), count ); // Macro detection has been started on %d players.
  9536. clif_displaymessage( fd, atcmd_output );
  9537. if( count > 0 ){
  9538. mapdata->last_macrocheck = gettick();
  9539. }
  9540. return 0;
  9541. }
  9542. #include <custom/atcommand.inc>
  9543. /**
  9544. * Fills the reference of available commands in atcommand DBMap
  9545. **/
  9546. #define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, 0 }
  9547. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, 0 }
  9548. // Define with restriction
  9549. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
  9550. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
  9551. void atcommand_basecommands(void) {
  9552. /**
  9553. * Command reference list, place the base of your commands here
  9554. * TODO: List all commands that causing crash
  9555. **/
  9556. AtCommandInfo atcommand_base[] = {
  9557. #include <custom/atcommand_def.inc>
  9558. ACMD_DEF(mapmove),
  9559. ACMD_DEF(where),
  9560. ACMD_DEF(jumpto),
  9561. ACMD_DEF(jump),
  9562. ACMD_DEF(who),
  9563. ACMD_DEF2("who2", who),
  9564. ACMD_DEF2("who3", who),
  9565. ACMD_DEF2("whomap", who),
  9566. ACMD_DEF2("whomap2", who),
  9567. ACMD_DEF2("whomap3", who),
  9568. ACMD_DEF(whogm),
  9569. ACMD_DEF(save),
  9570. ACMD_DEF(load),
  9571. ACMD_DEF(speed),
  9572. ACMD_DEF(storage),
  9573. ACMD_DEF(guildstorage),
  9574. ACMD_DEF(option),
  9575. ACMD_DEF(hide), // + /hide
  9576. ACMD_DEF(resetcooltime), // + /resetcooltime
  9577. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  9578. ACMD_DEF(kill),
  9579. ACMD_DEF(alive),
  9580. ACMD_DEF(kami),
  9581. ACMD_DEF(kamib),
  9582. ACMD_DEF(kamic),
  9583. ACMD_DEF(lkami),
  9584. ACMD_DEF(heal),
  9585. ACMD_DEF(healap),
  9586. ACMD_DEF(item),
  9587. ACMD_DEF(item2),
  9588. ACMD_DEF2("itembound",item),
  9589. ACMD_DEF2("itembound2",item2),
  9590. ACMD_DEF(itemreset),
  9591. ACMD_DEF(clearstorage),
  9592. ACMD_DEF(cleargstorage),
  9593. ACMD_DEF(clearcart),
  9594. ACMD_DEF(baselevelup),
  9595. ACMD_DEF(joblevelup),
  9596. ACMD_DEF(help),
  9597. ACMD_DEF(pvpoff),
  9598. ACMD_DEF(pvpon),
  9599. ACMD_DEF(gvgoff),
  9600. ACMD_DEF(gvgon),
  9601. ACMD_DEF(model),
  9602. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  9603. ACMD_DEF(monster),
  9604. ACMD_DEF2("monstersmall", monster),
  9605. ACMD_DEF2("monsterbig", monster),
  9606. ACMD_DEF(killmonster),
  9607. ACMD_DEF2("killmonster2", killmonster),
  9608. ACMD_DEF(refine),
  9609. ACMD_DEF(grade),
  9610. ACMD_DEF(produce),
  9611. ACMD_DEF(memo),
  9612. ACMD_DEF(gat),
  9613. ACMD_DEF(displaystatus),
  9614. ACMD_DEF(statuspoint),
  9615. ACMD_DEF(traitpoint),
  9616. ACMD_DEF(skillpoint),
  9617. ACMD_DEF(zeny),
  9618. ACMD_DEF2("str", param),
  9619. ACMD_DEF2("agi", param),
  9620. ACMD_DEF2("vit", param),
  9621. ACMD_DEF2("int", param),
  9622. ACMD_DEF2("dex", param),
  9623. ACMD_DEF2("luk", param),
  9624. ACMD_DEF2("pow", param),
  9625. ACMD_DEF2("sta", param),
  9626. ACMD_DEF2("wis", param),
  9627. ACMD_DEF2("spl", param),
  9628. ACMD_DEF2("con", param),
  9629. ACMD_DEF2("crt", param),
  9630. ACMD_DEF(guildlevelup),
  9631. ACMD_DEF(makeegg),
  9632. ACMD_DEF(hatch),
  9633. ACMD_DEF(petfriendly),
  9634. ACMD_DEF(pethungry),
  9635. ACMD_DEF(petrename),
  9636. ACMD_DEF(recall), // + /recall
  9637. ACMD_DEF(night),
  9638. ACMD_DEF(day),
  9639. ACMD_DEF(doom),
  9640. ACMD_DEF(doommap),
  9641. ACMD_DEF(raise),
  9642. ACMD_DEF(raisemap),
  9643. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  9644. ACMD_DEF(kickall),
  9645. ACMD_DEF(allskill),
  9646. ACMD_DEF(questskill),
  9647. ACMD_DEF(lostskill),
  9648. ACMD_DEF(spiritball),
  9649. ACMD_DEF(soulball),
  9650. ACMD_DEF(party),
  9651. ACMD_DEF(guild),
  9652. ACMD_DEF(breakguild),
  9653. ACMD_DEF(agitstart),
  9654. ACMD_DEF(agitend),
  9655. ACMD_DEF(mapexit),
  9656. ACMD_DEF(idsearch),
  9657. ACMD_DEF(broadcast), // + /b and /nb
  9658. ACMD_DEF(localbroadcast), // + /lb and /nlb
  9659. ACMD_DEF(recallall),
  9660. ACMD_DEF(reloaditemdb),
  9661. ACMD_DEF(reloadcashdb),
  9662. ACMD_DEF(reloadmobdb),
  9663. ACMD_DEF(reloadskilldb),
  9664. ACMD_DEFR(reloadscript, ATCMD_NOSCRIPT),
  9665. ACMD_DEF(reloadatcommand),
  9666. ACMD_DEF(reloadbattleconf),
  9667. ACMD_DEF(reloadstatusdb),
  9668. ACMD_DEF(reloadpcdb),
  9669. ACMD_DEF(reloadmotd),
  9670. ACMD_DEF(reloadquestdb),
  9671. ACMD_DEF(reloadmsgconf),
  9672. ACMD_DEF(reloadinstancedb),
  9673. ACMD_DEF(reloadachievementdb),
  9674. ACMD_DEF(reloadattendancedb),
  9675. ACMD_DEF(reloadbarterdb),
  9676. ACMD_DEF(reloadlogconf),
  9677. ACMD_DEF(partysharelvl),
  9678. ACMD_DEF(mapinfo),
  9679. ACMD_DEF(dye),
  9680. ACMD_DEF(hair_style),
  9681. ACMD_DEF(hair_color),
  9682. ACMD_DEF(stat_all),
  9683. ACMD_DEF(trait_all),
  9684. ACMD_DEF(char_block),
  9685. ACMD_DEF(ban),
  9686. ACMD_DEF(char_ban),
  9687. ACMD_DEF(char_unblock),
  9688. ACMD_DEF(unban),
  9689. ACMD_DEF(char_unban),
  9690. ACMD_DEF(mount_peco),
  9691. ACMD_DEF(guildspy),
  9692. ACMD_DEF(partyspy),
  9693. ACMD_DEF(clanspy),
  9694. ACMD_DEF(repairall),
  9695. ACMD_DEF(guildrecall),
  9696. ACMD_DEF(partyrecall),
  9697. ACMD_DEF(nuke),
  9698. ACMD_DEF(shownpc),
  9699. ACMD_DEF(hidenpc),
  9700. ACMD_DEF(loadnpc),
  9701. ACMD_DEF(unloadnpc),
  9702. ACMD_DEF(reloadnpcfile),
  9703. ACMD_DEF(servertime),
  9704. ACMD_DEF(jail),
  9705. ACMD_DEF(unjail),
  9706. ACMD_DEF(jailfor),
  9707. ACMD_DEF(jailtime),
  9708. ACMD_DEF(disguise),
  9709. ACMD_DEF(undisguise),
  9710. ACMD_DEF(email),
  9711. ACMD_DEF(effect),
  9712. ACMD_DEF(follow),
  9713. ACMD_DEF(addwarp),
  9714. ACMD_DEF(skillon),
  9715. ACMD_DEF(skilloff),
  9716. ACMD_DEF(killer),
  9717. ACMD_DEF(npcmove),
  9718. ACMD_DEF(killable),
  9719. ACMD_DEF(dropall),
  9720. ACMD_DEF(stockall),
  9721. ACMD_DEF(storeall),
  9722. ACMD_DEF(skillid),
  9723. ACMD_DEF(useskill),
  9724. ACMD_DEF(displayskill),
  9725. ACMD_DEF(displayskillcast),
  9726. ACMD_DEF(displayskillunit),
  9727. ACMD_DEF(snow),
  9728. ACMD_DEF(sakura),
  9729. ACMD_DEF(clouds),
  9730. ACMD_DEF(clouds2),
  9731. ACMD_DEF(fog),
  9732. ACMD_DEF(fireworks),
  9733. ACMD_DEF(leaves),
  9734. ACMD_DEF(summon),
  9735. ACMD_DEF(adjgroup),
  9736. ACMD_DEF(trade),
  9737. ACMD_DEF(send),
  9738. ACMD_DEF(setbattleflag),
  9739. ACMD_DEF(unmute),
  9740. ACMD_DEF(clearweather),
  9741. ACMD_DEF(uptime),
  9742. ACMD_DEF(changesex),
  9743. ACMD_DEF(changecharsex),
  9744. ACMD_DEF(mute),
  9745. ACMD_DEF(refresh),
  9746. ACMD_DEF(refreshall),
  9747. ACMD_DEF(identify),
  9748. ACMD_DEF(identifyall),
  9749. ACMD_DEF(gmotd),
  9750. ACMD_DEF(misceffect),
  9751. ACMD_DEF(mobsearch),
  9752. ACMD_DEF(cleanmap),
  9753. ACMD_DEF(cleanarea),
  9754. ACMD_DEF(npctalk),
  9755. ACMD_DEF(pettalk),
  9756. ACMD_DEF(users),
  9757. ACMD_DEF(reset),
  9758. ACMD_DEF(skilltree),
  9759. ACMD_DEF(marry),
  9760. ACMD_DEF(divorce),
  9761. ACMD_DEF(sound),
  9762. ACMD_DEF(undisguiseall),
  9763. ACMD_DEF(disguiseall),
  9764. ACMD_DEF(changelook),
  9765. ACMD_DEF(autoloot),
  9766. ACMD_DEF(autolootitem),
  9767. ACMD_DEF(autoloottype),
  9768. ACMD_DEF(mobinfo),
  9769. ACMD_DEF(exp),
  9770. ACMD_DEF(version),
  9771. ACMD_DEF(mutearea),
  9772. ACMD_DEF(rates),
  9773. ACMD_DEF(iteminfo),
  9774. ACMD_DEF(whodrops),
  9775. ACMD_DEF(whereis),
  9776. ACMD_DEF(mapflag),
  9777. ACMD_DEF(me),
  9778. ACMD_DEF(monsterignore),
  9779. ACMD_DEF(fakename),
  9780. ACMD_DEF(size),
  9781. ACMD_DEF(showexp),
  9782. ACMD_DEF(showzeny),
  9783. ACMD_DEF(showdelay),
  9784. ACMD_DEF(autotrade),
  9785. ACMD_DEF(changegm),
  9786. ACMD_DEF(changeleader),
  9787. ACMD_DEF(partyoption),
  9788. ACMD_DEF(invite),
  9789. ACMD_DEF(duel),
  9790. ACMD_DEF(leave),
  9791. ACMD_DEF(accept),
  9792. ACMD_DEF(reject),
  9793. ACMD_DEF(clone),
  9794. ACMD_DEF2("slaveclone", clone),
  9795. ACMD_DEF2("evilclone", clone),
  9796. ACMD_DEF(tonpc),
  9797. ACMD_DEF(commands),
  9798. ACMD_DEF(noask),
  9799. ACMD_DEF(request),
  9800. ACMD_DEF(homlevel),
  9801. ACMD_DEF(homevolution),
  9802. ACMD_DEF(hommutate),
  9803. ACMD_DEF(makehomun),
  9804. ACMD_DEF(homfriendly),
  9805. ACMD_DEF(homhungry),
  9806. ACMD_DEF(homtalk),
  9807. ACMD_DEF(hominfo),
  9808. ACMD_DEF(homstats),
  9809. ACMD_DEF(homshuffle),
  9810. ACMD_DEF(showmobs),
  9811. ACMD_DEF(feelreset),
  9812. ACMD_DEF(hatereset),
  9813. ACMD_DEF(auction),
  9814. ACMD_DEF(mail),
  9815. ACMD_DEF(ksprotection),
  9816. ACMD_DEF(allowks),
  9817. ACMD_DEF(cash),
  9818. ACMD_DEF(points),
  9819. ACMD_DEF(agitstart2),
  9820. ACMD_DEF(agitend2),
  9821. ACMD_DEF(resetskill),
  9822. ACMD_DEF(resetstat),
  9823. ACMD_DEF2("storagelist", itemlist),
  9824. ACMD_DEF2("cartlist", itemlist),
  9825. ACMD_DEF(itemlist),
  9826. ACMD_DEF(stats),
  9827. ACMD_DEF(delitem),
  9828. ACMD_DEF(charcommands),
  9829. ACMD_DEF(font),
  9830. ACMD_DEF(accinfo),
  9831. ACMD_DEF(set),
  9832. ACMD_DEF(undisguiseguild),
  9833. ACMD_DEF(disguiseguild),
  9834. ACMD_DEF(sizeall),
  9835. ACMD_DEF(sizeguild),
  9836. ACMD_DEF(addperm),
  9837. ACMD_DEF(rmvperm),
  9838. ACMD_DEF(unloadnpcfile),
  9839. ACMD_DEF(cart),
  9840. ACMD_DEF(mount2),
  9841. ACMD_DEF(join),
  9842. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  9843. ACMD_DEF(fontcolor),
  9844. ACMD_DEF(langtype),
  9845. ACMD_DEF(vip),
  9846. ACMD_DEF(showrate),
  9847. ACMD_DEF(fullstrip),
  9848. ACMD_DEF(costume),
  9849. ACMD_DEF(cloneequip),
  9850. ACMD_DEF(clonestat),
  9851. ACMD_DEF(bodystyle),
  9852. ACMD_DEF(adopt),
  9853. ACMD_DEF(agitstart3),
  9854. ACMD_DEF(agitend3),
  9855. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9856. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9857. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9858. ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
  9859. ACMD_DEF(setquest),
  9860. ACMD_DEF(erasequest),
  9861. ACMD_DEF(completequest),
  9862. ACMD_DEF(checkquest),
  9863. ACMD_DEF(refineui),
  9864. ACMD_DEFR(stylist, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9865. ACMD_DEF(addfame),
  9866. ACMD_DEFR(enchantgradeui, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9867. ACMD_DEFR(roulette, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  9868. ACMD_DEF(setcard),
  9869. ACMD_DEF(macrochecker),
  9870. };
  9871. AtCommandInfo* atcommand;
  9872. int32 i;
  9873. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  9874. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  9875. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  9876. continue;
  9877. }
  9878. CREATE(atcommand, AtCommandInfo, 1);
  9879. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  9880. atcommand->func = atcommand_base[i].func;
  9881. atcommand->restriction = atcommand_base[i].restriction;
  9882. strdb_put(atcommand_db, atcommand->command, atcommand);
  9883. }
  9884. return;
  9885. }
  9886. /*==========================================
  9887. * Command lookup functions
  9888. *------------------------------------------*/
  9889. bool atcommand_exists(const char* name)
  9890. {
  9891. return strdb_exists(atcommand_db, name);
  9892. }
  9893. const char* atcommand_alias_lookup( const std::string& cmd ){
  9894. return atcommand_alias_db.checkAlias( cmd.c_str() );
  9895. }
  9896. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  9897. {
  9898. if (strdb_exists(atcommand_db, name))
  9899. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  9900. return nullptr;
  9901. }
  9902. /// AtCommand suggestion
  9903. static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
  9904. DBIterator* atcommand_iter;
  9905. AtCommandInfo* command_info = nullptr;
  9906. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  9907. char* full_match[MAX_SUGGESTIONS];
  9908. char* suggestions[MAX_SUGGESTIONS];
  9909. char* match;
  9910. int32 prefix_count = 0, full_count = 0;
  9911. bool can_use;
  9912. if (!battle_config.atcommand_suggestions_enabled)
  9913. return;
  9914. atcommand_iter = db_iterator(atcommand_db);
  9915. // Build the matches
  9916. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  9917. match = strstr(command_info->command, name);
  9918. can_use = pc_can_use_command(sd, command_info->command, type);
  9919. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  9920. suggestions[prefix_count] = command_info->command;
  9921. ++prefix_count;
  9922. }
  9923. if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
  9924. full_match[full_count] = command_info->command;
  9925. ++full_count;
  9926. }
  9927. }
  9928. for( auto& pair : atcommand_alias_db ){
  9929. std::shared_ptr<s_atcommand_alias_info> info = pair.second;
  9930. if( pc_can_use_command( sd, info->command->command, type ) ){
  9931. for( const std::string& alias_str : info->aliases ){
  9932. char* alias = const_cast<char *>(alias_str.c_str());
  9933. match = strstr( alias, name );
  9934. if( prefix_count < MAX_SUGGESTIONS && match == alias ){
  9935. suggestions[prefix_count] = alias;
  9936. ++prefix_count;
  9937. }
  9938. if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
  9939. full_match[full_count] = alias;
  9940. ++full_count;
  9941. }
  9942. }
  9943. }
  9944. }
  9945. if ((full_count+prefix_count) > 0) {
  9946. char buffer[512];
  9947. int32 i;
  9948. // Merge full match and prefix match results
  9949. if (prefix_count < MAX_SUGGESTIONS) {
  9950. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  9951. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  9952. }
  9953. // Build the suggestion string
  9954. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  9955. strcat(buffer,"\n");
  9956. for(i=0; i < prefix_count; ++i) {
  9957. strcat(buffer,suggestions[i]);
  9958. strcat(buffer," ");
  9959. }
  9960. clif_displaymessage(sd->fd, buffer);
  9961. }
  9962. dbi_destroy(atcommand_iter);
  9963. }
  9964. /**
  9965. * Executes an at-command
  9966. * @param fd
  9967. * @param sd
  9968. * @param message
  9969. * @param type
  9970. * 0 : script call (atcommand)
  9971. * 1 : normal player @atcommand
  9972. * 2 : console (admin:@atcommand)
  9973. * 3 : script call (useatcmd)
  9974. */
  9975. bool is_atcommand(const int32 fd, map_session_data* sd, const char* message, int32 type)
  9976. {
  9977. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  9978. char output[CHAT_SIZE_MAX];
  9979. //Reconstructed message
  9980. char atcmd_msg[CHAT_SIZE_MAX * 2];
  9981. TBL_PC * ssd = nullptr; //sd for target
  9982. AtCommandInfo * info;
  9983. bool is_atcommand = true; // false if it's a charcommand
  9984. nullpo_retr(false, sd);
  9985. //Shouldn't happen
  9986. if ( !message || !*message )
  9987. return false;
  9988. //If cannot use atcomamnd while talking with NPC [Kichi]
  9989. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  9990. return false;
  9991. //Block NOCHAT but do not display it as a normal message
  9992. if ( sd->sc.getSCE(SC_NOCHAT) && sd->sc.getSCE(SC_NOCHAT)->val1&MANNER_NOCOMMAND )
  9993. return true;
  9994. // skip 10/11-langtype's codepage indicator, if detected
  9995. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  9996. message += 3;
  9997. //Should display as a normal message
  9998. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  9999. return false;
  10000. // type value 0|2 = script|console invoked: bypass restrictions
  10001. if ( type == 1 || type == 3) {
  10002. //Commands are disabled on maps flagged as 'nocommand'
  10003. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  10004. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  10005. return false;
  10006. }
  10007. }
  10008. if (*message == charcommand_symbol)
  10009. is_atcommand = false;
  10010. if (is_atcommand) { // @command
  10011. sprintf(atcmd_msg, "%s", message);
  10012. ssd = sd;
  10013. } else { // #command
  10014. char charname[NAME_LENGTH];
  10015. int32 n;
  10016. //Checks to see if #command has a name or a name + parameters.
  10017. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  10018. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  10019. ) {
  10020. if (pc_get_group_level(sd) == 0) {
  10021. if (n < 1)
  10022. return false; // No command found. Display as normal message.
  10023. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  10024. 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
  10025. return false;
  10026. }
  10027. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  10028. clif_displaymessage(fd, output);
  10029. return true;
  10030. }
  10031. ssd = map_nick2sd(charname,true);
  10032. if (ssd == nullptr) {
  10033. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  10034. clif_displaymessage(fd, output);
  10035. return true;
  10036. }
  10037. if (n > 2)
  10038. sprintf(atcmd_msg, "%s %s", command, params);
  10039. else
  10040. sprintf(atcmd_msg, "%s", command);
  10041. }
  10042. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  10043. sd->idletime = last_tick;
  10044. if (battle_config.hom_idle_no_share && sd->hd && battle_config.idletime_hom_option&IDLE_ATCOMMAND)
  10045. sd->idletime_hom = last_tick;
  10046. if (battle_config.mer_idle_no_share && sd->md && battle_config.idletime_mer_option&IDLE_ATCOMMAND)
  10047. sd->idletime_mer = last_tick;
  10048. //Clearing these to be used once more.
  10049. memset(command, '\0', sizeof(command));
  10050. memset(params, '\0', sizeof(params));
  10051. //check to see if any params exist within this command
  10052. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  10053. params[0] = '\0';
  10054. if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
  10055. sprintf(output,msg_txt(sd,154), command); // %s failed.
  10056. clif_displaymessage(fd, output);
  10057. return true;
  10058. }
  10059. // @commands (script based)
  10060. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  10061. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  10062. // Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
  10063. if( binding != nullptr && binding->npc_event[0] &&
  10064. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  10065. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  10066. {
  10067. // Check if self or character invoking; if self == character invoked, then self invoke.
  10068. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  10069. return true;
  10070. }
  10071. }
  10072. //Grab the command information and check for the proper GM level required to use it or if the command exists
  10073. info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
  10074. if (info == nullptr) {
  10075. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  10076. return false;
  10077. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  10078. clif_displaymessage(fd, output);
  10079. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  10080. return true;
  10081. }
  10082. //check restriction
  10083. if (info->restriction) {
  10084. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  10085. return true;
  10086. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  10087. return true;
  10088. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  10089. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  10090. return true;
  10091. }
  10092. // type == 1 : player invoked
  10093. if (type == 1) {
  10094. if ((is_atcommand && info->at_groups[sd->group->index] == 0) ||
  10095. (!is_atcommand && info->char_groups[sd->group->index] == 0) )
  10096. return false;
  10097. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  10098. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  10099. return true;
  10100. }
  10101. }
  10102. //Attempt to use the command
  10103. if ( (info->func(fd, ssd, command, params) != 0) )
  10104. {
  10105. sprintf(output,msg_txt(sd,154), command); // %s failed.
  10106. clif_displaymessage(fd, output);
  10107. return true;
  10108. }
  10109. //Log only if successful.
  10110. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  10111. return true;
  10112. }
  10113. void atcommand_db_load_groups(){
  10114. DBIterator *iter = db_iterator(atcommand_db);
  10115. AtCommandInfo* cmd;
  10116. size_t pc_group_max = player_group_db.size();
  10117. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  10118. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  10119. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  10120. for( auto& it : player_group_db ){
  10121. cmd->at_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_ATCOMMAND );
  10122. cmd->char_groups[it.second->index] = it.second->can_use_command( cmd->command, COMMAND_CHARCOMMAND );
  10123. }
  10124. }
  10125. dbi_destroy(iter);
  10126. }
  10127. void atcommand_db_clear(void) {
  10128. if (atcommand_db != nullptr) {
  10129. DBIterator *iter = db_iterator(atcommand_db);
  10130. AtCommandInfo* cmd;
  10131. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  10132. aFree(cmd->at_groups);
  10133. aFree(cmd->char_groups);
  10134. }
  10135. dbi_destroy(iter);
  10136. db_destroy(atcommand_db);
  10137. }
  10138. atcommand_alias_db.clear();
  10139. }
  10140. void atcommand_doload(void) {
  10141. atcommand_db_clear();
  10142. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  10143. atcommand_basecommands(); //fills initial atcommand_db with known commands
  10144. atcommand_alias_db.load();
  10145. #if defined(BUILDBOT)
  10146. DBIterator* atcommand_iter = db_iterator( atcommand_db );
  10147. for( AtCommandInfo* command_info = static_cast<AtCommandInfo*>( dbi_first( atcommand_iter ) ); dbi_exists( atcommand_iter ); command_info = static_cast<AtCommandInfo*>( dbi_next( atcommand_iter ) ) ){
  10148. // Attempt to find the command
  10149. std::shared_ptr<s_atcommand_alias_info> info = atcommand_alias_db.find( command_info->command );
  10150. // Failed to find the help property in the configuration file
  10151. if( info == nullptr ){
  10152. ShowError( "atcommand_doload: No entry for atcommand \"%s\" found in \"%s\"\n", command_info->command, atcommand_alias_db.getDefaultLocation().c_str() );
  10153. continue;
  10154. }
  10155. if( info->help.empty() ){
  10156. ShowError( "atcommand_doload: No help for atcommand \"%s\" contained in \"%s\"\n", command_info->command, atcommand_alias_db.getDefaultLocation().c_str() );
  10157. continue;
  10158. }
  10159. }
  10160. dbi_destroy( atcommand_iter );
  10161. #endif
  10162. }
  10163. void do_init_atcommand(void) {
  10164. atcommand_doload();
  10165. }
  10166. void do_final_atcommand(void) {
  10167. atcommand_db_clear();
  10168. }