atcommand.cpp 327 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775
  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 <math.h>
  5. #include <stdlib.h>
  6. #include "../common/cbasetypes.hpp"
  7. #include "../common/cli.hpp"
  8. #include "../common/conf.hpp"
  9. #include "../common/malloc.hpp"
  10. #include "../common/mmo.hpp"
  11. #include "../common/nullpo.hpp"
  12. #include "../common/random.hpp"
  13. #include "../common/showmsg.hpp"
  14. #include "../common/socket.hpp"
  15. #include "../common/strlib.hpp"
  16. #include "../common/timer.hpp"
  17. #include "../common/utilities.hpp"
  18. #include "../common/utils.hpp"
  19. #include "achievement.hpp"
  20. #include "battle.hpp"
  21. #include "channel.hpp"
  22. #include "chat.hpp"
  23. #include "chrif.hpp"
  24. #include "clan.hpp"
  25. #include "clif.hpp"
  26. #include "duel.hpp"
  27. #include "elemental.hpp"
  28. #include "guild.hpp"
  29. #include "homunculus.hpp"
  30. #include "instance.hpp"
  31. #include "intif.hpp"
  32. #include "itemdb.hpp" // MAX_ITEMGROUP
  33. #include "log.hpp"
  34. #include "mail.hpp"
  35. #include "map.hpp"
  36. #include "mapreg.hpp"
  37. #include "mercenary.hpp"
  38. #include "mob.hpp"
  39. #include "npc.hpp"
  40. #include "party.hpp"
  41. #include "pc.hpp"
  42. #include "pc_groups.hpp"
  43. #include "pet.hpp"
  44. #include "quest.hpp"
  45. #include "script.hpp"
  46. #include "storage.hpp"
  47. #include "trade.hpp"
  48. #define ATCOMMAND_LENGTH 50
  49. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  50. typedef struct AtCommandInfo AtCommandInfo;
  51. typedef struct AliasInfo AliasInfo;
  52. int atcmd_binding_count = 0;
  53. /// Atcommand restriction usage
  54. enum e_atcmd_restict {
  55. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  56. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  57. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  58. };
  59. struct AtCommandInfo {
  60. char command[ATCOMMAND_LENGTH];
  61. AtCommandFunc func;
  62. char* at_groups; /// Quick @commands "can-use" lookup
  63. char* char_groups; /// Quick @charcommands "can-use" lookup
  64. uint8 restriction; /// Restrictions see enum e_restict
  65. };
  66. struct AliasInfo {
  67. AtCommandInfo *command;
  68. char alias[ATCOMMAND_LENGTH];
  69. };
  70. char atcommand_symbol = '@'; // first char of the commands
  71. char charcommand_symbol = '#';
  72. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  73. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  74. static config_t atcommand_config;
  75. static char atcmd_output[CHAT_SIZE_MAX];
  76. static char atcmd_player_name[NAME_LENGTH];
  77. const char *parent_cmd;
  78. struct atcmd_binding_data** atcmd_binding;
  79. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  80. static const char* atcommand_checkalias(const char *aliasname); // @help
  81. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  82. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  83. // @commands (script-based)
  84. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  85. int i = 0;
  86. if( *name == atcommand_symbol || *name == charcommand_symbol )
  87. name++; // for backwards compatibility
  88. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  89. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  90. }
  91. /**
  92. * retrieves the help string associated with a given command.
  93. *
  94. * @param name the name of the command to retrieve help information for
  95. * @return the string associated with the command, or NULL
  96. */
  97. static const char* atcommand_help_string(const char* command)
  98. {
  99. const char* str = NULL;
  100. config_setting_t* info;
  101. if( *command == atcommand_symbol || *command == charcommand_symbol )
  102. {// remove the prefix symbol for the raw name of the command
  103. command ++;
  104. }
  105. // convert alias to the real command name
  106. command = atcommand_checkalias(command);
  107. // attempt to find the first default help command
  108. info = config_lookup(&atcommand_config, "help");
  109. if( info == NULL )
  110. {// failed to find the help property in the configuration file
  111. return NULL;
  112. }
  113. if( !config_setting_lookup_string( info, command, &str ) )
  114. {// failed to find the matching help string
  115. return NULL;
  116. }
  117. // push the result from the method
  118. return str;
  119. }
  120. /*==========================================
  121. * @send (used for testing packet sends from the client)
  122. *------------------------------------------*/
  123. ACMD_FUNC(send)
  124. {
  125. int len=0,type;
  126. // read message type as hex number (without the 0x)
  127. if(!message || !*message ||
  128. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  129. || sscanf(message, "%8x", &type)==1) )
  130. {
  131. int i;
  132. for (i = 900; i <= 903; ++i)
  133. clif_displaymessage(fd, msg_txt(sd,i));
  134. return -1;
  135. }
  136. #define PARSE_ERROR(error,p) \
  137. {\
  138. clif_displaymessage(fd, (error));\
  139. sprintf(atcmd_output, ">%s", (p));\
  140. clif_displaymessage(fd, atcmd_output);\
  141. }
  142. //define PARSE_ERROR
  143. #define CHECK_EOS(p) \
  144. if(*(p) == 0){\
  145. clif_displaymessage(fd, "Unexpected end of string");\
  146. return -1;\
  147. }
  148. //define CHECK_EOS
  149. #define SKIP_VALUE(p) \
  150. {\
  151. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  152. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  153. }
  154. //define SKIP_VALUE
  155. #define GET_VALUE(p,num) \
  156. {\
  157. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  158. PARSE_ERROR("Invalid number in:",(p));\
  159. return -1;\
  160. }\
  161. }
  162. //define GET_VALUE
  163. if (type > 0 && type < MAX_PACKET_DB) {
  164. int off,end;
  165. long num;
  166. if(len)
  167. {// show packet length
  168. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  169. clif_displaymessage(fd, atcmd_output);
  170. return 0;
  171. }
  172. len=packet_db[type].len;
  173. off=2;
  174. if(len == 0)
  175. {// unknown packet - ERROR
  176. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  177. clif_displaymessage(fd, atcmd_output);
  178. return -1;
  179. } else if(len == -1)
  180. {// dynamic packet
  181. len=SHRT_MAX-4; // maximum length
  182. off=4;
  183. }
  184. WFIFOHEAD(fd, len);
  185. WFIFOW(fd,0)=TOW(type);
  186. // parse packet contents
  187. SKIP_VALUE(message);
  188. while(*message != 0 && off < len){
  189. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  190. {// default (byte)
  191. GET_VALUE(message,num);
  192. WFIFOB(fd,off)=TOB(num);
  193. ++off;
  194. } else if(TOUPPER(*message) == 'B')
  195. {// byte
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOB(fd,off)=TOB(num);
  199. ++off;
  200. } else if(TOUPPER(*message) == 'W')
  201. {// word (2 bytes)
  202. ++message;
  203. GET_VALUE(message,num);
  204. WFIFOW(fd,off)=TOW(num);
  205. off+=2;
  206. } else if(TOUPPER(*message) == 'L')
  207. {// long word (4 bytes)
  208. ++message;
  209. GET_VALUE(message,num);
  210. WFIFOL(fd,off)=TOL(num);
  211. off+=4;
  212. } else if(TOUPPER(*message) == 'S')
  213. {// string - escapes are valid
  214. // get string length - num <= 0 means not fixed length (default)
  215. ++message;
  216. if(*message == '"'){
  217. num=0;
  218. } else {
  219. GET_VALUE(message,num);
  220. while(*message != '"')
  221. {// find start of string
  222. if(*message == 0 || ISSPACE(*message)){
  223. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  224. return -1;
  225. }
  226. ++message;
  227. }
  228. }
  229. // parse string
  230. ++message;
  231. CHECK_EOS(message);
  232. end=(num<=0? 0: min(off+((int)num),len));
  233. for(; *message != '"' && (off < end || end == 0); ++off){
  234. if(*message == '\\'){
  235. ++message;
  236. CHECK_EOS(message);
  237. switch(*message){
  238. case 'a': num=0x07; break; // Bell
  239. case 'b': num=0x08; break; // Backspace
  240. case 't': num=0x09; break; // Horizontal tab
  241. case 'n': num=0x0A; break; // Line feed
  242. case 'v': num=0x0B; break; // Vertical tab
  243. case 'f': num=0x0C; break; // Form feed
  244. case 'r': num=0x0D; break; // Carriage return
  245. case 'e': num=0x1B; break; // Escape
  246. default: num=*message; break;
  247. case 'x': // Hexadecimal
  248. {
  249. ++message;
  250. CHECK_EOS(message);
  251. if(!ISXDIGIT(*message)){
  252. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  253. return -1;
  254. }
  255. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  256. if(ISXDIGIT(*message)){
  257. ++message;
  258. CHECK_EOS(message);
  259. num<<=8;
  260. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  261. }
  262. WFIFOB(fd,off)=TOB(num);
  263. ++message;
  264. CHECK_EOS(message);
  265. continue;
  266. }
  267. case '0':
  268. case '1':
  269. case '2':
  270. case '3':
  271. case '4':
  272. case '5':
  273. case '6':
  274. case '7': // Octal
  275. {
  276. num=*message-'0'; // 1st octal digit
  277. ++message;
  278. CHECK_EOS(message);
  279. if(ISDIGIT(*message) && *message < '8'){
  280. num<<=3;
  281. num+=*message-'0'; // 2nd octal digit
  282. ++message;
  283. CHECK_EOS(message);
  284. if(ISDIGIT(*message) && *message < '8'){
  285. num<<=3;
  286. num+=*message-'0'; // 3rd octal digit
  287. ++message;
  288. CHECK_EOS(message);
  289. }
  290. }
  291. WFIFOB(fd,off)=TOB(num);
  292. continue;
  293. }
  294. }
  295. } else
  296. num=*message;
  297. WFIFOB(fd,off)=TOB(num);
  298. ++message;
  299. CHECK_EOS(message);
  300. }//for
  301. while(*message != '"')
  302. {// ignore extra characters
  303. ++message;
  304. CHECK_EOS(message);
  305. }
  306. // terminate the string
  307. if(off < end)
  308. {// fill the rest with 0's
  309. memset(WFIFOP(fd,off),0,end-off);
  310. off=end;
  311. }
  312. } else
  313. {// unknown
  314. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  315. return -1;
  316. }
  317. SKIP_VALUE(message);
  318. }
  319. if(packet_db[type].len == -1)
  320. {// send dynamic packet
  321. WFIFOW(fd,2)=TOW(off);
  322. WFIFOSET(fd,off);
  323. } else
  324. {// send static packet
  325. if(off < len)
  326. memset(WFIFOP(fd,off),0,len-off);
  327. WFIFOSET(fd,len);
  328. }
  329. } else {
  330. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  331. return -1;
  332. }
  333. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  334. clif_displaymessage(fd, atcmd_output);
  335. return 0;
  336. #undef PARSE_ERROR
  337. #undef CHECK_EOS
  338. #undef SKIP_VALUE
  339. #undef GET_VALUE
  340. }
  341. /**
  342. * Retrieves map name suggestions for a given string.
  343. * This will first check if any map names contain the given string, and will
  344. * print out MAX_SUGGESTIONS results if any maps are found.
  345. * Otherwise, suggestions will be calculated through Levenshtein distance,
  346. * and up to 5 of the closest matches will be printed.
  347. *
  348. * @author Euphy
  349. */
  350. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  351. // Minimum length for suggestions is 2 characters
  352. if( strlen( name ) < 2 ){
  353. return;
  354. }
  355. std::vector<const char*> suggestions;
  356. suggestions.reserve( MAX_SUGGESTIONS );
  357. // check for maps that contain string
  358. for (int i = 0; i < map_num; i++) {
  359. struct map_data *mapdata = map_getmapdata(i);
  360. // Prevent suggestion of instance mapnames
  361. if( mapdata->instance_id != 0 ){
  362. continue;
  363. }
  364. if( strstr( mapdata->name, name ) != nullptr ){
  365. suggestions.push_back( mapdata->name );
  366. if( suggestions.size() == MAX_SUGGESTIONS ){
  367. break;
  368. }
  369. }
  370. }
  371. // if no maps found, search by edit distance
  372. if( suggestions.empty() ){
  373. // Levenshtein > 4 is bad
  374. const int LEVENSHTEIN_MAX = 4;
  375. std::unordered_map<int, std::vector<const char*>> maps;
  376. for (int i = 0; i < map_num; i++) {
  377. struct map_data *mapdata = map_getmapdata(i);
  378. // Prevent suggestion of instance mapnames
  379. if(mapdata->instance_id != 0 ){
  380. continue;
  381. }
  382. // Calculate the levenshtein distance of the two strings
  383. int distance = levenshtein(mapdata->name, name);
  384. // Check if it is above the maximum defined distance
  385. if( distance > LEVENSHTEIN_MAX ){
  386. continue;
  387. }
  388. std::vector<const char*>& vector = maps[distance];
  389. // Do not add more entries than required
  390. if( vector.size() == MAX_SUGGESTIONS ){
  391. continue;
  392. }
  393. vector.push_back(mapdata->name);
  394. }
  395. for( int distance = 0; distance <= LEVENSHTEIN_MAX; distance++ ){
  396. std::vector<const char*>& vector = maps[distance];
  397. for( const char* found_map : vector ){
  398. suggestions.push_back( found_map );
  399. if( suggestions.size() == MAX_SUGGESTIONS ){
  400. break;
  401. }
  402. }
  403. if( suggestions.size() == MAX_SUGGESTIONS ){
  404. break;
  405. }
  406. }
  407. }
  408. // If no suggestion could be made, do not output anything at all
  409. if( suggestions.empty() ){
  410. return;
  411. }
  412. char buffer[CHAT_SIZE_MAX];
  413. // build the suggestion string
  414. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  415. strcat(buffer, "\n");
  416. for( const char* suggestion : suggestions ){
  417. strcat(buffer, suggestion);
  418. strcat(buffer, " ");
  419. }
  420. clif_displaymessage(sd->fd, buffer);
  421. }
  422. /*==========================================
  423. * @rura, @warp, @mapmove
  424. *------------------------------------------*/
  425. ACMD_FUNC(mapmove)
  426. {
  427. char map_name[MAP_NAME_LENGTH_EXT];
  428. unsigned short mapindex;
  429. short x = 0, y = 0;
  430. int16 m = -1;
  431. nullpo_retr(-1, sd);
  432. memset(map_name, '\0', sizeof(map_name));
  433. if (!message || !*message ||
  434. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  435. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  436. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  437. return -1;
  438. }
  439. mapindex = mapindex_name2id(map_name);
  440. if (mapindex)
  441. m = map_mapindex2mapid(mapindex);
  442. if (!mapindex) { // m < 0 means on different server! [Kevin]
  443. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  444. if (battle_config.warp_suggestions_enabled)
  445. warp_get_suggestions(sd, map_name);
  446. return -1;
  447. }
  448. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  449. { //This is to prevent the pc_setpos call from printing an error.
  450. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  451. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  452. x = y = 0; //Invalid cell, use random spot.
  453. }
  454. 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, sd->group_level)) {
  455. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  456. return -1;
  457. }
  458. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  459. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  460. return -1;
  461. }
  462. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  463. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  464. return -1;
  465. }
  466. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  467. return 0;
  468. }
  469. /*==========================================
  470. * Displays where a character is. Corrected version by Silent. [Skotlex]
  471. *------------------------------------------*/
  472. ACMD_FUNC(where)
  473. {
  474. struct map_session_data* pl_sd;
  475. nullpo_retr(-1, sd);
  476. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  477. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  478. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  479. return -1;
  480. }
  481. pl_sd = map_nick2sd(atcmd_player_name,true);
  482. if (pl_sd == NULL ||
  483. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  484. (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))
  485. ) {
  486. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  487. return -1;
  488. }
  489. 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);
  490. clif_displaymessage(fd, atcmd_output);
  491. return 0;
  492. }
  493. /*==========================================
  494. *
  495. *------------------------------------------*/
  496. ACMD_FUNC(jumpto)
  497. {
  498. struct map_session_data *pl_sd = NULL;
  499. nullpo_retr(-1, sd);
  500. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  501. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  502. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  503. return -1;
  504. }
  505. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  506. {
  507. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  508. return -1;
  509. }
  510. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  511. {
  512. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  513. return -1;
  514. }
  515. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  516. {
  517. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  518. return -1;
  519. }
  520. if( pc_isdead(sd) )
  521. {
  522. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  523. return -1;
  524. }
  525. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  526. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  527. clif_displaymessage(fd, atcmd_output);
  528. return 0;
  529. }
  530. /*==========================================
  531. *
  532. *------------------------------------------*/
  533. ACMD_FUNC(jump)
  534. {
  535. short x = 0, y = 0;
  536. nullpo_retr(-1, sd);
  537. memset(atcmd_output, '\0', sizeof(atcmd_output));
  538. sscanf(message, "%6hd %6hd", &x, &y);
  539. if (map_getmapflag(sd->bl.m, MF_NOTELEPORT) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  540. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  541. return -1;
  542. }
  543. if( pc_isdead(sd) )
  544. {
  545. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  546. return -1;
  547. }
  548. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  549. { //This is to prevent the pc_setpos call from printing an error.
  550. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  551. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  552. x = y = 0; //Invalid cell, use random spot.
  553. }
  554. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  555. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  556. clif_displaymessage(fd, atcmd_output);
  557. return 0;
  558. }
  559. /*==========================================
  560. * Display list of online characters with
  561. * various info.
  562. *------------------------------------------*/
  563. ACMD_FUNC(who) {
  564. struct map_session_data *pl_sd = NULL;
  565. struct s_mapiterator *iter = NULL;
  566. char player_name[NAME_LENGTH] = "";
  567. int count = 0;
  568. int level = 0;
  569. StringBuf buf;
  570. /**
  571. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  572. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  573. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  574. */
  575. int display_type = 1;
  576. int map_id = -1;
  577. nullpo_retr(-1, sd);
  578. if (strstr(command, "map") != NULL) {
  579. char map_name[MAP_NAME_LENGTH_EXT] = "";
  580. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  581. map_id = sd->bl.m;
  582. } else {
  583. sscanf(message, "%23s", player_name);
  584. }
  585. if (strstr(command, "2") != NULL)
  586. display_type = 2;
  587. else if (strstr(command, "3") != NULL)
  588. display_type = 3;
  589. level = pc_get_group_level(sd);
  590. StringBuf_Init(&buf);
  591. iter = mapit_getallusers();
  592. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  593. 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
  594. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  595. || (map_id >= 0 && pl_sd->bl.m != map_id))
  596. continue;
  597. switch (display_type) {
  598. case 2: {
  599. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  600. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  601. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  602. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  603. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  604. break;
  605. }
  606. case 3: {
  607. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  608. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  609. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  610. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  611. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  612. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  613. break;
  614. }
  615. default: {
  616. struct party_data *p = party_search(pl_sd->status.party_id);
  617. struct guild *g = pl_sd->guild;
  618. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  619. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  620. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  621. if (p != NULL)
  622. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  623. if (g != NULL)
  624. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  625. break;
  626. }
  627. }
  628. clif_displaymessage(fd, StringBuf_Value(&buf));
  629. StringBuf_Clear(&buf);
  630. count++;
  631. }
  632. }
  633. mapit_free(iter);
  634. if (map_id < 0) {
  635. if (count == 0)
  636. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  637. else if (count == 1)
  638. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  639. else
  640. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  641. } else {
  642. struct map_data *mapdata = map_getmapdata(map_id);
  643. if (count == 0)
  644. StringBuf_Printf(&buf, msg_txt(sd,54), mapdata->name); // No player found in map '%s'.
  645. else if (count == 1)
  646. StringBuf_Printf(&buf, msg_txt(sd,55), mapdata->name); // 1 player found in map '%s'.
  647. else
  648. StringBuf_Printf(&buf, msg_txt(sd,56), count, mapdata->name); // %d players found in map '%s'.
  649. }
  650. clif_displaymessage(fd, StringBuf_Value(&buf));
  651. StringBuf_Destroy(&buf);
  652. return 0;
  653. }
  654. /*==========================================
  655. *
  656. *------------------------------------------*/
  657. ACMD_FUNC(whogm)
  658. {
  659. struct map_session_data* pl_sd;
  660. struct s_mapiterator* iter;
  661. int j, count;
  662. int level;
  663. char match_text[CHAT_SIZE_MAX];
  664. char player_name[NAME_LENGTH];
  665. struct guild *g;
  666. struct party_data *p;
  667. nullpo_retr(-1, sd);
  668. memset(atcmd_output, '\0', sizeof(atcmd_output));
  669. memset(match_text, '\0', sizeof(match_text));
  670. memset(player_name, '\0', sizeof(player_name));
  671. if (sscanf(message, "%255[^\n]", match_text) < 1)
  672. strcpy(match_text, "");
  673. for (j = 0; match_text[j]; j++)
  674. match_text[j] = TOLOWER(match_text[j]);
  675. count = 0;
  676. level = pc_get_group_level(sd);
  677. iter = mapit_getallusers();
  678. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  679. {
  680. int pl_level = pc_get_group_level(pl_sd);
  681. if (!pl_level)
  682. continue;
  683. if (match_text[0])
  684. {
  685. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  686. for (j = 0; player_name[j]; j++)
  687. player_name[j] = TOLOWER(player_name[j]);
  688. // search with no case sensitive
  689. if (strstr(player_name, match_text) == NULL)
  690. continue;
  691. }
  692. if (pl_level > level) {
  693. if (pc_isinvisible(pl_sd))
  694. continue;
  695. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  696. clif_displaymessage(fd, atcmd_output);
  697. count++;
  698. continue;
  699. }
  700. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  701. pl_sd->status.name, pl_level,
  702. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  703. clif_displaymessage(fd, atcmd_output);
  704. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  705. pl_sd->status.base_level,
  706. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  707. clif_displaymessage(fd, atcmd_output);
  708. p = party_search(pl_sd->status.party_id);
  709. g = pl_sd->guild;
  710. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  711. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  712. clif_displaymessage(fd, atcmd_output);
  713. count++;
  714. }
  715. mapit_free(iter);
  716. if (count == 0)
  717. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  718. else if (count == 1)
  719. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  720. else {
  721. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  722. clif_displaymessage(fd, atcmd_output);
  723. }
  724. return 0;
  725. }
  726. /*==========================================
  727. *
  728. *------------------------------------------*/
  729. ACMD_FUNC(save)
  730. {
  731. nullpo_retr(-1, sd);
  732. if( map_getmapdata(sd->bl.m)->instance_id ) {
  733. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  734. return 1;
  735. }
  736. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  737. if (sd->status.pet_id > 0 && sd->pd)
  738. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  739. chrif_save(sd, CSAVE_NORMAL);
  740. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  741. return 0;
  742. }
  743. /*==========================================
  744. *
  745. *------------------------------------------*/
  746. ACMD_FUNC(load)
  747. {
  748. int16 m;
  749. nullpo_retr(-1, sd);
  750. m = map_mapindex2mapid(sd->status.save_point.map);
  751. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  752. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  753. return -1;
  754. }
  755. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  756. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  757. return -1;
  758. }
  759. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  760. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  761. return 0;
  762. }
  763. /*==========================================
  764. *
  765. *------------------------------------------*/
  766. ACMD_FUNC(speed)
  767. {
  768. short speed;
  769. nullpo_retr(-1, sd);
  770. memset(atcmd_output, '\0', sizeof(atcmd_output));
  771. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  772. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  773. clif_displaymessage(fd, atcmd_output);
  774. return -1;
  775. }
  776. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  777. if (speed < 0)
  778. sd->base_status.speed = DEFAULT_WALK_SPEED;
  779. else
  780. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  781. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  782. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  783. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  784. } else
  785. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  786. status_calc_bl(&sd->bl, SCB_SPEED);
  787. return 0;
  788. }
  789. /*==========================================
  790. *
  791. *------------------------------------------*/
  792. ACMD_FUNC(storage)
  793. {
  794. nullpo_retr(-1, sd);
  795. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  796. return -1;
  797. if (storage_storageopen(sd) == 1)
  798. { //Already open.
  799. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  800. return -1;
  801. }
  802. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  803. return 0;
  804. }
  805. /*==========================================
  806. *
  807. *------------------------------------------*/
  808. ACMD_FUNC(guildstorage)
  809. {
  810. nullpo_retr(-1, sd);
  811. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  812. return -1;
  813. switch (storage_guild_storageopen(sd)) {
  814. case GSTORAGE_OPEN:
  815. clif_displaymessage(fd, msg_txt(sd, 920)); // Guild storage opened.
  816. break;
  817. case GSTORAGE_STORAGE_ALREADY_OPEN:
  818. clif_displaymessage(fd, msg_txt(sd, 250)); // You have already opened your storage. Close it first.
  819. return -1;
  820. case GSTORAGE_ALREADY_OPEN:
  821. clif_displaymessage(fd, msg_txt(sd, 251)); // You have already opened your guild storage. Close it first.
  822. return -1;
  823. case GSTORAGE_NO_GUILD:
  824. clif_displaymessage(fd, msg_txt(sd, 252)); // You are not in a guild.
  825. return -1;
  826. case GSTORAGE_NO_STORAGE:
  827. clif_displaymessage(fd, msg_txt(sd, 786)); // The guild does not have a guild storage.
  828. return -1;
  829. case GSTORAGE_NO_PERMISSION:
  830. clif_displaymessage(fd, msg_txt(sd, 787)); // You do not have permission to use the guild storage.
  831. return -1;
  832. }
  833. return 0;
  834. }
  835. /*==========================================
  836. *
  837. *------------------------------------------*/
  838. ACMD_FUNC(option)
  839. {
  840. int param1 = 0, param2 = 0, param3 = 0;
  841. nullpo_retr(-1, sd);
  842. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  843. {// failed to match the parameters so inform the user of the options
  844. const char* text;
  845. // attempt to find the setting information for this command
  846. text = atcommand_help_string( command );
  847. // notify the user of the requirement to enter an option
  848. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  849. if( text )
  850. {// send the help text associated with this command
  851. clif_displaymessage( fd, text );
  852. }
  853. return -1;
  854. }
  855. sd->sc.opt1 = param1;
  856. sd->sc.opt2 = param2;
  857. pc_setoption(sd, param3);
  858. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  859. return 0;
  860. }
  861. /*==========================================
  862. *
  863. *------------------------------------------*/
  864. ACMD_FUNC(hide)
  865. {
  866. nullpo_retr(-1, sd);
  867. if (pc_isinvisible(sd)) {
  868. sd->sc.option &= ~OPTION_INVISIBLE;
  869. if (sd->disguise)
  870. status_set_viewdata(&sd->bl, sd->disguise);
  871. else
  872. status_set_viewdata(&sd->bl, sd->status.class_);
  873. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  874. // increment the number of pvp players on the map
  875. map_getmapdata(sd->bl.m)->users_pvp++;
  876. if( !battle_config.pk_mode && map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) )
  877. {// register the player for ranking calculations
  878. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  879. }
  880. //bugreport:2266
  881. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  882. } else {
  883. sd->sc.option |= OPTION_INVISIBLE;
  884. sd->vd.class_ = JT_INVISIBLE;
  885. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  886. // decrement the number of pvp players on the map
  887. map_getmapdata(sd->bl.m)->users_pvp--;
  888. if( map_getmapflag(sd->bl.m, MF_PVP) && !map_getmapflag(sd->bl.m, MF_PVP_NOCALCRANK) && sd->pvp_timer != INVALID_TIMER )
  889. {// unregister the player for ranking
  890. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  891. sd->pvp_timer = INVALID_TIMER;
  892. }
  893. }
  894. clif_changeoption(&sd->bl);
  895. return 0;
  896. }
  897. /*==========================================
  898. * Changes a character's class
  899. *------------------------------------------*/
  900. ACMD_FUNC(jobchange)
  901. {
  902. int job = 0, upper = 0;
  903. const char* text;
  904. nullpo_retr(-1, sd);
  905. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  906. int i;
  907. bool found = false;
  908. upper = 0;
  909. // Normal Jobs
  910. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  911. if (strncmpi(message, job_name(i), 16) == 0) {
  912. job = i;
  913. found = true;
  914. }
  915. }
  916. // High Jobs, Babys and Third
  917. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  918. if (strncmpi(message, job_name(i), 16) == 0) {
  919. job = i;
  920. found = true;
  921. }
  922. }
  923. if (!found) {
  924. text = atcommand_help_string(command);
  925. if (text)
  926. clif_displaymessage(fd, text);
  927. return -1;
  928. }
  929. }
  930. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  931. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  932. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2
  933. || job == JOB_STAR_EMPEROR2 || job == JOB_BABY_STAR_EMPEROR2 || job == JOB_SUMMER2)
  934. { // Deny direct transformation into dummy jobs
  935. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  936. return 0;
  937. }
  938. if (pcdb_checkid(job))
  939. {
  940. if (pc_jobchange(sd, job, upper))
  941. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  942. else {
  943. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  944. return -1;
  945. }
  946. } else {
  947. text = atcommand_help_string(command);
  948. if (text)
  949. clif_displaymessage(fd, text);
  950. return -1;
  951. }
  952. return 0;
  953. }
  954. /*==========================================
  955. *
  956. *------------------------------------------*/
  957. ACMD_FUNC(kill)
  958. {
  959. nullpo_retr(-1, sd);
  960. status_kill(&sd->bl);
  961. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  962. if (fd != sd->fd)
  963. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  964. return 0;
  965. }
  966. /*==========================================
  967. *
  968. *------------------------------------------*/
  969. ACMD_FUNC(alive)
  970. {
  971. nullpo_retr(-1, sd);
  972. if (!status_revive(&sd->bl, 100, 100))
  973. {
  974. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  975. return -1;
  976. }
  977. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  978. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  979. return 0;
  980. }
  981. /*==========================================
  982. * +kamic [LuzZza]
  983. *------------------------------------------*/
  984. ACMD_FUNC(kami)
  985. {
  986. unsigned long color=0;
  987. nullpo_retr(-1, sd);
  988. memset(atcmd_output, '\0', sizeof(atcmd_output));
  989. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  990. if (!message || !*message) {
  991. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  992. return -1;
  993. }
  994. sscanf(message, "%255[^\n]", atcmd_output);
  995. if (strstr(command, "l") != NULL)
  996. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  997. else
  998. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  999. } else {
  1000. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  1001. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  1002. return -1;
  1003. }
  1004. if(color > 0xFFFFFF) {
  1005. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  1006. return -1;
  1007. }
  1008. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  1009. }
  1010. return 0;
  1011. }
  1012. /*==========================================
  1013. *
  1014. *------------------------------------------*/
  1015. ACMD_FUNC(heal)
  1016. {
  1017. int hp = 0, sp = 0; // [Valaris] thanks to fov
  1018. nullpo_retr(-1, sd);
  1019. sscanf(message, "%11d %11d", &hp, &sp);
  1020. // some overflow checks
  1021. if( hp == INT_MIN ) hp++;
  1022. if( sp == INT_MIN ) sp++;
  1023. if ( hp == 0 && sp == 0 ) {
  1024. if (!status_percent_heal(&sd->bl, 100, 100))
  1025. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1026. else
  1027. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1028. return 0;
  1029. }
  1030. if ( hp > 0 && sp >= 0 ) {
  1031. if(!status_heal(&sd->bl, hp, sp, 0))
  1032. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1033. else
  1034. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1035. return 0;
  1036. }
  1037. if ( hp < 0 && sp <= 0 ) {
  1038. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1039. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1040. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1041. return 0;
  1042. }
  1043. //Opposing signs.
  1044. if ( hp ) {
  1045. if (hp > 0)
  1046. status_heal(&sd->bl, hp, 0, 0);
  1047. else {
  1048. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1049. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1050. }
  1051. }
  1052. if ( sp ) {
  1053. if (sp > 0)
  1054. status_heal(&sd->bl, 0, sp, 0);
  1055. else
  1056. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1057. }
  1058. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1059. return 0;
  1060. }
  1061. /*==========================================
  1062. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1063. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1064. *------------------------------------------*/
  1065. ACMD_FUNC(item)
  1066. {
  1067. char item_name[100];
  1068. int number = 0, bound = BOUND_NONE;
  1069. char flag = 0;
  1070. struct item item_tmp;
  1071. struct item_data *item_data[10];
  1072. int get_count, i, j=0;
  1073. char *itemlist;
  1074. nullpo_retr(-1, sd);
  1075. memset(item_name, '\0', sizeof(item_name));
  1076. parent_cmd = atcommand_checkalias(command+1);
  1077. if (!strcmpi(parent_cmd,"itembound")) {
  1078. if (!message || !*message || (
  1079. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1080. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1081. {
  1082. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1083. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1084. return -1;
  1085. }
  1086. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1087. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1088. return -1;
  1089. }
  1090. } else if (!message || !*message || (
  1091. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1092. sscanf(message, "%99s %11d", item_name, &number) < 1
  1093. )) {
  1094. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1095. return -1;
  1096. }
  1097. itemlist = strtok(item_name, ":");
  1098. while (itemlist != NULL && j<10) {
  1099. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1100. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1101. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1102. return -1;
  1103. }
  1104. itemlist = strtok(NULL, ":"); //next itemline
  1105. j++;
  1106. }
  1107. if (number <= 0)
  1108. number = 1;
  1109. get_count = number;
  1110. for(j--; j>=0; j--){ //produce items in list
  1111. unsigned short item_id = item_data[j]->nameid;
  1112. //Check if it's stackable.
  1113. if (!itemdb_isstackable2(item_data[j]))
  1114. get_count = 1;
  1115. for (i = 0; i < number; i += get_count) {
  1116. // if not pet egg
  1117. if (!pet_create_egg(sd, item_id)) {
  1118. memset(&item_tmp, 0, sizeof(item_tmp));
  1119. item_tmp.nameid = item_id;
  1120. item_tmp.identify = 1;
  1121. item_tmp.bound = bound;
  1122. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1123. clif_additem(sd, 0, 0, flag);
  1124. }
  1125. }
  1126. }
  1127. if (flag == 0)
  1128. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1129. return 0;
  1130. }
  1131. /*==========================================
  1132. *
  1133. *------------------------------------------*/
  1134. ACMD_FUNC(item2)
  1135. {
  1136. struct item item_tmp;
  1137. struct item_data *item_data;
  1138. char item_name[100];
  1139. unsigned short item_id;
  1140. int number = 0, bound = BOUND_NONE;
  1141. int identify = 0, refine = 0, attr = 0;
  1142. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1143. nullpo_retr(-1, sd);
  1144. memset(item_name, '\0', sizeof(item_name));
  1145. parent_cmd = atcommand_checkalias(command+1);
  1146. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1147. if (!message || !*message || (
  1148. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1149. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1150. {
  1151. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1152. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1153. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1154. return -1;
  1155. }
  1156. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1157. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1158. return -1;
  1159. }
  1160. } else if ( !message || !*message || (
  1161. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1162. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1163. )) {
  1164. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1165. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1166. return -1;
  1167. }
  1168. if (number <= 0)
  1169. number = 1;
  1170. item_id = 0;
  1171. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1172. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1173. item_id = item_data->nameid;
  1174. if (item_id > 500) {
  1175. int loop, get_count, i;
  1176. char flag = 0;
  1177. //Check if it's stackable.
  1178. if(!itemdb_isstackable2(item_data)){
  1179. loop = number;
  1180. get_count = 1;
  1181. }else{
  1182. loop = 1;
  1183. get_count = number;
  1184. }
  1185. if( itemdb_isequip2(item_data ) ){
  1186. refine = cap_value( refine, 0, MAX_REFINE );
  1187. }else{
  1188. // All other items cannot be refined and are always identified
  1189. identify = 1;
  1190. refine = attr = 0;
  1191. }
  1192. for (i = 0; i < loop; i++) {
  1193. // if not pet egg
  1194. if (!pet_create_egg(sd, item_id)) {
  1195. memset(&item_tmp, 0, sizeof(item_tmp));
  1196. item_tmp.nameid = item_id;
  1197. item_tmp.identify = identify;
  1198. item_tmp.refine = refine;
  1199. item_tmp.attribute = attr;
  1200. item_tmp.card[0] = c1;
  1201. item_tmp.card[1] = c2;
  1202. item_tmp.card[2] = c3;
  1203. item_tmp.card[3] = c4;
  1204. item_tmp.bound = bound;
  1205. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1206. clif_additem(sd, 0, 0, flag);
  1207. }
  1208. }
  1209. if (flag == 0)
  1210. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1211. } else {
  1212. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1213. return -1;
  1214. }
  1215. return 0;
  1216. }
  1217. /*==========================================
  1218. *
  1219. *------------------------------------------*/
  1220. ACMD_FUNC(itemreset)
  1221. {
  1222. int i;
  1223. nullpo_retr(-1, sd);
  1224. for (i = 0; i < MAX_INVENTORY; i++) {
  1225. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0) {
  1226. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1227. }
  1228. }
  1229. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1230. return 0;
  1231. }
  1232. /*==========================================
  1233. * Atcommand @lvlup
  1234. *------------------------------------------*/
  1235. ACMD_FUNC(baselevelup)
  1236. {
  1237. int level=0, i=0, status_point=0;
  1238. nullpo_retr(-1, sd);
  1239. level = atoi(message);
  1240. if (!message || !*message || !level) {
  1241. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1242. return -1;
  1243. }
  1244. if (level > 0) {
  1245. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1246. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1247. return -1;
  1248. } // End Addition
  1249. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1250. level = pc_maxbaselv(sd) - sd->status.base_level;
  1251. for (i = 0; i < level; i++)
  1252. status_point += pc_gets_status_point(sd->status.base_level + i);
  1253. sd->status.status_point += status_point;
  1254. sd->status.base_level += (unsigned int)level;
  1255. status_calc_pc(sd, SCO_FORCE);
  1256. status_percent_heal(&sd->bl, 100, 100);
  1257. clif_misceffect(&sd->bl, 0);
  1258. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level);
  1259. achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_);
  1260. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1261. } else {
  1262. if (sd->status.base_level == 1) {
  1263. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1264. return -1;
  1265. }
  1266. level*=-1;
  1267. if ((unsigned int)level >= sd->status.base_level)
  1268. level = sd->status.base_level-1;
  1269. for (i = 0; i > -level; i--)
  1270. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1271. if (sd->status.status_point < status_point)
  1272. pc_resetstate(sd);
  1273. if (sd->status.status_point < status_point)
  1274. sd->status.status_point = 0;
  1275. else
  1276. sd->status.status_point -= status_point;
  1277. sd->status.base_level -= (unsigned int)level;
  1278. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1279. status_calc_pc(sd, SCO_FORCE);
  1280. level*=-1;
  1281. }
  1282. sd->status.base_exp = 0;
  1283. clif_updatestatus(sd, SP_STATUSPOINT);
  1284. clif_updatestatus(sd, SP_BASELEVEL);
  1285. clif_updatestatus(sd, SP_BASEEXP);
  1286. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1287. pc_baselevelchanged(sd);
  1288. if(sd->status.party_id)
  1289. party_send_levelup(sd);
  1290. if( level > 0 && battle_config.atcommand_levelup_events )
  1291. npc_script_event(sd,NPCE_BASELVUP);
  1292. return 0;
  1293. }
  1294. /*==========================================
  1295. *
  1296. *------------------------------------------*/
  1297. ACMD_FUNC(joblevelup)
  1298. {
  1299. int level=0;
  1300. nullpo_retr(-1, sd);
  1301. level = atoi(message);
  1302. if (!message || !*message || !level) {
  1303. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1304. return -1;
  1305. }
  1306. if (level > 0) {
  1307. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1308. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1309. return -1;
  1310. }
  1311. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1312. level = pc_maxjoblv(sd) - sd->status.job_level;
  1313. sd->status.job_level += (unsigned int)level;
  1314. sd->status.skill_point += level;
  1315. clif_misceffect(&sd->bl, 1);
  1316. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level);
  1317. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1318. } else {
  1319. if (sd->status.job_level == 1) {
  1320. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1321. return -1;
  1322. }
  1323. level *=-1;
  1324. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1325. level = sd->status.job_level-1;
  1326. sd->status.job_level -= (unsigned int)level;
  1327. if (sd->status.skill_point < level)
  1328. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1329. if (sd->status.skill_point < level)
  1330. sd->status.skill_point = 0;
  1331. else
  1332. sd->status.skill_point -= level;
  1333. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1334. level *=-1;
  1335. }
  1336. sd->status.job_exp = 0;
  1337. clif_updatestatus(sd, SP_JOBLEVEL);
  1338. clif_updatestatus(sd, SP_JOBEXP);
  1339. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1340. clif_updatestatus(sd, SP_SKILLPOINT);
  1341. status_calc_pc(sd, SCO_FORCE);
  1342. if( level > 0 && battle_config.atcommand_levelup_events )
  1343. npc_script_event(sd,NPCE_JOBLVUP);
  1344. return 0;
  1345. }
  1346. /*==========================================
  1347. * @help
  1348. *------------------------------------------*/
  1349. ACMD_FUNC(help)
  1350. {
  1351. config_setting_t *help;
  1352. const char *text = NULL;
  1353. const char *command_name = NULL;
  1354. const char *default_command = "help";
  1355. nullpo_retr(-1, sd);
  1356. help = config_lookup(&atcommand_config, "help");
  1357. if (help == NULL) {
  1358. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1359. return -1;
  1360. }
  1361. if (!message || !*message) {
  1362. command_name = default_command; // If no command_name specified, display help for @help.
  1363. } else {
  1364. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1365. ++message;
  1366. command_name = atcommand_checkalias(message);
  1367. }
  1368. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1369. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1370. clif_displaymessage(fd, atcmd_output);
  1371. atcommand_get_suggestions(sd, command_name, true);
  1372. return -1;
  1373. }
  1374. if (!config_setting_lookup_string(help, command_name, &text)) {
  1375. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1376. clif_displaymessage(fd, atcmd_output);
  1377. atcommand_get_suggestions(sd, command_name, true);
  1378. return -1;
  1379. }
  1380. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1381. clif_displaymessage(fd, atcmd_output);
  1382. { // Display aliases
  1383. DBIterator* iter;
  1384. AtCommandInfo *command_info;
  1385. AliasInfo *alias_info = NULL;
  1386. StringBuf buf;
  1387. bool has_aliases = false;
  1388. StringBuf_Init(&buf);
  1389. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1390. command_info = get_atcommandinfo_byname(command_name);
  1391. iter = db_iterator(atcommand_alias_db);
  1392. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1393. if (alias_info->command == command_info) {
  1394. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1395. has_aliases = true;
  1396. }
  1397. }
  1398. dbi_destroy(iter);
  1399. if (has_aliases)
  1400. clif_displaymessage(fd, StringBuf_Value(&buf));
  1401. StringBuf_Destroy(&buf);
  1402. }
  1403. // Display help contents
  1404. clif_displaymessage(fd, text);
  1405. return 0;
  1406. }
  1407. /*==========================================
  1408. *
  1409. *------------------------------------------*/
  1410. ACMD_FUNC(pvpoff)
  1411. {
  1412. nullpo_retr(-1, sd);
  1413. if (!map_getmapflag(sd->bl.m, MF_PVP)) {
  1414. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1415. return -1;
  1416. }
  1417. map_setmapflag(sd->bl.m, MF_PVP, false);
  1418. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1419. return 0;
  1420. }
  1421. /*==========================================
  1422. *
  1423. *------------------------------------------*/
  1424. ACMD_FUNC(pvpon)
  1425. {
  1426. nullpo_retr(-1, sd);
  1427. if (map_getmapflag(sd->bl.m, MF_PVP)) {
  1428. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1429. return -1;
  1430. }
  1431. map_setmapflag(sd->bl.m, MF_PVP, true);
  1432. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1433. return 0;
  1434. }
  1435. /*==========================================
  1436. *
  1437. *------------------------------------------*/
  1438. ACMD_FUNC(gvgoff)
  1439. {
  1440. nullpo_retr(-1, sd);
  1441. if (!map_getmapflag(sd->bl.m, MF_GVG)) {
  1442. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1443. return -1;
  1444. }
  1445. map_setmapflag(sd->bl.m, MF_GVG, false);
  1446. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1447. return 0;
  1448. }
  1449. /*==========================================
  1450. *
  1451. *------------------------------------------*/
  1452. ACMD_FUNC(gvgon)
  1453. {
  1454. nullpo_retr(-1, sd);
  1455. if (map_getmapflag(sd->bl.m, MF_GVG)) {
  1456. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1457. return -1;
  1458. }
  1459. map_setmapflag(sd->bl.m, MF_GVG, true);
  1460. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1461. return 0;
  1462. }
  1463. /*==========================================
  1464. *
  1465. *------------------------------------------*/
  1466. ACMD_FUNC(model)
  1467. {
  1468. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1469. nullpo_retr(-1, sd);
  1470. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1471. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1472. 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>).
  1473. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1474. clif_displaymessage(fd, atcmd_output);
  1475. return -1;
  1476. }
  1477. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1478. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1479. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1480. pc_changelook(sd, LOOK_HAIR, hair_style);
  1481. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1482. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1483. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1484. } else {
  1485. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1486. return -1;
  1487. }
  1488. return 0;
  1489. }
  1490. /*==========================================
  1491. * @bodystyle [Rytech]
  1492. *------------------------------------------*/
  1493. ACMD_FUNC(bodystyle)
  1494. {
  1495. int body_style = 0;
  1496. nullpo_retr(-1, sd);
  1497. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1498. if (!(sd->class_&JOBL_THIRD)) {
  1499. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1500. return -1;
  1501. }
  1502. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1503. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1504. clif_displaymessage(fd, atcmd_output);
  1505. return -1;
  1506. }
  1507. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1508. pc_changelook(sd, LOOK_BODY2, body_style);
  1509. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1510. } else {
  1511. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1512. return -1;
  1513. }
  1514. return 0;
  1515. }
  1516. /*==========================================
  1517. * @dye && @ccolor
  1518. *------------------------------------------*/
  1519. ACMD_FUNC(dye)
  1520. {
  1521. int cloth_color = 0;
  1522. nullpo_retr(-1, sd);
  1523. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1524. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1525. 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>).
  1526. clif_displaymessage(fd, atcmd_output);
  1527. return -1;
  1528. }
  1529. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1530. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1531. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1532. } else {
  1533. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1534. return -1;
  1535. }
  1536. return 0;
  1537. }
  1538. /*==========================================
  1539. * @hairstyle && @hstyle
  1540. *------------------------------------------*/
  1541. ACMD_FUNC(hair_style)
  1542. {
  1543. int hair_style = 0;
  1544. nullpo_retr(-1, sd);
  1545. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1546. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1547. 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>).
  1548. clif_displaymessage(fd, atcmd_output);
  1549. return -1;
  1550. }
  1551. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1552. pc_changelook(sd, LOOK_HAIR, hair_style);
  1553. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1554. } else {
  1555. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1556. return -1;
  1557. }
  1558. return 0;
  1559. }
  1560. /*==========================================
  1561. * @haircolor && @hcolor
  1562. *------------------------------------------*/
  1563. ACMD_FUNC(hair_color)
  1564. {
  1565. int hair_color = 0;
  1566. nullpo_retr(-1, sd);
  1567. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1568. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1569. 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>).
  1570. clif_displaymessage(fd, atcmd_output);
  1571. return -1;
  1572. }
  1573. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1574. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1575. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1576. } else {
  1577. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1578. return -1;
  1579. }
  1580. return 0;
  1581. }
  1582. /*==========================================
  1583. * @go [city_number or city_name] - Updated by Harbin
  1584. *------------------------------------------*/
  1585. ACMD_FUNC(go)
  1586. {
  1587. int i;
  1588. int town;
  1589. char map_name[MAP_NAME_LENGTH];
  1590. const struct {
  1591. char map[MAP_NAME_LENGTH];
  1592. int x, y;
  1593. } data[] = {
  1594. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1595. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1596. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1597. { MAP_PAYON, 162, 233 }, // 3=Payon
  1598. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1599. #ifdef RENEWAL
  1600. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1601. #else
  1602. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1603. #endif
  1604. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1605. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1606. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1607. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1608. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1609. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1610. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1611. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1612. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1613. #ifdef RENEWAL
  1614. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1615. #else
  1616. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1617. #endif
  1618. { MAP_JAIL, 23, 61 }, // 16=Prison
  1619. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1620. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1621. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1622. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1623. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1624. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1625. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1626. { MAP_VEINS, 216, 123 }, // 24=Veins
  1627. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1628. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1629. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1630. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1631. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1632. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1633. { MAP_MORA, 44, 151 }, // 31=Mora
  1634. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1635. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1636. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1637. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1638. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1639. };
  1640. nullpo_retr(-1, sd);
  1641. if( map_getmapflag(sd->bl.m, MF_NOGO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1642. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1643. return 0;
  1644. }
  1645. memset(map_name, '\0', sizeof(map_name));
  1646. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1647. // get the number
  1648. town = atoi(message);
  1649. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1650. {// no value matched so send the list of locations
  1651. const char* text;
  1652. // attempt to find the text help string
  1653. text = atcommand_help_string( command );
  1654. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1655. if( text )
  1656. {// send the text to the client
  1657. clif_displaymessage( fd, text );
  1658. }
  1659. return -1;
  1660. }
  1661. // get possible name of the city
  1662. map_name[MAP_NAME_LENGTH-1] = '\0';
  1663. for (i = 0; map_name[i]; i++)
  1664. map_name[i] = TOLOWER(map_name[i]);
  1665. // try to identify the map name
  1666. if (strncmp(map_name, "prontera", 3) == 0) {
  1667. town = 0;
  1668. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1669. strncmp(map_name, "morroc", 4) == 0) {
  1670. town = 1;
  1671. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1672. town = 2;
  1673. } else if (strncmp(map_name, "payon", 3) == 0) {
  1674. town = 3;
  1675. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1676. town = 4;
  1677. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1678. town = 5;
  1679. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1680. town = 6;
  1681. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1682. strcmp(map_name, "christmas") == 0 ||
  1683. strncmp(map_name, "xmas", 3) == 0 ||
  1684. strncmp(map_name, "x-mas", 3) == 0) {
  1685. town = 7;
  1686. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1687. town = 8;
  1688. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1689. strncmp(map_name, "yuno", 3) == 0) {
  1690. town = 9;
  1691. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1692. town = 10;
  1693. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1694. strncmp(map_name, "gonryun", 3) == 0) {
  1695. town = 11;
  1696. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1697. town = 12;
  1698. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1699. town = 13;
  1700. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1701. town = 14;
  1702. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1703. strncmp(map_name, "startpoint", 3) == 0 ||
  1704. strncmp(map_name, "beginning", 3) == 0) {
  1705. town = 15;
  1706. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1707. strncmp(map_name, "prison", 3) == 0 ||
  1708. strncmp(map_name, "jail", 3) == 0) {
  1709. town = 16;
  1710. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1711. town = 17;
  1712. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1713. town = 18;
  1714. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1715. town = 19;
  1716. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1717. town = 20;
  1718. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1719. town = 21;
  1720. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1721. town = 22;
  1722. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1723. town = 23;
  1724. } else if (strncmp(map_name, "veins", 3) == 0) {
  1725. town = 24;
  1726. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1727. town = 25;
  1728. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1729. town = 26;
  1730. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1731. town = 27;
  1732. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1733. town = 28;
  1734. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1735. town = 29;
  1736. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1737. town = 30;
  1738. } else if (strcmp(map_name, "mora") == 0) {
  1739. town = 31;
  1740. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1741. town = 32;
  1742. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1743. town = 33;
  1744. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1745. town = 34;
  1746. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1747. town = 35;
  1748. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1749. town = 36;
  1750. }
  1751. if (town >= 0 && town < ARRAYLENGTH(data))
  1752. {
  1753. int16 m = map_mapname2mapid(data[town].map);
  1754. if (m >= 0 && map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1755. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1756. return -1;
  1757. }
  1758. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1759. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1760. return -1;
  1761. }
  1762. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1763. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1764. } else {
  1765. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1766. return -1;
  1767. }
  1768. } else { // if you arrive here, you have an error in town variable when reading of names
  1769. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1770. return -1;
  1771. }
  1772. return 0;
  1773. }
  1774. /*==========================================
  1775. *
  1776. *------------------------------------------*/
  1777. ACMD_FUNC(monster)
  1778. {
  1779. char name[NAME_LENGTH];
  1780. char monster[NAME_LENGTH];
  1781. char eventname[EVENT_NAME_LENGTH] = "";
  1782. int mob_id;
  1783. int number = 0;
  1784. int count;
  1785. int i, range;
  1786. short mx, my;
  1787. unsigned int size;
  1788. nullpo_retr(-1, sd);
  1789. memset(name, '\0', sizeof(name));
  1790. memset(monster, '\0', sizeof(monster));
  1791. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1792. if (!message || !*message) {
  1793. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1794. return -1;
  1795. }
  1796. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1797. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1798. //All data can be left as it is.
  1799. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1800. //Here, it is possible name was not given and we are using monster for it.
  1801. if (count < 3) //Blank mob's name.
  1802. name[0] = '\0';
  1803. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1804. //All data can be left as it is.
  1805. } else if (sscanf(message, "%23s", monster) > 0) {
  1806. //As before, name may be already filled.
  1807. name[0] = '\0';
  1808. } else {
  1809. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1810. return -1;
  1811. }
  1812. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1813. mob_id = mobdb_checkid(atoi(monster));
  1814. if (mob_id == 0) {
  1815. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1816. return -1;
  1817. }
  1818. if (mob_id == MOBID_EMPERIUM) {
  1819. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1820. return -1;
  1821. }
  1822. if (number <= 0)
  1823. number = 1;
  1824. if( !name[0] )
  1825. strcpy(name, "--ja--");
  1826. // 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
  1827. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1828. number = battle_config.atc_spawn_quantity_limit;
  1829. parent_cmd = atcommand_checkalias(command+1);
  1830. if (strcmp(parent_cmd, "monstersmall") == 0)
  1831. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1832. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1833. size = SZ_BIG;
  1834. else
  1835. size = SZ_SMALL;
  1836. if (battle_config.etc_log)
  1837. 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);
  1838. count = 0;
  1839. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1840. for (i = 0; i < number; i++) {
  1841. int k;
  1842. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1843. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1844. if(k) {
  1845. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1846. count ++;
  1847. }
  1848. }
  1849. if (count != 0)
  1850. if (number == count)
  1851. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1852. else {
  1853. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1854. clif_displaymessage(fd, atcmd_output);
  1855. }
  1856. else {
  1857. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1858. return -1;
  1859. }
  1860. return 0;
  1861. }
  1862. /*==========================================
  1863. *
  1864. *------------------------------------------*/
  1865. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1866. {
  1867. struct mob_data *md;
  1868. int flag;
  1869. nullpo_ret(md=(struct mob_data *)bl);
  1870. flag = va_arg(ap, int);
  1871. if (md->guardian_data)
  1872. return 0; //Do not touch WoE mobs!
  1873. if (flag)
  1874. status_zap(bl,md->status.hp, 0);
  1875. else
  1876. status_kill(bl);
  1877. return 1;
  1878. }
  1879. ACMD_FUNC(killmonster)
  1880. {
  1881. int map_id, drop_flag;
  1882. char map_name[MAP_NAME_LENGTH_EXT];
  1883. nullpo_retr(-1, sd);
  1884. memset(map_name, '\0', sizeof(map_name));
  1885. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1886. map_id = sd->bl.m;
  1887. else {
  1888. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1889. map_id = sd->bl.m;
  1890. }
  1891. parent_cmd = atcommand_checkalias(command+1);
  1892. drop_flag = strcmp(parent_cmd, "killmonster2");
  1893. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1894. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1895. return 0;
  1896. }
  1897. /*==========================================
  1898. *
  1899. *------------------------------------------*/
  1900. ACMD_FUNC(refine)
  1901. {
  1902. int j, position = 0, refine = 0, current_position, final_refine;
  1903. int count;
  1904. nullpo_retr(-1, sd);
  1905. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1906. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1907. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1908. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1909. clif_displaymessage(fd, atcmd_output);
  1910. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1911. clif_displaymessage(fd, atcmd_output);
  1912. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1913. clif_displaymessage(fd, atcmd_output);
  1914. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1915. clif_displaymessage(fd, atcmd_output);
  1916. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1917. clif_displaymessage(fd, atcmd_output);
  1918. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1919. clif_displaymessage(fd, atcmd_output);
  1920. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1921. clif_displaymessage(fd, atcmd_output);
  1922. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1923. clif_displaymessage(fd, atcmd_output);
  1924. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1925. clif_displaymessage(fd, atcmd_output);
  1926. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1927. clif_displaymessage(fd, atcmd_output);
  1928. return -1;
  1929. }
  1930. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1931. count = 0;
  1932. for (j = 0; j < EQI_MAX; j++) {
  1933. int i;
  1934. if ((i = sd->equip_index[j]) < 0)
  1935. continue;
  1936. if(j == EQI_AMMO)
  1937. continue;
  1938. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1939. continue;
  1940. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1941. continue;
  1942. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1943. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1944. sd->inventory.u.items_inventory[i].refine = final_refine;
  1945. current_position = sd->inventory.u.items_inventory[i].equip;
  1946. pc_unequipitem(sd, i, 3);
  1947. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1948. clif_delitem(sd, i, 1, 3);
  1949. clif_additem(sd, i, 1, 0);
  1950. pc_equipitem(sd, i, current_position);
  1951. clif_misceffect(&sd->bl, 3);
  1952. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  1953. count++;
  1954. }
  1955. }
  1956. if (count == 0)
  1957. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1958. else if (count == 1)
  1959. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1960. else {
  1961. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1962. clif_displaymessage(fd, atcmd_output);
  1963. }
  1964. return 0;
  1965. }
  1966. /*==========================================
  1967. *
  1968. *------------------------------------------*/
  1969. ACMD_FUNC(produce)
  1970. {
  1971. char item_name[100];
  1972. unsigned short item_id;
  1973. int attribute = 0, star = 0;
  1974. struct item_data *item_data;
  1975. struct item tmp_item;
  1976. nullpo_retr(-1, sd);
  1977. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1978. memset(item_name, '\0', sizeof(item_name));
  1979. if (!message || !*message || (
  1980. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  1981. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  1982. )) {
  1983. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1984. return -1;
  1985. }
  1986. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1987. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1988. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1989. return -1;
  1990. }
  1991. item_id = item_data->nameid;
  1992. if (itemdb_isequip2(item_data)) {
  1993. char flag = 0;
  1994. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1995. attribute = ATTRIBUTE_NORMAL;
  1996. if (star < MIN_STAR || star > MAX_STAR)
  1997. star = 0;
  1998. memset(&tmp_item, 0, sizeof tmp_item);
  1999. tmp_item.nameid = item_id;
  2000. tmp_item.amount = 1;
  2001. tmp_item.identify = 1;
  2002. tmp_item.card[0] = CARD0_FORGE;
  2003. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2004. ((star*5) << 8) + attribute:0;
  2005. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2006. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2007. clif_produceeffect(sd, 0, item_id);
  2008. clif_misceffect(&sd->bl, 3);
  2009. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2010. clif_additem(sd, 0, 0, flag);
  2011. } else {
  2012. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2013. clif_displaymessage(fd, atcmd_output);
  2014. return -1;
  2015. }
  2016. return 0;
  2017. }
  2018. /*==========================================
  2019. *
  2020. *------------------------------------------*/
  2021. ACMD_FUNC(memo)
  2022. {
  2023. int position = 0;
  2024. nullpo_retr(-1, sd);
  2025. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2026. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2027. {
  2028. int i;
  2029. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2030. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2031. {
  2032. if( sd->status.memo_point[i].map )
  2033. sprintf(atcmd_output, "%d - %s (%d,%d)", i, mapindex_id2name(sd->status.memo_point[i].map), sd->status.memo_point[i].x, sd->status.memo_point[i].y);
  2034. else
  2035. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2036. clif_displaymessage(sd->fd, atcmd_output);
  2037. }
  2038. return 0;
  2039. }
  2040. if( position < 0 || position >= MAX_MEMOPOINTS )
  2041. {
  2042. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2043. clif_displaymessage(fd, atcmd_output);
  2044. return -1;
  2045. }
  2046. return !pc_memo( sd, position );
  2047. }
  2048. /*==========================================
  2049. *
  2050. *------------------------------------------*/
  2051. ACMD_FUNC(gat)
  2052. {
  2053. int y;
  2054. nullpo_retr(-1, sd);
  2055. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2056. for (y = 2; y >= -2; y--) {
  2057. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2058. map_getmapdata(sd->bl.m)->name, sd->bl.x - 2, sd->bl.y + y,
  2059. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2060. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2061. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2062. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2063. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2064. clif_displaymessage(fd, atcmd_output);
  2065. }
  2066. return 0;
  2067. }
  2068. /*==========================================
  2069. *
  2070. *------------------------------------------*/
  2071. ACMD_FUNC(displaystatus)
  2072. {
  2073. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2074. nullpo_retr(-1, sd);
  2075. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2076. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2077. return -1;
  2078. }
  2079. if (i < 2) flag = 1;
  2080. if (i < 3) tick = 0;
  2081. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2082. return 0;
  2083. }
  2084. /*==========================================
  2085. * @stpoint (Rewritten by [Yor])
  2086. *------------------------------------------*/
  2087. ACMD_FUNC(statuspoint)
  2088. {
  2089. int point;
  2090. unsigned int new_status_point;
  2091. if (!message || !*message || (point = atoi(message)) == 0) {
  2092. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2093. return -1;
  2094. }
  2095. if(point < 0)
  2096. {
  2097. if(sd->status.status_point < (unsigned int)(-point))
  2098. {
  2099. new_status_point = 0;
  2100. }
  2101. else
  2102. {
  2103. new_status_point = sd->status.status_point + point;
  2104. }
  2105. }
  2106. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2107. {
  2108. new_status_point = UINT_MAX;
  2109. }
  2110. else
  2111. {
  2112. new_status_point = sd->status.status_point + point;
  2113. }
  2114. if (new_status_point != sd->status.status_point) {
  2115. sd->status.status_point = new_status_point;
  2116. clif_updatestatus(sd, SP_STATUSPOINT);
  2117. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2118. } else {
  2119. if (point < 0)
  2120. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2121. else
  2122. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2123. return -1;
  2124. }
  2125. return 0;
  2126. }
  2127. /*==========================================
  2128. * @skpoint (Rewritten by [Yor])
  2129. *------------------------------------------*/
  2130. ACMD_FUNC(skillpoint)
  2131. {
  2132. int point;
  2133. unsigned int new_skill_point;
  2134. nullpo_retr(-1, sd);
  2135. if (!message || !*message || (point = atoi(message)) == 0) {
  2136. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2137. return -1;
  2138. }
  2139. if(point < 0)
  2140. {
  2141. if(sd->status.skill_point < (unsigned int)(-point))
  2142. {
  2143. new_skill_point = 0;
  2144. }
  2145. else
  2146. {
  2147. new_skill_point = sd->status.skill_point + point;
  2148. }
  2149. }
  2150. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2151. {
  2152. new_skill_point = UINT_MAX;
  2153. }
  2154. else
  2155. {
  2156. new_skill_point = sd->status.skill_point + point;
  2157. }
  2158. if (new_skill_point != sd->status.skill_point) {
  2159. sd->status.skill_point = new_skill_point;
  2160. clif_updatestatus(sd, SP_SKILLPOINT);
  2161. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2162. } else {
  2163. if (point < 0)
  2164. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2165. else
  2166. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2167. return -1;
  2168. }
  2169. return 0;
  2170. }
  2171. /*==========================================
  2172. * @zeny
  2173. *------------------------------------------*/
  2174. ACMD_FUNC(zeny)
  2175. {
  2176. int zeny=0, ret=-1;
  2177. nullpo_retr(-1, sd);
  2178. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2179. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2180. return -1;
  2181. }
  2182. if(zeny > 0){
  2183. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2184. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2185. }
  2186. else {
  2187. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2188. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2189. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2190. }
  2191. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2192. return 0;
  2193. }
  2194. /*==========================================
  2195. *
  2196. *------------------------------------------*/
  2197. ACMD_FUNC(param)
  2198. {
  2199. uint8 i;
  2200. int value = 0;
  2201. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2202. unsigned short new_value, *status[6], max_status[6];
  2203. //we don't use direct initialization because it isn't part of the c standard.
  2204. nullpo_retr(-1, sd);
  2205. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2206. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2207. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2208. return -1;
  2209. }
  2210. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2211. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2212. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2213. return -1;
  2214. }
  2215. status[0] = &sd->status.str;
  2216. status[1] = &sd->status.agi;
  2217. status[2] = &sd->status.vit;
  2218. status[3] = &sd->status.int_;
  2219. status[4] = &sd->status.dex;
  2220. status[5] = &sd->status.luk;
  2221. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2222. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2223. else {
  2224. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2225. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2226. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2227. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2228. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2229. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2230. }
  2231. if(value > 0 && *status[i] + value >= max_status[i])
  2232. new_value = max_status[i];
  2233. else if(value < 0 && *status[i] <= -value)
  2234. new_value = 1;
  2235. else
  2236. new_value = *status[i] + value;
  2237. if (new_value != *status[i]) {
  2238. *status[i] = new_value;
  2239. clif_updatestatus(sd, SP_STR + i);
  2240. clif_updatestatus(sd, SP_USTR + i);
  2241. status_calc_pc(sd, SCO_FORCE);
  2242. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2243. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2244. } else {
  2245. if (value < 0)
  2246. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2247. else
  2248. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2249. return -1;
  2250. }
  2251. return 0;
  2252. }
  2253. /*==========================================
  2254. * Stat all by fritz (rewritten by [Yor])
  2255. *------------------------------------------*/
  2256. ACMD_FUNC(stat_all)
  2257. {
  2258. int value = 0;
  2259. uint8 count, i;
  2260. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2261. //we don't use direct initialization because it isn't part of the c standard.
  2262. nullpo_retr(-1, sd);
  2263. status[0] = &sd->status.str;
  2264. status[1] = &sd->status.agi;
  2265. status[2] = &sd->status.vit;
  2266. status[3] = &sd->status.int_;
  2267. status[4] = &sd->status.dex;
  2268. status[5] = &sd->status.luk;
  2269. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2270. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2271. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2272. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2273. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2274. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2275. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2276. value = SHRT_MAX;
  2277. } else {
  2278. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2279. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2280. else {
  2281. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2282. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2283. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2284. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2285. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2286. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2287. }
  2288. }
  2289. count = 0;
  2290. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2291. short new_value;
  2292. if (value > 0 && *status[i] + value >= max_status[i])
  2293. new_value = max_status[i];
  2294. else if (value < 0 && *status[i] <= -value)
  2295. new_value = 1;
  2296. else
  2297. new_value = *status[i] + value;
  2298. if (new_value != *status[i]) {
  2299. *status[i] = new_value;
  2300. clif_updatestatus(sd, SP_STR + i);
  2301. clif_updatestatus(sd, SP_USTR + i);
  2302. count++;
  2303. }
  2304. }
  2305. if (count > 0) { // if at least 1 stat modified
  2306. status_calc_pc(sd, SCO_FORCE);
  2307. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2308. achievement_update_objective(sd, AG_GOAL_STATUS, 0);
  2309. } else {
  2310. if (value < 0)
  2311. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2312. else
  2313. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2314. return -1;
  2315. }
  2316. return 0;
  2317. }
  2318. /*==========================================
  2319. *
  2320. *------------------------------------------*/
  2321. ACMD_FUNC(guildlevelup) {
  2322. int level = 0;
  2323. short added_level;
  2324. struct guild *guild_info;
  2325. nullpo_retr(-1, sd);
  2326. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2327. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2328. return -1;
  2329. }
  2330. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2331. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2332. return -1;
  2333. }
  2334. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2335. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2336. // return -1;
  2337. //}
  2338. added_level = (short)level;
  2339. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2340. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2341. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2342. added_level = 1 - guild_info->guild_lv;
  2343. if (added_level != 0) {
  2344. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2345. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2346. } else {
  2347. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2348. return -1;
  2349. }
  2350. return 0;
  2351. }
  2352. /*==========================================
  2353. *
  2354. *------------------------------------------*/
  2355. ACMD_FUNC(makeegg) {
  2356. struct item_data *item_data;
  2357. int id;
  2358. struct s_pet_db* pet;
  2359. nullpo_retr(-1, sd);
  2360. if (!message || !*message) {
  2361. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2362. return -1;
  2363. }
  2364. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2365. id = item_data->nameid;
  2366. else
  2367. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2368. ;
  2369. else
  2370. id = atoi(message);
  2371. pet = pet_db(id);
  2372. if (!pet)
  2373. pet = pet_db_search(id, PET_EGG);
  2374. if (pet != nullptr) {
  2375. sd->catch_target_class = pet->class_;
  2376. intif_create_pet(sd->status.account_id, sd->status.char_id, pet->class_, mob_db(pet->class_)->lv, pet->EggID, 0, pet->intimate, 100, 0, 1, pet->jname);
  2377. } else {
  2378. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2379. return -1;
  2380. }
  2381. return 0;
  2382. }
  2383. /*==========================================
  2384. *
  2385. *------------------------------------------*/
  2386. ACMD_FUNC(hatch) {
  2387. nullpo_retr(-1, sd);
  2388. if (sd->status.pet_id <= 0)
  2389. clif_sendegg(sd);
  2390. else {
  2391. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2392. return -1;
  2393. }
  2394. return 0;
  2395. }
  2396. /*==========================================
  2397. *
  2398. *------------------------------------------*/
  2399. ACMD_FUNC(petfriendly) {
  2400. int friendly;
  2401. struct pet_data *pd;
  2402. nullpo_retr(-1, sd);
  2403. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2404. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2405. return -1;
  2406. }
  2407. pd = sd->pd;
  2408. if (!pd) {
  2409. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2410. return -1;
  2411. }
  2412. if (friendly < 0 || friendly > 1000)
  2413. {
  2414. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2415. return -1;
  2416. }
  2417. if (friendly == pd->pet.intimate) {
  2418. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2419. return -1;
  2420. }
  2421. pet_set_intimate(pd, friendly);
  2422. clif_send_petstatus(sd);
  2423. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2424. return 0;
  2425. }
  2426. /*==========================================
  2427. *
  2428. *------------------------------------------*/
  2429. ACMD_FUNC(pethungry)
  2430. {
  2431. int hungry;
  2432. struct pet_data *pd;
  2433. nullpo_retr(-1, sd);
  2434. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2435. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2436. return -1;
  2437. }
  2438. pd = sd->pd;
  2439. if (!sd->status.pet_id || !pd) {
  2440. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2441. return -1;
  2442. }
  2443. if (hungry < 0 || hungry > 100) {
  2444. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2445. return -1;
  2446. }
  2447. if (hungry == pd->pet.hungry) {
  2448. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2449. return -1;
  2450. }
  2451. pd->pet.hungry = hungry;
  2452. clif_send_petstatus(sd);
  2453. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2454. return 0;
  2455. }
  2456. /*==========================================
  2457. *
  2458. *------------------------------------------*/
  2459. ACMD_FUNC(petrename)
  2460. {
  2461. struct pet_data *pd;
  2462. nullpo_retr(-1, sd);
  2463. if (!sd->status.pet_id || !sd->pd) {
  2464. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2465. return -1;
  2466. }
  2467. pd = sd->pd;
  2468. if (!pd->pet.rename_flag) {
  2469. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2470. return -1;
  2471. }
  2472. pd->pet.rename_flag = 0;
  2473. intif_save_petdata(sd->status.account_id, &pd->pet);
  2474. clif_send_petstatus(sd);
  2475. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2476. return 0;
  2477. }
  2478. /*==========================================
  2479. *
  2480. *------------------------------------------*/
  2481. ACMD_FUNC(recall) {
  2482. struct map_session_data *pl_sd = NULL;
  2483. nullpo_retr(-1, sd);
  2484. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2485. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2486. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2487. return -1;
  2488. }
  2489. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2490. {
  2491. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2492. return -1;
  2493. }
  2494. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2495. {
  2496. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2497. return -1;
  2498. }
  2499. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2500. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2501. return -1;
  2502. }
  2503. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2504. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2505. return -1;
  2506. }
  2507. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2508. return -1;
  2509. }
  2510. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2511. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2512. return -1;
  2513. }
  2514. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2515. clif_displaymessage(fd, atcmd_output);
  2516. return 0;
  2517. }
  2518. /*==========================================
  2519. * charblock command (usage: charblock <player_name>)
  2520. * This command do a definitiv ban on a player
  2521. *------------------------------------------*/
  2522. ACMD_FUNC(char_block)
  2523. {
  2524. nullpo_retr(-1, sd);
  2525. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2526. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2527. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2528. clif_displaymessage(fd, atcmd_output);
  2529. return -1;
  2530. }
  2531. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2532. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2533. clif_displaymessage(fd, atcmd_output);
  2534. return 0;
  2535. }
  2536. /*==========================================
  2537. * accountban command (usage: ban <%time> <player_name>)
  2538. * charban command (usage: charban <%time> <player_name>)
  2539. * %time see common/timer.cpp::solve_time()
  2540. *------------------------------------------*/
  2541. ACMD_FUNC(char_ban)
  2542. {
  2543. char *modif_p, output[CHAT_SIZE_MAX];
  2544. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2545. enum chrif_req_op bantype;
  2546. nullpo_retr(-1, sd);
  2547. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2548. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2549. parent_cmd = atcommand_checkalias(command+1);
  2550. if (strcmpi(parent_cmd,"charban") == 0)
  2551. bantype = CHRIF_OP_BAN;
  2552. else if (strcmpi(parent_cmd,"ban") == 0)
  2553. bantype = CHRIF_OP_LOGIN_BAN;
  2554. else
  2555. return -1;
  2556. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2557. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2558. clif_displaymessage(fd, output);
  2559. return -1;
  2560. }
  2561. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2562. modif_p = atcmd_output;
  2563. timediff = (int32)solve_time(modif_p); //discard seconds
  2564. if (timediff == 0) { //allow negative ?
  2565. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2566. clif_displaymessage(fd, output);
  2567. 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.
  2568. return -1;
  2569. }
  2570. if( timediff < 0 && (
  2571. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2572. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2573. ))
  2574. {
  2575. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2576. return -1;
  2577. }
  2578. if (bantype == CHRIF_OP_BAN)
  2579. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2580. else
  2581. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2582. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2583. clif_displaymessage(fd, output);
  2584. return 0;
  2585. }
  2586. /*==========================================
  2587. * charunblock command (usage: charunblock <player_name>)
  2588. *------------------------------------------*/
  2589. ACMD_FUNC(char_unblock)
  2590. {
  2591. nullpo_retr(-1, sd);
  2592. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2593. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2594. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2595. clif_displaymessage(fd, atcmd_output);
  2596. return -1;
  2597. }
  2598. // send answer to login server via char-server
  2599. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2600. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2601. clif_displaymessage(fd, atcmd_output);
  2602. return 0;
  2603. }
  2604. /*==========================================
  2605. * acc unban command (usage: unban <player_name>)
  2606. * char unban command (usage: charunban <player_name>)
  2607. *------------------------------------------*/
  2608. ACMD_FUNC(char_unban){
  2609. enum chrif_req_op unbantype;
  2610. nullpo_retr(-1, sd);
  2611. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2612. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2613. parent_cmd = atcommand_checkalias(command+1);
  2614. if (strcmpi(parent_cmd,"charunban") == 0)
  2615. unbantype = CHRIF_OP_UNBAN;
  2616. else if (strcmpi(parent_cmd,"unban") == 0)
  2617. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2618. else
  2619. return -1;
  2620. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2621. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2622. clif_displaymessage(fd, atcmd_output);
  2623. return -1;
  2624. }
  2625. if (unbantype == CHRIF_OP_UNBAN)
  2626. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2627. else
  2628. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2629. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2630. clif_displaymessage(fd, atcmd_output);
  2631. return 0;
  2632. }
  2633. /*==========================================
  2634. *
  2635. *------------------------------------------*/
  2636. ACMD_FUNC(night)
  2637. {
  2638. nullpo_retr(-1, sd);
  2639. if (night_flag != 1) {
  2640. map_night_timer(night_timer_tid, 0, 0, 1);
  2641. } else {
  2642. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2643. return -1;
  2644. }
  2645. return 0;
  2646. }
  2647. /*==========================================
  2648. *
  2649. *------------------------------------------*/
  2650. ACMD_FUNC(day)
  2651. {
  2652. nullpo_retr(-1, sd);
  2653. if (night_flag != 0) {
  2654. map_day_timer(day_timer_tid, 0, 0, 1);
  2655. } else {
  2656. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2657. return -1;
  2658. }
  2659. return 0;
  2660. }
  2661. /*==========================================
  2662. *
  2663. *------------------------------------------*/
  2664. ACMD_FUNC(doom)
  2665. {
  2666. struct map_session_data* pl_sd;
  2667. struct s_mapiterator* iter;
  2668. nullpo_retr(-1, sd);
  2669. iter = mapit_getallusers();
  2670. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2671. {
  2672. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2673. {
  2674. status_kill(&pl_sd->bl);
  2675. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2676. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2677. }
  2678. }
  2679. mapit_free(iter);
  2680. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2681. return 0;
  2682. }
  2683. /*==========================================
  2684. *
  2685. *------------------------------------------*/
  2686. ACMD_FUNC(doommap)
  2687. {
  2688. struct map_session_data* pl_sd;
  2689. struct s_mapiterator* iter;
  2690. nullpo_retr(-1, sd);
  2691. iter = mapit_getallusers();
  2692. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2693. {
  2694. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2695. {
  2696. status_kill(&pl_sd->bl);
  2697. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2698. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2699. }
  2700. }
  2701. mapit_free(iter);
  2702. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2703. return 0;
  2704. }
  2705. /*==========================================
  2706. *
  2707. *------------------------------------------*/
  2708. static void atcommand_raise_sub(struct map_session_data* sd) {
  2709. status_revive(&sd->bl, 100, 100);
  2710. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2711. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2712. }
  2713. /*==========================================
  2714. *
  2715. *------------------------------------------*/
  2716. ACMD_FUNC(raise)
  2717. {
  2718. struct map_session_data* pl_sd;
  2719. struct s_mapiterator* iter;
  2720. nullpo_retr(-1, sd);
  2721. iter = mapit_getallusers();
  2722. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2723. if( pc_isdead(pl_sd) )
  2724. atcommand_raise_sub(pl_sd);
  2725. mapit_free(iter);
  2726. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2727. return 0;
  2728. }
  2729. /*==========================================
  2730. *
  2731. *------------------------------------------*/
  2732. ACMD_FUNC(raisemap)
  2733. {
  2734. struct map_session_data* pl_sd;
  2735. struct s_mapiterator* iter;
  2736. nullpo_retr(-1, sd);
  2737. iter = mapit_getallusers();
  2738. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2739. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2740. atcommand_raise_sub(pl_sd);
  2741. mapit_free(iter);
  2742. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2743. return 0;
  2744. }
  2745. /*==========================================
  2746. *
  2747. *------------------------------------------*/
  2748. ACMD_FUNC(kick)
  2749. {
  2750. struct map_session_data *pl_sd;
  2751. nullpo_retr(-1, sd);
  2752. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2753. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2754. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2755. return -1;
  2756. }
  2757. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2758. {
  2759. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2760. return -1;
  2761. }
  2762. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2763. {
  2764. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2765. return -1;
  2766. }
  2767. clif_GM_kick(sd, pl_sd);
  2768. return 0;
  2769. }
  2770. /*==========================================
  2771. *
  2772. *------------------------------------------*/
  2773. ACMD_FUNC(kickall)
  2774. {
  2775. struct map_session_data* pl_sd;
  2776. struct s_mapiterator* iter;
  2777. nullpo_retr(-1, sd);
  2778. iter = mapit_getallusers();
  2779. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2780. {
  2781. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2782. if (sd->status.account_id != pl_sd->status.account_id)
  2783. clif_GM_kick(NULL, pl_sd);
  2784. }
  2785. }
  2786. mapit_free(iter);
  2787. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2788. return 0;
  2789. }
  2790. /*==========================================
  2791. *
  2792. *------------------------------------------*/
  2793. ACMD_FUNC(allskill)
  2794. {
  2795. nullpo_retr(-1, sd);
  2796. pc_allskillup(sd); // all skills
  2797. sd->status.skill_point = 0; // 0 skill points
  2798. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2799. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2800. return 0;
  2801. }
  2802. /*==========================================
  2803. *
  2804. *------------------------------------------*/
  2805. ACMD_FUNC(questskill)
  2806. {
  2807. uint16 skill_id;
  2808. nullpo_retr(-1, sd);
  2809. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2810. {// also send a list of skills applicable to this command
  2811. const char* text;
  2812. // attempt to find the text corresponding to this command
  2813. text = atcommand_help_string( command );
  2814. // send the error message as always
  2815. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2816. if( text )
  2817. {// send the skill ID list associated with this command
  2818. clif_displaymessage( fd, text );
  2819. }
  2820. return -1;
  2821. }
  2822. if (skill_id >= MAX_SKILL_ID) {
  2823. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2824. return -1;
  2825. }
  2826. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2827. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2828. return -1;
  2829. }
  2830. if (pc_checkskill(sd, skill_id) > 0) {
  2831. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2832. return -1;
  2833. }
  2834. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2835. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2836. return 0;
  2837. }
  2838. /*==========================================
  2839. *
  2840. *------------------------------------------*/
  2841. ACMD_FUNC(lostskill)
  2842. {
  2843. uint16 skill_id = 0, sk_idx = 0;
  2844. nullpo_retr(-1, sd);
  2845. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2846. {// also send a list of skills applicable to this command
  2847. const char* text;
  2848. // attempt to find the text corresponding to this command
  2849. text = atcommand_help_string( command );
  2850. // send the error message as always
  2851. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2852. if( text )
  2853. {// send the skill ID list associated with this command
  2854. clif_displaymessage( fd, text );
  2855. }
  2856. return -1;
  2857. }
  2858. if (!(sk_idx = skill_get_index(skill_id))) {
  2859. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2860. return -1;
  2861. }
  2862. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2863. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2864. return -1;
  2865. }
  2866. if (pc_checkskill(sd, skill_id) == 0) {
  2867. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2868. return -1;
  2869. }
  2870. sd->status.skill[sk_idx].lv = 0;
  2871. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2872. clif_deleteskill(sd,skill_id);
  2873. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2874. return 0;
  2875. }
  2876. /*==========================================
  2877. *
  2878. *------------------------------------------*/
  2879. ACMD_FUNC(spiritball)
  2880. {
  2881. uint32 max_spiritballs;
  2882. int number;
  2883. nullpo_retr(-1, sd);
  2884. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2885. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2886. {
  2887. char msg[CHAT_SIZE_MAX];
  2888. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2889. clif_displaymessage(fd, msg);
  2890. return -1;
  2891. }
  2892. if( sd->spiritball > 0 )
  2893. pc_delspiritball(sd, sd->spiritball, 1);
  2894. sd->spiritball = number;
  2895. clif_spiritball(&sd->bl);
  2896. // no message, player can look the difference
  2897. return 0;
  2898. }
  2899. /*==========================================
  2900. *
  2901. *------------------------------------------*/
  2902. ACMD_FUNC(party)
  2903. {
  2904. char party[NAME_LENGTH];
  2905. nullpo_retr(-1, sd);
  2906. memset(party, '\0', sizeof(party));
  2907. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2908. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2909. return -1;
  2910. }
  2911. party_create(sd, party, 0, 0);
  2912. return 0;
  2913. }
  2914. /*==========================================
  2915. *
  2916. *------------------------------------------*/
  2917. ACMD_FUNC(guild)
  2918. {
  2919. char guild[NAME_LENGTH];
  2920. int prev;
  2921. nullpo_retr(-1, sd);
  2922. memset(guild, '\0', sizeof(guild));
  2923. if (sd->clan) {
  2924. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2925. return -1;
  2926. }
  2927. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2928. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2929. return -1;
  2930. }
  2931. prev = battle_config.guild_emperium_check;
  2932. battle_config.guild_emperium_check = 0;
  2933. guild_create(sd, guild);
  2934. battle_config.guild_emperium_check = prev;
  2935. return 0;
  2936. }
  2937. ACMD_FUNC(breakguild)
  2938. {
  2939. nullpo_retr(-1, sd);
  2940. if (sd->status.guild_id) { // Check if the player has a guild
  2941. struct guild *g;
  2942. g = sd->guild; // Search the guild
  2943. if (g) { // Check if guild was found
  2944. if (sd->state.gmaster_flag) { // Check if player is guild master
  2945. int ret = 0;
  2946. ret = guild_break(sd, g->name); // Break guild
  2947. if (ret) { // Check if anything went wrong
  2948. return 0; // Guild was broken
  2949. } else {
  2950. return -1; // Something went wrong
  2951. }
  2952. } else { // Not guild master
  2953. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2954. return -1;
  2955. }
  2956. } else { // Guild was not found. HOW?
  2957. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2958. return -1;
  2959. }
  2960. } else { // Player does not have a guild
  2961. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2962. return -1;
  2963. }
  2964. }
  2965. /**
  2966. * Start WoE:FE
  2967. */
  2968. ACMD_FUNC(agitstart)
  2969. {
  2970. nullpo_retr(-1, sd);
  2971. if( guild_agit_start() ){
  2972. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2973. return 0;
  2974. }else{
  2975. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2976. return -1;
  2977. }
  2978. }
  2979. /**
  2980. * Start WoE:SE
  2981. */
  2982. ACMD_FUNC(agitstart2)
  2983. {
  2984. nullpo_retr(-1, sd);
  2985. if( guild_agit2_start() ){
  2986. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2987. return 0;
  2988. }else{
  2989. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2990. return -1;
  2991. }
  2992. }
  2993. /**
  2994. * Start WoE:TE
  2995. */
  2996. ACMD_FUNC(agitstart3)
  2997. {
  2998. nullpo_retr(-1, sd);
  2999. if( guild_agit3_start() ){
  3000. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3001. return 0;
  3002. }else{
  3003. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3004. return -1;
  3005. }
  3006. }
  3007. /**
  3008. * End WoE:FE
  3009. */
  3010. ACMD_FUNC(agitend)
  3011. {
  3012. nullpo_retr(-1, sd);
  3013. if( guild_agit_end() ){
  3014. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3015. return 0;
  3016. }else{
  3017. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3018. return -1;
  3019. }
  3020. }
  3021. /**
  3022. * End WoE:SE
  3023. */
  3024. ACMD_FUNC(agitend2)
  3025. {
  3026. nullpo_retr(-1, sd);
  3027. if( guild_agit2_end() ){
  3028. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3029. return 0;
  3030. }else{
  3031. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3032. return -1;
  3033. }
  3034. }
  3035. /**
  3036. * End WoE:TE
  3037. */
  3038. ACMD_FUNC(agitend3)
  3039. {
  3040. nullpo_retr(-1, sd);
  3041. if( guild_agit3_end() ){
  3042. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3043. return 0;
  3044. }else{
  3045. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3046. return -1;
  3047. }
  3048. }
  3049. /*==========================================
  3050. * @mapexit - shuts down the map server
  3051. *------------------------------------------*/
  3052. ACMD_FUNC(mapexit)
  3053. {
  3054. nullpo_retr(-1, sd);
  3055. do_shutdown();
  3056. return 0;
  3057. }
  3058. /*==========================================
  3059. * idsearch <part_of_name>: revrited by [Yor]
  3060. *------------------------------------------*/
  3061. ACMD_FUNC(idsearch)
  3062. {
  3063. char item_name[100];
  3064. unsigned int i, match;
  3065. struct item_data *item_array[MAX_SEARCH];
  3066. nullpo_retr(-1, sd);
  3067. memset(item_name, '\0', sizeof(item_name));
  3068. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3069. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3070. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3071. return -1;
  3072. }
  3073. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3074. clif_displaymessage(fd, atcmd_output);
  3075. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3076. if (match == MAX_SEARCH) {
  3077. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3078. clif_displaymessage(fd, atcmd_output);
  3079. }
  3080. for(i = 0; i < match; i++) {
  3081. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3082. clif_displaymessage(fd, atcmd_output);
  3083. }
  3084. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3085. clif_displaymessage(fd, atcmd_output);
  3086. return 0;
  3087. }
  3088. /*==========================================
  3089. * Recall All Characters Online To Your Location
  3090. *------------------------------------------*/
  3091. ACMD_FUNC(recallall)
  3092. {
  3093. struct map_session_data* pl_sd;
  3094. struct s_mapiterator* iter;
  3095. int count;
  3096. nullpo_retr(-1, sd);
  3097. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3098. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3099. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3100. return -1;
  3101. }
  3102. count = 0;
  3103. iter = mapit_getallusers();
  3104. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3105. {
  3106. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3107. {
  3108. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3109. continue; // Don't waste time warping the character to the same place.
  3110. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3111. count++;
  3112. else {
  3113. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3114. count++;
  3115. }
  3116. }
  3117. }
  3118. }
  3119. mapit_free(iter);
  3120. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3121. if (count) {
  3122. 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.
  3123. clif_displaymessage(fd, atcmd_output);
  3124. }
  3125. return 0;
  3126. }
  3127. /*==========================================
  3128. * Recall online characters of a guild to your location
  3129. *------------------------------------------*/
  3130. ACMD_FUNC(guildrecall)
  3131. {
  3132. struct map_session_data* pl_sd;
  3133. struct s_mapiterator* iter;
  3134. int count;
  3135. char guild_name[NAME_LENGTH];
  3136. struct guild *g;
  3137. nullpo_retr(-1, sd);
  3138. memset(guild_name, '\0', sizeof(guild_name));
  3139. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3140. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3141. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3142. return -1;
  3143. }
  3144. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3145. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3146. return -1;
  3147. }
  3148. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3149. (g = guild_search(atoi(message))) == NULL)
  3150. {
  3151. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3152. return -1;
  3153. }
  3154. count = 0;
  3155. iter = mapit_getallusers();
  3156. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3157. {
  3158. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3159. {
  3160. 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))
  3161. continue; // Skip GMs greater than you... or chars already on the cell
  3162. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3163. count++;
  3164. else{
  3165. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3166. count++;
  3167. }
  3168. }
  3169. }
  3170. }
  3171. mapit_free(iter);
  3172. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3173. clif_displaymessage(fd, atcmd_output);
  3174. if (count) {
  3175. 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.
  3176. clif_displaymessage(fd, atcmd_output);
  3177. }
  3178. return 0;
  3179. }
  3180. /*==========================================
  3181. * Recall online characters of a party to your location
  3182. *------------------------------------------*/
  3183. ACMD_FUNC(partyrecall)
  3184. {
  3185. struct map_session_data* pl_sd;
  3186. struct s_mapiterator* iter;
  3187. char party_name[NAME_LENGTH];
  3188. struct party_data *p;
  3189. int count;
  3190. nullpo_retr(-1, sd);
  3191. memset(party_name, '\0', sizeof(party_name));
  3192. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3193. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3194. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3195. return -1;
  3196. }
  3197. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3198. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3199. return -1;
  3200. }
  3201. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3202. (p = party_search(atoi(message))) == NULL)
  3203. {
  3204. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3205. return -1;
  3206. }
  3207. count = 0;
  3208. iter = mapit_getallusers();
  3209. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3210. {
  3211. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3212. {
  3213. 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))
  3214. continue; // Skip GMs greater than you... or chars already on the cell
  3215. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3216. count++;
  3217. else{
  3218. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3219. count++;
  3220. }
  3221. }
  3222. }
  3223. }
  3224. mapit_free(iter);
  3225. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3226. clif_displaymessage(fd, atcmd_output);
  3227. if (count) {
  3228. 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.
  3229. clif_displaymessage(fd, atcmd_output);
  3230. }
  3231. return 0;
  3232. }
  3233. /*==========================================
  3234. *
  3235. *------------------------------------------*/
  3236. void atcommand_doload();
  3237. ACMD_FUNC(reload) {
  3238. nullpo_retr(-1, sd);
  3239. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3240. const char* text;
  3241. text = atcommand_help_string( command );
  3242. if(text)
  3243. clif_displaymessage( fd, text );
  3244. return -1;
  3245. }
  3246. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3247. itemdb_reload();
  3248. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3249. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3250. mob_reload();
  3251. read_petdb();
  3252. hom_reload();
  3253. mercenary_readdb();
  3254. mercenary_read_skilldb();
  3255. reload_elementaldb();
  3256. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3257. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3258. skill_reload();
  3259. hom_reload_skill();
  3260. reload_elemental_skilldb();
  3261. mercenary_read_skilldb();
  3262. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3263. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3264. config_t run_test;
  3265. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3266. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3267. return -1;
  3268. }
  3269. config_destroy(&run_test);
  3270. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3271. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3272. return -1;
  3273. }
  3274. config_destroy(&run_test);
  3275. atcommand_doload();
  3276. pc_groups_reload();
  3277. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3278. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3279. struct Battle_Config prev_config;
  3280. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3281. battle_config_read(BATTLE_CONF_FILENAME);
  3282. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3283. || prev_config.item_rate_common != battle_config.item_rate_common
  3284. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3285. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3286. || prev_config.item_rate_card != battle_config.item_rate_card
  3287. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3288. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3289. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3290. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3291. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3292. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3293. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3294. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3295. || prev_config.item_rate_use != battle_config.item_rate_use
  3296. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3297. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3298. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3299. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3300. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3301. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3302. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3303. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3304. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3305. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3306. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3307. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3308. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3309. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3310. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3311. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3312. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3313. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3314. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3315. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3316. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3317. )
  3318. { // Exp or Drop rates changed.
  3319. mob_reload(); //Needed as well so rate changes take effect.
  3320. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3321. }
  3322. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3323. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3324. status_readdb();
  3325. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3326. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3327. pc_readdb();
  3328. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3329. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3330. pc_read_motd();
  3331. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3332. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3333. struct s_mapiterator* iter;
  3334. struct map_session_data* pl_sd;
  3335. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3336. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3337. iter = mapit_getallusers();
  3338. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
  3339. pc_close_npc(pl_sd,1);
  3340. clif_cutin(pl_sd, "", 255);
  3341. }
  3342. mapit_free(iter);
  3343. flush_fifos();
  3344. map_reloadnpc(true); // reload config files seeking for npcs
  3345. script_reload();
  3346. npc_reload();
  3347. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3348. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3349. map_msg_reload();
  3350. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3351. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3352. do_reload_quest();
  3353. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3354. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3355. instance_reload();
  3356. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3357. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3358. achievement_db_reload();
  3359. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3360. }
  3361. return 0;
  3362. }
  3363. /*==========================================
  3364. * @partysharelvl <share_range> [Akinari]
  3365. * Updates char server party share level range in runtime
  3366. * Temporary - Permanent update in inter_athena.conf
  3367. *------------------------------------------*/
  3368. ACMD_FUNC(partysharelvl) {
  3369. unsigned int share_lvl;
  3370. nullpo_retr(-1, sd);
  3371. if(!message || !*message) {
  3372. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3373. return -1;
  3374. } else {
  3375. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3376. }
  3377. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3378. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3379. else //Char server offline
  3380. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3381. return 0;
  3382. }
  3383. /*==========================================
  3384. * @mapinfo [0-3] <map name> by MC_Cameri
  3385. * => Shows information about the map [map name]
  3386. * 0 = no additional information
  3387. * 1 = Show users in that map and their location
  3388. * 2 = Shows NPCs in that map
  3389. * 3 = Shows the chats in that map
  3390. *------------------------------------------*/
  3391. ACMD_FUNC(mapinfo) {
  3392. struct map_session_data* pl_sd;
  3393. struct s_mapiterator* iter;
  3394. struct chat_data *cd = NULL;
  3395. char direction[12];
  3396. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3397. unsigned short m_index;
  3398. char mapname[MAP_NAME_LENGTH];
  3399. nullpo_retr(-1, sd);
  3400. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3401. memset(mapname, '\0', sizeof(mapname));
  3402. memset(direction, '\0', sizeof(direction));
  3403. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3404. if (list < 0 || list > 3) {
  3405. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3406. return -1;
  3407. }
  3408. if (mapname[0] == '\0') {
  3409. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3410. m_id = map_mapindex2mapid(sd->mapindex);
  3411. } else {
  3412. m_id = map_mapname2mapid(mapname);
  3413. }
  3414. if (m_id < 0) {
  3415. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3416. return -1;
  3417. }
  3418. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3419. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3420. // count chats (for initial message)
  3421. chat_num = 0;
  3422. iter = mapit_getallusers();
  3423. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3424. if( pl_sd->mapindex == m_index ) {
  3425. if( pl_sd->state.vending )
  3426. vend_num++;
  3427. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3428. chat_num++;
  3429. }
  3430. }
  3431. mapit_free(iter);
  3432. struct map_data *mapdata = map_getmapdata(m_id);
  3433. 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
  3434. clif_displaymessage(fd, atcmd_output);
  3435. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3436. if (map_getmapflag(m_id, MF_TOWN))
  3437. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3438. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3439. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3440. clif_displaymessage(fd, atcmd_output);
  3441. }
  3442. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3443. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3444. else
  3445. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3446. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3447. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3448. clif_displaymessage(fd, atcmd_output);
  3449. }
  3450. /* Skill damage adjustment info [Cydh] */
  3451. if (mapdata->flag[MF_SKILL_DAMAGE]) {
  3452. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3453. sprintf(atcmd_output, msg_txt(sd, 1053), // > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d
  3454. mapdata->damage_adjust.rate[SKILLDMG_PC],
  3455. mapdata->damage_adjust.rate[SKILLDMG_MOB],
  3456. mapdata->damage_adjust.rate[SKILLDMG_BOSS],
  3457. mapdata->damage_adjust.rate[SKILLDMG_OTHER],
  3458. mapdata->damage_adjust.caster);
  3459. clif_displaymessage(fd, atcmd_output);
  3460. if (!mapdata->skill_damage.empty()) {
  3461. clif_displaymessage(fd, msg_txt(sd, 1054)); // > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster
  3462. for (auto skilldmg : mapdata->skill_damage) {
  3463. sprintf(atcmd_output," %s : %d%%, %d%%, %d%%, %d%% | %d",
  3464. skill_get_name(skilldmg.first),
  3465. skilldmg.second.rate[SKILLDMG_PC],
  3466. skilldmg.second.rate[SKILLDMG_MOB],
  3467. skilldmg.second.rate[SKILLDMG_BOSS],
  3468. skilldmg.second.rate[SKILLDMG_OTHER],
  3469. skilldmg.second.caster);
  3470. clif_displaymessage(fd,atcmd_output);
  3471. }
  3472. }
  3473. }
  3474. if (map_getmapflag(m_id, MF_SKILL_DURATION)) {
  3475. clif_displaymessage(fd, msg_txt(sd, 1055)); // Skill Duration Adjustments:
  3476. for (const auto &it : mapdata->skill_duration) {
  3477. sprintf(atcmd_output, " > %s : %d%%", skill_get_name(it.first), it.second);
  3478. clif_displaymessage(fd, atcmd_output);
  3479. }
  3480. }
  3481. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3482. if (map_getmapflag(m_id, MF_PVP))
  3483. strcat(atcmd_output, " Pvp ON |");
  3484. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3485. strcat(atcmd_output, " NoGuild |");
  3486. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3487. strcat(atcmd_output, " NoParty |");
  3488. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3489. strcat(atcmd_output, " NightmareDrop |");
  3490. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3491. strcat(atcmd_output, " NoCalcRank |");
  3492. clif_displaymessage(fd, atcmd_output);
  3493. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3494. if (map_getmapflag(m_id, MF_GVG))
  3495. strcat(atcmd_output, " GvG ON |");
  3496. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3497. strcat(atcmd_output, " GvG Dungeon |");
  3498. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3499. strcat(atcmd_output, " GvG Castle |");
  3500. if (map_getmapflag(m_id, MF_GVG_TE))
  3501. strcat(atcmd_output, " GvG TE |");
  3502. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3503. strcat(atcmd_output, " GvG TE Castle |");
  3504. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3505. strcat(atcmd_output, " NoParty |");
  3506. clif_displaymessage(fd, atcmd_output);
  3507. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3508. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3509. strcat(atcmd_output, " NoTeleport |");
  3510. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3511. strcat(atcmd_output, " Monster NoTeleport |");
  3512. if (map_getmapflag(m_id, MF_NOWARP))
  3513. strcat(atcmd_output, " NoWarp |");
  3514. if (map_getmapflag(m_id, MF_NOWARPTO))
  3515. strcat(atcmd_output, " NoWarpTo |");
  3516. if (map_getmapflag(m_id, MF_NORETURN))
  3517. strcat(atcmd_output, " NoReturn |");
  3518. if (map_getmapflag(m_id, MF_NOGO))
  3519. strcat(atcmd_output, " NoGo |"); //
  3520. if (map_getmapflag(m_id, MF_NOMEMO))
  3521. strcat(atcmd_output, " NoMemo |");
  3522. clif_displaymessage(fd, atcmd_output);
  3523. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3524. (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
  3525. clif_displaymessage(fd, atcmd_output);
  3526. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3527. if (!mapdata->save.map)
  3528. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3529. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3530. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3531. clif_displaymessage(fd, atcmd_output);
  3532. }
  3533. else {
  3534. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3535. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3536. clif_displaymessage(fd, atcmd_output);
  3537. }
  3538. }
  3539. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3540. if (map_getmapflag(m_id, MF_SNOW))
  3541. strcat(atcmd_output, " Snow |");
  3542. if (map_getmapflag(m_id, MF_FOG))
  3543. strcat(atcmd_output, " Fog |");
  3544. if (map_getmapflag(m_id, MF_SAKURA))
  3545. strcat(atcmd_output, " Sakura |");
  3546. if (map_getmapflag(m_id, MF_CLOUDS))
  3547. strcat(atcmd_output, " Clouds |");
  3548. if (map_getmapflag(m_id, MF_CLOUDS2))
  3549. strcat(atcmd_output, " Clouds2 |");
  3550. if (map_getmapflag(m_id, MF_FIREWORKS))
  3551. strcat(atcmd_output, " Fireworks |");
  3552. if (map_getmapflag(m_id, MF_LEAVES))
  3553. strcat(atcmd_output, " Leaves |");
  3554. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3555. strcat(atcmd_output, " Displays Night |");
  3556. clif_displaymessage(fd, atcmd_output);
  3557. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3558. if (map_getmapflag(m_id, MF_NOBRANCH))
  3559. strcat(atcmd_output, " NoBranch |");
  3560. if (map_getmapflag(m_id, MF_NOTRADE))
  3561. strcat(atcmd_output, " NoTrade |");
  3562. if (map_getmapflag(m_id, MF_NOVENDING))
  3563. strcat(atcmd_output, " NoVending |");
  3564. if (map_getmapflag(m_id, MF_NODROP))
  3565. strcat(atcmd_output, " NoDrop |");
  3566. if (map_getmapflag(m_id, MF_NOSKILL))
  3567. strcat(atcmd_output, " NoSkill |");
  3568. if (map_getmapflag(m_id, MF_NOICEWALL))
  3569. strcat(atcmd_output, " NoIcewall |");
  3570. if (map_getmapflag(m_id, MF_ALLOWKS))
  3571. strcat(atcmd_output, " AllowKS |");
  3572. if (map_getmapflag(m_id, MF_RESET))
  3573. strcat(atcmd_output, " Reset |");
  3574. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3575. strcat(atcmd_output, " HideMobHPBar |");
  3576. clif_displaymessage(fd, atcmd_output);
  3577. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3578. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3579. strcat(atcmd_output, " NoCommand |");
  3580. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3581. strcat(atcmd_output, " NoBaseEXP |");
  3582. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3583. strcat(atcmd_output, " NoJobEXP |");
  3584. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3585. strcat(atcmd_output, " NoMobLoot |");
  3586. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3587. strcat(atcmd_output, " NoMVPLoot |");
  3588. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3589. strcat(atcmd_output, " PartyLock |");
  3590. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3591. strcat(atcmd_output, " GuildLock |");
  3592. if (map_getmapflag(m_id, MF_LOADEVENT))
  3593. strcat(atcmd_output, " Loadevent |");
  3594. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3595. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3596. if (map_getmapflag(m_id, MF_NOUSECART))
  3597. strcat(atcmd_output, " NoUsecart |");
  3598. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3599. strcat(atcmd_output, " NoItemConsumption |");
  3600. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3601. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3602. if (map_getmapflag(m_id, MF_NOMINEEFFECT))
  3603. strcat(atcmd_output, " NoMineEffect |");
  3604. if (map_getmapflag(m_id, MF_NOLOCKON))
  3605. strcat(atcmd_output, " NoLockOn |");
  3606. if (map_getmapflag(m_id, MF_NOTOMB))
  3607. strcat(atcmd_output, " NoTomb |");
  3608. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3609. strcat(atcmd_output, " NoCostume |");
  3610. clif_displaymessage(fd, atcmd_output);
  3611. switch (list) {
  3612. case 0:
  3613. // Do nothing. It's list 0, no additional display.
  3614. break;
  3615. case 1:
  3616. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3617. iter = mapit_getallusers();
  3618. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3619. {
  3620. if (pl_sd->mapindex == m_index) {
  3621. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3622. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3623. clif_displaymessage(fd, atcmd_output);
  3624. }
  3625. }
  3626. mapit_free(iter);
  3627. break;
  3628. case 2:
  3629. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3630. for (i = 0; i < mapdata->npc_num;)
  3631. {
  3632. struct npc_data *nd = mapdata->npc[i];
  3633. switch(nd->ud.dir) {
  3634. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3635. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3636. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3637. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3638. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3639. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3640. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3641. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3642. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3643. }
  3644. if(strcmp(nd->name,nd->exname) == 0)
  3645. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3646. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3647. else
  3648. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3649. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3650. clif_displaymessage(fd, atcmd_output);
  3651. }
  3652. break;
  3653. case 3:
  3654. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3655. iter = mapit_getallusers();
  3656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3657. {
  3658. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3659. pl_sd->mapindex == m_index &&
  3660. cd->usersd[0] == pl_sd)
  3661. {
  3662. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3663. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3664. clif_displaymessage(fd, atcmd_output);
  3665. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3666. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3667. clif_displaymessage(fd, atcmd_output);
  3668. }
  3669. }
  3670. mapit_free(iter);
  3671. break;
  3672. default: // normally impossible to arrive here
  3673. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3674. return -1;
  3675. break;
  3676. }
  3677. return 0;
  3678. }
  3679. /*==========================================
  3680. *
  3681. *------------------------------------------*/
  3682. ACMD_FUNC(mount_peco)
  3683. {
  3684. nullpo_retr(-1, sd);
  3685. if (sd->disguise) {
  3686. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3687. return -1;
  3688. }
  3689. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3690. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3691. unsigned int option = OPTION_DRAGON1;
  3692. if( message[0] ) {
  3693. int color = atoi(message);
  3694. option = ( color == 2 ? OPTION_DRAGON2 :
  3695. color == 3 ? OPTION_DRAGON3 :
  3696. color == 4 ? OPTION_DRAGON4 :
  3697. color == 5 ? OPTION_DRAGON5 :
  3698. OPTION_DRAGON1 );
  3699. }
  3700. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3701. pc_setoption(sd, sd->sc.option|option);
  3702. } else {
  3703. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3704. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3705. }
  3706. return 0;
  3707. }
  3708. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3709. if( !pc_isridingwug(sd) ) {
  3710. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3711. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3712. } else {
  3713. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3714. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3715. }
  3716. return 0;
  3717. }
  3718. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3719. if( !pc_ismadogear(sd) ) {
  3720. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3721. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3722. } else {
  3723. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3724. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3725. }
  3726. return 0;
  3727. }
  3728. if (!pc_isriding(sd)) { // if actually no peco
  3729. if (!pc_checkskill(sd, KN_RIDING)) {
  3730. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3731. return -1;
  3732. }
  3733. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3734. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3735. } else {//Dismount
  3736. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3737. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3738. }
  3739. return 0;
  3740. }
  3741. /*==========================================
  3742. *Spy Commands by Syrus22
  3743. *------------------------------------------*/
  3744. ACMD_FUNC(guildspy)
  3745. {
  3746. char guild_name[NAME_LENGTH];
  3747. struct guild *g;
  3748. nullpo_retr(-1, sd);
  3749. memset(guild_name, '\0', sizeof(guild_name));
  3750. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3751. if (!enable_spy)
  3752. {
  3753. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3754. return -1;
  3755. }
  3756. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3757. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3758. return -1;
  3759. }
  3760. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3761. (g = guild_search(atoi(message))) != NULL) {
  3762. if (sd->guildspy == g->guild_id) {
  3763. sd->guildspy = 0;
  3764. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3765. clif_displaymessage(fd, atcmd_output);
  3766. } else {
  3767. sd->guildspy = g->guild_id;
  3768. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3769. clif_displaymessage(fd, atcmd_output);
  3770. }
  3771. } else {
  3772. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3773. return -1;
  3774. }
  3775. return 0;
  3776. }
  3777. /*==========================================
  3778. *
  3779. *------------------------------------------*/
  3780. ACMD_FUNC(partyspy)
  3781. {
  3782. char party_name[NAME_LENGTH];
  3783. struct party_data *p;
  3784. nullpo_retr(-1, sd);
  3785. memset(party_name, '\0', sizeof(party_name));
  3786. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3787. if (!enable_spy)
  3788. {
  3789. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3790. return -1;
  3791. }
  3792. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3793. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3794. return -1;
  3795. }
  3796. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3797. (p = party_search(atoi(message))) != NULL) {
  3798. if (sd->partyspy == p->party.party_id) {
  3799. sd->partyspy = 0;
  3800. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3801. clif_displaymessage(fd, atcmd_output);
  3802. } else {
  3803. sd->partyspy = p->party.party_id;
  3804. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3805. clif_displaymessage(fd, atcmd_output);
  3806. }
  3807. } else {
  3808. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3809. return -1;
  3810. }
  3811. return 0;
  3812. }
  3813. ACMD_FUNC(clanspy){
  3814. char clan_name[NAME_LENGTH];
  3815. struct clan* c;
  3816. nullpo_retr(-1, sd);
  3817. memset(clan_name, '\0', sizeof(clan_name));
  3818. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3819. if( !enable_spy ){
  3820. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3821. return -1;
  3822. }
  3823. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3824. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3825. return -1;
  3826. }
  3827. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3828. (c = clan_search(atoi(message))) != NULL) {
  3829. if (sd->clanspy == c->id) {
  3830. sd->clanspy = 0;
  3831. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3832. clif_displaymessage(fd, atcmd_output);
  3833. }
  3834. else {
  3835. sd->clanspy = c->id;
  3836. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3837. clif_displaymessage(fd, atcmd_output);
  3838. }
  3839. }
  3840. else {
  3841. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3842. return -1;
  3843. }
  3844. return 0;
  3845. }
  3846. /*==========================================
  3847. * @repairall [Valaris]
  3848. *------------------------------------------*/
  3849. ACMD_FUNC(repairall)
  3850. {
  3851. int count, i;
  3852. nullpo_retr(-1, sd);
  3853. count = 0;
  3854. for (i = 0; i < MAX_INVENTORY; i++) {
  3855. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3856. sd->inventory.u.items_inventory[i].attribute = 0;
  3857. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3858. count++;
  3859. }
  3860. }
  3861. if (count > 0) {
  3862. clif_misceffect(&sd->bl, 3);
  3863. clif_equiplist(sd);
  3864. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3865. } else {
  3866. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3867. return -1;
  3868. }
  3869. return 0;
  3870. }
  3871. /*==========================================
  3872. * @nuke [Valaris]
  3873. *------------------------------------------*/
  3874. ACMD_FUNC(nuke)
  3875. {
  3876. struct map_session_data *pl_sd;
  3877. nullpo_retr(-1, sd);
  3878. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3879. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3880. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3881. return -1;
  3882. }
  3883. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3884. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3885. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3886. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3887. } else {
  3888. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3889. return -1;
  3890. }
  3891. } else {
  3892. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3893. return -1;
  3894. }
  3895. return 0;
  3896. }
  3897. /*==========================================
  3898. * @tonpc
  3899. *------------------------------------------*/
  3900. ACMD_FUNC(tonpc)
  3901. {
  3902. char npcname[NPC_NAME_LENGTH];
  3903. struct npc_data *nd;
  3904. nullpo_retr(-1, sd);
  3905. memset(npcname, 0, sizeof(npcname));
  3906. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3907. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3908. return -1;
  3909. }
  3910. if ((nd = npc_name2id(npcname)) != NULL) {
  3911. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3912. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3913. else
  3914. return -1;
  3915. } else {
  3916. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3917. return -1;
  3918. }
  3919. return 0;
  3920. }
  3921. /*==========================================
  3922. *
  3923. *------------------------------------------*/
  3924. ACMD_FUNC(shownpc)
  3925. {
  3926. char NPCname[NPC_NAME_LENGTH];
  3927. nullpo_retr(-1, sd);
  3928. memset(NPCname, '\0', sizeof(NPCname));
  3929. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3930. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3931. return -1;
  3932. }
  3933. if (npc_name2id(NPCname) != NULL) {
  3934. npc_enable(NPCname, 1);
  3935. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3936. } else {
  3937. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3938. return -1;
  3939. }
  3940. return 0;
  3941. }
  3942. /*==========================================
  3943. *
  3944. *------------------------------------------*/
  3945. ACMD_FUNC(hidenpc)
  3946. {
  3947. char NPCname[NPC_NAME_LENGTH];
  3948. nullpo_retr(-1, sd);
  3949. memset(NPCname, '\0', sizeof(NPCname));
  3950. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3951. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3952. return -1;
  3953. }
  3954. if (npc_name2id(NPCname) == NULL) {
  3955. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3956. return -1;
  3957. }
  3958. npc_enable(NPCname, 0);
  3959. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3960. return 0;
  3961. }
  3962. ACMD_FUNC(loadnpc)
  3963. {
  3964. if (!message || !*message) {
  3965. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3966. return -1;
  3967. }
  3968. if (!npc_addsrcfile(message, true)) {
  3969. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3970. return -1;
  3971. }
  3972. npc_read_event_script();
  3973. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  3974. return 0;
  3975. }
  3976. ACMD_FUNC(unloadnpc)
  3977. {
  3978. struct npc_data *nd;
  3979. char NPCname[NPC_NAME_LENGTH];
  3980. nullpo_retr(-1, sd);
  3981. memset(NPCname, '\0', sizeof(NPCname));
  3982. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3983. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3984. return -1;
  3985. }
  3986. if ((nd = npc_name2id(NPCname)) == NULL) {
  3987. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3988. return -1;
  3989. }
  3990. npc_unload_duplicates(nd);
  3991. npc_unload(nd,true);
  3992. npc_read_event_script();
  3993. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3994. return 0;
  3995. }
  3996. ACMD_FUNC(reloadnpcfile) {
  3997. if (!message || !*message) {
  3998. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  3999. return -1;
  4000. }
  4001. if (npc_unloadfile(message))
  4002. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4003. if (!npc_addsrcfile(message, true)) {
  4004. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4005. return -1;
  4006. }
  4007. npc_read_event_script();
  4008. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4009. return 0;
  4010. }
  4011. /*==========================================
  4012. * time in txt for time command (by [Yor])
  4013. *------------------------------------------*/
  4014. char* txt_time(t_tick duration_)
  4015. {
  4016. int days, hours, minutes, seconds;
  4017. char temp[CHAT_SIZE_MAX];
  4018. static char temp1[CHAT_SIZE_MAX];
  4019. memset(temp, '\0', sizeof(temp));
  4020. memset(temp1, '\0', sizeof(temp1));
  4021. // Cap it
  4022. int duration = (int)duration_;
  4023. days = duration / (60 * 60 * 24);
  4024. duration = duration - (60 * 60 * 24 * days);
  4025. hours = duration / (60 * 60);
  4026. duration = duration - (60 * 60 * hours);
  4027. minutes = duration / 60;
  4028. seconds = duration - (60 * minutes);
  4029. if (days == 1)
  4030. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4031. else if (days > 1)
  4032. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4033. if (hours == 1)
  4034. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4035. else if (hours > 1)
  4036. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4037. if (minutes < 2)
  4038. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4039. else
  4040. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4041. if (seconds == 1)
  4042. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4043. else if (seconds > 1)
  4044. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4045. return temp1;
  4046. }
  4047. /*==========================================
  4048. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4049. * Calculation management of GM modification (@day/@night GM commands) is done
  4050. *------------------------------------------*/
  4051. ACMD_FUNC(servertime)
  4052. {
  4053. const struct TimerData * timer_data;
  4054. time_t time_server; // variable for number of seconds (used with time() function)
  4055. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4056. char temp[CHAT_SIZE_MAX];
  4057. nullpo_retr(-1, sd);
  4058. memset(temp, '\0', sizeof(temp));
  4059. time(&time_server); // get time in seconds since 1/1/1970
  4060. datetime = localtime(&time_server); // convert seconds in structure
  4061. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4062. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4063. clif_displaymessage(fd, temp);
  4064. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4065. if (night_flag == 0)
  4066. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4067. else
  4068. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4069. } else if (battle_config.night_duration == 0)
  4070. if (night_flag == 1) { // we start with night
  4071. timer_data = get_timer(day_timer_tid);
  4072. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4073. clif_displaymessage(fd, temp);
  4074. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4075. } else
  4076. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4077. else if (battle_config.day_duration == 0)
  4078. if (night_flag == 0) { // we start with day
  4079. timer_data = get_timer(night_timer_tid);
  4080. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4081. clif_displaymessage(fd, temp);
  4082. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4083. } else
  4084. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4085. else {
  4086. const struct TimerData * timer_data2;
  4087. if (night_flag == 0) {
  4088. timer_data = get_timer(night_timer_tid);
  4089. timer_data2 = get_timer(day_timer_tid);
  4090. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4091. clif_displaymessage(fd, temp);
  4092. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4093. 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.
  4094. else
  4095. 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.
  4096. clif_displaymessage(fd, temp);
  4097. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4098. clif_displaymessage(fd, temp);
  4099. } else {
  4100. timer_data = get_timer(day_timer_tid);
  4101. timer_data2 = get_timer(night_timer_tid);
  4102. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4103. clif_displaymessage(fd, temp);
  4104. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4105. 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.
  4106. else
  4107. 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.
  4108. clif_displaymessage(fd, temp);
  4109. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4110. clif_displaymessage(fd, temp);
  4111. }
  4112. }
  4113. return 0;
  4114. }
  4115. /*==========================================
  4116. * @jail <char_name> by [Yor]
  4117. * Special warp! No check with nowarp and nowarpto flag
  4118. *------------------------------------------*/
  4119. ACMD_FUNC(jail)
  4120. {
  4121. struct map_session_data *pl_sd;
  4122. int x, y;
  4123. unsigned short m_index;
  4124. nullpo_retr(-1, sd);
  4125. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4126. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4127. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4128. return -1;
  4129. }
  4130. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4131. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4132. return -1;
  4133. }
  4134. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4135. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4136. return -1;
  4137. }
  4138. if (pl_sd->sc.data[SC_JAILED]) {
  4139. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4140. return -1;
  4141. }
  4142. switch(rnd() % 2) { //Jail Locations
  4143. case 0:
  4144. m_index = mapindex_name2id(MAP_JAIL);
  4145. x = 24;
  4146. y = 75;
  4147. break;
  4148. default:
  4149. m_index = mapindex_name2id(MAP_JAIL);
  4150. x = 49;
  4151. y = 75;
  4152. break;
  4153. }
  4154. //Duration of INT_MAX to specify infinity.
  4155. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4156. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4157. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4158. return 0;
  4159. }
  4160. /*==========================================
  4161. * @unjail/@discharge <char_name> by [Yor]
  4162. * Special warp! No check with nowarp and nowarpto flag
  4163. *------------------------------------------*/
  4164. ACMD_FUNC(unjail)
  4165. {
  4166. struct map_session_data *pl_sd;
  4167. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4168. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4169. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4170. return -1;
  4171. }
  4172. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4173. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4174. return -1;
  4175. }
  4176. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4177. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4178. return -1;
  4179. }
  4180. if (!pl_sd->sc.data[SC_JAILED]) {
  4181. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4182. return -1;
  4183. }
  4184. //Reset jail time to 1 sec.
  4185. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4186. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4187. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4188. return 0;
  4189. }
  4190. ACMD_FUNC(jailfor) {
  4191. struct map_session_data *pl_sd = NULL;
  4192. char * modif_p;
  4193. int jailtime = 0,x,y;
  4194. short m_index = 0;
  4195. nullpo_retr(-1, sd);
  4196. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4197. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4198. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4199. return -1;
  4200. }
  4201. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4202. modif_p = atcmd_output;
  4203. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4204. if (jailtime == 0) {
  4205. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4206. 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.
  4207. return -1;
  4208. }
  4209. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4210. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4211. return -1;
  4212. }
  4213. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4214. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4215. return -1;
  4216. }
  4217. // Added by Coltaro
  4218. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4219. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4220. if (jailtime <= 0) {
  4221. jailtime = 0;
  4222. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4223. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4224. } else {
  4225. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4226. char timestr[21];
  4227. time_t now=time(NULL);
  4228. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4229. 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
  4230. clif_displaymessage(pl_sd->fd, atcmd_output);
  4231. 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
  4232. clif_displaymessage(fd, atcmd_output);
  4233. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4234. sprintf(atcmd_output,"Release date is: %s",timestr);
  4235. clif_displaymessage(pl_sd->fd, atcmd_output);
  4236. clif_displaymessage(fd, atcmd_output);
  4237. }
  4238. } else if (jailtime < 0) {
  4239. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4240. return -1;
  4241. }
  4242. // Jail locations, add more as you wish.
  4243. switch(rnd()%2) {
  4244. case 1: // Jail #1
  4245. m_index = mapindex_name2id(MAP_JAIL);
  4246. x = 49; y = 75;
  4247. break;
  4248. default: // Default Jail
  4249. m_index = mapindex_name2id(MAP_JAIL);
  4250. x = 24; y = 75;
  4251. break;
  4252. }
  4253. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status_change_timer).
  4254. return 0;
  4255. }
  4256. //By Coltaro
  4257. ACMD_FUNC(jailtime){
  4258. int year, month, day, hour, minute, second;
  4259. char timestr[21];
  4260. time_t now = time(NULL);
  4261. nullpo_retr(-1, sd);
  4262. if (!sd->sc.data[SC_JAILED]) {
  4263. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4264. return -1;
  4265. }
  4266. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4267. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4268. return 0;
  4269. }
  4270. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4271. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4272. return -1;
  4273. }
  4274. // Get remaining jail time
  4275. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4276. 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
  4277. clif_displaymessage(fd, atcmd_output);
  4278. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4279. sprintf(atcmd_output,"Release date is: %s",timestr);
  4280. clif_displaymessage(fd, atcmd_output);
  4281. return 0;
  4282. }
  4283. /*==========================================
  4284. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4285. *------------------------------------------*/
  4286. ACMD_FUNC(disguise)
  4287. {
  4288. int id = 0;
  4289. nullpo_retr(-1, sd);
  4290. if (!message || !*message) {
  4291. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4292. return -1;
  4293. }
  4294. if ((id = atoi(message)) > 0)
  4295. { //Acquired an ID
  4296. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4297. id = 0; //Invalid id for either mobs or npcs.
  4298. } else { //Acquired a Name
  4299. if ((id = mobdb_searchname(message)) == 0)
  4300. {
  4301. struct npc_data* nd = npc_name2id(message);
  4302. if (nd != NULL)
  4303. id = nd->class_;
  4304. }
  4305. }
  4306. if (id == 0)
  4307. {
  4308. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4309. return -1;
  4310. }
  4311. if(pc_isriding(sd))
  4312. {
  4313. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4314. return -1;
  4315. }
  4316. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4317. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4318. return -1;
  4319. }
  4320. pc_disguise(sd, id);
  4321. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4322. return 0;
  4323. }
  4324. /*==========================================
  4325. * DisguiseAll
  4326. *------------------------------------------*/
  4327. ACMD_FUNC(disguiseall)
  4328. {
  4329. int mob_id=0;
  4330. struct map_session_data *pl_sd;
  4331. struct s_mapiterator* iter;
  4332. nullpo_retr(-1, sd);
  4333. if (!message || !*message) {
  4334. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4335. return -1;
  4336. }
  4337. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4338. mob_id = atoi(message);
  4339. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4340. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4341. return -1;
  4342. }
  4343. iter = mapit_getallusers();
  4344. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4345. pc_disguise(pl_sd, mob_id);
  4346. mapit_free(iter);
  4347. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4348. return 0;
  4349. }
  4350. /*==========================================
  4351. * DisguiseGuild
  4352. *------------------------------------------*/
  4353. ACMD_FUNC(disguiseguild)
  4354. {
  4355. int id = 0, i;
  4356. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4357. struct guild *g;
  4358. memset(monster, '\0', sizeof(monster));
  4359. memset(guild, '\0', sizeof(guild));
  4360. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4361. 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>).
  4362. return -1;
  4363. }
  4364. if( (id = atoi(monster)) > 0 ) {
  4365. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4366. id = 0;
  4367. } else {
  4368. if( (id = mobdb_searchname(monster)) == 0 ) {
  4369. struct npc_data* nd = npc_name2id(monster);
  4370. if( nd != NULL )
  4371. id = nd->class_;
  4372. }
  4373. }
  4374. if( id == 0 ) {
  4375. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4376. return -1;
  4377. }
  4378. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4379. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4380. return -1;
  4381. }
  4382. for( i = 0; i < g->max_member; i++ ){
  4383. struct map_session_data *pl_sd;
  4384. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4385. pc_disguise(pl_sd, id);
  4386. }
  4387. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4388. return 0;
  4389. }
  4390. /*==========================================
  4391. * @undisguise by [Yor]
  4392. *------------------------------------------*/
  4393. ACMD_FUNC(undisguise)
  4394. {
  4395. nullpo_retr(-1, sd);
  4396. if (sd->disguise) {
  4397. pc_disguise(sd, 0);
  4398. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4399. } else {
  4400. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4401. return -1;
  4402. }
  4403. return 0;
  4404. }
  4405. /*==========================================
  4406. * UndisguiseAll
  4407. *------------------------------------------*/
  4408. ACMD_FUNC(undisguiseall)
  4409. {
  4410. struct map_session_data *pl_sd;
  4411. struct s_mapiterator* iter;
  4412. nullpo_retr(-1, sd);
  4413. iter = mapit_getallusers();
  4414. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4415. if( pl_sd->disguise )
  4416. pc_disguise(pl_sd, 0);
  4417. mapit_free(iter);
  4418. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4419. return 0;
  4420. }
  4421. /*==========================================
  4422. * UndisguiseGuild
  4423. *------------------------------------------*/
  4424. ACMD_FUNC(undisguiseguild)
  4425. {
  4426. char guild_name[NAME_LENGTH];
  4427. struct guild *g;
  4428. int i;
  4429. nullpo_retr(-1, sd);
  4430. memset(guild_name, '\0', sizeof(guild_name));
  4431. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4432. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4433. return -1;
  4434. }
  4435. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4436. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4437. return -1;
  4438. }
  4439. for(i = 0; i < g->max_member; i++){
  4440. struct map_session_data *pl_sd;
  4441. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4442. pc_disguise(pl_sd, 0);
  4443. }
  4444. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4445. return 0;
  4446. }
  4447. /*==========================================
  4448. * @exp by [Skotlex]
  4449. *------------------------------------------*/
  4450. ACMD_FUNC(exp)
  4451. {
  4452. char output[CHAT_SIZE_MAX];
  4453. double nextb, nextj;
  4454. nullpo_retr(-1, sd);
  4455. memset(output, '\0', sizeof(output));
  4456. nextb = pc_nextbaseexp(sd);
  4457. if (nextb)
  4458. nextb = sd->status.base_exp*100.0/nextb;
  4459. nextj = pc_nextjobexp(sd);
  4460. if (nextj)
  4461. nextj = sd->status.job_exp*100.0/nextj;
  4462. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4463. clif_displaymessage(fd, output);
  4464. return 0;
  4465. }
  4466. /*==========================================
  4467. * @broadcast by [Valaris]
  4468. *------------------------------------------*/
  4469. ACMD_FUNC(broadcast)
  4470. {
  4471. nullpo_retr(-1, sd);
  4472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4473. if (!message || !*message) {
  4474. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4475. return -1;
  4476. }
  4477. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4478. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4479. return 0;
  4480. }
  4481. /*==========================================
  4482. * @localbroadcast by [Valaris]
  4483. *------------------------------------------*/
  4484. ACMD_FUNC(localbroadcast)
  4485. {
  4486. nullpo_retr(-1, sd);
  4487. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4488. if (!message || !*message) {
  4489. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4490. return -1;
  4491. }
  4492. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4493. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4494. return 0;
  4495. }
  4496. /*==========================================
  4497. * @email <actual@email> <new@email> by [Yor]
  4498. *------------------------------------------*/
  4499. ACMD_FUNC(email)
  4500. {
  4501. char actual_email[100];
  4502. char new_email[100];
  4503. nullpo_retr(-1, sd);
  4504. memset(actual_email, '\0', sizeof(actual_email));
  4505. memset(new_email, '\0', sizeof(new_email));
  4506. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4507. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4508. return -1;
  4509. }
  4510. if (e_mail_check(actual_email) == 0) {
  4511. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4512. return -1;
  4513. } else if (e_mail_check(new_email) == 0) {
  4514. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4515. return -1;
  4516. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4517. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4518. return -1;
  4519. } else if (strcmpi(actual_email, new_email) == 0) {
  4520. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4521. return -1;
  4522. }
  4523. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4524. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4525. return 0;
  4526. }
  4527. /*==========================================
  4528. *@effect
  4529. *------------------------------------------*/
  4530. ACMD_FUNC(effect)
  4531. {
  4532. int type = EF_NONE;
  4533. nullpo_retr(-1, sd);
  4534. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4535. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4536. return -1;
  4537. }
  4538. if( type <= EF_NONE || type >= EF_MAX ){
  4539. 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.
  4540. clif_displaymessage(fd, atcmd_output);
  4541. return -1;
  4542. }
  4543. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4544. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4545. return 0;
  4546. }
  4547. /*==========================================
  4548. * @killer by MouseJstr
  4549. * enable killing players even when not in pvp
  4550. *------------------------------------------*/
  4551. ACMD_FUNC(killer)
  4552. {
  4553. nullpo_retr(-1, sd);
  4554. sd->state.killer = !sd->state.killer;
  4555. if(sd->state.killer)
  4556. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4557. else {
  4558. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4559. pc_stop_attack(sd);
  4560. }
  4561. return 0;
  4562. }
  4563. /*==========================================
  4564. * @killable by MouseJstr
  4565. * enable other people killing you
  4566. *------------------------------------------*/
  4567. ACMD_FUNC(killable)
  4568. {
  4569. nullpo_retr(-1, sd);
  4570. sd->state.killable = !sd->state.killable;
  4571. if(sd->state.killable)
  4572. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4573. else {
  4574. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4575. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4576. }
  4577. return 0;
  4578. }
  4579. /*==========================================
  4580. * @skillon by MouseJstr
  4581. * turn skills on for the map
  4582. *------------------------------------------*/
  4583. ACMD_FUNC(skillon)
  4584. {
  4585. nullpo_retr(-1, sd);
  4586. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4587. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4588. return 0;
  4589. }
  4590. /*==========================================
  4591. * @skilloff by MouseJstr
  4592. * Turn skills off on the map
  4593. *------------------------------------------*/
  4594. ACMD_FUNC(skilloff)
  4595. {
  4596. nullpo_retr(-1, sd);
  4597. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4598. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4599. return 0;
  4600. }
  4601. /*==========================================
  4602. * @npcmove by MouseJstr
  4603. * move a npc
  4604. *------------------------------------------*/
  4605. ACMD_FUNC(npcmove)
  4606. {
  4607. short x = 0, y = 0;
  4608. struct npc_data *nd = 0;
  4609. char npc_name[NPC_NAME_LENGTH];
  4610. nullpo_retr(-1, sd);
  4611. memset(npc_name, '\0', sizeof npc_name);
  4612. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4613. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4614. return -1;
  4615. }
  4616. if ((nd = npc_name2id(npc_name)) == NULL)
  4617. {
  4618. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4619. return -1;
  4620. }
  4621. if ( npc_movenpc( nd, x, y ) )
  4622. { //actually failed to move
  4623. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4624. return -1; //Not on a map.
  4625. } else
  4626. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. * @addwarp by MouseJstr
  4631. * Create a new static warp point.
  4632. *------------------------------------------*/
  4633. ACMD_FUNC(addwarp)
  4634. {
  4635. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4636. short x,y;
  4637. unsigned short m;
  4638. struct npc_data* nd;
  4639. nullpo_retr(-1, sd);
  4640. memset(warpname, '\0', sizeof(warpname));
  4641. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4642. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4643. return -1;
  4644. }
  4645. m = mapindex_name2id(mapname);
  4646. if( m == 0 )
  4647. {
  4648. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4649. clif_displaymessage(fd, atcmd_output);
  4650. return -1;
  4651. }
  4652. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4653. if( nd == NULL )
  4654. return -1;
  4655. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4656. clif_displaymessage(fd, atcmd_output);
  4657. return 0;
  4658. }
  4659. /*==========================================
  4660. * @follow by [MouseJstr]
  4661. * Follow a player .. staying no more then 5 spaces away
  4662. *------------------------------------------*/
  4663. ACMD_FUNC(follow)
  4664. {
  4665. struct map_session_data *pl_sd = NULL;
  4666. nullpo_retr(-1, sd);
  4667. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4668. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4669. if (sd->followtarget == -1)
  4670. return -1;
  4671. pc_stop_following (sd);
  4672. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4673. return 0;
  4674. }
  4675. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4676. {
  4677. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4678. return -1;
  4679. }
  4680. if (sd->followtarget == pl_sd->bl.id) {
  4681. pc_stop_following (sd);
  4682. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4683. } else {
  4684. pc_follow(sd, pl_sd->bl.id);
  4685. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4686. }
  4687. return 0;
  4688. }
  4689. /*==========================================
  4690. * @dropall by [MouseJstr] and [Xantara]
  4691. * Drops all your possession on the ground based on item type
  4692. *------------------------------------------*/
  4693. ACMD_FUNC(dropall)
  4694. {
  4695. int8 type = -1;
  4696. uint16 i, count = 0, count2 = 0;
  4697. struct item_data *item_data = NULL;
  4698. nullpo_retr(-1, sd);
  4699. if( message[0] ) {
  4700. type = atoi(message);
  4701. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4702. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4703. {
  4704. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4705. 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
  4706. return -1;
  4707. }
  4708. }
  4709. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4710. if( sd->inventory.u.items_inventory[i].amount ) {
  4711. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4712. 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);
  4713. continue;
  4714. }
  4715. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4716. continue;
  4717. if( type == -1 || type == (uint8)item_data->type ) {
  4718. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4719. pc_unequipitem(sd, i, 3);
  4720. pc_equipswitch_remove(sd, i);
  4721. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4722. count += sd->inventory.u.items_inventory[i].amount;
  4723. else count2 += sd->inventory.u.items_inventory[i].amount;
  4724. }
  4725. }
  4726. }
  4727. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4728. clif_displaymessage(fd, atcmd_output);
  4729. return 0;
  4730. }
  4731. /*==========================================
  4732. * @storeall by [MouseJstr]
  4733. * Put everything into storage
  4734. *------------------------------------------*/
  4735. ACMD_FUNC(storeall)
  4736. {
  4737. int i;
  4738. nullpo_retr(-1, sd);
  4739. if (sd->state.storage_flag != 1)
  4740. { //Open storage.
  4741. if( storage_storageopen(sd) == 1 ) {
  4742. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4743. return -1;
  4744. }
  4745. }
  4746. for (i = 0; i < MAX_INVENTORY; i++) {
  4747. if (sd->inventory.u.items_inventory[i].amount) {
  4748. if(sd->inventory.u.items_inventory[i].equip != 0)
  4749. pc_unequipitem(sd, i, 3);
  4750. pc_equipswitch_remove(sd, i);
  4751. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4752. }
  4753. }
  4754. storage_storageclose(sd);
  4755. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4756. return 0;
  4757. }
  4758. ACMD_FUNC(clearstorage)
  4759. {
  4760. int i, j;
  4761. nullpo_retr(-1, sd);
  4762. if (sd->state.storage_flag == 1) {
  4763. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4764. return -1;
  4765. }
  4766. if (sd->state.storage_flag == 3) {
  4767. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4768. return -1;
  4769. }
  4770. j = sd->storage.amount;
  4771. for (i = 0; i < j; ++i) {
  4772. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4773. }
  4774. sd->state.storage_flag = 1;
  4775. storage_storageclose(sd);
  4776. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4777. return 0;
  4778. }
  4779. ACMD_FUNC(cleargstorage)
  4780. {
  4781. int i, j;
  4782. struct guild *g;
  4783. struct s_storage *gstorage;
  4784. nullpo_retr(-1, sd);
  4785. g = sd->guild;
  4786. if (g == NULL) {
  4787. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4788. return -1;
  4789. }
  4790. if (sd->state.storage_flag == 1) {
  4791. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4792. return -1;
  4793. }
  4794. if (sd->state.storage_flag == 2) {
  4795. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4796. return -1;
  4797. }
  4798. if (sd->state.storage_flag == 3) {
  4799. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4800. return -1;
  4801. }
  4802. gstorage = guild2storage2(sd->status.guild_id);
  4803. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4804. return -1;
  4805. }
  4806. j = gstorage->amount;
  4807. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4808. for (i = 0; i < j; ++i) {
  4809. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4810. }
  4811. storage_guild_storageclose(sd);
  4812. gstorage->lock = false; // Cleaning done, release lock
  4813. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4814. return 0;
  4815. }
  4816. ACMD_FUNC(clearcart)
  4817. {
  4818. int i;
  4819. nullpo_retr(-1, sd);
  4820. if (pc_iscarton(sd) == 0) {
  4821. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4822. return -1;
  4823. }
  4824. if (sd->state.vending == 1) { //Somehow...
  4825. return -1;
  4826. }
  4827. for (i = 0; i < MAX_CART; i++) {
  4828. if (sd->cart.u.items_cart[i].nameid > 0)
  4829. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4830. }
  4831. clif_clearcart(fd);
  4832. clif_updatestatus(sd,SP_CARTINFO);
  4833. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4834. return 0;
  4835. }
  4836. /*==========================================
  4837. * @skillid by [MouseJstr]
  4838. * lookup a skill by name
  4839. *------------------------------------------*/
  4840. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4841. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4842. ACMD_FUNC(skillid) {
  4843. int skillen, i, found = 0;
  4844. DBIterator* iter;
  4845. DBKey key;
  4846. DBData *data;
  4847. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4848. nullpo_retr(-1, sd);
  4849. if (!message || !*message) {
  4850. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4851. return -1;
  4852. }
  4853. skillen = strlen(message);
  4854. iter = db_iterator(skilldb_name2id);
  4855. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4856. int idx = skill_get_index(db_data2i(data));
  4857. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4858. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4859. clif_displaymessage(fd, atcmd_output);
  4860. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4861. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // // skill %d: %s (%s)
  4862. }
  4863. }
  4864. dbi_destroy(iter);
  4865. if( found ) {
  4866. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4867. clif_displaymessage(fd, atcmd_output);
  4868. }
  4869. for(i = 0; i < found; i++) { /* partials */
  4870. clif_displaymessage(fd, partials[i]);
  4871. }
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @useskill by [MouseJstr]
  4876. * A way of using skills without having to find them in the skills menu
  4877. *------------------------------------------*/
  4878. ACMD_FUNC(useskill)
  4879. {
  4880. struct map_session_data *pl_sd = NULL;
  4881. struct block_list *bl;
  4882. uint16 skill_id;
  4883. uint16 skill_lv;
  4884. nullpo_retr(-1, sd);
  4885. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4886. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4887. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4888. return -1;
  4889. }
  4890. if(!strcmp(atcmd_player_name,"self"))
  4891. pl_sd = sd; //quick keyword
  4892. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4893. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4894. return -1;
  4895. }
  4896. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4897. {
  4898. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4899. return -1;
  4900. }
  4901. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4902. bl = &sd->hd->bl;
  4903. else
  4904. bl = &sd->bl;
  4905. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4906. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4907. else
  4908. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4909. return 0;
  4910. }
  4911. /*==========================================
  4912. * @displayskill by [Skotlex]
  4913. * Debug command to locate new skill IDs. It sends the
  4914. * three possible skill-effect packets to the area.
  4915. *------------------------------------------*/
  4916. ACMD_FUNC(displayskill)
  4917. {
  4918. struct status_data * status;
  4919. t_tick tick;
  4920. uint16 skill_id;
  4921. uint16 skill_lv = 1;
  4922. nullpo_retr(-1, sd);
  4923. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4924. {
  4925. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4926. return -1;
  4927. }
  4928. status = status_get_status_data(&sd->bl);
  4929. tick = gettick();
  4930. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4931. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4932. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4933. return 0;
  4934. }
  4935. /*==========================================
  4936. * @skilltree by [MouseJstr]
  4937. * prints the skill tree for a player required to get to a skill
  4938. *------------------------------------------*/
  4939. ACMD_FUNC(skilltree)
  4940. {
  4941. struct map_session_data *pl_sd = NULL;
  4942. uint16 skill_id;
  4943. int meets, i, j, c=0;
  4944. struct skill_tree_entry *ent;
  4945. nullpo_retr(-1, sd);
  4946. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4947. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  4948. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  4949. return -1;
  4950. }
  4951. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4952. {
  4953. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4954. return -1;
  4955. }
  4956. i = pc_calc_skilltree_normalize_job(pl_sd);
  4957. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4958. 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).
  4959. clif_displaymessage(fd, atcmd_output);
  4960. c = pc_class2idx(c);
  4961. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4962. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4963. {
  4964. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4965. return 0;
  4966. }
  4967. ent = &skill_tree[c][j];
  4968. meets = 1;
  4969. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4970. {
  4971. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4972. {
  4973. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].skill_lv, skill_db[skill_get_index(ent->need[j].skill_id)]->desc); // Player requires level %d of skill %s.
  4974. clif_displaymessage(fd, atcmd_output);
  4975. meets = 0;
  4976. }
  4977. }
  4978. if (meets == 1) {
  4979. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4980. }
  4981. return 0;
  4982. }
  4983. // Hand a ring with partners name on it to this char
  4984. void getring (struct map_session_data* sd)
  4985. {
  4986. char flag = 0;
  4987. unsigned short item_id;
  4988. struct item item_tmp;
  4989. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4990. memset(&item_tmp, 0, sizeof(item_tmp));
  4991. item_tmp.nameid = item_id;
  4992. item_tmp.identify = 1;
  4993. item_tmp.card[0] = 255;
  4994. item_tmp.card[2] = sd->status.partner_id;
  4995. item_tmp.card[3] = sd->status.partner_id >> 16;
  4996. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4997. clif_additem(sd,0,0,flag);
  4998. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4999. }
  5000. }
  5001. /*==========================================
  5002. * @marry by [MouseJstr], fixed by Lupus
  5003. * Marry two players
  5004. *------------------------------------------*/
  5005. ACMD_FUNC(marry)
  5006. {
  5007. struct map_session_data *pl_sd = NULL;
  5008. nullpo_retr(-1, sd);
  5009. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5010. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5011. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5012. return -1;
  5013. }
  5014. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5015. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5016. return -1;
  5017. }
  5018. if (pc_marriage(sd, pl_sd)) {
  5019. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5020. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5021. if( pl_sd->bl.m != sd->bl.m )
  5022. clif_wedding_effect(&sd->bl);
  5023. getring(sd); // Auto-give named rings (Aru)
  5024. getring(pl_sd);
  5025. return 0;
  5026. }
  5027. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5028. return -1;
  5029. }
  5030. /*==========================================
  5031. * @divorce by [MouseJstr], fixed by [Lupus]
  5032. * divorce two players
  5033. *------------------------------------------*/
  5034. ACMD_FUNC(divorce)
  5035. {
  5036. nullpo_retr(-1, sd);
  5037. if (!pc_divorce(sd)) {
  5038. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5039. clif_displaymessage(fd, atcmd_output);
  5040. return -1;
  5041. }
  5042. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5043. clif_displaymessage(fd, atcmd_output);
  5044. return 0;
  5045. }
  5046. /*==========================================
  5047. * @changelook by [Celest]
  5048. *------------------------------------------*/
  5049. ACMD_FUNC(changelook)
  5050. {
  5051. int i, j = 0, k = 0;
  5052. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5053. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5054. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5055. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5056. return -1;
  5057. } else if ( i == 2 ) {
  5058. if (j < 1 || j > 8)
  5059. j = 1;
  5060. j = pos[j - 1];
  5061. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5062. k = j; // swap
  5063. j = LOOK_HEAD_TOP;
  5064. }
  5065. clif_changelook(&sd->bl,j,k);
  5066. return 0;
  5067. }
  5068. /*==========================================
  5069. * @autotrade by durf [Lupus] [Paradox924X]
  5070. * Turns on/off Autotrade for a specific player
  5071. *------------------------------------------*/
  5072. ACMD_FUNC(autotrade) {
  5073. nullpo_retr(-1, sd);
  5074. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5075. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5076. return -1;
  5077. }
  5078. if( pc_isdead(sd) ) {
  5079. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5080. return -1;
  5081. }
  5082. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5083. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5084. return -1;
  5085. }
  5086. sd->state.autotrade = 1;
  5087. if (battle_config.autotrade_monsterignore)
  5088. sd->state.monster_ignore = 1;
  5089. if( sd->state.vending ){
  5090. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5091. Sql_ShowDebug( mmysql_handle );
  5092. }
  5093. }else if( sd->state.buyingstore ){
  5094. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5095. Sql_ShowDebug( mmysql_handle );
  5096. }
  5097. }
  5098. if( battle_config.at_timeout ) {
  5099. int timeout = atoi(message);
  5100. status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
  5101. }
  5102. channel_pcquit(sd,0xF); //leave all chan
  5103. clif_authfail_fd(sd->fd, 15);
  5104. chrif_save(sd, CSAVE_AUTOTRADE);
  5105. return 0;
  5106. }
  5107. /*==========================================
  5108. * @changegm by durf (changed by Lupus)
  5109. * Changes Master of your Guild to a specified guild member
  5110. *------------------------------------------*/
  5111. ACMD_FUNC(changegm)
  5112. {
  5113. struct guild *g;
  5114. struct map_session_data *pl_sd;
  5115. nullpo_retr(-1, sd);
  5116. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5117. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5118. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5119. return -1;
  5120. }
  5121. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5122. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5123. return -1;
  5124. }
  5125. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5126. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5127. return -1;
  5128. }
  5129. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5130. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5131. return -1;
  5132. }
  5133. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5134. return 0;
  5135. }
  5136. /*==========================================
  5137. * @changeleader by Skotlex
  5138. * Changes the leader of a party.
  5139. *------------------------------------------*/
  5140. ACMD_FUNC(changeleader)
  5141. {
  5142. nullpo_retr(-1, sd);
  5143. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5144. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5145. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5146. return -1;
  5147. }
  5148. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5149. return 0;
  5150. }
  5151. /*==========================================
  5152. * @partyoption by Skotlex
  5153. * Used to change the item share setting of a party.
  5154. *------------------------------------------*/
  5155. ACMD_FUNC(partyoption)
  5156. {
  5157. struct party_data *p;
  5158. int mi, option;
  5159. char w1[16], w2[16];
  5160. nullpo_retr(-1, sd);
  5161. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5162. {
  5163. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5164. return -1;
  5165. }
  5166. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5167. if (mi == MAX_PARTY)
  5168. return -1; //Shouldn't happen
  5169. if (!p->party.member[mi].leader)
  5170. {
  5171. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5172. return -1;
  5173. }
  5174. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5175. {
  5176. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5177. return -1;
  5178. }
  5179. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5180. //Change item share type.
  5181. if (option != p->party.item)
  5182. party_changeoption(sd, p->party.exp, option);
  5183. else
  5184. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5185. return 0;
  5186. }
  5187. /*==========================================
  5188. * @autoloot by Upa-Kun
  5189. * Turns on/off AutoLoot for a specific player
  5190. *------------------------------------------*/
  5191. ACMD_FUNC(autoloot)
  5192. {
  5193. int rate;
  5194. nullpo_retr(-1, sd);
  5195. // autoloot command without value
  5196. if(!message || !*message)
  5197. {
  5198. if (sd->state.autoloot)
  5199. rate = 0;
  5200. else
  5201. rate = 10000;
  5202. } else {
  5203. double drate;
  5204. drate = atof(message);
  5205. rate = (int)(drate*100);
  5206. }
  5207. if (rate < 0) rate = 0;
  5208. if (rate > 10000) rate = 10000;
  5209. sd->state.autoloot = rate;
  5210. if (sd->state.autoloot) {
  5211. 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.
  5212. clif_displaymessage(fd, atcmd_output);
  5213. }else
  5214. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5215. return 0;
  5216. }
  5217. /*==========================================
  5218. * @alootid
  5219. *------------------------------------------*/
  5220. ACMD_FUNC(autolootitem)
  5221. {
  5222. struct item_data *item_data = NULL;
  5223. int i;
  5224. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5225. nullpo_retr(-1, sd);
  5226. if (message && *message) {
  5227. if (message[0] == '+') {
  5228. message++;
  5229. action = 1;
  5230. }
  5231. else if (message[0] == '-') {
  5232. message++;
  5233. action = 2;
  5234. }
  5235. else if (!strcmp(message,"reset"))
  5236. action = 4;
  5237. }
  5238. if (action < 3) // add or remove
  5239. {
  5240. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5241. item_data = itemdb_searchname(message);
  5242. if (!item_data) {
  5243. // No items founds in the DB with Id or Name
  5244. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5245. return -1;
  5246. }
  5247. }
  5248. switch(action) {
  5249. case 1:
  5250. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5251. if (i != AUTOLOOTITEM_SIZE) {
  5252. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5253. return -1;
  5254. }
  5255. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5256. if (i == AUTOLOOTITEM_SIZE) {
  5257. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5258. return -1;
  5259. }
  5260. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5261. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5262. clif_displaymessage(fd, atcmd_output);
  5263. sd->state.autolooting = 1;
  5264. break;
  5265. case 2:
  5266. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5267. if (i == AUTOLOOTITEM_SIZE) {
  5268. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5269. return -1;
  5270. }
  5271. sd->state.autolootid[i] = 0;
  5272. sprintf(atcmd_output, msg_txt(sd,1194), item_data->name, item_data->jname, item_data->nameid); // Removed item: '%s'/'%s' {%d} from your autolootitem list.
  5273. clif_displaymessage(fd, atcmd_output);
  5274. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5275. if (i == AUTOLOOTITEM_SIZE) {
  5276. sd->state.autolooting = 0;
  5277. }
  5278. break;
  5279. case 3:
  5280. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5281. clif_displaymessage(fd, atcmd_output);
  5282. 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>".
  5283. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5284. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5285. if (i == AUTOLOOTITEM_SIZE) {
  5286. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5287. } else {
  5288. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5289. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5290. {
  5291. if (sd->state.autolootid[i] == 0)
  5292. continue;
  5293. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5294. 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);
  5295. continue;
  5296. }
  5297. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5298. clif_displaymessage(fd, atcmd_output);
  5299. }
  5300. }
  5301. break;
  5302. case 4:
  5303. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5304. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5305. sd->state.autolooting = 0;
  5306. break;
  5307. }
  5308. return 0;
  5309. }
  5310. /*==========================================
  5311. * @autoloottype
  5312. * Flags:
  5313. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5314. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5315. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5316. * 262144: IT_CASH
  5317. *------------------------------------------
  5318. * Credits:
  5319. * chriser
  5320. * Aleos
  5321. *------------------------------------------*/
  5322. ACMD_FUNC(autoloottype)
  5323. {
  5324. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5325. enum item_types type= IT_UNKNOWN;
  5326. int ITEM_MAX = 1533;
  5327. nullpo_retr(-1, sd);
  5328. if (message && *message) {
  5329. if (message[0] == '+') {
  5330. message++;
  5331. action = 1;
  5332. }
  5333. else if (message[0] == '-') {
  5334. message++;
  5335. action = 2;
  5336. }
  5337. else if (!strcmp(message,"reset"))
  5338. action = 4;
  5339. }
  5340. if (action < 3) { // add or remove
  5341. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5342. type = IT_HEALING;
  5343. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5344. type = IT_USABLE;
  5345. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5346. type = IT_ETC;
  5347. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5348. type = IT_ARMOR;
  5349. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5350. type = IT_WEAPON;
  5351. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5352. type = IT_CARD;
  5353. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5354. type = IT_PETEGG;
  5355. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5356. type = IT_PETARMOR;
  5357. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5358. type = IT_AMMO;
  5359. else {
  5360. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5361. return -1;
  5362. }
  5363. }
  5364. switch (action) {
  5365. case 1:
  5366. if (sd->state.autoloottype&(1<<type)) {
  5367. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5368. return -1;
  5369. }
  5370. if (sd->state.autoloottype == ITEM_MAX) {
  5371. 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>.
  5372. return -1;
  5373. }
  5374. sd->state.autoloottype |= (1<<type); // Stores the type
  5375. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5376. clif_displaymessage(fd, atcmd_output);
  5377. break;
  5378. case 2:
  5379. if (!(sd->state.autoloottype&(1<<type))) {
  5380. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5381. return -1;
  5382. }
  5383. sd->state.autoloottype &= ~(1<<type);
  5384. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5385. clif_displaymessage(fd, atcmd_output);
  5386. break;
  5387. case 3:
  5388. 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>".
  5389. 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
  5390. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5391. if (sd->state.autoloottype == 0)
  5392. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5393. else {
  5394. uint8 i = 0;
  5395. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5396. while (i < IT_MAX) {
  5397. if (sd->state.autoloottype&(1<<i)) {
  5398. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5399. clif_displaymessage(fd, atcmd_output);
  5400. }
  5401. i++;
  5402. }
  5403. }
  5404. break;
  5405. case 4:
  5406. sd->state.autoloottype = 0;
  5407. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5408. break;
  5409. }
  5410. return 0;
  5411. }
  5412. /*==========================================
  5413. * It is made to rain.
  5414. * No longer available, keeping here just in case it's back someday. [Ind]
  5415. *------------------------------------------*/
  5416. //ACMD_FUNC(rain)
  5417. //{
  5418. // nullpo_retr(-1, sd);
  5419. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5420. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5421. // clif_weather(sd->bl.m);
  5422. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5423. // } else {
  5424. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5425. // clif_weather(sd->bl.m);
  5426. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5427. // }
  5428. // return 0;
  5429. //}
  5430. /*==========================================
  5431. * It is made to snow.
  5432. *------------------------------------------*/
  5433. ACMD_FUNC(snow)
  5434. {
  5435. nullpo_retr(-1, sd);
  5436. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5437. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5438. clif_weather(sd->bl.m);
  5439. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5440. } else {
  5441. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5442. clif_weather(sd->bl.m);
  5443. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5444. }
  5445. return 0;
  5446. }
  5447. /*==========================================
  5448. * Cherry tree snowstorm is made to fall. (Sakura)
  5449. *------------------------------------------*/
  5450. ACMD_FUNC(sakura)
  5451. {
  5452. nullpo_retr(-1, sd);
  5453. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5454. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5455. clif_weather(sd->bl.m);
  5456. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5457. } else {
  5458. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5459. clif_weather(sd->bl.m);
  5460. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5461. }
  5462. return 0;
  5463. }
  5464. /*==========================================
  5465. * Clouds appear.
  5466. *------------------------------------------*/
  5467. ACMD_FUNC(clouds)
  5468. {
  5469. nullpo_retr(-1, sd);
  5470. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5471. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5472. clif_weather(sd->bl.m);
  5473. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5474. } else {
  5475. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5476. clif_weather(sd->bl.m);
  5477. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5478. }
  5479. return 0;
  5480. }
  5481. /*==========================================
  5482. * Different type of clouds using effect 516
  5483. *------------------------------------------*/
  5484. ACMD_FUNC(clouds2)
  5485. {
  5486. nullpo_retr(-1, sd);
  5487. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5488. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5489. clif_weather(sd->bl.m);
  5490. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5491. } else {
  5492. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5493. clif_weather(sd->bl.m);
  5494. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5495. }
  5496. return 0;
  5497. }
  5498. /*==========================================
  5499. * Fog hangs over.
  5500. *------------------------------------------*/
  5501. ACMD_FUNC(fog)
  5502. {
  5503. nullpo_retr(-1, sd);
  5504. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5505. map_setmapflag(sd->bl.m, MF_FOG, false);
  5506. clif_weather(sd->bl.m);
  5507. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5508. } else {
  5509. map_setmapflag(sd->bl.m, MF_FOG, true);
  5510. clif_weather(sd->bl.m);
  5511. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5512. }
  5513. return 0;
  5514. }
  5515. /*==========================================
  5516. * Fallen leaves fall.
  5517. *------------------------------------------*/
  5518. ACMD_FUNC(leaves)
  5519. {
  5520. nullpo_retr(-1, sd);
  5521. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5522. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5523. clif_weather(sd->bl.m);
  5524. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5525. } else {
  5526. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5527. clif_weather(sd->bl.m);
  5528. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5529. }
  5530. return 0;
  5531. }
  5532. /*==========================================
  5533. * Fireworks appear.
  5534. *------------------------------------------*/
  5535. ACMD_FUNC(fireworks)
  5536. {
  5537. nullpo_retr(-1, sd);
  5538. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5539. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5540. clif_weather(sd->bl.m);
  5541. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5542. } else {
  5543. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5544. clif_weather(sd->bl.m);
  5545. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5546. }
  5547. return 0;
  5548. }
  5549. /*==========================================
  5550. * Clearing Weather Effects by Dexity
  5551. *------------------------------------------*/
  5552. ACMD_FUNC(clearweather)
  5553. {
  5554. nullpo_retr(-1, sd);
  5555. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  5556. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5557. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5558. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5559. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5560. map_setmapflag(sd->bl.m, MF_FOG, false);
  5561. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5562. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5563. clif_weather(sd->bl.m);
  5564. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5565. return 0;
  5566. }
  5567. /*===============================================================
  5568. * Sound Command - plays a sound for everyone around! [Codemaster]
  5569. *---------------------------------------------------------------*/
  5570. ACMD_FUNC(sound)
  5571. {
  5572. char sound_file[100];
  5573. memset(sound_file, '\0', sizeof(sound_file));
  5574. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5575. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5576. return -1;
  5577. }
  5578. if(strstr(sound_file, ".wav") == NULL)
  5579. strcat(sound_file, ".wav");
  5580. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5581. return 0;
  5582. }
  5583. /*==========================================
  5584. * MOB Search
  5585. *------------------------------------------*/
  5586. ACMD_FUNC(mobsearch)
  5587. {
  5588. char mob_name[100];
  5589. int mob_id;
  5590. int number = 0;
  5591. struct s_mapiterator* it;
  5592. nullpo_retr(-1, sd);
  5593. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5594. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5595. return -1;
  5596. }
  5597. if ((mob_id = atoi(mob_name)) == 0)
  5598. mob_id = mobdb_searchname(mob_name);
  5599. if( mobdb_checkid(mob_id) == 0){
  5600. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5601. clif_displaymessage(fd, atcmd_output);
  5602. return -1;
  5603. }
  5604. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5605. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5606. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5607. clif_displaymessage(fd, atcmd_output);
  5608. it = mapit_geteachmob();
  5609. for(;;)
  5610. {
  5611. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5612. if( md == NULL )
  5613. break;// no more mobs
  5614. if( md->bl.m != sd->bl.m )
  5615. continue;
  5616. if( md->mob_id != mob_id )
  5617. continue;
  5618. ++number;
  5619. if( md->spawn_timer == INVALID_TIMER )
  5620. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5621. else
  5622. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5623. clif_displaymessage(fd, atcmd_output);
  5624. }
  5625. mapit_free(it);
  5626. return 0;
  5627. }
  5628. /*==========================================
  5629. * @cleanmap - cleans items on the ground
  5630. * @cleanarea - cleans items on the ground within an specified area
  5631. *------------------------------------------*/
  5632. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5633. {
  5634. nullpo_ret(bl);
  5635. map_clearflooritem(bl);
  5636. return 0;
  5637. }
  5638. ACMD_FUNC(cleanmap)
  5639. {
  5640. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5641. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5642. return 0;
  5643. }
  5644. ACMD_FUNC(cleanarea)
  5645. {
  5646. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5647. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5648. 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);
  5649. }
  5650. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5651. 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);
  5652. }
  5653. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5654. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5655. }
  5656. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5657. return 0;
  5658. }
  5659. /*==========================================
  5660. * make a NPC/PET talk
  5661. * @npctalkc [SnakeDrak]
  5662. *------------------------------------------*/
  5663. ACMD_FUNC(npctalk)
  5664. {
  5665. char name[NPC_NAME_LENGTH],mes[100],temp[CHAT_SIZE_MAX];
  5666. struct npc_data *nd;
  5667. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5668. unsigned long color=0;
  5669. if (sd->sc.cant.chat)
  5670. return -1; //no "chatting" while muted.
  5671. if(!ifcolor) {
  5672. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5673. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5674. return -1;
  5675. }
  5676. }
  5677. else {
  5678. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5679. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5680. return -1;
  5681. }
  5682. }
  5683. if (!(nd = npc_name2id(name))) {
  5684. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5685. return -1;
  5686. }
  5687. strtok(name, "#"); // discard extra name identifier if present
  5688. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5689. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5690. else clif_disp_overhead(&nd->bl, temp);
  5691. return 0;
  5692. }
  5693. ACMD_FUNC(pettalk)
  5694. {
  5695. char mes[100],temp[CHAT_SIZE_MAX];
  5696. struct pet_data *pd;
  5697. nullpo_retr(-1, sd);
  5698. if ( battle_config.min_chat_delay ) {
  5699. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5700. return 0;
  5701. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5702. }
  5703. if(!sd->status.pet_id || !(pd=sd->pd))
  5704. {
  5705. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5706. return -1;
  5707. }
  5708. if (sd->sc.cant.chat)
  5709. return -1; //no "chatting" while muted.
  5710. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5711. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5712. return -1;
  5713. }
  5714. if (message[0] == '/')
  5715. {// pet emotion processing
  5716. const char* emo[] = {
  5717. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5718. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5719. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5720. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5721. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5722. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5723. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5724. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5725. "/whisp"
  5726. };
  5727. int i;
  5728. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5729. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5730. if( i < ARRAYLENGTH(emo) )
  5731. {
  5732. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5733. sd->emotionlasttime = time(NULL);
  5734. return 0;
  5735. }
  5736. sd->emotionlasttime = time(NULL);
  5737. clif_emotion(&pd->bl, i);
  5738. return 0;
  5739. }
  5740. }
  5741. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5742. clif_disp_overhead(&pd->bl, temp);
  5743. return 0;
  5744. }
  5745. /// @users - displays the number of players present on each map (and percentage)
  5746. /// #users displays on the target user instead of self
  5747. ACMD_FUNC(users)
  5748. {
  5749. char buf[CHAT_SIZE_MAX];
  5750. int i;
  5751. int users[MAX_MAPINDEX];
  5752. int users_all;
  5753. struct s_mapiterator* iter;
  5754. memset(users, 0, sizeof(users));
  5755. users_all = 0;
  5756. // count users on each map
  5757. iter = mapit_getallusers();
  5758. for(;;)
  5759. {
  5760. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5761. if( sd2 == NULL )
  5762. break;// no more users
  5763. if( sd2->mapindex >= MAX_MAPINDEX )
  5764. continue;// invalid mapindex
  5765. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5766. if( users_all < INT_MAX ) ++users_all;
  5767. }
  5768. mapit_free(iter);
  5769. // display results for each map
  5770. for( i = 0; i < MAX_MAPINDEX; ++i )
  5771. {
  5772. if( users[i] == 0 )
  5773. continue;// empty
  5774. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5775. clif_displaymessage(sd->fd, buf);
  5776. }
  5777. // display overall count
  5778. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5779. clif_displaymessage(sd->fd, buf);
  5780. return 0;
  5781. }
  5782. /*==========================================
  5783. *
  5784. *------------------------------------------*/
  5785. ACMD_FUNC(reset)
  5786. {
  5787. pc_resetstate(sd);
  5788. pc_resetskill(sd,1);
  5789. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5790. clif_displaymessage(fd, atcmd_output);
  5791. return 0;
  5792. }
  5793. /*==========================================
  5794. *
  5795. *------------------------------------------*/
  5796. ACMD_FUNC(summon)
  5797. {
  5798. char name[NAME_LENGTH];
  5799. int mob_id = 0;
  5800. int duration = 0;
  5801. struct mob_data *md;
  5802. t_tick tick=gettick();
  5803. nullpo_retr(-1, sd);
  5804. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5805. {
  5806. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5807. return -1;
  5808. }
  5809. if (duration < 1)
  5810. duration =1;
  5811. else if (duration > 60)
  5812. duration =60;
  5813. if ((mob_id = atoi(name)) == 0)
  5814. mob_id = mobdb_searchname(name);
  5815. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5816. {
  5817. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5818. return -1;
  5819. }
  5820. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5821. if(!md)
  5822. return -1;
  5823. md->master_id=sd->bl.id;
  5824. md->special_state.ai=AI_ATTACK;
  5825. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5826. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5827. mob_spawn(md);
  5828. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5829. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5830. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5831. return 0;
  5832. }
  5833. /*==========================================
  5834. * @adjgroup
  5835. * Temporarily move player to another group
  5836. * Useful during beta testing to allow players to use GM commands for short periods of time
  5837. *------------------------------------------*/
  5838. ACMD_FUNC(adjgroup)
  5839. {
  5840. int new_group = 0;
  5841. nullpo_retr(-1, sd);
  5842. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5843. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5844. return -1;
  5845. }
  5846. if (!pc_group_exists(new_group)) {
  5847. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5848. return -1;
  5849. }
  5850. sd->group_id = new_group;
  5851. pc_group_pc_load(sd);/* update cache */
  5852. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5853. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5854. return 0;
  5855. }
  5856. /*==========================================
  5857. * @trade by [MouseJstr]
  5858. * Open a trade window with a remote player
  5859. *------------------------------------------*/
  5860. ACMD_FUNC(trade)
  5861. {
  5862. struct map_session_data *pl_sd = NULL;
  5863. nullpo_retr(-1, sd);
  5864. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5865. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5866. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5867. return -1;
  5868. }
  5869. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5870. {
  5871. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5872. return -1;
  5873. }
  5874. trade_traderequest(sd, pl_sd);
  5875. return 0;
  5876. }
  5877. /*==========================================
  5878. * @setbattleflag by [MouseJstr]
  5879. * set a battle_config flag without having to reboot
  5880. *------------------------------------------*/
  5881. ACMD_FUNC(setbattleflag)
  5882. {
  5883. char flag[128], value[128];
  5884. int reload = 0;
  5885. nullpo_retr(-1, sd);
  5886. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5887. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5888. return -1;
  5889. }
  5890. if (battle_set_value(flag, value) == 0)
  5891. {
  5892. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5893. return -1;
  5894. }
  5895. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5896. if (reload)
  5897. mob_reload();
  5898. return 0;
  5899. }
  5900. /*==========================================
  5901. * @unmute [Valaris]
  5902. *------------------------------------------*/
  5903. ACMD_FUNC(unmute)
  5904. {
  5905. struct map_session_data *pl_sd = NULL;
  5906. nullpo_retr(-1, sd);
  5907. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5908. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5909. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5910. return -1;
  5911. }
  5912. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5913. {
  5914. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5915. return -1;
  5916. }
  5917. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5918. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5919. return -1;
  5920. }
  5921. pl_sd->status.manner = 0;
  5922. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5923. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5924. return 0;
  5925. }
  5926. /*==========================================
  5927. * @uptime by MC Cameri
  5928. *------------------------------------------*/
  5929. ACMD_FUNC(uptime)
  5930. {
  5931. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5932. minute = 60, days = 0, hours = 0, minutes = 0;
  5933. nullpo_retr(-1, sd);
  5934. seconds = get_uptime();
  5935. days = seconds/day;
  5936. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5937. hours = seconds/hour;
  5938. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5939. minutes = seconds/minute;
  5940. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5941. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  5942. clif_displaymessage(fd, atcmd_output);
  5943. return 0;
  5944. }
  5945. /*==========================================
  5946. * @changesex
  5947. * => Changes one's account sex. Switch from male to female or visversa
  5948. *------------------------------------------*/
  5949. ACMD_FUNC(changesex)
  5950. {
  5951. int i;
  5952. nullpo_retr(-1, sd);
  5953. pc_resetskill(sd,4);
  5954. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5955. for (i = 0; i < EQI_MAX; i++) {
  5956. if (sd->equip_index[i] >= 0)
  5957. pc_unequipitem(sd, sd->equip_index[i], 3);
  5958. }
  5959. chrif_changesex(sd, true);
  5960. return 0;
  5961. }
  5962. /*==========================================
  5963. * @changecharsex
  5964. * => Changes one's character sex. Switch from male to female or visversa.
  5965. *------------------------------------------*/
  5966. ACMD_FUNC(changecharsex)
  5967. {
  5968. int i;
  5969. nullpo_retr(-1, sd);
  5970. pc_resetskill(sd,4);
  5971. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5972. for (i = 0; i < EQI_MAX; i++) {
  5973. if (sd->equip_index[i] >= 0)
  5974. pc_unequipitem(sd, sd->equip_index[i], 3);
  5975. }
  5976. chrif_changesex(sd, false);
  5977. return 0;
  5978. }
  5979. /*================================================
  5980. * @mute - Mutes a player for a set amount of time
  5981. *------------------------------------------------*/
  5982. ACMD_FUNC(mute)
  5983. {
  5984. struct map_session_data *pl_sd = NULL;
  5985. int manner;
  5986. nullpo_retr(-1, sd);
  5987. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5988. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5989. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5990. return -1;
  5991. }
  5992. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5993. {
  5994. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5995. return -1;
  5996. }
  5997. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5998. {
  5999. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6000. return -1;
  6001. }
  6002. clif_manner_message(sd, 0);
  6003. clif_manner_message(pl_sd, 5);
  6004. if( pl_sd->status.manner < manner ) {
  6005. pl_sd->status.manner -= manner;
  6006. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6007. } else {
  6008. pl_sd->status.manner = 0;
  6009. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6010. }
  6011. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6012. return 0;
  6013. }
  6014. /*==========================================
  6015. * @refresh (like @jumpto <<yourself>>)
  6016. *------------------------------------------*/
  6017. ACMD_FUNC(refresh)
  6018. {
  6019. nullpo_retr(-1, sd);
  6020. clif_refresh(sd);
  6021. return 0;
  6022. }
  6023. ACMD_FUNC(refreshall)
  6024. {
  6025. struct map_session_data* iter_sd;
  6026. struct s_mapiterator* iter;
  6027. nullpo_retr(-1, sd);
  6028. iter = mapit_getallusers();
  6029. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6030. clif_refresh(iter_sd);
  6031. mapit_free(iter);
  6032. return 0;
  6033. }
  6034. /*==========================================
  6035. * @identify
  6036. * => GM's magnifier.
  6037. *------------------------------------------*/
  6038. ACMD_FUNC(identify)
  6039. {
  6040. int i,num;
  6041. nullpo_retr(-1, sd);
  6042. for(i=num=0;i<MAX_INVENTORY;i++){
  6043. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6044. num++;
  6045. }
  6046. }
  6047. if (num > 0) {
  6048. clif_item_identify_list(sd);
  6049. } else {
  6050. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6051. }
  6052. return 0;
  6053. }
  6054. /*===============================================
  6055. * @identifyall
  6056. * => Indentify all items in inventory - Akinari
  6057. *-----------------------------------------------*/
  6058. ACMD_FUNC(identifyall)
  6059. {
  6060. nullpo_retr(-1, sd);
  6061. pc_identifyall(sd, true);
  6062. return 0;
  6063. }
  6064. /*==========================================
  6065. * @gmotd (Global MOTD)
  6066. * by davidsiaw :P
  6067. *------------------------------------------*/
  6068. ACMD_FUNC(gmotd)
  6069. {
  6070. FILE* fp;
  6071. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6072. {
  6073. char buf[CHAT_SIZE_MAX];
  6074. size_t len;
  6075. while( fgets(buf, sizeof(buf), fp) )
  6076. {
  6077. if( buf[0] == '/' && buf[1] == '/' )
  6078. {
  6079. continue;
  6080. }
  6081. len = strlen(buf);
  6082. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6083. {// strip trailing EOL characters
  6084. len--;
  6085. }
  6086. if( len )
  6087. {
  6088. buf[len] = 0;
  6089. intif_broadcast(buf, len+1, 0);
  6090. }
  6091. }
  6092. fclose(fp);
  6093. }
  6094. return 0;
  6095. }
  6096. ACMD_FUNC(misceffect)
  6097. {
  6098. int effect = 0;
  6099. nullpo_retr(-1, sd);
  6100. if (!message || !*message)
  6101. return -1;
  6102. if (sscanf(message, "%11d", &effect) < 1)
  6103. return -1;
  6104. clif_misceffect(&sd->bl,effect);
  6105. return 0;
  6106. }
  6107. /*==========================================
  6108. * MAIL SYSTEM
  6109. *------------------------------------------*/
  6110. ACMD_FUNC(mail)
  6111. {
  6112. nullpo_ret(sd);
  6113. mail_openmail(sd);
  6114. return 0;
  6115. }
  6116. /*==========================================
  6117. * Show Monster DB Info v 1.0
  6118. * originally by [Lupus]
  6119. *------------------------------------------*/
  6120. ACMD_FUNC(mobinfo)
  6121. {
  6122. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6123. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6124. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6125. char atcmd_output2[CHAT_SIZE_MAX];
  6126. struct item_data *item_data;
  6127. struct mob_db *mob;
  6128. uint16 mob_ids[MAX_SEARCH];
  6129. int count;
  6130. int i, k;
  6131. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6132. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6133. if (!message || !*message) {
  6134. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6135. return -1;
  6136. }
  6137. // If monster identifier/name argument is a name
  6138. if ((i = mobdb_checkid(atoi(message))))
  6139. {
  6140. mob_ids[0] = i;
  6141. count = 1;
  6142. } else
  6143. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6144. if (!count) {
  6145. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6146. return -1;
  6147. }
  6148. if (count >= MAX_SEARCH) {
  6149. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6150. clif_displaymessage(fd, atcmd_output);
  6151. count = MAX_SEARCH;
  6152. }
  6153. for (k = 0; k < count; k++) {
  6154. unsigned int j,base_exp,job_exp;
  6155. mob = mob_db(mob_ids[k]);
  6156. base_exp = mob->base_exp;
  6157. job_exp = mob->job_exp;
  6158. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6159. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6160. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6161. }
  6162. #ifdef RENEWAL_EXP
  6163. if( battle_config.atcommand_mobinfo_type ) {
  6164. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6165. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6166. }
  6167. #endif
  6168. // stats
  6169. if (mob->mexp)
  6170. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6171. else
  6172. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6173. clif_displaymessage(fd, atcmd_output);
  6174. 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:%u Job EXP:%u HIT:%d FLEE:%d
  6175. clif_displaymessage(fd, atcmd_output);
  6176. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6177. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6178. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6179. clif_displaymessage(fd, atcmd_output);
  6180. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6181. mob->status.batk + mob->status.rhw.atk, mob->status.batk + mob->status.rhw.atk2, mob->status.rhw.range,
  6182. mob->range2 , mob->range3, msize[mob->status.size],
  6183. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6184. clif_displaymessage(fd, atcmd_output);
  6185. // drops
  6186. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6187. strcpy(atcmd_output, " ");
  6188. j = 0;
  6189. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6190. int droprate;
  6191. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6192. continue;
  6193. droprate = mob->dropitem[i].p;
  6194. #ifdef RENEWAL_DROP
  6195. if( battle_config.atcommand_mobinfo_type ) {
  6196. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6197. if (droprate <= 0 && !battle_config.drop_rate0item)
  6198. droprate = 1;
  6199. }
  6200. #endif
  6201. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6202. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6203. if (item_data->slot)
  6204. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6205. else
  6206. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6207. strcat(atcmd_output, atcmd_output2);
  6208. if (++j % 3 == 0) {
  6209. clif_displaymessage(fd, atcmd_output);
  6210. strcpy(atcmd_output, " ");
  6211. }
  6212. }
  6213. if (j == 0)
  6214. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6215. else if (j % 3 != 0)
  6216. clif_displaymessage(fd, atcmd_output);
  6217. // mvp
  6218. if (mob->mexp) {
  6219. float mvppercent, mvpremain;
  6220. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6221. clif_displaymessage(fd, atcmd_output);
  6222. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6223. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6224. j = 0;
  6225. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6226. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6227. continue;
  6228. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6229. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6230. if(battle_config.item_drop_mvp_mode == 0) {
  6231. mvpremain -= mvppercent;
  6232. }
  6233. if (mvppercent > 0) {
  6234. j++;
  6235. if (j == 1) {
  6236. if (item_data->slot)
  6237. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6238. else
  6239. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6240. } else {
  6241. if (item_data->slot)
  6242. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6243. else
  6244. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6245. }
  6246. strcat(atcmd_output, atcmd_output2);
  6247. }
  6248. }
  6249. if (j == 0)
  6250. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6251. else
  6252. clif_displaymessage(fd, atcmd_output);
  6253. }
  6254. }
  6255. return 0;
  6256. }
  6257. /*=========================================
  6258. * @showmobs by KarLaeda
  6259. * => For 15 sec displays the mobs on minimap
  6260. *------------------------------------------*/
  6261. ACMD_FUNC(showmobs)
  6262. {
  6263. char mob_name[100];
  6264. int mob_id;
  6265. int number = 0;
  6266. struct s_mapiterator* it;
  6267. nullpo_retr(-1, sd);
  6268. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6269. return -1;
  6270. if((mob_id = atoi(mob_name)) == 0)
  6271. mob_id = mobdb_searchname(mob_name);
  6272. if(mobdb_checkid(mob_id) == 0){
  6273. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6274. clif_displaymessage(fd, atcmd_output);
  6275. return 0;
  6276. }
  6277. if(status_has_mode(&mob_db(mob_id)->status,MD_STATUS_IMMUNE) && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6278. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6279. return 0;
  6280. }
  6281. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname[0])
  6282. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6283. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6284. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6285. mob_name, mapindex_id2name(sd->mapindex));
  6286. clif_displaymessage(fd, atcmd_output);
  6287. it = mapit_geteachmob();
  6288. for(;;)
  6289. {
  6290. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6291. if( md == NULL )
  6292. break;// no more mobs
  6293. if( md->bl.m != sd->bl.m )
  6294. continue;
  6295. if( mob_id != -1 && md->mob_id != mob_id )
  6296. continue;
  6297. if( md->special_state.ai || md->master_id )
  6298. continue; // hide slaves and player summoned mobs
  6299. if( md->spawn_timer != INVALID_TIMER )
  6300. continue; // hide mobs waiting for respawn
  6301. ++number;
  6302. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6303. }
  6304. mapit_free(it);
  6305. return 0;
  6306. }
  6307. /*==========================================
  6308. * homunculus level up [orn]
  6309. *------------------------------------------*/
  6310. ACMD_FUNC(homlevel)
  6311. {
  6312. TBL_HOM * hd;
  6313. int level = 0, i = 0;
  6314. nullpo_retr(-1, sd);
  6315. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6316. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6317. return -1;
  6318. }
  6319. if ( !hom_is_active(sd->hd) ) {
  6320. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6321. return -1;
  6322. }
  6323. hd = sd->hd;
  6324. for (i = 1; i <= level && hd->exp_next; i++){
  6325. hd->homunculus.exp += hd->exp_next;
  6326. if( !hom_levelup(hd) )
  6327. break;
  6328. }
  6329. status_calc_homunculus(hd, SCO_NONE);
  6330. status_percent_heal(&hd->bl, 100, 100);
  6331. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6332. return 0;
  6333. }
  6334. /*==========================================
  6335. * homunculus evolution H [orn]
  6336. *------------------------------------------*/
  6337. ACMD_FUNC(homevolution)
  6338. {
  6339. nullpo_retr(-1, sd);
  6340. if ( !hom_is_active(sd->hd) ) {
  6341. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6342. return -1;
  6343. }
  6344. if ( !hom_evolution(sd->hd) ) {
  6345. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6346. return -1;
  6347. }
  6348. clif_homskillinfoblock(sd);
  6349. return 0;
  6350. }
  6351. ACMD_FUNC(hommutate)
  6352. {
  6353. int homun_id, m_class = 0, m_id;
  6354. nullpo_retr(-1, sd);
  6355. if (!hom_is_active(sd->hd)) {
  6356. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6357. return -1;
  6358. }
  6359. if (!message || !*message) {
  6360. homun_id = 6048 + (rnd() % 4);
  6361. } else {
  6362. homun_id = atoi(message);
  6363. }
  6364. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6365. m_id = hom_class2mapid(homun_id);
  6366. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6367. hom_mutate(sd->hd, homun_id);
  6368. } else {
  6369. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6370. }
  6371. return 0;
  6372. }
  6373. /*==========================================
  6374. * call choosen homunculus [orn]
  6375. *------------------------------------------*/
  6376. ACMD_FUNC(makehomun)
  6377. {
  6378. int homunid;
  6379. nullpo_retr(-1, sd);
  6380. if ( sd->status.hom_id ) {
  6381. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6382. return -1;
  6383. }
  6384. if (!message || !*message) {
  6385. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6386. return -1;
  6387. }
  6388. homunid = atoi(message);
  6389. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6390. {
  6391. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6392. return -1;
  6393. }
  6394. hom_create_request(sd,homunid);
  6395. return 0;
  6396. }
  6397. /*==========================================
  6398. * modify homunculus intimacy [orn]
  6399. *------------------------------------------*/
  6400. ACMD_FUNC(homfriendly)
  6401. {
  6402. int friendly = 0;
  6403. nullpo_retr(-1, sd);
  6404. if ( !hom_is_active(sd->hd) ) {
  6405. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6406. return -1;
  6407. }
  6408. if (!message || !*message) {
  6409. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6410. return -1;
  6411. }
  6412. friendly = atoi(message);
  6413. friendly = cap_value(friendly, 0, 1000);
  6414. sd->hd->homunculus.intimacy = friendly * 100 ;
  6415. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6416. return 0;
  6417. }
  6418. /*==========================================
  6419. * modify homunculus hunger [orn]
  6420. *------------------------------------------*/
  6421. ACMD_FUNC(homhungry)
  6422. {
  6423. int hungry = 0;
  6424. nullpo_retr(-1, sd);
  6425. if ( !hom_is_active(sd->hd) ) {
  6426. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6427. return -1;
  6428. }
  6429. if (!message || !*message) {
  6430. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6431. return -1;
  6432. }
  6433. hungry = atoi(message);
  6434. hungry = cap_value(hungry, 0, 100);
  6435. sd->hd->homunculus.hunger = hungry;
  6436. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6437. return 0;
  6438. }
  6439. /*==========================================
  6440. * make the homunculus speak [orn]
  6441. *------------------------------------------*/
  6442. ACMD_FUNC(homtalk)
  6443. {
  6444. char mes[100],temp[CHAT_SIZE_MAX];
  6445. nullpo_retr(-1, sd);
  6446. if ( battle_config.min_chat_delay ) {
  6447. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6448. return 0;
  6449. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6450. }
  6451. if (sd->sc.cant.chat)
  6452. return -1; //no "chatting" while muted.
  6453. if ( !hom_is_active(sd->hd) ) {
  6454. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6455. return -1;
  6456. }
  6457. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6458. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6459. return -1;
  6460. }
  6461. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6462. clif_disp_overhead(&sd->hd->bl, temp);
  6463. return 0;
  6464. }
  6465. /*==========================================
  6466. * Show homunculus stats
  6467. *------------------------------------------*/
  6468. ACMD_FUNC(hominfo)
  6469. {
  6470. struct homun_data *hd;
  6471. struct status_data *status;
  6472. nullpo_retr(-1, sd);
  6473. if ( !hom_is_active(sd->hd) ) {
  6474. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6475. return -1;
  6476. }
  6477. hd = sd->hd;
  6478. status = status_get_status_data(&hd->bl);
  6479. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6480. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6481. status->hp, status->max_hp, status->sp, status->max_sp);
  6482. clif_displaymessage(fd, atcmd_output);
  6483. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6484. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6485. clif_displaymessage(fd, atcmd_output);
  6486. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6487. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6488. clif_displaymessage(fd, atcmd_output);
  6489. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6490. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6491. status->str, status->agi, status->vit,
  6492. status->int_, status->dex, status->luk);
  6493. clif_displaymessage(fd, atcmd_output);
  6494. return 0;
  6495. }
  6496. ACMD_FUNC(homstats)
  6497. {
  6498. struct homun_data *hd;
  6499. struct s_homunculus_db *db;
  6500. struct s_homunculus *hom;
  6501. int lv, min, max, evo;
  6502. nullpo_retr(-1, sd);
  6503. if ( !hom_is_active(sd->hd) ) {
  6504. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6505. return -1;
  6506. }
  6507. hd = sd->hd;
  6508. hom = &hd->homunculus;
  6509. db = hd->homunculusDB;
  6510. lv = hom->level;
  6511. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6512. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6513. clif_displaymessage(fd, atcmd_output);
  6514. lv--; //Since the first increase is at level 2.
  6515. evo = (hom->class_ == db->evo_class);
  6516. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6517. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6518. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6519. clif_displaymessage(fd, atcmd_output);
  6520. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6521. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6522. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6523. clif_displaymessage(fd, atcmd_output);
  6524. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6525. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6526. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6527. clif_displaymessage(fd, atcmd_output);
  6528. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6529. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6530. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6531. clif_displaymessage(fd, atcmd_output);
  6532. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6533. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6534. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6535. clif_displaymessage(fd, atcmd_output);
  6536. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6537. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6538. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6539. clif_displaymessage(fd, atcmd_output);
  6540. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6541. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6542. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6543. clif_displaymessage(fd, atcmd_output);
  6544. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6545. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6546. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6547. clif_displaymessage(fd, atcmd_output);
  6548. return 0;
  6549. }
  6550. ACMD_FUNC(homshuffle)
  6551. {
  6552. nullpo_retr(-1, sd);
  6553. if(!sd->hd)
  6554. return -1; // nothing to do
  6555. if(!hom_shuffle(sd->hd))
  6556. return -1;
  6557. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6558. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6559. return 0;
  6560. }
  6561. /*==========================================
  6562. * Show Items DB Info v 1.0
  6563. * originally by [Lupus]
  6564. *------------------------------------------*/
  6565. ACMD_FUNC(iteminfo)
  6566. {
  6567. struct item_data *item_array[MAX_SEARCH];
  6568. int i, count = 1;
  6569. if (!message || !*message) {
  6570. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6571. return -1;
  6572. }
  6573. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6574. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6575. if (!count) {
  6576. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6577. return -1;
  6578. }
  6579. if (count == MAX_SEARCH) {
  6580. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6581. clif_displaymessage(fd, atcmd_output);
  6582. }
  6583. for (i = 0; i < count; i++) {
  6584. struct item_data * item_data = item_array[i];
  6585. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6586. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6587. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6588. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6589. );
  6590. clif_displaymessage(fd, atcmd_output);
  6591. 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
  6592. clif_displaymessage(fd, atcmd_output);
  6593. if (item_data->maxchance == -1) {
  6594. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6595. clif_displaymessage(fd, atcmd_output);
  6596. }
  6597. else if (!battle_config.atcommand_mobinfo_type) {
  6598. if (item_data->maxchance)
  6599. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6600. else
  6601. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6602. clif_displaymessage(fd, atcmd_output);
  6603. }
  6604. }
  6605. return 0;
  6606. }
  6607. /*==========================================
  6608. * Show who drops the item.
  6609. *------------------------------------------*/
  6610. ACMD_FUNC(whodrops)
  6611. {
  6612. struct item_data *item_data, *item_array[MAX_SEARCH];
  6613. int i,j, count = 1;
  6614. if (!message || !*message) {
  6615. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6616. return -1;
  6617. }
  6618. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6619. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6620. if (!count) {
  6621. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6622. return -1;
  6623. }
  6624. if (count == MAX_SEARCH) {
  6625. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6626. clif_displaymessage(fd, atcmd_output);
  6627. }
  6628. for (i = 0; i < count; i++) {
  6629. item_data = item_array[i];
  6630. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6631. clif_displaymessage(fd, atcmd_output);
  6632. if (item_data->mob[0].chance == 0) {
  6633. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6634. clif_displaymessage(fd, atcmd_output);
  6635. } else {
  6636. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6637. clif_displaymessage(fd, atcmd_output);
  6638. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6639. {
  6640. int dropchance = item_data->mob[j].chance;
  6641. #ifdef RENEWAL_DROP
  6642. if( battle_config.atcommand_mobinfo_type )
  6643. dropchance = dropchance * pc_level_penalty_mod(mob_db(item_data->mob[j].id)->lv - sd->status.base_level, mob_db(item_data->mob[j].id)->status.class_, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6644. #endif
  6645. if (pc_isvip(sd)) // Display item rate increase for VIP
  6646. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6647. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6648. clif_displaymessage(fd, atcmd_output);
  6649. }
  6650. }
  6651. }
  6652. return 0;
  6653. }
  6654. ACMD_FUNC(whereis)
  6655. {
  6656. uint16 mob_ids[MAX_SEARCH] = {0};
  6657. int count = 0;
  6658. if (!message || !*message) {
  6659. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6660. return -1;
  6661. }
  6662. int i_message = atoi(message);
  6663. if (mobdb_checkid(i_message)) {
  6664. // ID given
  6665. mob_ids[0] = i_message;
  6666. count = 1;
  6667. } else {
  6668. // Name given, get all monster associated whith this name
  6669. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6670. }
  6671. if (count <= 0) {
  6672. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6673. return -1;
  6674. }
  6675. if (count >= MAX_SEARCH) {
  6676. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6677. clif_displaymessage(fd, atcmd_output);
  6678. count = MAX_SEARCH;
  6679. }
  6680. for (int i = 0; i < count; i++) {
  6681. uint16 mob_id = mob_ids[i];
  6682. struct mob_db * mob = mob_db(mob_id);
  6683. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6684. clif_displaymessage(fd, atcmd_output);
  6685. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6686. if (spawns.size() <= 0) {
  6687. // This monster does not spawn normally.
  6688. clif_displaymessage(fd, msg_txt(sd,1290));
  6689. } else {
  6690. for(auto& spawn : spawns)
  6691. {
  6692. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6693. if (mapid < 0)
  6694. continue;
  6695. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  6696. clif_displaymessage(fd, atcmd_output);
  6697. }
  6698. }
  6699. }
  6700. return 0;
  6701. }
  6702. ACMD_FUNC(version)
  6703. {
  6704. pc_show_version(sd);
  6705. return 0;
  6706. }
  6707. /*==========================================
  6708. * @mutearea by MouseJstr
  6709. *------------------------------------------*/
  6710. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6711. {
  6712. int time, id;
  6713. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6714. if (pl_sd == NULL)
  6715. return 0;
  6716. id = va_arg(ap, int);
  6717. time = va_arg(ap, int);
  6718. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6719. pl_sd->status.manner -= time;
  6720. if (pl_sd->status.manner < 0)
  6721. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6722. else
  6723. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6724. }
  6725. return 0;
  6726. }
  6727. ACMD_FUNC(mutearea)
  6728. {
  6729. int time;
  6730. nullpo_ret(sd);
  6731. if (!message || !*message) {
  6732. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6733. return -1;
  6734. }
  6735. time = atoi(message);
  6736. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6737. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6738. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6739. return 0;
  6740. }
  6741. ACMD_FUNC(rates)
  6742. {
  6743. char buf[CHAT_SIZE_MAX];
  6744. nullpo_ret(sd);
  6745. memset(buf, '\0', sizeof(buf));
  6746. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6747. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6748. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6749. clif_displaymessage(fd, buf);
  6750. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6751. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6752. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6753. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6754. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6755. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6756. clif_displaymessage(fd, buf);
  6757. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6758. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6759. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6760. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6761. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6762. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6763. clif_displaymessage(fd, buf);
  6764. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6765. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6766. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6767. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6768. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6769. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6770. clif_displaymessage(fd, buf);
  6771. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6772. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6773. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6774. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6775. clif_displaymessage(fd, buf);
  6776. return 0;
  6777. }
  6778. /*==========================================
  6779. * @me by lordalfa
  6780. * => Displays the OUTPUT string on top of the Visible players Heads.
  6781. *------------------------------------------*/
  6782. ACMD_FUNC(me)
  6783. {
  6784. char tempmes[CHAT_SIZE_MAX];
  6785. nullpo_retr(-1, sd);
  6786. memset(tempmes, '\0', sizeof(tempmes));
  6787. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6788. if (sd->sc.cant.chat)
  6789. return -1; //no "chatting" while muted.
  6790. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6791. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6792. return -1;
  6793. }
  6794. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6795. clif_disp_overhead(&sd->bl, atcmd_output);
  6796. return 0;
  6797. }
  6798. /*==========================================
  6799. * @size
  6800. * => Resize your character sprite. [Valaris]
  6801. *------------------------------------------*/
  6802. ACMD_FUNC(size)
  6803. {
  6804. int size = SZ_SMALL;
  6805. nullpo_retr(-1, sd);
  6806. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6807. if(sd->state.size) {
  6808. sd->state.size = SZ_SMALL;
  6809. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6810. }
  6811. sd->state.size = size;
  6812. if( size == SZ_MEDIUM )
  6813. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6814. else if( size == SZ_BIG )
  6815. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6816. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6817. return 0;
  6818. }
  6819. ACMD_FUNC(sizeall)
  6820. {
  6821. int size;
  6822. struct map_session_data *pl_sd;
  6823. struct s_mapiterator* iter;
  6824. size = atoi(message);
  6825. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6826. iter = mapit_getallusers();
  6827. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6828. if( pl_sd->state.size != size ) {
  6829. if( pl_sd->state.size ) {
  6830. pl_sd->state.size = SZ_SMALL;
  6831. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6832. }
  6833. pl_sd->state.size = size;
  6834. if( size == SZ_MEDIUM )
  6835. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6836. else if( size == SZ_BIG )
  6837. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6838. }
  6839. }
  6840. mapit_free(iter);
  6841. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6842. return 0;
  6843. }
  6844. ACMD_FUNC(sizeguild)
  6845. {
  6846. int size = SZ_SMALL, i;
  6847. char guild[NAME_LENGTH];
  6848. struct map_session_data *pl_sd;
  6849. struct guild *g;
  6850. nullpo_retr(-1, sd);
  6851. memset(guild, '\0', sizeof(guild));
  6852. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6853. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6854. return -1;
  6855. }
  6856. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6857. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6858. return -1;
  6859. }
  6860. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6861. for( i = 0; i < g->max_member; i++ ) {
  6862. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6863. if( pl_sd->state.size ) {
  6864. pl_sd->state.size = SZ_SMALL;
  6865. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6866. }
  6867. pl_sd->state.size = size;
  6868. if( size == SZ_MEDIUM )
  6869. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6870. else if( size == SZ_BIG )
  6871. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6872. }
  6873. }
  6874. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6875. return 0;
  6876. }
  6877. /*==========================================
  6878. * @monsterignore
  6879. * => Makes monsters ignore you. [Valaris]
  6880. *------------------------------------------*/
  6881. ACMD_FUNC(monsterignore)
  6882. {
  6883. nullpo_retr(-1, sd);
  6884. if (!sd->state.monster_ignore) {
  6885. sd->state.monster_ignore = 1;
  6886. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6887. } else {
  6888. sd->state.monster_ignore = 0;
  6889. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6890. }
  6891. return 0;
  6892. }
  6893. /*==========================================
  6894. * @fakename
  6895. * => Gives your character a fake name. [Valaris]
  6896. *------------------------------------------*/
  6897. ACMD_FUNC(fakename)
  6898. {
  6899. nullpo_retr(-1, sd);
  6900. if( !message || !*message )
  6901. {
  6902. if( sd->fakename[0] )
  6903. {
  6904. sd->fakename[0] = '\0';
  6905. clif_name_area(&sd->bl);
  6906. if (sd->disguise)
  6907. clif_name_self(&sd->bl);
  6908. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6909. return 0;
  6910. }
  6911. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6912. return -1;
  6913. }
  6914. if( strlen(message) < 2 )
  6915. {
  6916. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6917. return -1;
  6918. }
  6919. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6920. clif_name_area(&sd->bl);
  6921. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6922. clif_name_self(&sd->bl);
  6923. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6924. return 0;
  6925. }
  6926. /*==========================================
  6927. * Ragnarok Resources
  6928. *------------------------------------------*/
  6929. ACMD_FUNC(mapflag) {
  6930. char flag_name[50];
  6931. short flag = 0, i, j;
  6932. std::string buf;
  6933. nullpo_retr(-1, sd);
  6934. memset(flag_name, '\0', sizeof(flag_name));
  6935. if (!message || !*message || (sscanf(message, "%49s %6hd", flag_name, &flag) < 1)) {
  6936. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6937. clif_displaymessage(sd->fd,"----------------------------------");
  6938. for( i = MF_MIN; i < MF_MAX; i++ ){
  6939. union u_mapflag_args args = {};
  6940. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  6941. clif_displaymessage(sd->fd, flag_name);
  6942. }
  6943. }
  6944. clif_displaymessage(sd->fd," ");
  6945. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6946. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6947. return 1;
  6948. }
  6949. // Check if the list of mapflags was requested
  6950. if( strcasecmp(flag_name,"available") ){
  6951. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6952. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  6953. if( mapflag != MF_INVALID ){
  6954. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  6955. MF_PVP_NIGHTMAREDROP,
  6956. MF_RESTRICTED,
  6957. MF_NOCOMMAND,
  6958. MF_BEXP,
  6959. MF_JEXP,
  6960. MF_BATTLEGROUND,
  6961. MF_SKILL_DAMAGE,
  6962. MF_SKILL_DURATION };
  6963. if (flag && std::find(disabled_mf.begin(), disabled_mf.end(), mapflag) != disabled_mf.end()) {
  6964. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  6965. clif_displaymessage(sd->fd,atcmd_output);
  6966. } else {
  6967. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  6968. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  6969. clif_displaymessage(sd->fd,atcmd_output);
  6970. }
  6971. return 0;
  6972. }else{
  6973. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  6974. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  6975. return 1;
  6976. }
  6977. }
  6978. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6979. clif_displaymessage(sd->fd,"----------------------------------");
  6980. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  6981. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  6982. buf.append(flag_name);
  6983. if( (i + 1) < MF_MAX )
  6984. buf.append(", ");
  6985. j++;
  6986. }
  6987. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  6988. clif_displaymessage(sd->fd, buf.c_str() );
  6989. buf.clear();
  6990. j = 0;
  6991. }
  6992. }
  6993. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6994. return 0;
  6995. }
  6996. /*===================================
  6997. * Remove some messages
  6998. *-----------------------------------*/
  6999. ACMD_FUNC(showexp)
  7000. {
  7001. if (sd->state.showexp) {
  7002. sd->state.showexp = 0;
  7003. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7004. return 0;
  7005. }
  7006. sd->state.showexp = 1;
  7007. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7008. return 0;
  7009. }
  7010. ACMD_FUNC(showzeny)
  7011. {
  7012. if (sd->state.showzeny) {
  7013. sd->state.showzeny = 0;
  7014. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7015. return 0;
  7016. }
  7017. sd->state.showzeny = 1;
  7018. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7019. return 0;
  7020. }
  7021. ACMD_FUNC(showdelay)
  7022. {
  7023. if (sd->state.showdelay) {
  7024. sd->state.showdelay = 0;
  7025. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7026. return 0;
  7027. }
  7028. sd->state.showdelay = 1;
  7029. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7030. return 0;
  7031. }
  7032. /*==========================================
  7033. * Duel organizing functions [LuzZza]
  7034. *
  7035. * @duel [limit|nick] - create a duel
  7036. * @invite <nick> - invite player
  7037. * @accept - accept invitation
  7038. * @reject - reject invitation
  7039. * @leave - leave duel
  7040. *------------------------------------------*/
  7041. ACMD_FUNC(invite)
  7042. {
  7043. unsigned int did = sd->duel_group;
  7044. struct map_session_data *target_sd = NULL;
  7045. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7046. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7047. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7048. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7049. clif_displaymessage(fd, atcmd_output);
  7050. return -1;
  7051. }
  7052. if(did == 0 || !duel_exist(did) ) {
  7053. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7054. return 0;
  7055. }
  7056. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7057. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7058. return 0;
  7059. }
  7060. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7061. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7062. return 0;
  7063. }
  7064. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7065. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7066. return 0;
  7067. }
  7068. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7069. {
  7070. 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.
  7071. clif_displaymessage(fd, atcmd_output);
  7072. return 0;
  7073. }
  7074. duel_invite(did, sd, target_sd);
  7075. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7076. return 0;
  7077. }
  7078. ACMD_FUNC(duel)
  7079. {
  7080. unsigned int maxpl = 0;
  7081. if(sd->duel_group > 0) {
  7082. duel_showinfo(sd->duel_group, sd);
  7083. return 0;
  7084. }
  7085. if(sd->duel_invite > 0) {
  7086. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7087. return 0;
  7088. }
  7089. if(!duel_checktime(sd)) {
  7090. char output[CHAT_SIZE_MAX];
  7091. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7092. clif_displaymessage(fd, output);
  7093. return 0;
  7094. }
  7095. if( message[0] ) {
  7096. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7097. if(maxpl < 2 || maxpl > 65535) {
  7098. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7099. return 0;
  7100. }
  7101. duel_create(sd, maxpl);
  7102. } else {
  7103. struct map_session_data *target_sd = NULL;
  7104. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7105. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7106. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7107. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7108. clif_displaymessage(fd, atcmd_output);
  7109. return -1;
  7110. }
  7111. target_sd = map_nick2sd(atcmd_player_name,true);
  7112. if(target_sd != NULL) {
  7113. unsigned int newduel;
  7114. if((newduel = duel_create(sd, 2)) != -1) {
  7115. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7116. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7117. return 0;
  7118. }
  7119. duel_invite(newduel, sd, target_sd);
  7120. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7121. }
  7122. } else {
  7123. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7124. return 0;
  7125. }
  7126. }
  7127. } else
  7128. duel_create(sd, 0);
  7129. return 0;
  7130. }
  7131. ACMD_FUNC(leave)
  7132. {
  7133. if(sd->duel_group <= 0) {
  7134. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7135. return 0;
  7136. }
  7137. duel_leave(sd->duel_group, sd);
  7138. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7139. return 0;
  7140. }
  7141. ACMD_FUNC(accept)
  7142. {
  7143. if(!duel_checktime(sd)) {
  7144. char output[CHAT_SIZE_MAX];
  7145. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7146. clif_displaymessage(fd, output);
  7147. return 0;
  7148. }
  7149. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7150. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7151. return 0;
  7152. }
  7153. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7154. {
  7155. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7156. return 0;
  7157. }
  7158. duel_accept(sd->duel_invite, sd);
  7159. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7160. return 0;
  7161. }
  7162. ACMD_FUNC(reject)
  7163. {
  7164. if(sd->duel_invite <= 0) {
  7165. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7166. return 0;
  7167. }
  7168. duel_reject(sd->duel_invite, sd);
  7169. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7170. return 0;
  7171. }
  7172. /*===================================
  7173. * Cash Points
  7174. *-----------------------------------*/
  7175. ACMD_FUNC(cash)
  7176. {
  7177. char output[128];
  7178. int value;
  7179. int ret=0;
  7180. nullpo_retr(-1, sd);
  7181. // Since there is no cashpoint update packet we need to force updating like this
  7182. if( sd->state.cashshop_open ){
  7183. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7184. return -1;
  7185. }
  7186. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7187. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7188. return -1;
  7189. }
  7190. parent_cmd = atcommand_checkalias(command+1);
  7191. if( !strcmpi(parent_cmd,"cash") )
  7192. {
  7193. if( value > 0 ) {
  7194. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7195. // If this option is set, the message is already sent by pc function
  7196. if( !battle_config.cashshop_show_points ){
  7197. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7198. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7199. }
  7200. }
  7201. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7202. } else {
  7203. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7204. value = -sd->cashPoints;
  7205. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7206. // If this option is set, the message is already sent by pc function
  7207. if( !battle_config.cashshop_show_points ){
  7208. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7209. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7210. }
  7211. }
  7212. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7213. }
  7214. }
  7215. else
  7216. { // @points
  7217. if( value > 0 ) {
  7218. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7219. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7220. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7221. }
  7222. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7223. } else {
  7224. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7225. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7226. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7227. }
  7228. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7229. }
  7230. }
  7231. return 0;
  7232. }
  7233. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7234. ACMD_FUNC(clone)
  7235. {
  7236. int x=0,y=0,flag=0,master=0,i=0;
  7237. struct map_session_data *pl_sd=NULL;
  7238. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7239. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7240. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7241. return 0;
  7242. }
  7243. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7244. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7245. return 0;
  7246. }
  7247. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7248. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7249. return 0;
  7250. }
  7251. parent_cmd = atcommand_checkalias(command+1);
  7252. if (strcmpi(parent_cmd, "clone") == 0)
  7253. flag = 1;
  7254. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7255. flag = 2;
  7256. if(pc_isdead(sd)){
  7257. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7258. return 0;
  7259. }
  7260. master = sd->bl.id;
  7261. if (battle_config.atc_slave_clone_limit
  7262. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7263. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7264. return 0;
  7265. }
  7266. }
  7267. do {
  7268. x = sd->bl.x + (rnd() % 10 - 5);
  7269. y = sd->bl.y + (rnd() % 10 - 5);
  7270. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7271. if (i >= 10) {
  7272. x = sd->bl.x;
  7273. y = sd->bl.y;
  7274. }
  7275. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7276. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7277. return 0;
  7278. }
  7279. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7280. return 0;
  7281. }
  7282. /*=====================================
  7283. * Autorejecting Invites/Deals [LuzZza]
  7284. * Usage: @noask
  7285. *-------------------------------------*/
  7286. ACMD_FUNC(noask)
  7287. {
  7288. if(sd->state.noask) {
  7289. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7290. sd->state.noask = 0;
  7291. } else {
  7292. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7293. sd->state.noask = 1;
  7294. }
  7295. return 0;
  7296. }
  7297. /*=====================================
  7298. * Send a @request message to all GMs of lowest_gm_level.
  7299. * Usage: @request <petition>
  7300. *-------------------------------------*/
  7301. ACMD_FUNC(request)
  7302. {
  7303. if (!message || !*message) {
  7304. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7305. return -1;
  7306. }
  7307. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7308. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7309. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7310. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7311. return 0;
  7312. }
  7313. /*==========================================
  7314. * Feel (SG save map) Reset [HiddenDragon]
  7315. *------------------------------------------*/
  7316. ACMD_FUNC(feelreset)
  7317. {
  7318. pc_resetfeel(sd);
  7319. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7320. return 0;
  7321. }
  7322. /*==========================================
  7323. * AUCTION SYSTEM
  7324. *------------------------------------------*/
  7325. ACMD_FUNC(auction)
  7326. {
  7327. nullpo_ret(sd);
  7328. if (!battle_config.feature_auction) {
  7329. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7330. return 0;
  7331. }
  7332. clif_Auction_openwindow(sd);
  7333. return 0;
  7334. }
  7335. /*==========================================
  7336. * Kill Steal Protection
  7337. *------------------------------------------*/
  7338. ACMD_FUNC(ksprotection)
  7339. {
  7340. nullpo_retr(-1,sd);
  7341. if( sd->state.noks ) {
  7342. sd->state.noks = 0;
  7343. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7344. }
  7345. else
  7346. {
  7347. if( !message || !*message || !strcmpi(message, "party") )
  7348. { // Default is Party
  7349. sd->state.noks = 2;
  7350. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7351. }
  7352. else if( !strcmpi(message, "self") )
  7353. {
  7354. sd->state.noks = 1;
  7355. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7356. }
  7357. else if( !strcmpi(message, "guild") )
  7358. {
  7359. sd->state.noks = 3;
  7360. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7361. }
  7362. else
  7363. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7364. }
  7365. return 0;
  7366. }
  7367. /*==========================================
  7368. * Map Kill Steal Protection Setting
  7369. *------------------------------------------*/
  7370. ACMD_FUNC(allowks)
  7371. {
  7372. nullpo_retr(-1,sd);
  7373. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7374. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7375. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7376. } else {
  7377. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7378. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7379. }
  7380. return 0;
  7381. }
  7382. ACMD_FUNC(resetstat)
  7383. {
  7384. nullpo_retr(-1, sd);
  7385. pc_resetstate(sd);
  7386. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7387. clif_displaymessage(fd, atcmd_output);
  7388. return 0;
  7389. }
  7390. ACMD_FUNC(resetskill)
  7391. {
  7392. nullpo_retr(-1,sd);
  7393. pc_resetskill(sd,1);
  7394. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7395. clif_displaymessage(fd, atcmd_output);
  7396. return 0;
  7397. }
  7398. /*==========================================
  7399. * #storagelist: Displays the items list of a player's storage.
  7400. * #cartlist: Displays contents of target's cart.
  7401. * #itemlist: Displays contents of target's inventory.
  7402. *------------------------------------------*/
  7403. ACMD_FUNC(itemlist)
  7404. {
  7405. int i, j, count, counter;
  7406. const char* location;
  7407. const struct item* items;
  7408. int size;
  7409. StringBuf buf;
  7410. nullpo_retr(-1, sd);
  7411. parent_cmd = atcommand_checkalias(command+1);
  7412. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7413. location = "storage";
  7414. items = sd->storage.u.items_storage;
  7415. size = sd->storage.max_amount;
  7416. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7417. location = "cart";
  7418. items = sd->cart.u.items_cart;
  7419. size = MAX_CART;
  7420. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7421. location = "inventory";
  7422. items = sd->inventory.u.items_inventory;
  7423. size = MAX_INVENTORY;
  7424. } else
  7425. return 1;
  7426. StringBuf_Init(&buf);
  7427. count = 0; // total slots occupied
  7428. counter = 0; // total items found
  7429. for( i = 0; i < size; ++i ) {
  7430. const struct item* it = &items[i];
  7431. struct item_data* itd;
  7432. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7433. continue;
  7434. counter += it->amount;
  7435. count++;
  7436. if( count == 1 ) {
  7437. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7438. clif_displaymessage(fd, StringBuf_Value(&buf));
  7439. StringBuf_Clear(&buf);
  7440. }
  7441. if( it->refine )
  7442. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7443. else
  7444. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7445. if( it->equip ) {
  7446. char equipstr[CHAT_SIZE_MAX];
  7447. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7448. if( it->equip&EQP_GARMENT )
  7449. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7450. if( it->equip&EQP_ACC_L )
  7451. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7452. if( it->equip&EQP_ARMOR )
  7453. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7454. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7455. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7456. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7457. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7458. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7459. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7460. if( it->equip&EQP_SHOES )
  7461. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7462. if( it->equip&EQP_ACC_R )
  7463. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7464. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7465. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7466. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7467. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7468. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7469. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7470. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7471. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7472. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7473. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7474. if( (it->equip&EQP_HELM) == EQP_HELM )
  7475. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7476. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7477. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7478. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7479. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7480. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7481. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7482. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7483. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7484. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7485. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7486. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7487. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7488. if( it->equip&EQP_COSTUME_GARMENT )
  7489. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7490. //if( it->equip&EQP_COSTUME_FLOOR )
  7491. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7492. if( it->equip&EQP_AMMO )
  7493. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7494. if( it->equip&EQP_SHADOW_ARMOR )
  7495. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7496. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7497. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7498. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7499. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7500. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7501. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7502. if( it->equip&EQP_SHADOW_SHOES )
  7503. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7504. if( it->equip&EQP_SHADOW_ACC_R )
  7505. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7506. if( it->equip&EQP_SHADOW_ACC_L )
  7507. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7508. // remove final ', '
  7509. equipstr[strlen(equipstr) - 2] = '\0';
  7510. StringBuf_AppendStr(&buf, equipstr);
  7511. }
  7512. clif_displaymessage(fd, StringBuf_Value(&buf));
  7513. StringBuf_Clear(&buf);
  7514. if( it->card[0] == CARD0_PET ) { // pet egg
  7515. if (it->card[3])
  7516. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7517. else
  7518. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7519. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7520. StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); // -> (crafted item, creator id: %u, star crumbs %d, element %d)
  7521. } else if(it->card[0] == CARD0_CREATE) { // created item
  7522. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7523. } else { // normal item
  7524. int counter2 = 0;
  7525. for( j = 0; j < itd->slot; ++j ) {
  7526. struct item_data* card;
  7527. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7528. continue;
  7529. counter2++;
  7530. if( counter2 == 1 )
  7531. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7532. if( counter2 != 1 )
  7533. StringBuf_AppendStr(&buf, ", ");
  7534. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7535. }
  7536. if( counter2 > 0 )
  7537. StringBuf_AppendStr(&buf, ")");
  7538. }
  7539. if( StringBuf_Length(&buf) > 0 )
  7540. clif_displaymessage(fd, StringBuf_Value(&buf));
  7541. StringBuf_Clear(&buf);
  7542. }
  7543. if( count == 0 )
  7544. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7545. else
  7546. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7547. clif_displaymessage(fd, StringBuf_Value(&buf));
  7548. StringBuf_Destroy(&buf);
  7549. return 0;
  7550. }
  7551. ACMD_FUNC(stats)
  7552. {
  7553. char job_jobname[100];
  7554. char output[CHAT_SIZE_MAX];
  7555. int i;
  7556. struct {
  7557. const char* format;
  7558. int value;
  7559. } output_table[] = {
  7560. { "Base Level - %d", 0 },
  7561. { NULL, 0 },
  7562. { "Hp - %d", 0 },
  7563. { "MaxHp - %d", 0 },
  7564. { "Sp - %d", 0 },
  7565. { "MaxSp - %d", 0 },
  7566. { "Str - %3d", 0 },
  7567. { "Agi - %3d", 0 },
  7568. { "Vit - %3d", 0 },
  7569. { "Int - %3d", 0 },
  7570. { "Dex - %3d", 0 },
  7571. { "Luk - %3d", 0 },
  7572. { "Zeny - %d", 0 },
  7573. { "Free SK Points - %d", 0 },
  7574. { "JobChangeLvl (2nd) - %d", 0 },
  7575. { "JobChangeLvl (3rd) - %d", 0 },
  7576. { NULL, 0 }
  7577. };
  7578. memset(job_jobname, '\0', sizeof(job_jobname));
  7579. memset(output, '\0', sizeof(output));
  7580. //direct array initialization with variables is not standard C compliant.
  7581. output_table[0].value = sd->status.base_level;
  7582. output_table[1].format = job_jobname;
  7583. output_table[1].value = sd->status.job_level;
  7584. output_table[2].value = sd->status.hp;
  7585. output_table[3].value = sd->status.max_hp;
  7586. output_table[4].value = sd->status.sp;
  7587. output_table[5].value = sd->status.max_sp;
  7588. output_table[6].value = sd->status.str;
  7589. output_table[7].value = sd->status.agi;
  7590. output_table[8].value = sd->status.vit;
  7591. output_table[9].value = sd->status.int_;
  7592. output_table[10].value = sd->status.dex;
  7593. output_table[11].value = sd->status.luk;
  7594. output_table[12].value = sd->status.zeny;
  7595. output_table[13].value = sd->status.skill_point;
  7596. output_table[14].value = sd->change_level_2nd;
  7597. output_table[15].value = sd->change_level_3rd;
  7598. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7599. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7600. clif_displaymessage(fd, output);
  7601. for (i = 0; output_table[i].format != NULL; i++) {
  7602. sprintf(output, output_table[i].format, output_table[i].value);
  7603. clif_displaymessage(fd, output);
  7604. }
  7605. return 0;
  7606. }
  7607. ACMD_FUNC(delitem)
  7608. {
  7609. char item_name[100];
  7610. unsigned short nameid;
  7611. int amount = 0, total, idx;
  7612. struct item_data* id;
  7613. nullpo_retr(-1, sd);
  7614. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7615. {
  7616. 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>).
  7617. return -1;
  7618. }
  7619. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7620. {
  7621. nameid = id->nameid;
  7622. }
  7623. else
  7624. {
  7625. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7626. return -1;
  7627. }
  7628. total = amount;
  7629. // delete items
  7630. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7631. {
  7632. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7633. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7634. {// delete pet
  7635. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7636. }
  7637. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7638. amount-= delamount;
  7639. }
  7640. // notify target
  7641. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7642. clif_displaymessage(sd->fd, atcmd_output);
  7643. // notify source
  7644. if( amount == total )
  7645. {
  7646. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7647. }
  7648. else if( amount )
  7649. {
  7650. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7651. clif_displaymessage(fd, atcmd_output);
  7652. }
  7653. else
  7654. {
  7655. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7656. clif_displaymessage(fd, atcmd_output);
  7657. }
  7658. return 0;
  7659. }
  7660. /*==========================================
  7661. * Custom Fonts
  7662. *------------------------------------------*/
  7663. ACMD_FUNC(font)
  7664. {
  7665. int font_id;
  7666. nullpo_retr(-1,sd);
  7667. font_id = atoi(message);
  7668. if( font_id == 0 ) {
  7669. if( sd->status.font ) {
  7670. sd->status.font = 0;
  7671. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7672. clif_font(sd);
  7673. } else {
  7674. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7675. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7676. }
  7677. } else if( font_id < 0 || font_id > 9 )
  7678. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7679. else if( font_id != sd->status.font ) {
  7680. sd->status.font = font_id;
  7681. clif_font(sd);
  7682. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7683. } else
  7684. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7685. return 0;
  7686. }
  7687. /*==========================================
  7688. * type: 1 = commands (@), 2 = charcommands (#)
  7689. *------------------------------------------*/
  7690. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7691. {
  7692. char line_buff[CHATBOX_SIZE];
  7693. char* cur = line_buff;
  7694. AtCommandInfo* cmd;
  7695. DBIterator *iter = db_iterator(atcommand_db);
  7696. int count = 0;
  7697. memset(line_buff,' ',CHATBOX_SIZE);
  7698. line_buff[CHATBOX_SIZE-1] = 0;
  7699. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7700. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7701. unsigned int slen = 0;
  7702. switch( type ) {
  7703. case COMMAND_CHARCOMMAND:
  7704. if( cmd->char_groups[sd->group_pos] == 0 )
  7705. continue;
  7706. break;
  7707. case COMMAND_ATCOMMAND:
  7708. if( cmd->at_groups[sd->group_pos] == 0 )
  7709. continue;
  7710. break;
  7711. default:
  7712. continue;
  7713. }
  7714. slen = strlen(cmd->command);
  7715. // flush the text buffer if this command won't fit into it
  7716. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7717. clif_displaymessage(fd,line_buff);
  7718. cur = line_buff;
  7719. memset(line_buff,' ',CHATBOX_SIZE);
  7720. line_buff[CHATBOX_SIZE-1] = 0;
  7721. }
  7722. memcpy(cur,cmd->command,slen);
  7723. cur += slen+(10-slen%10);
  7724. count++;
  7725. }
  7726. dbi_destroy(iter);
  7727. clif_displaymessage(fd,line_buff);
  7728. if ( atcmd_binding_count ) {
  7729. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7730. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7731. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7732. unsigned int slen = strlen(atcmd_binding[i]->command);
  7733. if ( count_bind == 0 ) {
  7734. cur = line_buff;
  7735. memset(line_buff,' ',CHATBOX_SIZE);
  7736. line_buff[CHATBOX_SIZE-1] = 0;
  7737. clif_displaymessage(fd, "-----------------");
  7738. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7739. }
  7740. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7741. clif_displaymessage(fd,line_buff);
  7742. cur = line_buff;
  7743. memset(line_buff,' ',CHATBOX_SIZE);
  7744. line_buff[CHATBOX_SIZE-1] = 0;
  7745. }
  7746. memcpy(cur,atcmd_binding[i]->command,slen);
  7747. cur += slen+(10-slen%10);
  7748. count_bind++;
  7749. }
  7750. }
  7751. if ( count_bind )
  7752. clif_displaymessage(fd,line_buff);// last one
  7753. count += count_bind;
  7754. }
  7755. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7756. clif_displaymessage(fd, atcmd_output);
  7757. return;
  7758. }
  7759. /*==========================================
  7760. * @commands Lists available @ commands to you
  7761. *------------------------------------------*/
  7762. ACMD_FUNC(commands)
  7763. {
  7764. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7765. return 0;
  7766. }
  7767. /*==========================================
  7768. * @charcommands Lists available # commands to you
  7769. *------------------------------------------*/
  7770. ACMD_FUNC(charcommands) {
  7771. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7772. return 0;
  7773. }
  7774. /* for new mounts */
  7775. ACMD_FUNC(mount2) {
  7776. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7777. if (!sd->sc.data[SC_ALL_RIDING]) {
  7778. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7779. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
  7780. } else {
  7781. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7782. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7783. }
  7784. return 0;
  7785. }
  7786. ACMD_FUNC(accinfo) {
  7787. char query[NAME_LENGTH];
  7788. char type = 0; // type = 1, get only account name
  7789. if (!message || !*message || strlen(message) > NAME_LENGTH
  7790. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7791. {
  7792. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7793. 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".
  7794. return -1;
  7795. } else if (type != 0) {
  7796. type = type-'0'; //make it int
  7797. if (type != 1) {
  7798. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7799. return -1;
  7800. }
  7801. }
  7802. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7803. return 0;
  7804. }
  7805. /**
  7806. * @set <variable name{[index]}>{ <value>}
  7807. *
  7808. * Gets or sets a value of a non server variable.
  7809. * If a value is specified it is used to set the variable's value,
  7810. * if not the variable's value is read.
  7811. * In any case it reads and displays the variable's value.
  7812. *
  7813. * Original implementation by Ind
  7814. */
  7815. ACMD_FUNC(set) {
  7816. char reg[46], val[128], name[32];
  7817. int toset = 0, len, index;
  7818. bool is_str = false;
  7819. int64 uid;
  7820. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7821. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7822. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7823. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7824. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7825. return -1;
  7826. }
  7827. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7828. if( reg[0] == '.' ) {
  7829. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7830. return -1;
  7831. } else if( reg[0] == '\'' ) {
  7832. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7833. return -1;
  7834. }
  7835. // Check if the user wanted to set an array
  7836. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7837. // The user did not specify array brackets, so we set the index to zero
  7838. index = 0;
  7839. }
  7840. is_str = is_string_variable(name);
  7841. if( ( len = strlen(val) ) > 1 ) {
  7842. if( val[0] == '"' && val[len-1] == '"') {
  7843. val[len-1] = '\0'; //Strip quotes.
  7844. memmove(val, val+1, len-1);
  7845. }
  7846. }
  7847. // Only set the variable if there is a value for it
  7848. if( toset >= 2 ){
  7849. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7850. }
  7851. uid = reference_uid( add_str( name ), index );
  7852. if( is_str ) {// string variable
  7853. char* value;
  7854. switch( reg[0] ) {
  7855. case '@':
  7856. value = pc_readregstr(sd, uid);
  7857. break;
  7858. case '$':
  7859. value = mapreg_readregstr(uid);
  7860. break;
  7861. case '#':
  7862. if( reg[1] == '#' )
  7863. value = pc_readaccountreg2str(sd, uid);// global
  7864. else
  7865. value = pc_readaccountregstr(sd, uid);// local
  7866. break;
  7867. default:
  7868. value = pc_readglobalreg_str(sd, uid);
  7869. break;
  7870. }
  7871. if( value == NULL || *value == '\0' ){// empty string
  7872. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7873. }else{
  7874. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7875. }
  7876. } else {// integer variable
  7877. int value;
  7878. switch( reg[0] ) {
  7879. case '@':
  7880. value = pc_readreg(sd, uid);
  7881. break;
  7882. case '$':
  7883. value = mapreg_readreg(uid);
  7884. break;
  7885. case '#':
  7886. if( reg[1] == '#' )
  7887. value = pc_readaccountreg2(sd, uid);// global
  7888. else
  7889. value = pc_readaccountreg(sd, uid);// local
  7890. break;
  7891. default:
  7892. value = pc_readglobalreg(sd, uid);
  7893. break;
  7894. }
  7895. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7896. }
  7897. clif_displaymessage(fd, atcmd_output);
  7898. return 0;
  7899. }
  7900. ACMD_FUNC(addperm) {
  7901. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7902. bool add;
  7903. int i;
  7904. parent_cmd = atcommand_checkalias(command+1);
  7905. add = (strcmpi(parent_cmd, "addperm") == 0);
  7906. if( !message || !*message ) {
  7907. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7908. clif_displaymessage(fd, atcmd_output);
  7909. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7910. for( i = 0; i < perm_size; i++ ) {
  7911. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7912. clif_displaymessage(fd, atcmd_output);
  7913. }
  7914. return -1;
  7915. }
  7916. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7917. if( i == perm_size ) {
  7918. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7919. clif_displaymessage(fd, atcmd_output);
  7920. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7921. for( i = 0; i < perm_size; i++ ) {
  7922. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7923. clif_displaymessage(fd, atcmd_output);
  7924. }
  7925. return -1;
  7926. }
  7927. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7928. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7929. clif_displaymessage(fd, atcmd_output);
  7930. return -1;
  7931. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7932. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7933. clif_displaymessage(fd, atcmd_output);
  7934. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7935. clif_displaymessage(fd, atcmd_output);
  7936. for( i = 0; i < perm_size; i++ ) {
  7937. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7938. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7939. clif_displaymessage(fd, atcmd_output);
  7940. }
  7941. }
  7942. return -1;
  7943. }
  7944. if( add )
  7945. sd->permissions |= pc_g_permission_name[i].permission;
  7946. else
  7947. sd->permissions &=~ pc_g_permission_name[i].permission;
  7948. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7949. clif_displaymessage(fd, atcmd_output);
  7950. return 0;
  7951. }
  7952. ACMD_FUNC(unloadnpcfile) {
  7953. if( !message || !*message ) {
  7954. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7955. return -1;
  7956. }
  7957. if( npc_unloadfile(message) )
  7958. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7959. else {
  7960. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7961. return -1;
  7962. }
  7963. return 0;
  7964. }
  7965. ACMD_FUNC(cart) {
  7966. #define MC_CART_MDFY(idx, x) \
  7967. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7968. sd->status.skill[(idx)].lv = (x)?1:0; \
  7969. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7970. int val = atoi(message);
  7971. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7972. uint16 sk_idx = 0;
  7973. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7974. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7975. clif_displaymessage(fd, atcmd_output);
  7976. return -1;
  7977. }
  7978. if( val == 0 && !pc_iscarton(sd) ) {
  7979. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7980. return -1;
  7981. }
  7982. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7983. return -1;
  7984. if( need_skill ) {
  7985. MC_CART_MDFY(sk_idx,1);
  7986. }
  7987. if( !pc_setcart(sd, val) ) {
  7988. if( need_skill ) {
  7989. MC_CART_MDFY(sk_idx,0);
  7990. }
  7991. return -1;/* @cart failed */
  7992. }
  7993. if( need_skill ) {
  7994. MC_CART_MDFY(sk_idx,0);
  7995. }
  7996. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7997. return 0;
  7998. #undef MC_CART_MDFY
  7999. }
  8000. /* Channel System [Ind] */
  8001. ACMD_FUNC(join){
  8002. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8003. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8004. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8005. clif_displaymessage(fd, atcmd_output);
  8006. return -1;
  8007. }
  8008. return channel_pcjoin(sd, chname, pass);
  8009. }
  8010. /*
  8011. * Display available option for @channel command
  8012. * @command : the name of used command (for alias case)
  8013. */
  8014. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8015. {
  8016. int fd = sd->fd;
  8017. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8018. bool can_create = (can_delete || channel_config.private_channel.allow);
  8019. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8020. //option create
  8021. if( can_create ) {
  8022. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8023. clif_displaymessage(fd, atcmd_output);
  8024. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8025. }
  8026. //option delete
  8027. if(can_delete){
  8028. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8029. clif_displaymessage(fd, atcmd_output);
  8030. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8031. }
  8032. //option list
  8033. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8034. clif_displaymessage(fd, atcmd_output);
  8035. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8036. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8037. clif_displaymessage(fd, atcmd_output);
  8038. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8039. if( can_create ) {
  8040. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8041. clif_displaymessage(fd, atcmd_output);
  8042. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8043. }
  8044. //option setcolor
  8045. if(can_create){
  8046. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8047. clif_displaymessage(fd, atcmd_output);
  8048. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8049. }
  8050. //option join
  8051. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8052. clif_displaymessage(fd, atcmd_output);
  8053. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8054. //option leave
  8055. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8056. clif_displaymessage(fd, atcmd_output);
  8057. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8058. //option bindto
  8059. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8060. clif_displaymessage(fd, atcmd_output);
  8061. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8062. //option unbind
  8063. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8064. clif_displaymessage(fd, atcmd_output);
  8065. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8066. //option ban/unban/banlist
  8067. if( can_create ) {
  8068. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8069. clif_displaymessage(fd, atcmd_output);
  8070. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8071. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8072. clif_displaymessage(fd, atcmd_output);
  8073. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8074. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8075. clif_displaymessage(fd, atcmd_output);
  8076. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8077. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8078. clif_displaymessage(fd, atcmd_output);
  8079. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8080. }
  8081. //option setopt
  8082. if(can_create){
  8083. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8084. clif_displaymessage(fd, atcmd_output);
  8085. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8086. }
  8087. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8088. clif_displaymessage(fd, atcmd_output);
  8089. }
  8090. ACMD_FUNC(channel) {
  8091. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8092. sub1[0] = sub2[0] = '\0';
  8093. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8094. atcmd_channel_help(sd,command);
  8095. return 0;
  8096. }
  8097. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8098. return channel_pcdelete(sd,sub1);
  8099. } else if ( strcmpi(key,"list") == 0 ) {
  8100. return channel_display_list(sd,sub1);
  8101. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8102. return channel_pccolor(sd, sub1, sub2);
  8103. } else if ( strcmpi(key,"join") == 0 ) {
  8104. return channel_pcjoin(sd, sub1, sub2);
  8105. }else if ( strcmpi(key,"leave") == 0 ) {
  8106. return channel_pcleave(sd, sub1);
  8107. } else if ( strcmpi(key,"bindto") == 0 ) {
  8108. return channel_pcbind(sd, sub1);
  8109. } else if ( strcmpi(key,"unbind") == 0 ) {
  8110. return channel_pcunbind(sd);
  8111. } else if ( strcmpi(key,"ban") == 0 ) {
  8112. return channel_pcban(sd,sub1,sub2,0);
  8113. } else if ( strcmpi(key,"kick") == 0 ) {
  8114. return channel_pckick(sd,sub1,sub2);
  8115. } else if ( strcmpi(key,"banlist") == 0 ) {
  8116. return channel_pcban(sd,sub1,NULL,3);
  8117. } else if ( strcmpi(key,"unban") == 0 ) {
  8118. return channel_pcban(sd,sub1,sub2,1);
  8119. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8120. return channel_pcban(sd,sub1,NULL,2);
  8121. } else {
  8122. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8123. sub3[0] = sub4[0] = '\0';
  8124. sscanf(sub2, "%19s %19s", sub3, sub4);
  8125. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8126. if (sub4[0] != '\0') {
  8127. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8128. return -1;
  8129. }
  8130. return channel_pccreate(sd,sub1,sub3);
  8131. } else if ( strcmpi(key,"setopt") == 0 ) {
  8132. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8133. }
  8134. atcmd_channel_help(sd,command);
  8135. }
  8136. return 0;
  8137. }
  8138. ACMD_FUNC(fontcolor)
  8139. {
  8140. if( !message || !*message ) {
  8141. channel_display_list(sd,"colors");
  8142. return -1;
  8143. }
  8144. if( strcmpi(message,"Normal") == 0 ) {
  8145. sd->fontcolor = 0;
  8146. } else {
  8147. unsigned char k;
  8148. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8149. if( k == channel_config.colors_count ) {
  8150. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8151. clif_displaymessage(fd, atcmd_output);
  8152. return -1;
  8153. }
  8154. sd->fontcolor = k;
  8155. }
  8156. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8157. clif_displaymessage(fd, atcmd_output);
  8158. return 0;
  8159. }
  8160. ACMD_FUNC(langtype)
  8161. {
  8162. char langstr[8];
  8163. int i=0, fail=0;
  8164. memset(langstr, '\0', sizeof(langstr));
  8165. if(sscanf(message, "%3s", langstr) >= 1){
  8166. int lang=0;
  8167. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8168. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8169. char output[100];
  8170. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8171. sd->langtype = lang;
  8172. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8173. clif_displaymessage(fd,output);
  8174. return 0;
  8175. } else if (lang != -1) { //defined langage but failed check
  8176. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8177. return -1;
  8178. }
  8179. }
  8180. //wrong or no entry
  8181. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8182. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8183. while(fail != -1){ //out of range
  8184. fail = msg_checklangtype(i,false);
  8185. if(fail == 1)
  8186. clif_displaymessage(fd,msg_langtype2langstr(i));
  8187. i++;
  8188. }
  8189. return -1;
  8190. }
  8191. #ifdef VIP_ENABLE
  8192. ACMD_FUNC(vip) {
  8193. struct map_session_data *pl_sd = NULL;
  8194. char * modif_p;
  8195. int32 vipdifftime = 0;
  8196. time_t now=time(NULL);
  8197. nullpo_retr(-1, sd);
  8198. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8199. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8200. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8201. return -1;
  8202. }
  8203. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8204. modif_p = atcmd_output;
  8205. vipdifftime = (int32)solve_time(modif_p);
  8206. if (vipdifftime == 0) {
  8207. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8208. 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.
  8209. return -1;
  8210. }
  8211. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8212. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8213. return -1;
  8214. }
  8215. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8216. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8217. return -1;
  8218. }
  8219. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8220. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8221. if (pl_sd->vip.time <= now) {
  8222. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8223. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8224. } else {
  8225. int year,month,day,hour,minute,second;
  8226. char timestr[21];
  8227. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8228. sprintf(atcmd_output,msg_txt(pl_sd,705),year,month,day,hour,minute); // Your VIP status is valid for %d years, %d months, %d days, %d hours and %d minutes.
  8229. clif_displaymessage(pl_sd->fd,atcmd_output);
  8230. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8231. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8232. clif_displaymessage(pl_sd->fd,atcmd_output);
  8233. if (pl_sd != sd) {
  8234. sprintf(atcmd_output,msg_txt(sd,706),pl_sd->status.name,year,month,day,hour,minute); // Player '%s' is now VIP for %d years, %d months, %d days, %d hours and %d minutes.
  8235. clif_displaymessage(fd,atcmd_output);
  8236. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8237. clif_displaymessage(fd,atcmd_output);
  8238. }
  8239. }
  8240. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8241. return 0;
  8242. }
  8243. /** Enable/disable rate info */
  8244. ACMD_FUNC(showrate) {
  8245. nullpo_retr(-1,sd);
  8246. if (!sd->vip.disableshowrate) {
  8247. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8248. sd->vip.disableshowrate = 1;
  8249. } else {
  8250. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8251. sd->vip.disableshowrate = 0;
  8252. }
  8253. clif_displaymessage(fd,atcmd_output);
  8254. return 0;
  8255. }
  8256. #endif
  8257. ACMD_FUNC(fullstrip) {
  8258. int i;
  8259. TBL_PC *tsd;
  8260. nullpo_retr(-1,sd);
  8261. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8262. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8263. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8264. return -1;
  8265. }
  8266. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8267. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8268. return -1;
  8269. }
  8270. for( i = 0; i < EQI_MAX; i++ ) {
  8271. if( tsd->equip_index[ i ] >= 0 )
  8272. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8273. }
  8274. return 0;
  8275. }
  8276. ACMD_FUNC(changedress){
  8277. sc_type name2id[] = {
  8278. SC_WEDDING,
  8279. SC_XMAS,
  8280. SC_SUMMER,
  8281. SC_DRESSUP,
  8282. SC_HANBOK,
  8283. SC_OKTOBERFEST
  8284. };
  8285. for( sc_type type : name2id ) {
  8286. if( sd->sc.data[type] ) {
  8287. status_change_end( &sd->bl, type, INVALID_TIMER );
  8288. // You should only be able to have one - so we cancel here
  8289. break;
  8290. }
  8291. }
  8292. return 0;
  8293. }
  8294. ACMD_FUNC(costume) {
  8295. const char* names[] = {
  8296. "Wedding",
  8297. "Xmas",
  8298. "Summer",
  8299. "Summer2",
  8300. "Hanbok",
  8301. "Oktoberfest"
  8302. };
  8303. const int name2id[] = {
  8304. SC_WEDDING,
  8305. SC_XMAS,
  8306. SC_SUMMER,
  8307. SC_DRESSUP,
  8308. SC_HANBOK,
  8309. SC_OKTOBERFEST
  8310. };
  8311. unsigned short k = 0, len = ARRAYLENGTH(names);
  8312. if( !message || !*message ) {
  8313. for( k = 0; k < len; k++ ) {
  8314. if( sd->sc.data[name2id[k]] ) {
  8315. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8316. clif_displaymessage(sd->fd, atcmd_output);
  8317. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8318. return 0;
  8319. }
  8320. }
  8321. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8322. for( k = 0; k < len; k++ ) {
  8323. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8324. clif_displaymessage(sd->fd, atcmd_output);
  8325. }
  8326. return -1;
  8327. }
  8328. for( k = 0; k < len; k++ ) {
  8329. if( sd->sc.data[name2id[k]] ) {
  8330. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8331. clif_displaymessage(sd->fd, atcmd_output);
  8332. return -1;
  8333. }
  8334. }
  8335. for( k = 0; k < len; k++ )
  8336. if( strcmpi(message, names[k]) == 0 )
  8337. break;
  8338. if( k == len ) {
  8339. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8340. clif_displaymessage(sd->fd, atcmd_output);
  8341. return -1;
  8342. }
  8343. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, INFINITE_TICK);
  8344. return 0;
  8345. }
  8346. /**
  8347. * Clone other player's equipments
  8348. * Usage: @cloneequip <char name/ID>
  8349. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8350. * @author [Cydh], [Antares]
  8351. */
  8352. ACMD_FUNC(cloneequip) {
  8353. struct map_session_data *pl_sd;
  8354. nullpo_retr(-1, sd);
  8355. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8356. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8357. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8358. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8359. clif_displaymessage(fd, atcmd_output);
  8360. return -1;
  8361. }
  8362. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8363. clif_displaymessage(fd, msg_txt(sd, 3));
  8364. return -1;
  8365. }
  8366. if (sd == pl_sd) {
  8367. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8368. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8369. clif_displaymessage(fd, atcmd_output);
  8370. return -1;
  8371. }
  8372. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8373. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8374. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8375. clif_displaymessage(fd, atcmd_output);
  8376. return -1;
  8377. }
  8378. else {
  8379. int8 i;
  8380. for (i = 0; i < EQI_MAX; i++) {
  8381. short idx;
  8382. char flag = 0;
  8383. struct item tmp_item;
  8384. if ((idx = pl_sd->equip_index[i]) < 0)
  8385. continue;
  8386. if (i == EQI_AMMO)
  8387. continue;
  8388. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8389. continue;
  8390. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8391. if (itemdb_isspecial(tmp_item.card[0]))
  8392. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8393. tmp_item.bound = 0;
  8394. tmp_item.expire_time = 0;
  8395. tmp_item.unique_id = 0;
  8396. tmp_item.favorite = 0;
  8397. tmp_item.amount = 1;
  8398. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8399. clif_additem(sd, 0, 0, flag);
  8400. else
  8401. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8402. }
  8403. }
  8404. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8405. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8406. clif_displaymessage(fd, atcmd_output);
  8407. return 0;
  8408. }
  8409. /**
  8410. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8411. * Usage: @clonestat <char name/ID>
  8412. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8413. * @author [Cydh], [Antares]
  8414. */
  8415. ACMD_FUNC(clonestat) {
  8416. struct map_session_data *pl_sd;
  8417. nullpo_retr(-1, sd);
  8418. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8419. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8420. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8421. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8422. clif_displaymessage(fd, atcmd_output);
  8423. return -1;
  8424. }
  8425. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8426. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8427. return -1;
  8428. }
  8429. if (sd == pl_sd) {
  8430. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8431. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8432. clif_displaymessage(fd, atcmd_output);
  8433. return -1;
  8434. }
  8435. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8436. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8437. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8438. clif_displaymessage(fd, atcmd_output);
  8439. return -1;
  8440. }
  8441. else {
  8442. uint8 i;
  8443. short max_status[6];
  8444. pc_resetstate(sd);
  8445. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8446. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8447. else {
  8448. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8449. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8450. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8451. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8452. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8453. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8454. }
  8455. #define clonestat_check(cmd,stat)\
  8456. {\
  8457. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8458. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8459. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8460. clif_displaymessage(fd, atcmd_output);\
  8461. sd->status.cmd = max_status[(stat)];\
  8462. }\
  8463. else\
  8464. sd->status.cmd = pl_sd->status.cmd;\
  8465. }
  8466. clonestat_check(str, PARAM_STR);
  8467. clonestat_check(agi, PARAM_AGI);
  8468. clonestat_check(vit, PARAM_VIT);
  8469. clonestat_check(int_, PARAM_INT);
  8470. clonestat_check(dex, PARAM_DEX);
  8471. clonestat_check(luk, PARAM_LUK);
  8472. for (i = 0; i < PARAM_MAX; i++) {
  8473. clif_updatestatus(sd, SP_STR + i);
  8474. clif_updatestatus(sd, SP_USTR + i);
  8475. }
  8476. status_calc_pc(sd, SCO_FORCE);
  8477. }
  8478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8479. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8480. clif_displaymessage(fd, atcmd_output);
  8481. #undef clonestat_check
  8482. return 0;
  8483. }
  8484. /**
  8485. * Adopt a character.
  8486. * Usage: @adopt <char name>
  8487. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8488. */
  8489. ACMD_FUNC(adopt)
  8490. {
  8491. TBL_PC *b_sd;
  8492. enum adopt_responses response;
  8493. nullpo_retr(-1, sd);
  8494. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8495. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8496. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8497. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8498. clif_displaymessage(fd, atcmd_output);
  8499. return -1;
  8500. }
  8501. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8502. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8503. return -1;
  8504. }
  8505. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8506. if (response == ADOPT_ALLOWED) {
  8507. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8508. b_sd->adopt_invite = sd->status.account_id;
  8509. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8510. return 0;
  8511. }
  8512. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8513. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8514. return -1;
  8515. }
  8516. /**
  8517. * Opens the limited sale window.
  8518. * Usage: @limitedsale or client command /limitedsale on supported clients
  8519. */
  8520. ACMD_FUNC(limitedsale){
  8521. nullpo_retr(-1, sd);
  8522. clif_sale_open(sd);
  8523. return 0;
  8524. }
  8525. /**
  8526. * Displays camera information from the client.
  8527. * Usage: @camerainfo or client command /viewpointvalue or /setcamera on supported clients
  8528. */
  8529. ACMD_FUNC(camerainfo){
  8530. nullpo_retr(-1, sd);
  8531. if( message == nullptr || message[0] == '\0' ){
  8532. clif_camerainfo( sd, true );
  8533. return 0;
  8534. }
  8535. float range = 0;
  8536. float rotation = 0;
  8537. float latitude = 0;
  8538. if( sscanf( message, "%f %f %f", &range, &rotation, &latitude ) < 3 ){
  8539. clif_displaymessage( fd, msg_txt( sd, 793 ) ); // Usage @camerainfo range rotation latitude
  8540. return -1;
  8541. }
  8542. clif_camerainfo( sd, false, range, rotation, latitude );
  8543. return 0;
  8544. }
  8545. #include "../custom/atcommand.inc"
  8546. /**
  8547. * Fills the reference of available commands in atcommand DBMap
  8548. **/
  8549. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8550. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8551. // Define with restriction
  8552. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8553. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8554. void atcommand_basecommands(void) {
  8555. /**
  8556. * Command reference list, place the base of your commands here
  8557. * TODO: List all commands that causing crash
  8558. **/
  8559. AtCommandInfo atcommand_base[] = {
  8560. #include "../custom/atcommand_def.inc"
  8561. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8562. ACMD_DEF(where),
  8563. ACMD_DEF(jumpto),
  8564. ACMD_DEF(jump),
  8565. ACMD_DEF(who),
  8566. ACMD_DEF2("who2", who),
  8567. ACMD_DEF2("who3", who),
  8568. ACMD_DEF2("whomap", who),
  8569. ACMD_DEF2("whomap2", who),
  8570. ACMD_DEF2("whomap3", who),
  8571. ACMD_DEF(whogm),
  8572. ACMD_DEF(save),
  8573. ACMD_DEF(load),
  8574. ACMD_DEF(speed),
  8575. ACMD_DEF(storage),
  8576. ACMD_DEF(guildstorage),
  8577. ACMD_DEF(option),
  8578. ACMD_DEF(hide), // + /hide
  8579. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8580. ACMD_DEF(kill),
  8581. ACMD_DEF(alive),
  8582. ACMD_DEF(kami),
  8583. ACMD_DEF2("kamib", kami),
  8584. ACMD_DEF2("kamic", kami),
  8585. ACMD_DEF2("lkami", kami),
  8586. ACMD_DEF(heal),
  8587. ACMD_DEF(item),
  8588. ACMD_DEF(item2),
  8589. ACMD_DEF2("itembound",item),
  8590. ACMD_DEF2("itembound2",item2),
  8591. ACMD_DEF(itemreset),
  8592. ACMD_DEF(clearstorage),
  8593. ACMD_DEF(cleargstorage),
  8594. ACMD_DEF(clearcart),
  8595. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8596. ACMD_DEF2("jlvl", joblevelup),
  8597. ACMD_DEF(help),
  8598. ACMD_DEF(pvpoff),
  8599. ACMD_DEF(pvpon),
  8600. ACMD_DEF(gvgoff),
  8601. ACMD_DEF(gvgon),
  8602. ACMD_DEF(model),
  8603. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8604. ACMD_DEF(monster),
  8605. ACMD_DEF2("monstersmall", monster),
  8606. ACMD_DEF2("monsterbig", monster),
  8607. ACMD_DEF(killmonster),
  8608. ACMD_DEF2("killmonster2", killmonster),
  8609. ACMD_DEF(refine),
  8610. ACMD_DEF(produce),
  8611. ACMD_DEF(memo),
  8612. ACMD_DEF(gat),
  8613. ACMD_DEF(displaystatus),
  8614. ACMD_DEF2("stpoint", statuspoint),
  8615. ACMD_DEF2("skpoint", skillpoint),
  8616. ACMD_DEF(zeny),
  8617. ACMD_DEF2("str", param),
  8618. ACMD_DEF2("agi", param),
  8619. ACMD_DEF2("vit", param),
  8620. ACMD_DEF2("int", param),
  8621. ACMD_DEF2("dex", param),
  8622. ACMD_DEF2("luk", param),
  8623. ACMD_DEF2("glvl", guildlevelup),
  8624. ACMD_DEF(makeegg),
  8625. ACMD_DEF(hatch),
  8626. ACMD_DEF(petfriendly),
  8627. ACMD_DEF(pethungry),
  8628. ACMD_DEF(petrename),
  8629. ACMD_DEF(recall), // + /recall
  8630. ACMD_DEF(night),
  8631. ACMD_DEF(day),
  8632. ACMD_DEF(doom),
  8633. ACMD_DEF(doommap),
  8634. ACMD_DEF(raise),
  8635. ACMD_DEF(raisemap),
  8636. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8637. ACMD_DEF(kickall),
  8638. ACMD_DEF(allskill),
  8639. ACMD_DEF(questskill),
  8640. ACMD_DEF(lostskill),
  8641. ACMD_DEF(spiritball),
  8642. ACMD_DEF(party),
  8643. ACMD_DEF(guild),
  8644. ACMD_DEF(breakguild),
  8645. ACMD_DEF(agitstart),
  8646. ACMD_DEF(agitend),
  8647. ACMD_DEF(mapexit),
  8648. ACMD_DEF(idsearch),
  8649. ACMD_DEF(broadcast), // + /b and /nb
  8650. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8651. ACMD_DEF(recallall),
  8652. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8653. ACMD_DEF2("reloaditemdb", reload),
  8654. ACMD_DEF2("reloadmobdb", reload),
  8655. ACMD_DEF2("reloadskilldb", reload),
  8656. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8657. ACMD_DEF2("reloadatcommand", reload),
  8658. ACMD_DEF2("reloadbattleconf", reload),
  8659. ACMD_DEF2("reloadstatusdb", reload),
  8660. ACMD_DEF2("reloadpcdb", reload),
  8661. ACMD_DEF2("reloadmotd", reload),
  8662. ACMD_DEF2("reloadquestdb", reload),
  8663. ACMD_DEF2("reloadmsgconf", reload),
  8664. ACMD_DEF2("reloadinstancedb", reload),
  8665. ACMD_DEF2("reloadachievementdb",reload),
  8666. ACMD_DEF(partysharelvl),
  8667. ACMD_DEF(mapinfo),
  8668. ACMD_DEF(dye),
  8669. ACMD_DEF2("hairstyle", hair_style),
  8670. ACMD_DEF2("haircolor", hair_color),
  8671. ACMD_DEF2("allstats", stat_all),
  8672. ACMD_DEF2("block", char_block),
  8673. ACMD_DEF2("ban", char_ban),
  8674. ACMD_DEF2("unblock", char_unblock),
  8675. ACMD_DEF2("unban", char_unban),
  8676. ACMD_DEF2("charban", char_ban),
  8677. ACMD_DEF2("charunban", char_unban),
  8678. ACMD_DEF2("mount", mount_peco),
  8679. ACMD_DEF(guildspy),
  8680. ACMD_DEF(partyspy),
  8681. ACMD_DEF(clanspy),
  8682. ACMD_DEF(repairall),
  8683. ACMD_DEF(guildrecall),
  8684. ACMD_DEF(partyrecall),
  8685. ACMD_DEF(nuke),
  8686. ACMD_DEF(shownpc),
  8687. ACMD_DEF(hidenpc),
  8688. ACMD_DEF(loadnpc),
  8689. ACMD_DEF(unloadnpc),
  8690. ACMD_DEF(reloadnpcfile),
  8691. ACMD_DEF2("time", servertime),
  8692. ACMD_DEF(jail),
  8693. ACMD_DEF(unjail),
  8694. ACMD_DEF(jailfor),
  8695. ACMD_DEF(jailtime),
  8696. ACMD_DEF(disguise),
  8697. ACMD_DEF(undisguise),
  8698. ACMD_DEF(email),
  8699. ACMD_DEF(effect),
  8700. ACMD_DEF(follow),
  8701. ACMD_DEF(addwarp),
  8702. ACMD_DEF(skillon),
  8703. ACMD_DEF(skilloff),
  8704. ACMD_DEF(killer),
  8705. ACMD_DEF(npcmove),
  8706. ACMD_DEF(killable),
  8707. ACMD_DEF(dropall),
  8708. ACMD_DEF(storeall),
  8709. ACMD_DEF(skillid),
  8710. ACMD_DEF(useskill),
  8711. ACMD_DEF(displayskill),
  8712. ACMD_DEF(snow),
  8713. ACMD_DEF(sakura),
  8714. ACMD_DEF(clouds),
  8715. ACMD_DEF(clouds2),
  8716. ACMD_DEF(fog),
  8717. ACMD_DEF(fireworks),
  8718. ACMD_DEF(leaves),
  8719. ACMD_DEF(summon),
  8720. ACMD_DEF(adjgroup),
  8721. ACMD_DEF(trade),
  8722. ACMD_DEF(send),
  8723. ACMD_DEF(setbattleflag),
  8724. ACMD_DEF(unmute),
  8725. ACMD_DEF(clearweather),
  8726. ACMD_DEF(uptime),
  8727. ACMD_DEF(changesex),
  8728. ACMD_DEF(changecharsex),
  8729. ACMD_DEF(mute),
  8730. ACMD_DEF(refresh),
  8731. ACMD_DEF(refreshall),
  8732. ACMD_DEF(identify),
  8733. ACMD_DEF(identifyall),
  8734. ACMD_DEF(gmotd),
  8735. ACMD_DEF(misceffect),
  8736. ACMD_DEF(mobsearch),
  8737. ACMD_DEF(cleanmap),
  8738. ACMD_DEF(cleanarea),
  8739. ACMD_DEF(npctalk),
  8740. ACMD_DEF(pettalk),
  8741. ACMD_DEF(users),
  8742. ACMD_DEF(reset),
  8743. ACMD_DEF(skilltree),
  8744. ACMD_DEF(marry),
  8745. ACMD_DEF(divorce),
  8746. ACMD_DEF(sound),
  8747. ACMD_DEF(undisguiseall),
  8748. ACMD_DEF(disguiseall),
  8749. ACMD_DEF(changelook),
  8750. ACMD_DEF(autoloot),
  8751. ACMD_DEF2("alootid", autolootitem),
  8752. ACMD_DEF(autoloottype),
  8753. ACMD_DEF(mobinfo),
  8754. ACMD_DEF(exp),
  8755. ACMD_DEF(version),
  8756. ACMD_DEF(mutearea),
  8757. ACMD_DEF(rates),
  8758. ACMD_DEF(iteminfo),
  8759. ACMD_DEF(whodrops),
  8760. ACMD_DEF(whereis),
  8761. ACMD_DEF(mapflag),
  8762. ACMD_DEF(me),
  8763. ACMD_DEF(monsterignore),
  8764. ACMD_DEF(fakename),
  8765. ACMD_DEF(size),
  8766. ACMD_DEF(showexp),
  8767. ACMD_DEF(showzeny),
  8768. ACMD_DEF(showdelay),
  8769. ACMD_DEF(autotrade),
  8770. ACMD_DEF(changegm),
  8771. ACMD_DEF(changeleader),
  8772. ACMD_DEF(partyoption),
  8773. ACMD_DEF(invite),
  8774. ACMD_DEF(duel),
  8775. ACMD_DEF(leave),
  8776. ACMD_DEF(accept),
  8777. ACMD_DEF(reject),
  8778. ACMD_DEF(clone),
  8779. ACMD_DEF2("slaveclone", clone),
  8780. ACMD_DEF2("evilclone", clone),
  8781. ACMD_DEF(tonpc),
  8782. ACMD_DEF(commands),
  8783. ACMD_DEF(noask),
  8784. ACMD_DEF(request),
  8785. ACMD_DEF(homlevel),
  8786. ACMD_DEF(homevolution),
  8787. ACMD_DEF(hommutate),
  8788. ACMD_DEF(makehomun),
  8789. ACMD_DEF(homfriendly),
  8790. ACMD_DEF(homhungry),
  8791. ACMD_DEF(homtalk),
  8792. ACMD_DEF(hominfo),
  8793. ACMD_DEF(homstats),
  8794. ACMD_DEF(homshuffle),
  8795. ACMD_DEF(showmobs),
  8796. ACMD_DEF(feelreset),
  8797. ACMD_DEF(auction),
  8798. ACMD_DEF(mail),
  8799. ACMD_DEF2("noks", ksprotection),
  8800. ACMD_DEF(allowks),
  8801. ACMD_DEF(cash),
  8802. ACMD_DEF2("points", cash),
  8803. ACMD_DEF(agitstart2),
  8804. ACMD_DEF(agitend2),
  8805. ACMD_DEF(resetskill),
  8806. ACMD_DEF(resetstat),
  8807. ACMD_DEF2("storagelist", itemlist),
  8808. ACMD_DEF2("cartlist", itemlist),
  8809. ACMD_DEF2("itemlist", itemlist),
  8810. ACMD_DEF(stats),
  8811. ACMD_DEF(delitem),
  8812. ACMD_DEF(charcommands),
  8813. ACMD_DEF(font),
  8814. ACMD_DEF(accinfo),
  8815. ACMD_DEF(set),
  8816. ACMD_DEF(undisguiseguild),
  8817. ACMD_DEF(disguiseguild),
  8818. ACMD_DEF(sizeall),
  8819. ACMD_DEF(sizeguild),
  8820. ACMD_DEF(addperm),
  8821. ACMD_DEF2("rmvperm", addperm),
  8822. ACMD_DEF(unloadnpcfile),
  8823. ACMD_DEF(cart),
  8824. ACMD_DEF(mount2),
  8825. ACMD_DEF(join),
  8826. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8827. ACMD_DEF(fontcolor),
  8828. ACMD_DEF(langtype),
  8829. #ifdef VIP_ENABLE
  8830. ACMD_DEF(vip),
  8831. ACMD_DEF(showrate),
  8832. #endif
  8833. ACMD_DEF(fullstrip),
  8834. ACMD_DEF(costume),
  8835. ACMD_DEF(cloneequip),
  8836. ACMD_DEF(clonestat),
  8837. ACMD_DEF(bodystyle),
  8838. ACMD_DEF(adopt),
  8839. ACMD_DEF(agitstart3),
  8840. ACMD_DEF(agitend3),
  8841. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8842. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8843. ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8844. };
  8845. AtCommandInfo* atcommand;
  8846. int i;
  8847. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8848. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8849. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8850. continue;
  8851. }
  8852. CREATE(atcommand, AtCommandInfo, 1);
  8853. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8854. atcommand->func = atcommand_base[i].func;
  8855. atcommand->restriction = atcommand_base[i].restriction;
  8856. strdb_put(atcommand_db, atcommand->command, atcommand);
  8857. }
  8858. return;
  8859. }
  8860. /*==========================================
  8861. * Command lookup functions
  8862. *------------------------------------------*/
  8863. bool atcommand_exists(const char* name)
  8864. {
  8865. return strdb_exists(atcommand_db, name);
  8866. }
  8867. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8868. {
  8869. if (strdb_exists(atcommand_db, name))
  8870. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8871. return NULL;
  8872. }
  8873. static const char* atcommand_checkalias(const char *aliasname)
  8874. {
  8875. AliasInfo *alias_info = NULL;
  8876. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8877. return alias_info->command->command;
  8878. return aliasname;
  8879. }
  8880. /// AtCommand suggestion
  8881. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8882. DBIterator* atcommand_iter;
  8883. DBIterator* alias_iter;
  8884. AtCommandInfo* command_info = NULL;
  8885. AliasInfo* alias_info = NULL;
  8886. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8887. char* full_match[MAX_SUGGESTIONS];
  8888. char* suggestions[MAX_SUGGESTIONS];
  8889. char* match;
  8890. int prefix_count = 0, full_count = 0;
  8891. bool can_use;
  8892. if (!battle_config.atcommand_suggestions_enabled)
  8893. return;
  8894. atcommand_iter = db_iterator(atcommand_db);
  8895. alias_iter = db_iterator(atcommand_alias_db);
  8896. // Build the matches
  8897. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8898. match = strstr(command_info->command, name);
  8899. can_use = pc_can_use_command(sd, command_info->command, type);
  8900. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8901. suggestions[prefix_count] = command_info->command;
  8902. ++prefix_count;
  8903. }
  8904. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8905. full_match[full_count] = command_info->command;
  8906. ++full_count;
  8907. }
  8908. }
  8909. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8910. match = strstr(alias_info->alias, name);
  8911. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8912. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8913. suggestions[prefix_count] = alias_info->alias;
  8914. ++prefix_count;
  8915. }
  8916. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8917. full_match[full_count] = alias_info->alias;
  8918. ++full_count;
  8919. }
  8920. }
  8921. if ((full_count+prefix_count) > 0) {
  8922. char buffer[512];
  8923. int i;
  8924. // Merge full match and prefix match results
  8925. if (prefix_count < MAX_SUGGESTIONS) {
  8926. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8927. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8928. }
  8929. // Build the suggestion string
  8930. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  8931. strcat(buffer,"\n");
  8932. for(i=0; i < prefix_count; ++i) {
  8933. strcat(buffer,suggestions[i]);
  8934. strcat(buffer," ");
  8935. }
  8936. clif_displaymessage(sd->fd, buffer);
  8937. }
  8938. dbi_destroy(atcommand_iter);
  8939. dbi_destroy(alias_iter);
  8940. }
  8941. /**
  8942. * Executes an at-command
  8943. * @param fd
  8944. * @param sd
  8945. * @param message
  8946. * @param type
  8947. * 0 : script call (atcommand)
  8948. * 1 : normal player @atcommand
  8949. * 2 : console (admin:@atcommand)
  8950. * 3 : script call (useatcmd)
  8951. */
  8952. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8953. {
  8954. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8955. char output[CHAT_SIZE_MAX];
  8956. //Reconstructed message
  8957. char atcmd_msg[CHAT_SIZE_MAX * 2];
  8958. TBL_PC * ssd = NULL; //sd for target
  8959. AtCommandInfo * info;
  8960. bool is_atcommand = true; // false if it's a charcommand
  8961. nullpo_retr(false, sd);
  8962. //Shouldn't happen
  8963. if ( !message || !*message )
  8964. return false;
  8965. //If cannot use atcomamnd while talking with NPC [Kichi]
  8966. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8967. return false;
  8968. //Block NOCHAT but do not display it as a normal message
  8969. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8970. return true;
  8971. // skip 10/11-langtype's codepage indicator, if detected
  8972. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8973. message += 3;
  8974. //Should display as a normal message
  8975. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8976. return false;
  8977. // type value 0|2 = script|console invoked: bypass restrictions
  8978. if ( type == 1 || type == 3) {
  8979. //Commands are disabled on maps flagged as 'nocommand'
  8980. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  8981. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  8982. return false;
  8983. }
  8984. }
  8985. if (*message == charcommand_symbol)
  8986. is_atcommand = false;
  8987. if (is_atcommand) { // @command
  8988. sprintf(atcmd_msg, "%s", message);
  8989. ssd = sd;
  8990. } else { // #command
  8991. char charname[NAME_LENGTH];
  8992. int n;
  8993. //Checks to see if #command has a name or a name + parameters.
  8994. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8995. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8996. ) {
  8997. if (pc_get_group_level(sd) == 0) {
  8998. if (n < 1)
  8999. return false; // No command found. Display as normal message.
  9000. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9001. if (!info || info->char_groups[sd->group_pos] == 0) // If we can't use or doesn't exist: don't even display the command failed message
  9002. return false;
  9003. }
  9004. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  9005. clif_displaymessage(fd, output);
  9006. return true;
  9007. }
  9008. ssd = map_nick2sd(charname,true);
  9009. if (ssd == NULL) {
  9010. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  9011. clif_displaymessage(fd, output);
  9012. return true;
  9013. }
  9014. if (n > 2)
  9015. sprintf(atcmd_msg, "%s %s", command, params);
  9016. else
  9017. sprintf(atcmd_msg, "%s", command);
  9018. }
  9019. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9020. sd->idletime = last_tick;
  9021. //Clearing these to be used once more.
  9022. memset(command, '\0', sizeof(command));
  9023. memset(params, '\0', sizeof(params));
  9024. //check to see if any params exist within this command
  9025. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9026. params[0] = '\0';
  9027. // @commands (script based)
  9028. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9029. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9030. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9031. if( binding != NULL && binding->npc_event[0] &&
  9032. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9033. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9034. {
  9035. // Check if self or character invoking; if self == character invoked, then self invoke.
  9036. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9037. return true;
  9038. }
  9039. }
  9040. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9041. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9042. if (info == NULL) {
  9043. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9044. return false;
  9045. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9046. clif_displaymessage(fd, output);
  9047. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9048. return true;
  9049. }
  9050. //check restriction
  9051. if (info->restriction) {
  9052. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9053. return true;
  9054. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9055. return true;
  9056. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9057. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9058. return true;
  9059. }
  9060. // type == 1 : player invoked
  9061. if (type == 1) {
  9062. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9063. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9064. return false;
  9065. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9066. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9067. return true;
  9068. }
  9069. }
  9070. //Attempt to use the command
  9071. if ( (info->func(fd, ssd, command, params) != 0) )
  9072. {
  9073. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9074. clif_displaymessage(fd, output);
  9075. return true;
  9076. }
  9077. //Log only if successful.
  9078. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9079. return true;
  9080. }
  9081. /*==========================================
  9082. *
  9083. *------------------------------------------*/
  9084. static void atcommand_config_read(const char* config_filename)
  9085. {
  9086. config_setting_t *aliases = NULL, *help = NULL;
  9087. const char *symbol = NULL;
  9088. int num_aliases = 0;
  9089. if (conf_read_file(&atcommand_config, config_filename))
  9090. return;
  9091. // Command symbols
  9092. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9093. if (ISPRINT(*symbol) && // no control characters
  9094. *symbol != '/' && // symbol of client commands
  9095. *symbol != '%' && // symbol of party chat
  9096. *symbol != '$' && // symbol of guild chat
  9097. *symbol != charcommand_symbol)
  9098. atcommand_symbol = *symbol;
  9099. }
  9100. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9101. if (ISPRINT(*symbol) && // no control characters
  9102. *symbol != '/' && // symbol of client commands
  9103. *symbol != '%' && // symbol of party chat
  9104. *symbol != '$' && // symbol of guild chat
  9105. *symbol != atcommand_symbol)
  9106. charcommand_symbol = *symbol;
  9107. }
  9108. // Command aliases
  9109. aliases = config_lookup(&atcommand_config, "aliases");
  9110. if (aliases != NULL) {
  9111. int i = 0;
  9112. int count = config_setting_length(aliases);
  9113. for (i = 0; i < count; ++i) {
  9114. config_setting_t *command;
  9115. const char *commandname = NULL;
  9116. int j = 0, alias_count = 0;
  9117. AtCommandInfo *commandinfo = NULL;
  9118. command = config_setting_get_elem(aliases, i);
  9119. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9120. continue;
  9121. commandname = config_setting_name(command);
  9122. if (!atcommand_exists(commandname)) {
  9123. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9124. continue;
  9125. }
  9126. commandinfo = get_atcommandinfo_byname(commandname);
  9127. alias_count = config_setting_length(command);
  9128. for (j = 0; j < alias_count; ++j) {
  9129. const char *alias = config_setting_get_string_elem(command, j);
  9130. if (alias != NULL) {
  9131. AliasInfo *alias_info;
  9132. if (strdb_exists(atcommand_alias_db, alias)) {
  9133. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9134. continue;
  9135. }
  9136. CREATE(alias_info, AliasInfo, 1);
  9137. alias_info->command = commandinfo;
  9138. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9139. strdb_put(atcommand_alias_db, alias, alias_info);
  9140. ++num_aliases;
  9141. }
  9142. }
  9143. }
  9144. }
  9145. // Commands help
  9146. // We only check if all commands exist
  9147. help = config_lookup(&atcommand_config, "help");
  9148. if (help != NULL) {
  9149. int count = config_setting_length(help);
  9150. int i;
  9151. for (i = 0; i < count; ++i) {
  9152. config_setting_t *command;
  9153. const char *commandname;
  9154. command = config_setting_get_elem(help, i);
  9155. commandname = config_setting_name(command);
  9156. if (!atcommand_exists(commandname))
  9157. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9158. }
  9159. }
  9160. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' command aliases in '" CL_WHITE "%s" CL_RESET "'.\n", num_aliases, config_filename);
  9161. return;
  9162. }
  9163. void atcommand_db_load_groups(int* group_ids) {
  9164. DBIterator *iter = db_iterator(atcommand_db);
  9165. AtCommandInfo* cmd;
  9166. int i;
  9167. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9168. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9169. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9170. for(i = 0; i < pc_group_max; i++) {
  9171. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9172. cmd->at_groups[i] = 1;
  9173. else
  9174. cmd->at_groups[i] = 0;
  9175. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9176. cmd->char_groups[i] = 1;
  9177. else
  9178. cmd->char_groups[i] = 0;
  9179. }
  9180. }
  9181. dbi_destroy(iter);
  9182. return;
  9183. }
  9184. void atcommand_db_clear(void) {
  9185. if (atcommand_db != NULL) {
  9186. DBIterator *iter = db_iterator(atcommand_db);
  9187. AtCommandInfo* cmd;
  9188. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9189. aFree(cmd->at_groups);
  9190. aFree(cmd->char_groups);
  9191. }
  9192. dbi_destroy(iter);
  9193. db_destroy(atcommand_db);
  9194. }
  9195. if (atcommand_alias_db != NULL)
  9196. db_destroy(atcommand_alias_db);
  9197. config_destroy(&atcommand_config);
  9198. }
  9199. void atcommand_doload(void) {
  9200. atcommand_db_clear();
  9201. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9202. atcommand_alias_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9203. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9204. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9205. }
  9206. void do_init_atcommand(void) {
  9207. atcommand_doload();
  9208. }
  9209. void do_final_atcommand(void) {
  9210. atcommand_db_clear();
  9211. }