atcommand.cpp 326 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733
  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. } else {
  2244. if (value < 0)
  2245. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2246. else
  2247. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2248. return -1;
  2249. }
  2250. return 0;
  2251. }
  2252. /*==========================================
  2253. * Stat all by fritz (rewritten by [Yor])
  2254. *------------------------------------------*/
  2255. ACMD_FUNC(stat_all)
  2256. {
  2257. int value = 0;
  2258. uint8 count, i;
  2259. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2260. //we don't use direct initialization because it isn't part of the c standard.
  2261. nullpo_retr(-1, sd);
  2262. status[0] = &sd->status.str;
  2263. status[1] = &sd->status.agi;
  2264. status[2] = &sd->status.vit;
  2265. status[3] = &sd->status.int_;
  2266. status[4] = &sd->status.dex;
  2267. status[5] = &sd->status.luk;
  2268. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2269. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2270. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2271. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2272. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2273. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2274. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2275. value = SHRT_MAX;
  2276. } else {
  2277. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2278. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2279. else {
  2280. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2281. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2282. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2283. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2284. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2285. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2286. }
  2287. }
  2288. count = 0;
  2289. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2290. short new_value;
  2291. if (value > 0 && *status[i] + value >= max_status[i])
  2292. new_value = max_status[i];
  2293. else if (value < 0 && *status[i] <= -value)
  2294. new_value = 1;
  2295. else
  2296. new_value = *status[i] + value;
  2297. if (new_value != *status[i]) {
  2298. *status[i] = new_value;
  2299. clif_updatestatus(sd, SP_STR + i);
  2300. clif_updatestatus(sd, SP_USTR + i);
  2301. count++;
  2302. }
  2303. }
  2304. if (count > 0) { // if at least 1 stat modified
  2305. status_calc_pc(sd, SCO_FORCE);
  2306. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2307. } else {
  2308. if (value < 0)
  2309. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2310. else
  2311. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2312. return -1;
  2313. }
  2314. return 0;
  2315. }
  2316. /*==========================================
  2317. *
  2318. *------------------------------------------*/
  2319. ACMD_FUNC(guildlevelup) {
  2320. int level = 0;
  2321. short added_level;
  2322. struct guild *guild_info;
  2323. nullpo_retr(-1, sd);
  2324. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2325. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2326. return -1;
  2327. }
  2328. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2329. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2330. return -1;
  2331. }
  2332. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2333. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2334. // return -1;
  2335. //}
  2336. added_level = (short)level;
  2337. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2338. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2339. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2340. added_level = 1 - guild_info->guild_lv;
  2341. if (added_level != 0) {
  2342. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2343. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2344. } else {
  2345. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2346. return -1;
  2347. }
  2348. return 0;
  2349. }
  2350. /*==========================================
  2351. *
  2352. *------------------------------------------*/
  2353. ACMD_FUNC(makeegg) {
  2354. struct item_data *item_data;
  2355. int id;
  2356. struct s_pet_db* pet;
  2357. nullpo_retr(-1, sd);
  2358. if (!message || !*message) {
  2359. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2360. return -1;
  2361. }
  2362. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2363. id = item_data->nameid;
  2364. else
  2365. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2366. ;
  2367. else
  2368. id = atoi(message);
  2369. pet = pet_db(id);
  2370. if (!pet)
  2371. pet = pet_db_search(id, PET_EGG);
  2372. if (pet != nullptr) {
  2373. sd->catch_target_class = pet->class_;
  2374. 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);
  2375. } else {
  2376. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2377. return -1;
  2378. }
  2379. return 0;
  2380. }
  2381. /*==========================================
  2382. *
  2383. *------------------------------------------*/
  2384. ACMD_FUNC(hatch) {
  2385. nullpo_retr(-1, sd);
  2386. if (sd->status.pet_id <= 0)
  2387. clif_sendegg(sd);
  2388. else {
  2389. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2390. return -1;
  2391. }
  2392. return 0;
  2393. }
  2394. /*==========================================
  2395. *
  2396. *------------------------------------------*/
  2397. ACMD_FUNC(petfriendly) {
  2398. int friendly;
  2399. struct pet_data *pd;
  2400. nullpo_retr(-1, sd);
  2401. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2402. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2403. return -1;
  2404. }
  2405. pd = sd->pd;
  2406. if (!pd) {
  2407. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2408. return -1;
  2409. }
  2410. if (friendly < 0 || friendly > 1000)
  2411. {
  2412. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2413. return -1;
  2414. }
  2415. if (friendly == pd->pet.intimate) {
  2416. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2417. return -1;
  2418. }
  2419. pet_set_intimate(pd, friendly);
  2420. clif_send_petstatus(sd);
  2421. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. *
  2426. *------------------------------------------*/
  2427. ACMD_FUNC(pethungry)
  2428. {
  2429. int hungry;
  2430. struct pet_data *pd;
  2431. nullpo_retr(-1, sd);
  2432. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2433. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2434. return -1;
  2435. }
  2436. pd = sd->pd;
  2437. if (!sd->status.pet_id || !pd) {
  2438. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2439. return -1;
  2440. }
  2441. if (hungry < 0 || hungry > 100) {
  2442. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2443. return -1;
  2444. }
  2445. if (hungry == pd->pet.hungry) {
  2446. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2447. return -1;
  2448. }
  2449. pd->pet.hungry = hungry;
  2450. clif_send_petstatus(sd);
  2451. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2452. return 0;
  2453. }
  2454. /*==========================================
  2455. *
  2456. *------------------------------------------*/
  2457. ACMD_FUNC(petrename)
  2458. {
  2459. struct pet_data *pd;
  2460. nullpo_retr(-1, sd);
  2461. if (!sd->status.pet_id || !sd->pd) {
  2462. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2463. return -1;
  2464. }
  2465. pd = sd->pd;
  2466. if (!pd->pet.rename_flag) {
  2467. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2468. return -1;
  2469. }
  2470. pd->pet.rename_flag = 0;
  2471. intif_save_petdata(sd->status.account_id, &pd->pet);
  2472. clif_send_petstatus(sd);
  2473. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2474. return 0;
  2475. }
  2476. /*==========================================
  2477. *
  2478. *------------------------------------------*/
  2479. ACMD_FUNC(recall) {
  2480. struct map_session_data *pl_sd = NULL;
  2481. nullpo_retr(-1, sd);
  2482. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2483. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2484. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2485. return -1;
  2486. }
  2487. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2488. {
  2489. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2490. return -1;
  2491. }
  2492. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2493. {
  2494. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2495. return -1;
  2496. }
  2497. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2498. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2499. return -1;
  2500. }
  2501. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2502. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2503. return -1;
  2504. }
  2505. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2506. return -1;
  2507. }
  2508. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2509. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2510. return -1;
  2511. }
  2512. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2513. clif_displaymessage(fd, atcmd_output);
  2514. return 0;
  2515. }
  2516. /*==========================================
  2517. * charblock command (usage: charblock <player_name>)
  2518. * This command do a definitiv ban on a player
  2519. *------------------------------------------*/
  2520. ACMD_FUNC(char_block)
  2521. {
  2522. nullpo_retr(-1, sd);
  2523. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2524. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2525. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2526. clif_displaymessage(fd, atcmd_output);
  2527. return -1;
  2528. }
  2529. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2530. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2531. clif_displaymessage(fd, atcmd_output);
  2532. return 0;
  2533. }
  2534. /*==========================================
  2535. * accountban command (usage: ban <%time> <player_name>)
  2536. * charban command (usage: charban <%time> <player_name>)
  2537. * %time see common/timer.cpp::solve_time()
  2538. *------------------------------------------*/
  2539. ACMD_FUNC(char_ban)
  2540. {
  2541. char *modif_p, output[CHAT_SIZE_MAX];
  2542. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2543. enum chrif_req_op bantype;
  2544. nullpo_retr(-1, sd);
  2545. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2546. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2547. parent_cmd = atcommand_checkalias(command+1);
  2548. if (strcmpi(parent_cmd,"charban") == 0)
  2549. bantype = CHRIF_OP_BAN;
  2550. else if (strcmpi(parent_cmd,"ban") == 0)
  2551. bantype = CHRIF_OP_LOGIN_BAN;
  2552. else
  2553. return -1;
  2554. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2555. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2556. clif_displaymessage(fd, output);
  2557. return -1;
  2558. }
  2559. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2560. modif_p = atcmd_output;
  2561. timediff = (int32)solve_time(modif_p); //discard seconds
  2562. if (timediff == 0) { //allow negative ?
  2563. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2564. clif_displaymessage(fd, output);
  2565. 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.
  2566. return -1;
  2567. }
  2568. if( timediff < 0 && (
  2569. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2570. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2571. ))
  2572. {
  2573. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2574. return -1;
  2575. }
  2576. if (bantype == CHRIF_OP_BAN)
  2577. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2578. else
  2579. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2580. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2581. clif_displaymessage(fd, output);
  2582. return 0;
  2583. }
  2584. /*==========================================
  2585. * charunblock command (usage: charunblock <player_name>)
  2586. *------------------------------------------*/
  2587. ACMD_FUNC(char_unblock)
  2588. {
  2589. nullpo_retr(-1, sd);
  2590. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2591. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2592. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2593. clif_displaymessage(fd, atcmd_output);
  2594. return -1;
  2595. }
  2596. // send answer to login server via char-server
  2597. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2598. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2599. clif_displaymessage(fd, atcmd_output);
  2600. return 0;
  2601. }
  2602. /*==========================================
  2603. * acc unban command (usage: unban <player_name>)
  2604. * char unban command (usage: charunban <player_name>)
  2605. *------------------------------------------*/
  2606. ACMD_FUNC(char_unban){
  2607. enum chrif_req_op unbantype;
  2608. nullpo_retr(-1, sd);
  2609. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2610. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2611. parent_cmd = atcommand_checkalias(command+1);
  2612. if (strcmpi(parent_cmd,"charunban") == 0)
  2613. unbantype = CHRIF_OP_UNBAN;
  2614. else if (strcmpi(parent_cmd,"unban") == 0)
  2615. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2616. else
  2617. return -1;
  2618. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2619. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2620. clif_displaymessage(fd, atcmd_output);
  2621. return -1;
  2622. }
  2623. if (unbantype == CHRIF_OP_UNBAN)
  2624. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2625. else
  2626. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2627. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2628. clif_displaymessage(fd, atcmd_output);
  2629. return 0;
  2630. }
  2631. /*==========================================
  2632. *
  2633. *------------------------------------------*/
  2634. ACMD_FUNC(night)
  2635. {
  2636. nullpo_retr(-1, sd);
  2637. if (night_flag != 1) {
  2638. map_night_timer(night_timer_tid, 0, 0, 1);
  2639. } else {
  2640. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2641. return -1;
  2642. }
  2643. return 0;
  2644. }
  2645. /*==========================================
  2646. *
  2647. *------------------------------------------*/
  2648. ACMD_FUNC(day)
  2649. {
  2650. nullpo_retr(-1, sd);
  2651. if (night_flag != 0) {
  2652. map_day_timer(day_timer_tid, 0, 0, 1);
  2653. } else {
  2654. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2655. return -1;
  2656. }
  2657. return 0;
  2658. }
  2659. /*==========================================
  2660. *
  2661. *------------------------------------------*/
  2662. ACMD_FUNC(doom)
  2663. {
  2664. struct map_session_data* pl_sd;
  2665. struct s_mapiterator* iter;
  2666. nullpo_retr(-1, sd);
  2667. iter = mapit_getallusers();
  2668. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2669. {
  2670. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2671. {
  2672. status_kill(&pl_sd->bl);
  2673. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2674. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2675. }
  2676. }
  2677. mapit_free(iter);
  2678. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2679. return 0;
  2680. }
  2681. /*==========================================
  2682. *
  2683. *------------------------------------------*/
  2684. ACMD_FUNC(doommap)
  2685. {
  2686. struct map_session_data* pl_sd;
  2687. struct s_mapiterator* iter;
  2688. nullpo_retr(-1, sd);
  2689. iter = mapit_getallusers();
  2690. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2691. {
  2692. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2693. {
  2694. status_kill(&pl_sd->bl);
  2695. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2696. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2697. }
  2698. }
  2699. mapit_free(iter);
  2700. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2701. return 0;
  2702. }
  2703. /*==========================================
  2704. *
  2705. *------------------------------------------*/
  2706. static void atcommand_raise_sub(struct map_session_data* sd) {
  2707. status_revive(&sd->bl, 100, 100);
  2708. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2709. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2710. }
  2711. /*==========================================
  2712. *
  2713. *------------------------------------------*/
  2714. ACMD_FUNC(raise)
  2715. {
  2716. struct map_session_data* pl_sd;
  2717. struct s_mapiterator* iter;
  2718. nullpo_retr(-1, sd);
  2719. iter = mapit_getallusers();
  2720. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2721. if( pc_isdead(pl_sd) )
  2722. atcommand_raise_sub(pl_sd);
  2723. mapit_free(iter);
  2724. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2725. return 0;
  2726. }
  2727. /*==========================================
  2728. *
  2729. *------------------------------------------*/
  2730. ACMD_FUNC(raisemap)
  2731. {
  2732. struct map_session_data* pl_sd;
  2733. struct s_mapiterator* iter;
  2734. nullpo_retr(-1, sd);
  2735. iter = mapit_getallusers();
  2736. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2737. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2738. atcommand_raise_sub(pl_sd);
  2739. mapit_free(iter);
  2740. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2741. return 0;
  2742. }
  2743. /*==========================================
  2744. *
  2745. *------------------------------------------*/
  2746. ACMD_FUNC(kick)
  2747. {
  2748. struct map_session_data *pl_sd;
  2749. nullpo_retr(-1, sd);
  2750. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2751. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2752. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2753. return -1;
  2754. }
  2755. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2756. {
  2757. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2758. return -1;
  2759. }
  2760. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2761. {
  2762. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2763. return -1;
  2764. }
  2765. clif_GM_kick(sd, pl_sd);
  2766. return 0;
  2767. }
  2768. /*==========================================
  2769. *
  2770. *------------------------------------------*/
  2771. ACMD_FUNC(kickall)
  2772. {
  2773. struct map_session_data* pl_sd;
  2774. struct s_mapiterator* iter;
  2775. nullpo_retr(-1, sd);
  2776. iter = mapit_getallusers();
  2777. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2778. {
  2779. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2780. if (sd->status.account_id != pl_sd->status.account_id)
  2781. clif_GM_kick(NULL, pl_sd);
  2782. }
  2783. }
  2784. mapit_free(iter);
  2785. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2786. return 0;
  2787. }
  2788. /*==========================================
  2789. *
  2790. *------------------------------------------*/
  2791. ACMD_FUNC(allskill)
  2792. {
  2793. nullpo_retr(-1, sd);
  2794. pc_allskillup(sd); // all skills
  2795. sd->status.skill_point = 0; // 0 skill points
  2796. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2797. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2798. return 0;
  2799. }
  2800. /*==========================================
  2801. *
  2802. *------------------------------------------*/
  2803. ACMD_FUNC(questskill)
  2804. {
  2805. uint16 skill_id;
  2806. nullpo_retr(-1, sd);
  2807. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2808. {// also send a list of skills applicable to this command
  2809. const char* text;
  2810. // attempt to find the text corresponding to this command
  2811. text = atcommand_help_string( command );
  2812. // send the error message as always
  2813. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2814. if( text )
  2815. {// send the skill ID list associated with this command
  2816. clif_displaymessage( fd, text );
  2817. }
  2818. return -1;
  2819. }
  2820. if (skill_id >= MAX_SKILL_ID) {
  2821. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2822. return -1;
  2823. }
  2824. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2825. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2826. return -1;
  2827. }
  2828. if (pc_checkskill(sd, skill_id) > 0) {
  2829. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2830. return -1;
  2831. }
  2832. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2833. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2834. return 0;
  2835. }
  2836. /*==========================================
  2837. *
  2838. *------------------------------------------*/
  2839. ACMD_FUNC(lostskill)
  2840. {
  2841. uint16 skill_id = 0, sk_idx = 0;
  2842. nullpo_retr(-1, sd);
  2843. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2844. {// also send a list of skills applicable to this command
  2845. const char* text;
  2846. // attempt to find the text corresponding to this command
  2847. text = atcommand_help_string( command );
  2848. // send the error message as always
  2849. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2850. if( text )
  2851. {// send the skill ID list associated with this command
  2852. clif_displaymessage( fd, text );
  2853. }
  2854. return -1;
  2855. }
  2856. if (!(sk_idx = skill_get_index(skill_id))) {
  2857. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2858. return -1;
  2859. }
  2860. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2861. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2862. return -1;
  2863. }
  2864. if (pc_checkskill(sd, skill_id) == 0) {
  2865. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2866. return -1;
  2867. }
  2868. sd->status.skill[sk_idx].lv = 0;
  2869. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2870. clif_deleteskill(sd,skill_id);
  2871. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2872. return 0;
  2873. }
  2874. /*==========================================
  2875. *
  2876. *------------------------------------------*/
  2877. ACMD_FUNC(spiritball)
  2878. {
  2879. uint32 max_spiritballs;
  2880. int number;
  2881. nullpo_retr(-1, sd);
  2882. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2883. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2884. {
  2885. char msg[CHAT_SIZE_MAX];
  2886. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2887. clif_displaymessage(fd, msg);
  2888. return -1;
  2889. }
  2890. if( sd->spiritball > 0 )
  2891. pc_delspiritball(sd, sd->spiritball, 1);
  2892. sd->spiritball = number;
  2893. clif_spiritball(&sd->bl);
  2894. // no message, player can look the difference
  2895. return 0;
  2896. }
  2897. /*==========================================
  2898. *
  2899. *------------------------------------------*/
  2900. ACMD_FUNC(party)
  2901. {
  2902. char party[NAME_LENGTH];
  2903. nullpo_retr(-1, sd);
  2904. memset(party, '\0', sizeof(party));
  2905. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2906. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2907. return -1;
  2908. }
  2909. party_create(sd, party, 0, 0);
  2910. return 0;
  2911. }
  2912. /*==========================================
  2913. *
  2914. *------------------------------------------*/
  2915. ACMD_FUNC(guild)
  2916. {
  2917. char guild[NAME_LENGTH];
  2918. int prev;
  2919. nullpo_retr(-1, sd);
  2920. memset(guild, '\0', sizeof(guild));
  2921. if (sd->clan) {
  2922. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2923. return -1;
  2924. }
  2925. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2926. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2927. return -1;
  2928. }
  2929. prev = battle_config.guild_emperium_check;
  2930. battle_config.guild_emperium_check = 0;
  2931. guild_create(sd, guild);
  2932. battle_config.guild_emperium_check = prev;
  2933. return 0;
  2934. }
  2935. ACMD_FUNC(breakguild)
  2936. {
  2937. nullpo_retr(-1, sd);
  2938. if (sd->status.guild_id) { // Check if the player has a guild
  2939. struct guild *g;
  2940. g = sd->guild; // Search the guild
  2941. if (g) { // Check if guild was found
  2942. if (sd->state.gmaster_flag) { // Check if player is guild master
  2943. int ret = 0;
  2944. ret = guild_break(sd, g->name); // Break guild
  2945. if (ret) { // Check if anything went wrong
  2946. return 0; // Guild was broken
  2947. } else {
  2948. return -1; // Something went wrong
  2949. }
  2950. } else { // Not guild master
  2951. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2952. return -1;
  2953. }
  2954. } else { // Guild was not found. HOW?
  2955. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2956. return -1;
  2957. }
  2958. } else { // Player does not have a guild
  2959. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2960. return -1;
  2961. }
  2962. }
  2963. /**
  2964. * Start WoE:FE
  2965. */
  2966. ACMD_FUNC(agitstart)
  2967. {
  2968. nullpo_retr(-1, sd);
  2969. if( guild_agit_start() ){
  2970. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2971. return 0;
  2972. }else{
  2973. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2974. return -1;
  2975. }
  2976. }
  2977. /**
  2978. * Start WoE:SE
  2979. */
  2980. ACMD_FUNC(agitstart2)
  2981. {
  2982. nullpo_retr(-1, sd);
  2983. if( guild_agit2_start() ){
  2984. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2985. return 0;
  2986. }else{
  2987. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2988. return -1;
  2989. }
  2990. }
  2991. /**
  2992. * Start WoE:TE
  2993. */
  2994. ACMD_FUNC(agitstart3)
  2995. {
  2996. nullpo_retr(-1, sd);
  2997. if( guild_agit3_start() ){
  2998. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  2999. return 0;
  3000. }else{
  3001. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3002. return -1;
  3003. }
  3004. }
  3005. /**
  3006. * End WoE:FE
  3007. */
  3008. ACMD_FUNC(agitend)
  3009. {
  3010. nullpo_retr(-1, sd);
  3011. if( guild_agit_end() ){
  3012. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3013. return 0;
  3014. }else{
  3015. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3016. return -1;
  3017. }
  3018. }
  3019. /**
  3020. * End WoE:SE
  3021. */
  3022. ACMD_FUNC(agitend2)
  3023. {
  3024. nullpo_retr(-1, sd);
  3025. if( guild_agit2_end() ){
  3026. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3027. return 0;
  3028. }else{
  3029. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3030. return -1;
  3031. }
  3032. }
  3033. /**
  3034. * End WoE:TE
  3035. */
  3036. ACMD_FUNC(agitend3)
  3037. {
  3038. nullpo_retr(-1, sd);
  3039. if( guild_agit3_end() ){
  3040. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3041. return 0;
  3042. }else{
  3043. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3044. return -1;
  3045. }
  3046. }
  3047. /*==========================================
  3048. * @mapexit - shuts down the map server
  3049. *------------------------------------------*/
  3050. ACMD_FUNC(mapexit)
  3051. {
  3052. nullpo_retr(-1, sd);
  3053. do_shutdown();
  3054. return 0;
  3055. }
  3056. /*==========================================
  3057. * idsearch <part_of_name>: revrited by [Yor]
  3058. *------------------------------------------*/
  3059. ACMD_FUNC(idsearch)
  3060. {
  3061. char item_name[100];
  3062. unsigned int i, match;
  3063. struct item_data *item_array[MAX_SEARCH];
  3064. nullpo_retr(-1, sd);
  3065. memset(item_name, '\0', sizeof(item_name));
  3066. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3067. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3068. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3069. return -1;
  3070. }
  3071. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3072. clif_displaymessage(fd, atcmd_output);
  3073. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3074. if (match == MAX_SEARCH) {
  3075. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3076. clif_displaymessage(fd, atcmd_output);
  3077. }
  3078. for(i = 0; i < match; i++) {
  3079. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3080. clif_displaymessage(fd, atcmd_output);
  3081. }
  3082. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3083. clif_displaymessage(fd, atcmd_output);
  3084. return 0;
  3085. }
  3086. /*==========================================
  3087. * Recall All Characters Online To Your Location
  3088. *------------------------------------------*/
  3089. ACMD_FUNC(recallall)
  3090. {
  3091. struct map_session_data* pl_sd;
  3092. struct s_mapiterator* iter;
  3093. int count;
  3094. nullpo_retr(-1, sd);
  3095. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3096. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3097. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3098. return -1;
  3099. }
  3100. count = 0;
  3101. iter = mapit_getallusers();
  3102. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3103. {
  3104. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3105. {
  3106. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3107. continue; // Don't waste time warping the character to the same place.
  3108. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3109. count++;
  3110. else {
  3111. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3112. count++;
  3113. }
  3114. }
  3115. }
  3116. }
  3117. mapit_free(iter);
  3118. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3119. if (count) {
  3120. 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.
  3121. clif_displaymessage(fd, atcmd_output);
  3122. }
  3123. return 0;
  3124. }
  3125. /*==========================================
  3126. * Recall online characters of a guild to your location
  3127. *------------------------------------------*/
  3128. ACMD_FUNC(guildrecall)
  3129. {
  3130. struct map_session_data* pl_sd;
  3131. struct s_mapiterator* iter;
  3132. int count;
  3133. char guild_name[NAME_LENGTH];
  3134. struct guild *g;
  3135. nullpo_retr(-1, sd);
  3136. memset(guild_name, '\0', sizeof(guild_name));
  3137. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3138. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3139. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3140. return -1;
  3141. }
  3142. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3143. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3144. return -1;
  3145. }
  3146. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3147. (g = guild_search(atoi(message))) == NULL)
  3148. {
  3149. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3150. return -1;
  3151. }
  3152. count = 0;
  3153. iter = mapit_getallusers();
  3154. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3155. {
  3156. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3157. {
  3158. 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))
  3159. continue; // Skip GMs greater than you... or chars already on the cell
  3160. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3161. count++;
  3162. else{
  3163. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3164. count++;
  3165. }
  3166. }
  3167. }
  3168. }
  3169. mapit_free(iter);
  3170. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3171. clif_displaymessage(fd, atcmd_output);
  3172. if (count) {
  3173. 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.
  3174. clif_displaymessage(fd, atcmd_output);
  3175. }
  3176. return 0;
  3177. }
  3178. /*==========================================
  3179. * Recall online characters of a party to your location
  3180. *------------------------------------------*/
  3181. ACMD_FUNC(partyrecall)
  3182. {
  3183. struct map_session_data* pl_sd;
  3184. struct s_mapiterator* iter;
  3185. char party_name[NAME_LENGTH];
  3186. struct party_data *p;
  3187. int count;
  3188. nullpo_retr(-1, sd);
  3189. memset(party_name, '\0', sizeof(party_name));
  3190. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3191. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3192. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3193. return -1;
  3194. }
  3195. if (sd->bl.m >= 0 && map_getmapflag(sd->bl.m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3196. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3197. return -1;
  3198. }
  3199. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3200. (p = party_search(atoi(message))) == NULL)
  3201. {
  3202. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3203. return -1;
  3204. }
  3205. count = 0;
  3206. iter = mapit_getallusers();
  3207. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3208. {
  3209. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3210. {
  3211. 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))
  3212. continue; // Skip GMs greater than you... or chars already on the cell
  3213. if (pl_sd->bl.m >= 0 && map_getmapflag(pl_sd->bl.m, MF_NOWARP) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3214. count++;
  3215. else{
  3216. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3217. count++;
  3218. }
  3219. }
  3220. }
  3221. }
  3222. mapit_free(iter);
  3223. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3224. clif_displaymessage(fd, atcmd_output);
  3225. if (count) {
  3226. 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.
  3227. clif_displaymessage(fd, atcmd_output);
  3228. }
  3229. return 0;
  3230. }
  3231. /*==========================================
  3232. *
  3233. *------------------------------------------*/
  3234. void atcommand_doload();
  3235. ACMD_FUNC(reload) {
  3236. nullpo_retr(-1, sd);
  3237. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3238. const char* text;
  3239. text = atcommand_help_string( command );
  3240. if(text)
  3241. clif_displaymessage( fd, text );
  3242. return -1;
  3243. }
  3244. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3245. itemdb_reload();
  3246. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3247. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3248. mob_reload();
  3249. read_petdb();
  3250. hom_reload();
  3251. mercenary_readdb();
  3252. mercenary_read_skilldb();
  3253. reload_elementaldb();
  3254. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3255. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3256. skill_reload();
  3257. hom_reload_skill();
  3258. reload_elemental_skilldb();
  3259. mercenary_read_skilldb();
  3260. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3261. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3262. config_t run_test;
  3263. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3264. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3265. return -1;
  3266. }
  3267. config_destroy(&run_test);
  3268. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3269. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3270. return -1;
  3271. }
  3272. config_destroy(&run_test);
  3273. atcommand_doload();
  3274. pc_groups_reload();
  3275. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3276. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3277. struct Battle_Config prev_config;
  3278. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3279. battle_config_read(BATTLE_CONF_FILENAME);
  3280. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3281. || prev_config.item_rate_common != battle_config.item_rate_common
  3282. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3283. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3284. || prev_config.item_rate_card != battle_config.item_rate_card
  3285. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3286. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3287. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3288. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3289. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3290. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3291. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3292. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3293. || prev_config.item_rate_use != battle_config.item_rate_use
  3294. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3295. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3296. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3297. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3298. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3299. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3300. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3301. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3302. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3303. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3304. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3305. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3306. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3307. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3308. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3309. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3310. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3311. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3312. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3313. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3314. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3315. )
  3316. { // Exp or Drop rates changed.
  3317. mob_reload(); //Needed as well so rate changes take effect.
  3318. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3319. }
  3320. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3321. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3322. status_readdb();
  3323. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3324. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3325. pc_readdb();
  3326. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3327. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3328. pc_read_motd();
  3329. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3330. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3331. struct s_mapiterator* iter;
  3332. struct map_session_data* pl_sd;
  3333. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3334. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3335. iter = mapit_getallusers();
  3336. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3337. pc_close_npc(pl_sd,2);
  3338. mapit_free(iter);
  3339. flush_fifos();
  3340. map_reloadnpc(true); // reload config files seeking for npcs
  3341. script_reload();
  3342. npc_reload();
  3343. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3344. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3345. map_msg_reload();
  3346. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3347. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3348. do_reload_quest();
  3349. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3350. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3351. instance_reload();
  3352. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3353. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3354. achievement_db_reload();
  3355. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3356. }
  3357. return 0;
  3358. }
  3359. /*==========================================
  3360. * @partysharelvl <share_range> [Akinari]
  3361. * Updates char server party share level range in runtime
  3362. * Temporary - Permanent update in inter_athena.conf
  3363. *------------------------------------------*/
  3364. ACMD_FUNC(partysharelvl) {
  3365. unsigned int share_lvl;
  3366. nullpo_retr(-1, sd);
  3367. if(!message || !*message) {
  3368. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3369. return -1;
  3370. } else {
  3371. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3372. }
  3373. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3374. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3375. else //Char server offline
  3376. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3377. return 0;
  3378. }
  3379. /*==========================================
  3380. * @mapinfo [0-3] <map name> by MC_Cameri
  3381. * => Shows information about the map [map name]
  3382. * 0 = no additional information
  3383. * 1 = Show users in that map and their location
  3384. * 2 = Shows NPCs in that map
  3385. * 3 = Shows the chats in that map
  3386. *------------------------------------------*/
  3387. ACMD_FUNC(mapinfo) {
  3388. struct map_session_data* pl_sd;
  3389. struct s_mapiterator* iter;
  3390. struct chat_data *cd = NULL;
  3391. char direction[12];
  3392. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3393. unsigned short m_index;
  3394. char mapname[MAP_NAME_LENGTH];
  3395. nullpo_retr(-1, sd);
  3396. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3397. memset(mapname, '\0', sizeof(mapname));
  3398. memset(direction, '\0', sizeof(direction));
  3399. sscanf(message, "%11d %11[^\n]", &list, mapname);
  3400. if (list < 0 || list > 3) {
  3401. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3402. return -1;
  3403. }
  3404. if (mapname[0] == '\0') {
  3405. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3406. m_id = map_mapindex2mapid(sd->mapindex);
  3407. } else {
  3408. m_id = map_mapname2mapid(mapname);
  3409. }
  3410. if (m_id < 0) {
  3411. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3412. return -1;
  3413. }
  3414. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3415. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3416. // count chats (for initial message)
  3417. chat_num = 0;
  3418. iter = mapit_getallusers();
  3419. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3420. if( pl_sd->mapindex == m_index ) {
  3421. if( pl_sd->state.vending )
  3422. vend_num++;
  3423. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3424. chat_num++;
  3425. }
  3426. }
  3427. mapit_free(iter);
  3428. struct map_data *mapdata = map_getmapdata(m_id);
  3429. 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
  3430. clif_displaymessage(fd, atcmd_output);
  3431. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3432. if (map_getmapflag(m_id, MF_TOWN))
  3433. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3434. if (map_getmapflag(m_id, MF_RESTRICTED)){
  3435. sprintf(atcmd_output, " Restricted (zone %d)",mapdata->zone);
  3436. clif_displaymessage(fd, atcmd_output);
  3437. }
  3438. if (battle_config.autotrade_mapflag == map_getmapflag(m_id, MF_AUTOTRADE))
  3439. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3440. else
  3441. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3442. if (map_getmapflag(m_id, MF_BATTLEGROUND)){
  3443. sprintf(atcmd_output, msg_txt(sd,1045),map_getmapflag(m_id, MF_BATTLEGROUND)); // Battlegrounds ON (type %d)
  3444. clif_displaymessage(fd, atcmd_output);
  3445. }
  3446. /* Skill damage adjustment info [Cydh] */
  3447. union u_mapflag_args args = {};
  3448. args.flag_val = SKILLDMG_MAX; // Check if it's enabled first
  3449. if (map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)) {
  3450. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3451. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3452. ,(args.flag_val = SKILLDMG_PC && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args))
  3453. ,(args.flag_val = SKILLDMG_MOB && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args))
  3454. ,(args.flag_val = SKILLDMG_BOSS && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args))
  3455. ,(args.flag_val = SKILLDMG_OTHER && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args))
  3456. ,(args.flag_val = SKILLDMG_CASTER && map_getmapflag_sub(m_id, MF_SKILL_DAMAGE, &args)));
  3457. clif_displaymessage(fd, atcmd_output);
  3458. if (mapdata->skill_damage.size()) {
  3459. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3460. for (int j = 0; j < mapdata->skill_damage.size(); j++) {
  3461. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3462. ,j+1
  3463. ,skill_get_name(mapdata->skill_damage[j].skill_id)
  3464. ,mapdata->skill_damage[j].rate[SKILLDMG_PC]
  3465. ,mapdata->skill_damage[j].rate[SKILLDMG_MOB]
  3466. ,mapdata->skill_damage[j].rate[SKILLDMG_BOSS]
  3467. ,mapdata->skill_damage[j].rate[SKILLDMG_OTHER]
  3468. ,mapdata->skill_damage[j].caster);
  3469. clif_displaymessage(fd,atcmd_output);
  3470. }
  3471. }
  3472. }
  3473. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3474. if (map_getmapflag(m_id, MF_PVP))
  3475. strcat(atcmd_output, " Pvp ON |");
  3476. if (map_getmapflag(m_id, MF_PVP_NOGUILD))
  3477. strcat(atcmd_output, " NoGuild |");
  3478. if (map_getmapflag(m_id, MF_PVP_NOPARTY))
  3479. strcat(atcmd_output, " NoParty |");
  3480. if (map_getmapflag(m_id, MF_PVP_NIGHTMAREDROP))
  3481. strcat(atcmd_output, " NightmareDrop |");
  3482. if (map_getmapflag(m_id, MF_PVP_NOCALCRANK))
  3483. strcat(atcmd_output, " NoCalcRank |");
  3484. clif_displaymessage(fd, atcmd_output);
  3485. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3486. if (map_getmapflag(m_id, MF_GVG))
  3487. strcat(atcmd_output, " GvG ON |");
  3488. if (map_getmapflag(m_id, MF_GVG_DUNGEON))
  3489. strcat(atcmd_output, " GvG Dungeon |");
  3490. if (map_getmapflag(m_id, MF_GVG_CASTLE))
  3491. strcat(atcmd_output, " GvG Castle |");
  3492. if (map_getmapflag(m_id, MF_GVG_TE))
  3493. strcat(atcmd_output, " GvG TE |");
  3494. if (map_getmapflag(m_id, MF_GVG_TE_CASTLE))
  3495. strcat(atcmd_output, " GvG TE Castle |");
  3496. if (map_getmapflag(m_id, MF_GVG_NOPARTY))
  3497. strcat(atcmd_output, " NoParty |");
  3498. clif_displaymessage(fd, atcmd_output);
  3499. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3500. if (map_getmapflag(m_id, MF_NOTELEPORT))
  3501. strcat(atcmd_output, " NoTeleport |");
  3502. if (map_getmapflag(m_id, MF_MONSTER_NOTELEPORT))
  3503. strcat(atcmd_output, " Monster NoTeleport |");
  3504. if (map_getmapflag(m_id, MF_NOWARP))
  3505. strcat(atcmd_output, " NoWarp |");
  3506. if (map_getmapflag(m_id, MF_NOWARPTO))
  3507. strcat(atcmd_output, " NoWarpTo |");
  3508. if (map_getmapflag(m_id, MF_NORETURN))
  3509. strcat(atcmd_output, " NoReturn |");
  3510. if (map_getmapflag(m_id, MF_NOGO))
  3511. strcat(atcmd_output, " NoGo |"); //
  3512. if (map_getmapflag(m_id, MF_NOMEMO))
  3513. strcat(atcmd_output, " NoMemo |");
  3514. clif_displaymessage(fd, atcmd_output);
  3515. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3516. (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
  3517. clif_displaymessage(fd, atcmd_output);
  3518. if (map_getmapflag(m_id, MF_NOSAVE)) {
  3519. if (!mapdata->save.map)
  3520. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3521. else if (mapdata->save.x == -1 || mapdata->save.y == -1 ) {
  3522. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(mapdata->save.map)); // No Save, Save Point: %s,Random
  3523. clif_displaymessage(fd, atcmd_output);
  3524. }
  3525. else {
  3526. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3527. mapindex_id2name(mapdata->save.map),mapdata->save.x,mapdata->save.y);
  3528. clif_displaymessage(fd, atcmd_output);
  3529. }
  3530. }
  3531. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3532. if (map_getmapflag(m_id, MF_SNOW))
  3533. strcat(atcmd_output, " Snow |");
  3534. if (map_getmapflag(m_id, MF_FOG))
  3535. strcat(atcmd_output, " Fog |");
  3536. if (map_getmapflag(m_id, MF_SAKURA))
  3537. strcat(atcmd_output, " Sakura |");
  3538. if (map_getmapflag(m_id, MF_CLOUDS))
  3539. strcat(atcmd_output, " Clouds |");
  3540. if (map_getmapflag(m_id, MF_CLOUDS2))
  3541. strcat(atcmd_output, " Clouds2 |");
  3542. if (map_getmapflag(m_id, MF_FIREWORKS))
  3543. strcat(atcmd_output, " Fireworks |");
  3544. if (map_getmapflag(m_id, MF_LEAVES))
  3545. strcat(atcmd_output, " Leaves |");
  3546. if (map_getmapflag(m_id, MF_NIGHTENABLED))
  3547. strcat(atcmd_output, " Displays Night |");
  3548. clif_displaymessage(fd, atcmd_output);
  3549. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3550. if (map_getmapflag(m_id, MF_NOBRANCH))
  3551. strcat(atcmd_output, " NoBranch |");
  3552. if (map_getmapflag(m_id, MF_NOTRADE))
  3553. strcat(atcmd_output, " NoTrade |");
  3554. if (map_getmapflag(m_id, MF_NOVENDING))
  3555. strcat(atcmd_output, " NoVending |");
  3556. if (map_getmapflag(m_id, MF_NODROP))
  3557. strcat(atcmd_output, " NoDrop |");
  3558. if (map_getmapflag(m_id, MF_NOSKILL))
  3559. strcat(atcmd_output, " NoSkill |");
  3560. if (map_getmapflag(m_id, MF_NOICEWALL))
  3561. strcat(atcmd_output, " NoIcewall |");
  3562. if (map_getmapflag(m_id, MF_ALLOWKS))
  3563. strcat(atcmd_output, " AllowKS |");
  3564. if (map_getmapflag(m_id, MF_RESET))
  3565. strcat(atcmd_output, " Reset |");
  3566. if (map_getmapflag(m_id, MF_HIDEMOBHPBAR))
  3567. strcat(atcmd_output, " HideMobHPBar |");
  3568. clif_displaymessage(fd, atcmd_output);
  3569. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3570. if (map_getmapflag(m_id, MF_NOCOMMAND))
  3571. strcat(atcmd_output, " NoCommand |");
  3572. if (map_getmapflag(m_id, MF_NOBASEEXP))
  3573. strcat(atcmd_output, " NoBaseEXP |");
  3574. if (map_getmapflag(m_id, MF_NOJOBEXP))
  3575. strcat(atcmd_output, " NoJobEXP |");
  3576. if (map_getmapflag(m_id, MF_NOMOBLOOT))
  3577. strcat(atcmd_output, " NoMobLoot |");
  3578. if (map_getmapflag(m_id, MF_NOMVPLOOT))
  3579. strcat(atcmd_output, " NoMVPLoot |");
  3580. if (map_getmapflag(m_id, MF_PARTYLOCK))
  3581. strcat(atcmd_output, " PartyLock |");
  3582. if (map_getmapflag(m_id, MF_GUILDLOCK))
  3583. strcat(atcmd_output, " GuildLock |");
  3584. if (map_getmapflag(m_id, MF_LOADEVENT))
  3585. strcat(atcmd_output, " Loadevent |");
  3586. if (map_getmapflag(m_id, MF_NOMAPCHANNELAUTOJOIN))
  3587. strcat(atcmd_output, " NoMapChannelAutoJoin |");
  3588. if (map_getmapflag(m_id, MF_NOUSECART))
  3589. strcat(atcmd_output, " NoUsecart |");
  3590. if (map_getmapflag(m_id, MF_NOITEMCONSUMPTION))
  3591. strcat(atcmd_output, " NoItemConsumption |");
  3592. if (map_getmapflag(m_id, MF_NOSUNMOONSTARMIRACLE))
  3593. strcat(atcmd_output, " NoSunMoonStarMiracle |");
  3594. if (map_getmapflag(m_id, MF_NOMINEEFFECT))
  3595. strcat(atcmd_output, " NoMineEffect |");
  3596. if (map_getmapflag(m_id, MF_NOLOCKON))
  3597. strcat(atcmd_output, " NoLockOn |");
  3598. if (map_getmapflag(m_id, MF_NOTOMB))
  3599. strcat(atcmd_output, " NoTomb |");
  3600. if (map_getmapflag(m_id, MF_NOCOSTUME))
  3601. strcat(atcmd_output, " NoCostume |");
  3602. clif_displaymessage(fd, atcmd_output);
  3603. switch (list) {
  3604. case 0:
  3605. // Do nothing. It's list 0, no additional display.
  3606. break;
  3607. case 1:
  3608. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3609. iter = mapit_getallusers();
  3610. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3611. {
  3612. if (pl_sd->mapindex == m_index) {
  3613. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3614. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3615. clif_displaymessage(fd, atcmd_output);
  3616. }
  3617. }
  3618. mapit_free(iter);
  3619. break;
  3620. case 2:
  3621. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3622. for (i = 0; i < mapdata->npc_num;)
  3623. {
  3624. struct npc_data *nd = mapdata->npc[i];
  3625. switch(nd->ud.dir) {
  3626. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3627. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3628. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3629. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3630. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3631. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3632. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3633. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3634. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3635. }
  3636. if(strcmp(nd->name,nd->exname) == 0)
  3637. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3638. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3639. else
  3640. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3641. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3642. clif_displaymessage(fd, atcmd_output);
  3643. }
  3644. break;
  3645. case 3:
  3646. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3647. iter = mapit_getallusers();
  3648. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3649. {
  3650. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3651. pl_sd->mapindex == m_index &&
  3652. cd->usersd[0] == pl_sd)
  3653. {
  3654. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3655. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3656. clif_displaymessage(fd, atcmd_output);
  3657. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3658. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3659. clif_displaymessage(fd, atcmd_output);
  3660. }
  3661. }
  3662. mapit_free(iter);
  3663. break;
  3664. default: // normally impossible to arrive here
  3665. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3666. return -1;
  3667. break;
  3668. }
  3669. return 0;
  3670. }
  3671. /*==========================================
  3672. *
  3673. *------------------------------------------*/
  3674. ACMD_FUNC(mount_peco)
  3675. {
  3676. nullpo_retr(-1, sd);
  3677. if (sd->disguise) {
  3678. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3679. return -1;
  3680. }
  3681. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3682. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3683. unsigned int option = OPTION_DRAGON1;
  3684. if( message[0] ) {
  3685. int color = atoi(message);
  3686. option = ( color == 2 ? OPTION_DRAGON2 :
  3687. color == 3 ? OPTION_DRAGON3 :
  3688. color == 4 ? OPTION_DRAGON4 :
  3689. color == 5 ? OPTION_DRAGON5 :
  3690. OPTION_DRAGON1 );
  3691. }
  3692. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3693. pc_setoption(sd, sd->sc.option|option);
  3694. } else {
  3695. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3696. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3697. }
  3698. return 0;
  3699. }
  3700. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3701. if( !pc_isridingwug(sd) ) {
  3702. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3703. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3704. } else {
  3705. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3706. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3707. }
  3708. return 0;
  3709. }
  3710. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3711. if( !pc_ismadogear(sd) ) {
  3712. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3713. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3714. } else {
  3715. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3716. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3717. }
  3718. return 0;
  3719. }
  3720. if (!pc_isriding(sd)) { // if actually no peco
  3721. if (!pc_checkskill(sd, KN_RIDING)) {
  3722. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3723. return -1;
  3724. }
  3725. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3726. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3727. } else {//Dismount
  3728. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3729. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3730. }
  3731. return 0;
  3732. }
  3733. /*==========================================
  3734. *Spy Commands by Syrus22
  3735. *------------------------------------------*/
  3736. ACMD_FUNC(guildspy)
  3737. {
  3738. char guild_name[NAME_LENGTH];
  3739. struct guild *g;
  3740. nullpo_retr(-1, sd);
  3741. memset(guild_name, '\0', sizeof(guild_name));
  3742. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3743. if (!enable_spy)
  3744. {
  3745. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3746. return -1;
  3747. }
  3748. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3749. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3750. return -1;
  3751. }
  3752. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3753. (g = guild_search(atoi(message))) != NULL) {
  3754. if (sd->guildspy == g->guild_id) {
  3755. sd->guildspy = 0;
  3756. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3757. clif_displaymessage(fd, atcmd_output);
  3758. } else {
  3759. sd->guildspy = g->guild_id;
  3760. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3761. clif_displaymessage(fd, atcmd_output);
  3762. }
  3763. } else {
  3764. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3765. return -1;
  3766. }
  3767. return 0;
  3768. }
  3769. /*==========================================
  3770. *
  3771. *------------------------------------------*/
  3772. ACMD_FUNC(partyspy)
  3773. {
  3774. char party_name[NAME_LENGTH];
  3775. struct party_data *p;
  3776. nullpo_retr(-1, sd);
  3777. memset(party_name, '\0', sizeof(party_name));
  3778. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3779. if (!enable_spy)
  3780. {
  3781. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3782. return -1;
  3783. }
  3784. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3785. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3786. return -1;
  3787. }
  3788. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3789. (p = party_search(atoi(message))) != NULL) {
  3790. if (sd->partyspy == p->party.party_id) {
  3791. sd->partyspy = 0;
  3792. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3793. clif_displaymessage(fd, atcmd_output);
  3794. } else {
  3795. sd->partyspy = p->party.party_id;
  3796. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3797. clif_displaymessage(fd, atcmd_output);
  3798. }
  3799. } else {
  3800. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3801. return -1;
  3802. }
  3803. return 0;
  3804. }
  3805. ACMD_FUNC(clanspy){
  3806. char clan_name[NAME_LENGTH];
  3807. struct clan* c;
  3808. nullpo_retr(-1, sd);
  3809. memset(clan_name, '\0', sizeof(clan_name));
  3810. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3811. if( !enable_spy ){
  3812. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3813. return -1;
  3814. }
  3815. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3816. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3817. return -1;
  3818. }
  3819. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3820. (c = clan_search(atoi(message))) != NULL) {
  3821. if (sd->clanspy == c->id) {
  3822. sd->clanspy = 0;
  3823. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3824. clif_displaymessage(fd, atcmd_output);
  3825. }
  3826. else {
  3827. sd->clanspy = c->id;
  3828. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3829. clif_displaymessage(fd, atcmd_output);
  3830. }
  3831. }
  3832. else {
  3833. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3834. return -1;
  3835. }
  3836. return 0;
  3837. }
  3838. /*==========================================
  3839. * @repairall [Valaris]
  3840. *------------------------------------------*/
  3841. ACMD_FUNC(repairall)
  3842. {
  3843. int count, i;
  3844. nullpo_retr(-1, sd);
  3845. count = 0;
  3846. for (i = 0; i < MAX_INVENTORY; i++) {
  3847. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3848. sd->inventory.u.items_inventory[i].attribute = 0;
  3849. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3850. count++;
  3851. }
  3852. }
  3853. if (count > 0) {
  3854. clif_misceffect(&sd->bl, 3);
  3855. clif_equiplist(sd);
  3856. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3857. } else {
  3858. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3859. return -1;
  3860. }
  3861. return 0;
  3862. }
  3863. /*==========================================
  3864. * @nuke [Valaris]
  3865. *------------------------------------------*/
  3866. ACMD_FUNC(nuke)
  3867. {
  3868. struct map_session_data *pl_sd;
  3869. nullpo_retr(-1, sd);
  3870. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3871. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3872. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3873. return -1;
  3874. }
  3875. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3876. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3877. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3878. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3879. } else {
  3880. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3881. return -1;
  3882. }
  3883. } else {
  3884. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3885. return -1;
  3886. }
  3887. return 0;
  3888. }
  3889. /*==========================================
  3890. * @tonpc
  3891. *------------------------------------------*/
  3892. ACMD_FUNC(tonpc)
  3893. {
  3894. char npcname[NPC_NAME_LENGTH];
  3895. struct npc_data *nd;
  3896. nullpo_retr(-1, sd);
  3897. memset(npcname, 0, sizeof(npcname));
  3898. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3899. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3900. return -1;
  3901. }
  3902. if ((nd = npc_name2id(npcname)) != NULL) {
  3903. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3904. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3905. else
  3906. return -1;
  3907. } else {
  3908. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3909. return -1;
  3910. }
  3911. return 0;
  3912. }
  3913. /*==========================================
  3914. *
  3915. *------------------------------------------*/
  3916. ACMD_FUNC(shownpc)
  3917. {
  3918. char NPCname[NPC_NAME_LENGTH];
  3919. nullpo_retr(-1, sd);
  3920. memset(NPCname, '\0', sizeof(NPCname));
  3921. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3922. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3923. return -1;
  3924. }
  3925. if (npc_name2id(NPCname) != NULL) {
  3926. npc_enable(NPCname, 1);
  3927. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3928. } else {
  3929. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3930. return -1;
  3931. }
  3932. return 0;
  3933. }
  3934. /*==========================================
  3935. *
  3936. *------------------------------------------*/
  3937. ACMD_FUNC(hidenpc)
  3938. {
  3939. char NPCname[NPC_NAME_LENGTH];
  3940. nullpo_retr(-1, sd);
  3941. memset(NPCname, '\0', sizeof(NPCname));
  3942. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3943. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3944. return -1;
  3945. }
  3946. if (npc_name2id(NPCname) == NULL) {
  3947. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3948. return -1;
  3949. }
  3950. npc_enable(NPCname, 0);
  3951. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3952. return 0;
  3953. }
  3954. ACMD_FUNC(loadnpc)
  3955. {
  3956. if (!message || !*message) {
  3957. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3958. return -1;
  3959. }
  3960. if (!npc_addsrcfile(message, true)) {
  3961. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3962. return -1;
  3963. }
  3964. npc_read_event_script();
  3965. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  3966. return 0;
  3967. }
  3968. ACMD_FUNC(unloadnpc)
  3969. {
  3970. struct npc_data *nd;
  3971. char NPCname[NPC_NAME_LENGTH];
  3972. nullpo_retr(-1, sd);
  3973. memset(NPCname, '\0', sizeof(NPCname));
  3974. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3975. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3976. return -1;
  3977. }
  3978. if ((nd = npc_name2id(NPCname)) == NULL) {
  3979. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3980. return -1;
  3981. }
  3982. npc_unload_duplicates(nd);
  3983. npc_unload(nd,true);
  3984. npc_read_event_script();
  3985. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3986. return 0;
  3987. }
  3988. ACMD_FUNC(reloadnpcfile) {
  3989. if (!message || !*message) {
  3990. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  3991. return -1;
  3992. }
  3993. if (npc_unloadfile(message))
  3994. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  3995. if (!npc_addsrcfile(message, true)) {
  3996. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3997. return -1;
  3998. }
  3999. npc_read_event_script();
  4000. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4001. return 0;
  4002. }
  4003. /*==========================================
  4004. * time in txt for time command (by [Yor])
  4005. *------------------------------------------*/
  4006. char* txt_time(unsigned int duration)
  4007. {
  4008. int days, hours, minutes, seconds;
  4009. char temp[CHAT_SIZE_MAX];
  4010. static char temp1[CHAT_SIZE_MAX];
  4011. memset(temp, '\0', sizeof(temp));
  4012. memset(temp1, '\0', sizeof(temp1));
  4013. days = duration / (60 * 60 * 24);
  4014. duration = duration - (60 * 60 * 24 * days);
  4015. hours = duration / (60 * 60);
  4016. duration = duration - (60 * 60 * hours);
  4017. minutes = duration / 60;
  4018. seconds = duration - (60 * minutes);
  4019. if (days == 1)
  4020. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4021. else if (days > 1)
  4022. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4023. if (hours == 1)
  4024. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4025. else if (hours > 1)
  4026. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4027. if (minutes < 2)
  4028. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4029. else
  4030. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4031. if (seconds == 1)
  4032. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4033. else if (seconds > 1)
  4034. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4035. return temp1;
  4036. }
  4037. /*==========================================
  4038. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4039. * Calculation management of GM modification (@day/@night GM commands) is done
  4040. *------------------------------------------*/
  4041. ACMD_FUNC(servertime)
  4042. {
  4043. const struct TimerData * timer_data;
  4044. time_t time_server; // variable for number of seconds (used with time() function)
  4045. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4046. char temp[CHAT_SIZE_MAX];
  4047. nullpo_retr(-1, sd);
  4048. memset(temp, '\0', sizeof(temp));
  4049. time(&time_server); // get time in seconds since 1/1/1970
  4050. datetime = localtime(&time_server); // convert seconds in structure
  4051. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4052. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4053. clif_displaymessage(fd, temp);
  4054. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4055. if (night_flag == 0)
  4056. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4057. else
  4058. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4059. } else if (battle_config.night_duration == 0)
  4060. if (night_flag == 1) { // we start with night
  4061. timer_data = get_timer(day_timer_tid);
  4062. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4063. clif_displaymessage(fd, temp);
  4064. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4065. } else
  4066. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4067. else if (battle_config.day_duration == 0)
  4068. if (night_flag == 0) { // we start with day
  4069. timer_data = get_timer(night_timer_tid);
  4070. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4071. clif_displaymessage(fd, temp);
  4072. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4073. } else
  4074. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4075. else {
  4076. const struct TimerData * timer_data2;
  4077. if (night_flag == 0) {
  4078. timer_data = get_timer(night_timer_tid);
  4079. timer_data2 = get_timer(day_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. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4083. 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.
  4084. else
  4085. 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.
  4086. clif_displaymessage(fd, temp);
  4087. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4088. clif_displaymessage(fd, temp);
  4089. } else {
  4090. timer_data = get_timer(day_timer_tid);
  4091. timer_data2 = get_timer(night_timer_tid);
  4092. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4093. clif_displaymessage(fd, temp);
  4094. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4095. 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.
  4096. else
  4097. 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.
  4098. clif_displaymessage(fd, temp);
  4099. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4100. clif_displaymessage(fd, temp);
  4101. }
  4102. }
  4103. return 0;
  4104. }
  4105. /*==========================================
  4106. * @jail <char_name> by [Yor]
  4107. * Special warp! No check with nowarp and nowarpto flag
  4108. *------------------------------------------*/
  4109. ACMD_FUNC(jail)
  4110. {
  4111. struct map_session_data *pl_sd;
  4112. int x, y;
  4113. unsigned short m_index;
  4114. nullpo_retr(-1, sd);
  4115. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4116. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4117. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4118. return -1;
  4119. }
  4120. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4121. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4122. return -1;
  4123. }
  4124. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4125. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4126. return -1;
  4127. }
  4128. if (pl_sd->sc.data[SC_JAILED]) {
  4129. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4130. return -1;
  4131. }
  4132. switch(rnd() % 2) { //Jail Locations
  4133. case 0:
  4134. m_index = mapindex_name2id(MAP_JAIL);
  4135. x = 24;
  4136. y = 75;
  4137. break;
  4138. default:
  4139. m_index = mapindex_name2id(MAP_JAIL);
  4140. x = 49;
  4141. y = 75;
  4142. break;
  4143. }
  4144. //Duration of INT_MAX to specify infinity.
  4145. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4146. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4147. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4148. return 0;
  4149. }
  4150. /*==========================================
  4151. * @unjail/@discharge <char_name> by [Yor]
  4152. * Special warp! No check with nowarp and nowarpto flag
  4153. *------------------------------------------*/
  4154. ACMD_FUNC(unjail)
  4155. {
  4156. struct map_session_data *pl_sd;
  4157. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4158. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4159. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4160. return -1;
  4161. }
  4162. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4163. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4164. return -1;
  4165. }
  4166. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4167. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4168. return -1;
  4169. }
  4170. if (!pl_sd->sc.data[SC_JAILED]) {
  4171. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4172. return -1;
  4173. }
  4174. //Reset jail time to 1 sec.
  4175. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4176. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4177. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4178. return 0;
  4179. }
  4180. ACMD_FUNC(jailfor) {
  4181. struct map_session_data *pl_sd = NULL;
  4182. char * modif_p;
  4183. int jailtime = 0,x,y;
  4184. short m_index = 0;
  4185. nullpo_retr(-1, sd);
  4186. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4187. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4188. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4189. return -1;
  4190. }
  4191. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4192. modif_p = atcmd_output;
  4193. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4194. if (jailtime == 0) {
  4195. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4196. 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.
  4197. return -1;
  4198. }
  4199. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4200. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4201. return -1;
  4202. }
  4203. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4204. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4205. return -1;
  4206. }
  4207. // Added by Coltaro
  4208. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4209. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4210. if (jailtime <= 0) {
  4211. jailtime = 0;
  4212. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4213. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4214. } else {
  4215. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4216. char timestr[21];
  4217. time_t now=time(NULL);
  4218. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4219. 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
  4220. clif_displaymessage(pl_sd->fd, atcmd_output);
  4221. 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
  4222. clif_displaymessage(fd, atcmd_output);
  4223. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4224. sprintf(atcmd_output,"Release date is: %s",timestr);
  4225. clif_displaymessage(pl_sd->fd, atcmd_output);
  4226. clif_displaymessage(fd, atcmd_output);
  4227. }
  4228. } else if (jailtime < 0) {
  4229. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4230. return -1;
  4231. }
  4232. // Jail locations, add more as you wish.
  4233. switch(rnd()%2) {
  4234. case 1: // Jail #1
  4235. m_index = mapindex_name2id(MAP_JAIL);
  4236. x = 49; y = 75;
  4237. break;
  4238. default: // Default Jail
  4239. m_index = mapindex_name2id(MAP_JAIL);
  4240. x = 24; y = 75;
  4241. break;
  4242. }
  4243. 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).
  4244. return 0;
  4245. }
  4246. //By Coltaro
  4247. ACMD_FUNC(jailtime){
  4248. int year, month, day, hour, minute, second;
  4249. char timestr[21];
  4250. time_t now = time(NULL);
  4251. nullpo_retr(-1, sd);
  4252. if (!sd->sc.data[SC_JAILED]) {
  4253. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4254. return -1;
  4255. }
  4256. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4257. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4258. return 0;
  4259. }
  4260. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4261. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4262. return -1;
  4263. }
  4264. // Get remaining jail time
  4265. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4266. 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
  4267. clif_displaymessage(fd, atcmd_output);
  4268. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4269. sprintf(atcmd_output,"Release date is: %s",timestr);
  4270. clif_displaymessage(fd, atcmd_output);
  4271. return 0;
  4272. }
  4273. /*==========================================
  4274. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4275. *------------------------------------------*/
  4276. ACMD_FUNC(disguise)
  4277. {
  4278. int id = 0;
  4279. nullpo_retr(-1, sd);
  4280. if (!message || !*message) {
  4281. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4282. return -1;
  4283. }
  4284. if ((id = atoi(message)) > 0)
  4285. { //Acquired an ID
  4286. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4287. id = 0; //Invalid id for either mobs or npcs.
  4288. } else { //Acquired a Name
  4289. if ((id = mobdb_searchname(message)) == 0)
  4290. {
  4291. struct npc_data* nd = npc_name2id(message);
  4292. if (nd != NULL)
  4293. id = nd->class_;
  4294. }
  4295. }
  4296. if (id == 0)
  4297. {
  4298. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4299. return -1;
  4300. }
  4301. if(pc_isriding(sd))
  4302. {
  4303. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4304. return -1;
  4305. }
  4306. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4307. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4308. return -1;
  4309. }
  4310. pc_disguise(sd, id);
  4311. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4312. return 0;
  4313. }
  4314. /*==========================================
  4315. * DisguiseAll
  4316. *------------------------------------------*/
  4317. ACMD_FUNC(disguiseall)
  4318. {
  4319. int mob_id=0;
  4320. struct map_session_data *pl_sd;
  4321. struct s_mapiterator* iter;
  4322. nullpo_retr(-1, sd);
  4323. if (!message || !*message) {
  4324. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4325. return -1;
  4326. }
  4327. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4328. mob_id = atoi(message);
  4329. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4330. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4331. return -1;
  4332. }
  4333. iter = mapit_getallusers();
  4334. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4335. pc_disguise(pl_sd, mob_id);
  4336. mapit_free(iter);
  4337. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4338. return 0;
  4339. }
  4340. /*==========================================
  4341. * DisguiseGuild
  4342. *------------------------------------------*/
  4343. ACMD_FUNC(disguiseguild)
  4344. {
  4345. int id = 0, i;
  4346. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4347. struct guild *g;
  4348. memset(monster, '\0', sizeof(monster));
  4349. memset(guild, '\0', sizeof(guild));
  4350. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4351. 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>).
  4352. return -1;
  4353. }
  4354. if( (id = atoi(monster)) > 0 ) {
  4355. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4356. id = 0;
  4357. } else {
  4358. if( (id = mobdb_searchname(monster)) == 0 ) {
  4359. struct npc_data* nd = npc_name2id(monster);
  4360. if( nd != NULL )
  4361. id = nd->class_;
  4362. }
  4363. }
  4364. if( id == 0 ) {
  4365. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4366. return -1;
  4367. }
  4368. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4369. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4370. return -1;
  4371. }
  4372. for( i = 0; i < g->max_member; i++ ){
  4373. struct map_session_data *pl_sd;
  4374. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4375. pc_disguise(pl_sd, id);
  4376. }
  4377. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4378. return 0;
  4379. }
  4380. /*==========================================
  4381. * @undisguise by [Yor]
  4382. *------------------------------------------*/
  4383. ACMD_FUNC(undisguise)
  4384. {
  4385. nullpo_retr(-1, sd);
  4386. if (sd->disguise) {
  4387. pc_disguise(sd, 0);
  4388. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4389. } else {
  4390. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4391. return -1;
  4392. }
  4393. return 0;
  4394. }
  4395. /*==========================================
  4396. * UndisguiseAll
  4397. *------------------------------------------*/
  4398. ACMD_FUNC(undisguiseall)
  4399. {
  4400. struct map_session_data *pl_sd;
  4401. struct s_mapiterator* iter;
  4402. nullpo_retr(-1, sd);
  4403. iter = mapit_getallusers();
  4404. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4405. if( pl_sd->disguise )
  4406. pc_disguise(pl_sd, 0);
  4407. mapit_free(iter);
  4408. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4409. return 0;
  4410. }
  4411. /*==========================================
  4412. * UndisguiseGuild
  4413. *------------------------------------------*/
  4414. ACMD_FUNC(undisguiseguild)
  4415. {
  4416. char guild_name[NAME_LENGTH];
  4417. struct guild *g;
  4418. int i;
  4419. nullpo_retr(-1, sd);
  4420. memset(guild_name, '\0', sizeof(guild_name));
  4421. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4422. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4423. return -1;
  4424. }
  4425. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4426. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4427. return -1;
  4428. }
  4429. for(i = 0; i < g->max_member; i++){
  4430. struct map_session_data *pl_sd;
  4431. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4432. pc_disguise(pl_sd, 0);
  4433. }
  4434. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4435. return 0;
  4436. }
  4437. /*==========================================
  4438. * @exp by [Skotlex]
  4439. *------------------------------------------*/
  4440. ACMD_FUNC(exp)
  4441. {
  4442. char output[CHAT_SIZE_MAX];
  4443. double nextb, nextj;
  4444. nullpo_retr(-1, sd);
  4445. memset(output, '\0', sizeof(output));
  4446. nextb = pc_nextbaseexp(sd);
  4447. if (nextb)
  4448. nextb = sd->status.base_exp*100.0/nextb;
  4449. nextj = pc_nextjobexp(sd);
  4450. if (nextj)
  4451. nextj = sd->status.job_exp*100.0/nextj;
  4452. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4453. clif_displaymessage(fd, output);
  4454. return 0;
  4455. }
  4456. /*==========================================
  4457. * @broadcast by [Valaris]
  4458. *------------------------------------------*/
  4459. ACMD_FUNC(broadcast)
  4460. {
  4461. nullpo_retr(-1, sd);
  4462. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4463. if (!message || !*message) {
  4464. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4465. return -1;
  4466. }
  4467. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4468. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4469. return 0;
  4470. }
  4471. /*==========================================
  4472. * @localbroadcast by [Valaris]
  4473. *------------------------------------------*/
  4474. ACMD_FUNC(localbroadcast)
  4475. {
  4476. nullpo_retr(-1, sd);
  4477. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4478. if (!message || !*message) {
  4479. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4480. return -1;
  4481. }
  4482. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4483. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4484. return 0;
  4485. }
  4486. /*==========================================
  4487. * @email <actual@email> <new@email> by [Yor]
  4488. *------------------------------------------*/
  4489. ACMD_FUNC(email)
  4490. {
  4491. char actual_email[100];
  4492. char new_email[100];
  4493. nullpo_retr(-1, sd);
  4494. memset(actual_email, '\0', sizeof(actual_email));
  4495. memset(new_email, '\0', sizeof(new_email));
  4496. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4497. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4498. return -1;
  4499. }
  4500. if (e_mail_check(actual_email) == 0) {
  4501. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4502. return -1;
  4503. } else if (e_mail_check(new_email) == 0) {
  4504. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4505. return -1;
  4506. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4507. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4508. return -1;
  4509. } else if (strcmpi(actual_email, new_email) == 0) {
  4510. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4511. return -1;
  4512. }
  4513. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4514. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4515. return 0;
  4516. }
  4517. /*==========================================
  4518. *@effect
  4519. *------------------------------------------*/
  4520. ACMD_FUNC(effect)
  4521. {
  4522. int type = EF_NONE;
  4523. nullpo_retr(-1, sd);
  4524. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4525. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4526. return -1;
  4527. }
  4528. if( type <= EF_NONE || type >= EF_MAX ){
  4529. 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.
  4530. clif_displaymessage(fd, atcmd_output);
  4531. return -1;
  4532. }
  4533. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4534. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4535. return 0;
  4536. }
  4537. /*==========================================
  4538. * @killer by MouseJstr
  4539. * enable killing players even when not in pvp
  4540. *------------------------------------------*/
  4541. ACMD_FUNC(killer)
  4542. {
  4543. nullpo_retr(-1, sd);
  4544. sd->state.killer = !sd->state.killer;
  4545. if(sd->state.killer)
  4546. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4547. else {
  4548. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4549. pc_stop_attack(sd);
  4550. }
  4551. return 0;
  4552. }
  4553. /*==========================================
  4554. * @killable by MouseJstr
  4555. * enable other people killing you
  4556. *------------------------------------------*/
  4557. ACMD_FUNC(killable)
  4558. {
  4559. nullpo_retr(-1, sd);
  4560. sd->state.killable = !sd->state.killable;
  4561. if(sd->state.killable)
  4562. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4563. else {
  4564. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4565. map_foreachinallrange(unit_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4566. }
  4567. return 0;
  4568. }
  4569. /*==========================================
  4570. * @skillon by MouseJstr
  4571. * turn skills on for the map
  4572. *------------------------------------------*/
  4573. ACMD_FUNC(skillon)
  4574. {
  4575. nullpo_retr(-1, sd);
  4576. map_setmapflag(sd->bl.m, MF_NOSKILL, false);
  4577. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4578. return 0;
  4579. }
  4580. /*==========================================
  4581. * @skilloff by MouseJstr
  4582. * Turn skills off on the map
  4583. *------------------------------------------*/
  4584. ACMD_FUNC(skilloff)
  4585. {
  4586. nullpo_retr(-1, sd);
  4587. map_setmapflag(sd->bl.m, MF_NOSKILL, true);
  4588. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4589. return 0;
  4590. }
  4591. /*==========================================
  4592. * @npcmove by MouseJstr
  4593. * move a npc
  4594. *------------------------------------------*/
  4595. ACMD_FUNC(npcmove)
  4596. {
  4597. short x = 0, y = 0;
  4598. struct npc_data *nd = 0;
  4599. char npc_name[NPC_NAME_LENGTH];
  4600. nullpo_retr(-1, sd);
  4601. memset(npc_name, '\0', sizeof npc_name);
  4602. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4603. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4604. return -1;
  4605. }
  4606. if ((nd = npc_name2id(npc_name)) == NULL)
  4607. {
  4608. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4609. return -1;
  4610. }
  4611. if ( npc_movenpc( nd, x, y ) )
  4612. { //actually failed to move
  4613. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4614. return -1; //Not on a map.
  4615. } else
  4616. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4617. return 0;
  4618. }
  4619. /*==========================================
  4620. * @addwarp by MouseJstr
  4621. * Create a new static warp point.
  4622. *------------------------------------------*/
  4623. ACMD_FUNC(addwarp)
  4624. {
  4625. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4626. short x,y;
  4627. unsigned short m;
  4628. struct npc_data* nd;
  4629. nullpo_retr(-1, sd);
  4630. memset(warpname, '\0', sizeof(warpname));
  4631. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4632. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4633. return -1;
  4634. }
  4635. m = mapindex_name2id(mapname);
  4636. if( m == 0 )
  4637. {
  4638. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4639. clif_displaymessage(fd, atcmd_output);
  4640. return -1;
  4641. }
  4642. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4643. if( nd == NULL )
  4644. return -1;
  4645. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4646. clif_displaymessage(fd, atcmd_output);
  4647. return 0;
  4648. }
  4649. /*==========================================
  4650. * @follow by [MouseJstr]
  4651. * Follow a player .. staying no more then 5 spaces away
  4652. *------------------------------------------*/
  4653. ACMD_FUNC(follow)
  4654. {
  4655. struct map_session_data *pl_sd = NULL;
  4656. nullpo_retr(-1, sd);
  4657. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4658. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4659. if (sd->followtarget == -1)
  4660. return -1;
  4661. pc_stop_following (sd);
  4662. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4663. return 0;
  4664. }
  4665. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4666. {
  4667. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4668. return -1;
  4669. }
  4670. if (sd->followtarget == pl_sd->bl.id) {
  4671. pc_stop_following (sd);
  4672. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4673. } else {
  4674. pc_follow(sd, pl_sd->bl.id);
  4675. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4676. }
  4677. return 0;
  4678. }
  4679. /*==========================================
  4680. * @dropall by [MouseJstr] and [Xantara]
  4681. * Drops all your possession on the ground based on item type
  4682. *------------------------------------------*/
  4683. ACMD_FUNC(dropall)
  4684. {
  4685. int8 type = -1;
  4686. uint16 i, count = 0, count2 = 0;
  4687. struct item_data *item_data = NULL;
  4688. nullpo_retr(-1, sd);
  4689. if( message[0] ) {
  4690. type = atoi(message);
  4691. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4692. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4693. {
  4694. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4695. 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
  4696. return -1;
  4697. }
  4698. }
  4699. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4700. if( sd->inventory.u.items_inventory[i].amount ) {
  4701. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4702. 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);
  4703. continue;
  4704. }
  4705. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4706. continue;
  4707. if( type == -1 || type == (uint8)item_data->type ) {
  4708. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4709. pc_unequipitem(sd, i, 3);
  4710. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4711. count += sd->inventory.u.items_inventory[i].amount;
  4712. else count2 += sd->inventory.u.items_inventory[i].amount;
  4713. }
  4714. }
  4715. }
  4716. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4717. clif_displaymessage(fd, atcmd_output);
  4718. return 0;
  4719. }
  4720. /*==========================================
  4721. * @storeall by [MouseJstr]
  4722. * Put everything into storage
  4723. *------------------------------------------*/
  4724. ACMD_FUNC(storeall)
  4725. {
  4726. int i;
  4727. nullpo_retr(-1, sd);
  4728. if (sd->state.storage_flag != 1)
  4729. { //Open storage.
  4730. if( storage_storageopen(sd) == 1 ) {
  4731. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4732. return -1;
  4733. }
  4734. }
  4735. for (i = 0; i < MAX_INVENTORY; i++) {
  4736. if (sd->inventory.u.items_inventory[i].amount) {
  4737. if(sd->inventory.u.items_inventory[i].equip != 0)
  4738. pc_unequipitem(sd, i, 3);
  4739. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4740. }
  4741. }
  4742. storage_storageclose(sd);
  4743. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4744. return 0;
  4745. }
  4746. ACMD_FUNC(clearstorage)
  4747. {
  4748. int i, j;
  4749. nullpo_retr(-1, sd);
  4750. if (sd->state.storage_flag == 1) {
  4751. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4752. return -1;
  4753. }
  4754. if (sd->state.storage_flag == 3) {
  4755. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4756. return -1;
  4757. }
  4758. j = sd->storage.amount;
  4759. for (i = 0; i < j; ++i) {
  4760. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4761. }
  4762. sd->state.storage_flag = 1;
  4763. storage_storageclose(sd);
  4764. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4765. return 0;
  4766. }
  4767. ACMD_FUNC(cleargstorage)
  4768. {
  4769. int i, j;
  4770. struct guild *g;
  4771. struct s_storage *gstorage;
  4772. nullpo_retr(-1, sd);
  4773. g = sd->guild;
  4774. if (g == NULL) {
  4775. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4776. return -1;
  4777. }
  4778. if (sd->state.storage_flag == 1) {
  4779. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4780. return -1;
  4781. }
  4782. if (sd->state.storage_flag == 2) {
  4783. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4784. return -1;
  4785. }
  4786. if (sd->state.storage_flag == 3) {
  4787. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4788. return -1;
  4789. }
  4790. gstorage = guild2storage2(sd->status.guild_id);
  4791. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4792. return -1;
  4793. }
  4794. j = gstorage->amount;
  4795. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4796. for (i = 0; i < j; ++i) {
  4797. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4798. }
  4799. storage_guild_storageclose(sd);
  4800. gstorage->lock = false; // Cleaning done, release lock
  4801. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4802. return 0;
  4803. }
  4804. ACMD_FUNC(clearcart)
  4805. {
  4806. int i;
  4807. nullpo_retr(-1, sd);
  4808. if (pc_iscarton(sd) == 0) {
  4809. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4810. return -1;
  4811. }
  4812. if (sd->state.vending == 1) { //Somehow...
  4813. return -1;
  4814. }
  4815. for (i = 0; i < MAX_CART; i++) {
  4816. if (sd->cart.u.items_cart[i].nameid > 0)
  4817. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4818. }
  4819. clif_clearcart(fd);
  4820. clif_updatestatus(sd,SP_CARTINFO);
  4821. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4822. return 0;
  4823. }
  4824. /*==========================================
  4825. * @skillid by [MouseJstr]
  4826. * lookup a skill by name
  4827. *------------------------------------------*/
  4828. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4829. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4830. ACMD_FUNC(skillid) {
  4831. int skillen, i, found = 0;
  4832. DBIterator* iter;
  4833. DBKey key;
  4834. DBData *data;
  4835. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4836. nullpo_retr(-1, sd);
  4837. if (!message || !*message) {
  4838. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4839. return -1;
  4840. }
  4841. skillen = strlen(message);
  4842. iter = db_iterator(skilldb_name2id);
  4843. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4844. int idx = skill_get_index(db_data2i(data));
  4845. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4846. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4847. clif_displaymessage(fd, atcmd_output);
  4848. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4849. 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)
  4850. }
  4851. }
  4852. dbi_destroy(iter);
  4853. if( found ) {
  4854. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4855. clif_displaymessage(fd, atcmd_output);
  4856. }
  4857. for(i = 0; i < found; i++) { /* partials */
  4858. clif_displaymessage(fd, partials[i]);
  4859. }
  4860. return 0;
  4861. }
  4862. /*==========================================
  4863. * @useskill by [MouseJstr]
  4864. * A way of using skills without having to find them in the skills menu
  4865. *------------------------------------------*/
  4866. ACMD_FUNC(useskill)
  4867. {
  4868. struct map_session_data *pl_sd = NULL;
  4869. struct block_list *bl;
  4870. uint16 skill_id;
  4871. uint16 skill_lv;
  4872. nullpo_retr(-1, sd);
  4873. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4874. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4875. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4876. return -1;
  4877. }
  4878. if(!strcmp(atcmd_player_name,"self"))
  4879. pl_sd = sd; //quick keyword
  4880. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4881. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4882. return -1;
  4883. }
  4884. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4885. {
  4886. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4887. return -1;
  4888. }
  4889. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4890. bl = &sd->hd->bl;
  4891. else
  4892. bl = &sd->bl;
  4893. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4894. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4895. else
  4896. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @displayskill by [Skotlex]
  4901. * Debug command to locate new skill IDs. It sends the
  4902. * three possible skill-effect packets to the area.
  4903. *------------------------------------------*/
  4904. ACMD_FUNC(displayskill)
  4905. {
  4906. struct status_data * status;
  4907. unsigned int tick;
  4908. uint16 skill_id;
  4909. uint16 skill_lv = 1;
  4910. nullpo_retr(-1, sd);
  4911. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4912. {
  4913. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4914. return -1;
  4915. }
  4916. status = status_get_status_data(&sd->bl);
  4917. tick = gettick();
  4918. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4919. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4920. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4921. return 0;
  4922. }
  4923. /*==========================================
  4924. * @skilltree by [MouseJstr]
  4925. * prints the skill tree for a player required to get to a skill
  4926. *------------------------------------------*/
  4927. ACMD_FUNC(skilltree)
  4928. {
  4929. struct map_session_data *pl_sd = NULL;
  4930. uint16 skill_id;
  4931. int meets, i, j, c=0;
  4932. struct skill_tree_entry *ent;
  4933. nullpo_retr(-1, sd);
  4934. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4935. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  4936. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  4937. return -1;
  4938. }
  4939. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4940. {
  4941. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4942. return -1;
  4943. }
  4944. i = pc_calc_skilltree_normalize_job(pl_sd);
  4945. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4946. 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).
  4947. clif_displaymessage(fd, atcmd_output);
  4948. c = pc_class2idx(c);
  4949. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4950. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4951. {
  4952. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4953. return 0;
  4954. }
  4955. ent = &skill_tree[c][j];
  4956. meets = 1;
  4957. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4958. {
  4959. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4960. {
  4961. 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.
  4962. clif_displaymessage(fd, atcmd_output);
  4963. meets = 0;
  4964. }
  4965. }
  4966. if (meets == 1) {
  4967. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4968. }
  4969. return 0;
  4970. }
  4971. // Hand a ring with partners name on it to this char
  4972. void getring (struct map_session_data* sd)
  4973. {
  4974. char flag = 0;
  4975. unsigned short item_id;
  4976. struct item item_tmp;
  4977. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4978. memset(&item_tmp, 0, sizeof(item_tmp));
  4979. item_tmp.nameid = item_id;
  4980. item_tmp.identify = 1;
  4981. item_tmp.card[0] = 255;
  4982. item_tmp.card[2] = sd->status.partner_id;
  4983. item_tmp.card[3] = sd->status.partner_id >> 16;
  4984. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4985. clif_additem(sd,0,0,flag);
  4986. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4987. }
  4988. }
  4989. /*==========================================
  4990. * @marry by [MouseJstr], fixed by Lupus
  4991. * Marry two players
  4992. *------------------------------------------*/
  4993. ACMD_FUNC(marry)
  4994. {
  4995. struct map_session_data *pl_sd = NULL;
  4996. nullpo_retr(-1, sd);
  4997. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4998. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4999. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5000. return -1;
  5001. }
  5002. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5003. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5004. return -1;
  5005. }
  5006. if (pc_marriage(sd, pl_sd)) {
  5007. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5008. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5009. if( pl_sd->bl.m != sd->bl.m )
  5010. clif_wedding_effect(&sd->bl);
  5011. getring(sd); // Auto-give named rings (Aru)
  5012. getring(pl_sd);
  5013. return 0;
  5014. }
  5015. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5016. return -1;
  5017. }
  5018. /*==========================================
  5019. * @divorce by [MouseJstr], fixed by [Lupus]
  5020. * divorce two players
  5021. *------------------------------------------*/
  5022. ACMD_FUNC(divorce)
  5023. {
  5024. nullpo_retr(-1, sd);
  5025. if (!pc_divorce(sd)) {
  5026. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5027. clif_displaymessage(fd, atcmd_output);
  5028. return -1;
  5029. }
  5030. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5031. clif_displaymessage(fd, atcmd_output);
  5032. return 0;
  5033. }
  5034. /*==========================================
  5035. * @changelook by [Celest]
  5036. *------------------------------------------*/
  5037. ACMD_FUNC(changelook)
  5038. {
  5039. int i, j = 0, k = 0;
  5040. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5041. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5042. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5043. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5044. return -1;
  5045. } else if ( i == 2 ) {
  5046. if (j < 1 || j > 8)
  5047. j = 1;
  5048. j = pos[j - 1];
  5049. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5050. k = j; // swap
  5051. j = LOOK_HEAD_TOP;
  5052. }
  5053. clif_changelook(&sd->bl,j,k);
  5054. return 0;
  5055. }
  5056. /*==========================================
  5057. * @autotrade by durf [Lupus] [Paradox924X]
  5058. * Turns on/off Autotrade for a specific player
  5059. *------------------------------------------*/
  5060. ACMD_FUNC(autotrade) {
  5061. nullpo_retr(-1, sd);
  5062. if( map_getmapflag(sd->bl.m, MF_AUTOTRADE) != battle_config.autotrade_mapflag ) {
  5063. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5064. return -1;
  5065. }
  5066. if( pc_isdead(sd) ) {
  5067. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5068. return -1;
  5069. }
  5070. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5071. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5072. return -1;
  5073. }
  5074. sd->state.autotrade = 1;
  5075. if (battle_config.autotrade_monsterignore)
  5076. sd->state.monster_ignore = 1;
  5077. if( sd->state.vending ){
  5078. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5079. Sql_ShowDebug( mmysql_handle );
  5080. }
  5081. }else if( sd->state.buyingstore ){
  5082. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5083. Sql_ShowDebug( mmysql_handle );
  5084. }
  5085. }
  5086. if( battle_config.at_timeout ) {
  5087. int timeout = atoi(message);
  5088. 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);
  5089. }
  5090. channel_pcquit(sd,0xF); //leave all chan
  5091. clif_authfail_fd(sd->fd, 15);
  5092. chrif_save(sd, CSAVE_AUTOTRADE);
  5093. return 0;
  5094. }
  5095. /*==========================================
  5096. * @changegm by durf (changed by Lupus)
  5097. * Changes Master of your Guild to a specified guild member
  5098. *------------------------------------------*/
  5099. ACMD_FUNC(changegm)
  5100. {
  5101. struct guild *g;
  5102. struct map_session_data *pl_sd;
  5103. nullpo_retr(-1, sd);
  5104. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5105. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5106. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5107. return -1;
  5108. }
  5109. if( map_getmapflag(sd->bl.m, MF_GUILDLOCK) || map_getmapflag(sd->bl.m, MF_GVG_CASTLE) ) {
  5110. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5111. return -1;
  5112. }
  5113. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5114. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5115. return -1;
  5116. }
  5117. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5118. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5119. return -1;
  5120. }
  5121. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5122. return 0;
  5123. }
  5124. /*==========================================
  5125. * @changeleader by Skotlex
  5126. * Changes the leader of a party.
  5127. *------------------------------------------*/
  5128. ACMD_FUNC(changeleader)
  5129. {
  5130. nullpo_retr(-1, sd);
  5131. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5132. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5133. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5134. return -1;
  5135. }
  5136. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5137. return 0;
  5138. }
  5139. /*==========================================
  5140. * @partyoption by Skotlex
  5141. * Used to change the item share setting of a party.
  5142. *------------------------------------------*/
  5143. ACMD_FUNC(partyoption)
  5144. {
  5145. struct party_data *p;
  5146. int mi, option;
  5147. char w1[16], w2[16];
  5148. nullpo_retr(-1, sd);
  5149. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5150. {
  5151. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5152. return -1;
  5153. }
  5154. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5155. if (mi == MAX_PARTY)
  5156. return -1; //Shouldn't happen
  5157. if (!p->party.member[mi].leader)
  5158. {
  5159. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5160. return -1;
  5161. }
  5162. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5163. {
  5164. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5165. return -1;
  5166. }
  5167. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5168. //Change item share type.
  5169. if (option != p->party.item)
  5170. party_changeoption(sd, p->party.exp, option);
  5171. else
  5172. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5173. return 0;
  5174. }
  5175. /*==========================================
  5176. * @autoloot by Upa-Kun
  5177. * Turns on/off AutoLoot for a specific player
  5178. *------------------------------------------*/
  5179. ACMD_FUNC(autoloot)
  5180. {
  5181. int rate;
  5182. nullpo_retr(-1, sd);
  5183. // autoloot command without value
  5184. if(!message || !*message)
  5185. {
  5186. if (sd->state.autoloot)
  5187. rate = 0;
  5188. else
  5189. rate = 10000;
  5190. } else {
  5191. double drate;
  5192. drate = atof(message);
  5193. rate = (int)(drate*100);
  5194. }
  5195. if (rate < 0) rate = 0;
  5196. if (rate > 10000) rate = 10000;
  5197. sd->state.autoloot = rate;
  5198. if (sd->state.autoloot) {
  5199. 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.
  5200. clif_displaymessage(fd, atcmd_output);
  5201. }else
  5202. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5203. return 0;
  5204. }
  5205. /*==========================================
  5206. * @alootid
  5207. *------------------------------------------*/
  5208. ACMD_FUNC(autolootitem)
  5209. {
  5210. struct item_data *item_data = NULL;
  5211. int i;
  5212. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5213. nullpo_retr(-1, sd);
  5214. if (message && *message) {
  5215. if (message[0] == '+') {
  5216. message++;
  5217. action = 1;
  5218. }
  5219. else if (message[0] == '-') {
  5220. message++;
  5221. action = 2;
  5222. }
  5223. else if (!strcmp(message,"reset"))
  5224. action = 4;
  5225. }
  5226. if (action < 3) // add or remove
  5227. {
  5228. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5229. item_data = itemdb_searchname(message);
  5230. if (!item_data) {
  5231. // No items founds in the DB with Id or Name
  5232. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5233. return -1;
  5234. }
  5235. }
  5236. switch(action) {
  5237. case 1:
  5238. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5239. if (i != AUTOLOOTITEM_SIZE) {
  5240. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5241. return -1;
  5242. }
  5243. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5244. if (i == AUTOLOOTITEM_SIZE) {
  5245. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5246. return -1;
  5247. }
  5248. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5249. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5250. clif_displaymessage(fd, atcmd_output);
  5251. sd->state.autolooting = 1;
  5252. break;
  5253. case 2:
  5254. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5255. if (i == AUTOLOOTITEM_SIZE) {
  5256. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5257. return -1;
  5258. }
  5259. sd->state.autolootid[i] = 0;
  5260. 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.
  5261. clif_displaymessage(fd, atcmd_output);
  5262. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5263. if (i == AUTOLOOTITEM_SIZE) {
  5264. sd->state.autolooting = 0;
  5265. }
  5266. break;
  5267. case 3:
  5268. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5269. clif_displaymessage(fd, atcmd_output);
  5270. 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>".
  5271. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5272. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5273. if (i == AUTOLOOTITEM_SIZE) {
  5274. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5275. } else {
  5276. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5277. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5278. {
  5279. if (sd->state.autolootid[i] == 0)
  5280. continue;
  5281. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5282. 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);
  5283. continue;
  5284. }
  5285. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5286. clif_displaymessage(fd, atcmd_output);
  5287. }
  5288. }
  5289. break;
  5290. case 4:
  5291. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5292. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5293. sd->state.autolooting = 0;
  5294. break;
  5295. }
  5296. return 0;
  5297. }
  5298. /*==========================================
  5299. * @autoloottype
  5300. * Flags:
  5301. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5302. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5303. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5304. * 262144: IT_CASH
  5305. *------------------------------------------
  5306. * Credits:
  5307. * chriser
  5308. * Aleos
  5309. *------------------------------------------*/
  5310. ACMD_FUNC(autoloottype)
  5311. {
  5312. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5313. enum item_types type= IT_UNKNOWN;
  5314. int ITEM_MAX = 1533;
  5315. nullpo_retr(-1, sd);
  5316. if (message && *message) {
  5317. if (message[0] == '+') {
  5318. message++;
  5319. action = 1;
  5320. }
  5321. else if (message[0] == '-') {
  5322. message++;
  5323. action = 2;
  5324. }
  5325. else if (!strcmp(message,"reset"))
  5326. action = 4;
  5327. }
  5328. if (action < 3) { // add or remove
  5329. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5330. type = IT_HEALING;
  5331. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5332. type = IT_USABLE;
  5333. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5334. type = IT_ETC;
  5335. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5336. type = IT_ARMOR;
  5337. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5338. type = IT_WEAPON;
  5339. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5340. type = IT_CARD;
  5341. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5342. type = IT_PETEGG;
  5343. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5344. type = IT_PETARMOR;
  5345. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5346. type = IT_AMMO;
  5347. else {
  5348. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5349. return -1;
  5350. }
  5351. }
  5352. switch (action) {
  5353. case 1:
  5354. if (sd->state.autoloottype&(1<<type)) {
  5355. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5356. return -1;
  5357. }
  5358. if (sd->state.autoloottype == ITEM_MAX) {
  5359. 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>.
  5360. return -1;
  5361. }
  5362. sd->state.autoloottype |= (1<<type); // Stores the type
  5363. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5364. clif_displaymessage(fd, atcmd_output);
  5365. break;
  5366. case 2:
  5367. if (!(sd->state.autoloottype&(1<<type))) {
  5368. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5369. return -1;
  5370. }
  5371. sd->state.autoloottype &= ~(1<<type);
  5372. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5373. clif_displaymessage(fd, atcmd_output);
  5374. break;
  5375. case 3:
  5376. 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>".
  5377. 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
  5378. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5379. if (sd->state.autoloottype == 0)
  5380. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5381. else {
  5382. uint8 i = 0;
  5383. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5384. while (i < IT_MAX) {
  5385. if (sd->state.autoloottype&(1<<i)) {
  5386. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5387. clif_displaymessage(fd, atcmd_output);
  5388. }
  5389. i++;
  5390. }
  5391. }
  5392. break;
  5393. case 4:
  5394. sd->state.autoloottype = 0;
  5395. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5396. break;
  5397. }
  5398. return 0;
  5399. }
  5400. /*==========================================
  5401. * It is made to rain.
  5402. * No longer available, keeping here just in case it's back someday. [Ind]
  5403. *------------------------------------------*/
  5404. //ACMD_FUNC(rain)
  5405. //{
  5406. // nullpo_retr(-1, sd);
  5407. // if (map_getmapflag(sd->bl.m, MF_RAIN)) {
  5408. // map_setmapflag(sd->bl.m, MF_RAIN, false);
  5409. // clif_weather(sd->bl.m);
  5410. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5411. // } else {
  5412. // map_setmapflag(sd->bl.m, MF_RAIN, true);
  5413. // clif_weather(sd->bl.m);
  5414. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5415. // }
  5416. // return 0;
  5417. //}
  5418. /*==========================================
  5419. * It is made to snow.
  5420. *------------------------------------------*/
  5421. ACMD_FUNC(snow)
  5422. {
  5423. nullpo_retr(-1, sd);
  5424. if (map_getmapflag(sd->bl.m, MF_SNOW)) {
  5425. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5426. clif_weather(sd->bl.m);
  5427. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5428. } else {
  5429. map_setmapflag(sd->bl.m, MF_SNOW, true);
  5430. clif_weather(sd->bl.m);
  5431. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5432. }
  5433. return 0;
  5434. }
  5435. /*==========================================
  5436. * Cherry tree snowstorm is made to fall. (Sakura)
  5437. *------------------------------------------*/
  5438. ACMD_FUNC(sakura)
  5439. {
  5440. nullpo_retr(-1, sd);
  5441. if (map_getmapflag(sd->bl.m, MF_SAKURA)) {
  5442. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5443. clif_weather(sd->bl.m);
  5444. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5445. } else {
  5446. map_setmapflag(sd->bl.m, MF_SAKURA, true);
  5447. clif_weather(sd->bl.m);
  5448. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5449. }
  5450. return 0;
  5451. }
  5452. /*==========================================
  5453. * Clouds appear.
  5454. *------------------------------------------*/
  5455. ACMD_FUNC(clouds)
  5456. {
  5457. nullpo_retr(-1, sd);
  5458. if (map_getmapflag(sd->bl.m, MF_CLOUDS)) {
  5459. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5460. clif_weather(sd->bl.m);
  5461. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5462. } else {
  5463. map_setmapflag(sd->bl.m, MF_CLOUDS, true);
  5464. clif_weather(sd->bl.m);
  5465. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5466. }
  5467. return 0;
  5468. }
  5469. /*==========================================
  5470. * Different type of clouds using effect 516
  5471. *------------------------------------------*/
  5472. ACMD_FUNC(clouds2)
  5473. {
  5474. nullpo_retr(-1, sd);
  5475. if (map_getmapflag(sd->bl.m, MF_CLOUDS2)) {
  5476. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5477. clif_weather(sd->bl.m);
  5478. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5479. } else {
  5480. map_setmapflag(sd->bl.m, MF_CLOUDS2, true);
  5481. clif_weather(sd->bl.m);
  5482. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5483. }
  5484. return 0;
  5485. }
  5486. /*==========================================
  5487. * Fog hangs over.
  5488. *------------------------------------------*/
  5489. ACMD_FUNC(fog)
  5490. {
  5491. nullpo_retr(-1, sd);
  5492. if (map_getmapflag(sd->bl.m, MF_FOG)) {
  5493. map_setmapflag(sd->bl.m, MF_FOG, false);
  5494. clif_weather(sd->bl.m);
  5495. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5496. } else {
  5497. map_setmapflag(sd->bl.m, MF_FOG, true);
  5498. clif_weather(sd->bl.m);
  5499. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5500. }
  5501. return 0;
  5502. }
  5503. /*==========================================
  5504. * Fallen leaves fall.
  5505. *------------------------------------------*/
  5506. ACMD_FUNC(leaves)
  5507. {
  5508. nullpo_retr(-1, sd);
  5509. if (map_getmapflag(sd->bl.m, MF_LEAVES)) {
  5510. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5511. clif_weather(sd->bl.m);
  5512. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5513. } else {
  5514. map_setmapflag(sd->bl.m, MF_LEAVES, true);
  5515. clif_weather(sd->bl.m);
  5516. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5517. }
  5518. return 0;
  5519. }
  5520. /*==========================================
  5521. * Fireworks appear.
  5522. *------------------------------------------*/
  5523. ACMD_FUNC(fireworks)
  5524. {
  5525. nullpo_retr(-1, sd);
  5526. if (map_getmapflag(sd->bl.m, MF_FIREWORKS)) {
  5527. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5528. clif_weather(sd->bl.m);
  5529. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5530. } else {
  5531. map_setmapflag(sd->bl.m, MF_FIREWORKS, true);
  5532. clif_weather(sd->bl.m);
  5533. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5534. }
  5535. return 0;
  5536. }
  5537. /*==========================================
  5538. * Clearing Weather Effects by Dexity
  5539. *------------------------------------------*/
  5540. ACMD_FUNC(clearweather)
  5541. {
  5542. nullpo_retr(-1, sd);
  5543. //map_setmapflag(sd->bl.m, MF_RAIN, false); // No longer available, keeping here just in case it's back someday. [Ind]
  5544. map_setmapflag(sd->bl.m, MF_SNOW, false);
  5545. map_setmapflag(sd->bl.m, MF_SAKURA, false);
  5546. map_setmapflag(sd->bl.m, MF_CLOUDS, false);
  5547. map_setmapflag(sd->bl.m, MF_CLOUDS2, false);
  5548. map_setmapflag(sd->bl.m, MF_FOG, false);
  5549. map_setmapflag(sd->bl.m, MF_FIREWORKS, false);
  5550. map_setmapflag(sd->bl.m, MF_LEAVES, false);
  5551. clif_weather(sd->bl.m);
  5552. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5553. return 0;
  5554. }
  5555. /*===============================================================
  5556. * Sound Command - plays a sound for everyone around! [Codemaster]
  5557. *---------------------------------------------------------------*/
  5558. ACMD_FUNC(sound)
  5559. {
  5560. char sound_file[100];
  5561. memset(sound_file, '\0', sizeof(sound_file));
  5562. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5563. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5564. return -1;
  5565. }
  5566. if(strstr(sound_file, ".wav") == NULL)
  5567. strcat(sound_file, ".wav");
  5568. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5569. return 0;
  5570. }
  5571. /*==========================================
  5572. * MOB Search
  5573. *------------------------------------------*/
  5574. ACMD_FUNC(mobsearch)
  5575. {
  5576. char mob_name[100];
  5577. int mob_id;
  5578. int number = 0;
  5579. struct s_mapiterator* it;
  5580. nullpo_retr(-1, sd);
  5581. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5582. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5583. return -1;
  5584. }
  5585. if ((mob_id = atoi(mob_name)) == 0)
  5586. mob_id = mobdb_searchname(mob_name);
  5587. if( mobdb_checkid(mob_id) == 0){
  5588. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5589. clif_displaymessage(fd, atcmd_output);
  5590. return -1;
  5591. }
  5592. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5593. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5594. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5595. clif_displaymessage(fd, atcmd_output);
  5596. it = mapit_geteachmob();
  5597. for(;;)
  5598. {
  5599. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5600. if( md == NULL )
  5601. break;// no more mobs
  5602. if( md->bl.m != sd->bl.m )
  5603. continue;
  5604. if( md->mob_id != mob_id )
  5605. continue;
  5606. ++number;
  5607. if( md->spawn_timer == INVALID_TIMER )
  5608. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5609. else
  5610. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5611. clif_displaymessage(fd, atcmd_output);
  5612. }
  5613. mapit_free(it);
  5614. return 0;
  5615. }
  5616. /*==========================================
  5617. * @cleanmap - cleans items on the ground
  5618. * @cleanarea - cleans items on the ground within an specified area
  5619. *------------------------------------------*/
  5620. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5621. {
  5622. nullpo_ret(bl);
  5623. map_clearflooritem(bl);
  5624. return 0;
  5625. }
  5626. ACMD_FUNC(cleanmap)
  5627. {
  5628. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5629. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5630. return 0;
  5631. }
  5632. ACMD_FUNC(cleanarea)
  5633. {
  5634. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5635. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5636. 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);
  5637. }
  5638. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5639. 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);
  5640. }
  5641. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5642. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5643. }
  5644. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5645. return 0;
  5646. }
  5647. /*==========================================
  5648. * make a NPC/PET talk
  5649. * @npctalkc [SnakeDrak]
  5650. *------------------------------------------*/
  5651. ACMD_FUNC(npctalk)
  5652. {
  5653. char name[NPC_NAME_LENGTH],mes[100],temp[100];
  5654. struct npc_data *nd;
  5655. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5656. unsigned long color=0;
  5657. if (sd->sc.cant.chat)
  5658. return -1; //no "chatting" while muted.
  5659. if(!ifcolor) {
  5660. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5661. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5662. return -1;
  5663. }
  5664. }
  5665. else {
  5666. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5667. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5668. return -1;
  5669. }
  5670. }
  5671. if (!(nd = npc_name2id(name))) {
  5672. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5673. return -1;
  5674. }
  5675. strtok(name, "#"); // discard extra name identifier if present
  5676. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5677. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5678. else clif_disp_overhead(&nd->bl, temp);
  5679. return 0;
  5680. }
  5681. ACMD_FUNC(pettalk)
  5682. {
  5683. char mes[100],temp[100];
  5684. struct pet_data *pd;
  5685. nullpo_retr(-1, sd);
  5686. if ( battle_config.min_chat_delay ) {
  5687. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5688. return 0;
  5689. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5690. }
  5691. if(!sd->status.pet_id || !(pd=sd->pd))
  5692. {
  5693. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5694. return -1;
  5695. }
  5696. if (sd->sc.cant.chat)
  5697. return -1; //no "chatting" while muted.
  5698. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5699. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5700. return -1;
  5701. }
  5702. if (message[0] == '/')
  5703. {// pet emotion processing
  5704. const char* emo[] = {
  5705. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5706. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5707. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5708. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5709. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5710. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5711. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5712. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5713. "/whisp"
  5714. };
  5715. int i;
  5716. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5717. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5718. if( i < ARRAYLENGTH(emo) )
  5719. {
  5720. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5721. sd->emotionlasttime = time(NULL);
  5722. return 0;
  5723. }
  5724. sd->emotionlasttime = time(NULL);
  5725. clif_emotion(&pd->bl, i);
  5726. return 0;
  5727. }
  5728. }
  5729. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5730. clif_disp_overhead(&pd->bl, temp);
  5731. return 0;
  5732. }
  5733. /// @users - displays the number of players present on each map (and percentage)
  5734. /// #users displays on the target user instead of self
  5735. ACMD_FUNC(users)
  5736. {
  5737. char buf[CHAT_SIZE_MAX];
  5738. int i;
  5739. int users[MAX_MAPINDEX];
  5740. int users_all;
  5741. struct s_mapiterator* iter;
  5742. memset(users, 0, sizeof(users));
  5743. users_all = 0;
  5744. // count users on each map
  5745. iter = mapit_getallusers();
  5746. for(;;)
  5747. {
  5748. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5749. if( sd2 == NULL )
  5750. break;// no more users
  5751. if( sd2->mapindex >= MAX_MAPINDEX )
  5752. continue;// invalid mapindex
  5753. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5754. if( users_all < INT_MAX ) ++users_all;
  5755. }
  5756. mapit_free(iter);
  5757. // display results for each map
  5758. for( i = 0; i < MAX_MAPINDEX; ++i )
  5759. {
  5760. if( users[i] == 0 )
  5761. continue;// empty
  5762. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5763. clif_displaymessage(sd->fd, buf);
  5764. }
  5765. // display overall count
  5766. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5767. clif_displaymessage(sd->fd, buf);
  5768. return 0;
  5769. }
  5770. /*==========================================
  5771. *
  5772. *------------------------------------------*/
  5773. ACMD_FUNC(reset)
  5774. {
  5775. pc_resetstate(sd);
  5776. pc_resetskill(sd,1);
  5777. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5778. clif_displaymessage(fd, atcmd_output);
  5779. return 0;
  5780. }
  5781. /*==========================================
  5782. *
  5783. *------------------------------------------*/
  5784. ACMD_FUNC(summon)
  5785. {
  5786. char name[NAME_LENGTH];
  5787. int mob_id = 0;
  5788. int duration = 0;
  5789. struct mob_data *md;
  5790. unsigned int tick=gettick();
  5791. nullpo_retr(-1, sd);
  5792. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5793. {
  5794. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5795. return -1;
  5796. }
  5797. if (duration < 1)
  5798. duration =1;
  5799. else if (duration > 60)
  5800. duration =60;
  5801. if ((mob_id = atoi(name)) == 0)
  5802. mob_id = mobdb_searchname(name);
  5803. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5804. {
  5805. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5806. return -1;
  5807. }
  5808. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5809. if(!md)
  5810. return -1;
  5811. md->master_id=sd->bl.id;
  5812. md->special_state.ai=AI_ATTACK;
  5813. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5814. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5815. mob_spawn(md);
  5816. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5817. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5818. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5819. return 0;
  5820. }
  5821. /*==========================================
  5822. * @adjgroup
  5823. * Temporarily move player to another group
  5824. * Useful during beta testing to allow players to use GM commands for short periods of time
  5825. *------------------------------------------*/
  5826. ACMD_FUNC(adjgroup)
  5827. {
  5828. int new_group = 0;
  5829. nullpo_retr(-1, sd);
  5830. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5831. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5832. return -1;
  5833. }
  5834. if (!pc_group_exists(new_group)) {
  5835. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5836. return -1;
  5837. }
  5838. sd->group_id = new_group;
  5839. pc_group_pc_load(sd);/* update cache */
  5840. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5841. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5842. return 0;
  5843. }
  5844. /*==========================================
  5845. * @trade by [MouseJstr]
  5846. * Open a trade window with a remote player
  5847. *------------------------------------------*/
  5848. ACMD_FUNC(trade)
  5849. {
  5850. struct map_session_data *pl_sd = NULL;
  5851. nullpo_retr(-1, sd);
  5852. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5853. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5854. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5855. return -1;
  5856. }
  5857. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5858. {
  5859. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5860. return -1;
  5861. }
  5862. trade_traderequest(sd, pl_sd);
  5863. return 0;
  5864. }
  5865. /*==========================================
  5866. * @setbattleflag by [MouseJstr]
  5867. * set a battle_config flag without having to reboot
  5868. *------------------------------------------*/
  5869. ACMD_FUNC(setbattleflag)
  5870. {
  5871. char flag[128], value[128];
  5872. int reload = 0;
  5873. nullpo_retr(-1, sd);
  5874. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5875. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5876. return -1;
  5877. }
  5878. if (battle_set_value(flag, value) == 0)
  5879. {
  5880. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5881. return -1;
  5882. }
  5883. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5884. if (reload)
  5885. mob_reload();
  5886. return 0;
  5887. }
  5888. /*==========================================
  5889. * @unmute [Valaris]
  5890. *------------------------------------------*/
  5891. ACMD_FUNC(unmute)
  5892. {
  5893. struct map_session_data *pl_sd = NULL;
  5894. nullpo_retr(-1, sd);
  5895. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5896. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5897. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5898. return -1;
  5899. }
  5900. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5901. {
  5902. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5903. return -1;
  5904. }
  5905. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5906. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5907. return -1;
  5908. }
  5909. pl_sd->status.manner = 0;
  5910. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5911. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5912. return 0;
  5913. }
  5914. /*==========================================
  5915. * @uptime by MC Cameri
  5916. *------------------------------------------*/
  5917. ACMD_FUNC(uptime)
  5918. {
  5919. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5920. minute = 60, days = 0, hours = 0, minutes = 0;
  5921. nullpo_retr(-1, sd);
  5922. seconds = get_uptime();
  5923. days = seconds/day;
  5924. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5925. hours = seconds/hour;
  5926. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5927. minutes = seconds/minute;
  5928. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5929. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  5930. clif_displaymessage(fd, atcmd_output);
  5931. return 0;
  5932. }
  5933. /*==========================================
  5934. * @changesex
  5935. * => Changes one's account sex. Switch from male to female or visversa
  5936. *------------------------------------------*/
  5937. ACMD_FUNC(changesex)
  5938. {
  5939. int i;
  5940. nullpo_retr(-1, sd);
  5941. pc_resetskill(sd,4);
  5942. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5943. for (i = 0; i < EQI_MAX; i++) {
  5944. if (sd->equip_index[i] >= 0)
  5945. pc_unequipitem(sd, sd->equip_index[i], 3);
  5946. }
  5947. chrif_changesex(sd, true);
  5948. return 0;
  5949. }
  5950. /*==========================================
  5951. * @changecharsex
  5952. * => Changes one's character sex. Switch from male to female or visversa.
  5953. *------------------------------------------*/
  5954. ACMD_FUNC(changecharsex)
  5955. {
  5956. int i;
  5957. nullpo_retr(-1, sd);
  5958. pc_resetskill(sd,4);
  5959. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5960. for (i = 0; i < EQI_MAX; i++) {
  5961. if (sd->equip_index[i] >= 0)
  5962. pc_unequipitem(sd, sd->equip_index[i], 3);
  5963. }
  5964. chrif_changesex(sd, false);
  5965. return 0;
  5966. }
  5967. /*================================================
  5968. * @mute - Mutes a player for a set amount of time
  5969. *------------------------------------------------*/
  5970. ACMD_FUNC(mute)
  5971. {
  5972. struct map_session_data *pl_sd = NULL;
  5973. int manner;
  5974. nullpo_retr(-1, sd);
  5975. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5976. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5977. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5978. return -1;
  5979. }
  5980. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5981. {
  5982. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5983. return -1;
  5984. }
  5985. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5986. {
  5987. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5988. return -1;
  5989. }
  5990. clif_manner_message(sd, 0);
  5991. clif_manner_message(pl_sd, 5);
  5992. if( pl_sd->status.manner < manner ) {
  5993. pl_sd->status.manner -= manner;
  5994. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5995. } else {
  5996. pl_sd->status.manner = 0;
  5997. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5998. }
  5999. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6000. return 0;
  6001. }
  6002. /*==========================================
  6003. * @refresh (like @jumpto <<yourself>>)
  6004. *------------------------------------------*/
  6005. ACMD_FUNC(refresh)
  6006. {
  6007. nullpo_retr(-1, sd);
  6008. clif_refresh(sd);
  6009. return 0;
  6010. }
  6011. ACMD_FUNC(refreshall)
  6012. {
  6013. struct map_session_data* iter_sd;
  6014. struct s_mapiterator* iter;
  6015. nullpo_retr(-1, sd);
  6016. iter = mapit_getallusers();
  6017. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6018. clif_refresh(iter_sd);
  6019. mapit_free(iter);
  6020. return 0;
  6021. }
  6022. /*==========================================
  6023. * @identify
  6024. * => GM's magnifier.
  6025. *------------------------------------------*/
  6026. ACMD_FUNC(identify)
  6027. {
  6028. int i,num;
  6029. nullpo_retr(-1, sd);
  6030. for(i=num=0;i<MAX_INVENTORY;i++){
  6031. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6032. num++;
  6033. }
  6034. }
  6035. if (num > 0) {
  6036. clif_item_identify_list(sd);
  6037. } else {
  6038. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6039. }
  6040. return 0;
  6041. }
  6042. /*===============================================
  6043. * @identifyall
  6044. * => Indentify all items in inventory - Akinari
  6045. *-----------------------------------------------*/
  6046. ACMD_FUNC(identifyall)
  6047. {
  6048. int i;
  6049. nullpo_retr(-1, sd);
  6050. pc_identifyall(sd, true);
  6051. return 0;
  6052. }
  6053. /*==========================================
  6054. * @gmotd (Global MOTD)
  6055. * by davidsiaw :P
  6056. *------------------------------------------*/
  6057. ACMD_FUNC(gmotd)
  6058. {
  6059. FILE* fp;
  6060. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6061. {
  6062. char buf[CHAT_SIZE_MAX];
  6063. size_t len;
  6064. while( fgets(buf, sizeof(buf), fp) )
  6065. {
  6066. if( buf[0] == '/' && buf[1] == '/' )
  6067. {
  6068. continue;
  6069. }
  6070. len = strlen(buf);
  6071. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6072. {// strip trailing EOL characters
  6073. len--;
  6074. }
  6075. if( len )
  6076. {
  6077. buf[len] = 0;
  6078. intif_broadcast(buf, len+1, 0);
  6079. }
  6080. }
  6081. fclose(fp);
  6082. }
  6083. return 0;
  6084. }
  6085. ACMD_FUNC(misceffect)
  6086. {
  6087. int effect = 0;
  6088. nullpo_retr(-1, sd);
  6089. if (!message || !*message)
  6090. return -1;
  6091. if (sscanf(message, "%11d", &effect) < 1)
  6092. return -1;
  6093. clif_misceffect(&sd->bl,effect);
  6094. return 0;
  6095. }
  6096. /*==========================================
  6097. * MAIL SYSTEM
  6098. *------------------------------------------*/
  6099. ACMD_FUNC(mail)
  6100. {
  6101. nullpo_ret(sd);
  6102. mail_openmail(sd);
  6103. return 0;
  6104. }
  6105. /*==========================================
  6106. * Show Monster DB Info v 1.0
  6107. * originally by [Lupus]
  6108. *------------------------------------------*/
  6109. ACMD_FUNC(mobinfo)
  6110. {
  6111. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6112. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6113. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6114. char atcmd_output2[CHAT_SIZE_MAX];
  6115. struct item_data *item_data;
  6116. struct mob_db *mob;
  6117. uint16 mob_ids[MAX_SEARCH];
  6118. int count;
  6119. int i, k;
  6120. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6121. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6122. if (!message || !*message) {
  6123. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6124. return -1;
  6125. }
  6126. // If monster identifier/name argument is a name
  6127. if ((i = mobdb_checkid(atoi(message))))
  6128. {
  6129. mob_ids[0] = i;
  6130. count = 1;
  6131. } else
  6132. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6133. if (!count) {
  6134. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6135. return -1;
  6136. }
  6137. if (count >= MAX_SEARCH) {
  6138. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6139. clif_displaymessage(fd, atcmd_output);
  6140. count = MAX_SEARCH;
  6141. }
  6142. for (k = 0; k < count; k++) {
  6143. unsigned int j,base_exp,job_exp;
  6144. mob = mob_db(mob_ids[k]);
  6145. base_exp = mob->base_exp;
  6146. job_exp = mob->job_exp;
  6147. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6148. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6149. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6150. }
  6151. #ifdef RENEWAL_EXP
  6152. if( battle_config.atcommand_mobinfo_type ) {
  6153. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6154. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6155. }
  6156. #endif
  6157. // stats
  6158. if (mob->mexp)
  6159. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6160. else
  6161. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6162. clif_displaymessage(fd, atcmd_output);
  6163. 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
  6164. clif_displaymessage(fd, atcmd_output);
  6165. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6166. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6167. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6168. clif_displaymessage(fd, atcmd_output);
  6169. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6170. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6171. mob->range2 , mob->range3, msize[mob->status.size],
  6172. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6173. clif_displaymessage(fd, atcmd_output);
  6174. // drops
  6175. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6176. strcpy(atcmd_output, " ");
  6177. j = 0;
  6178. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6179. int droprate;
  6180. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6181. continue;
  6182. droprate = mob->dropitem[i].p;
  6183. #ifdef RENEWAL_DROP
  6184. if( battle_config.atcommand_mobinfo_type ) {
  6185. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6186. if (droprate <= 0 && !battle_config.drop_rate0item)
  6187. droprate = 1;
  6188. }
  6189. #endif
  6190. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6191. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6192. if (item_data->slot)
  6193. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6194. else
  6195. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6196. strcat(atcmd_output, atcmd_output2);
  6197. if (++j % 3 == 0) {
  6198. clif_displaymessage(fd, atcmd_output);
  6199. strcpy(atcmd_output, " ");
  6200. }
  6201. }
  6202. if (j == 0)
  6203. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6204. else if (j % 3 != 0)
  6205. clif_displaymessage(fd, atcmd_output);
  6206. // mvp
  6207. if (mob->mexp) {
  6208. float mvppercent, mvpremain;
  6209. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6210. clif_displaymessage(fd, atcmd_output);
  6211. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6212. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6213. j = 0;
  6214. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6215. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6216. continue;
  6217. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6218. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6219. if(battle_config.item_drop_mvp_mode == 0) {
  6220. mvpremain -= mvppercent;
  6221. }
  6222. if (mvppercent > 0) {
  6223. j++;
  6224. if (j == 1) {
  6225. if (item_data->slot)
  6226. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6227. else
  6228. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6229. } else {
  6230. if (item_data->slot)
  6231. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6232. else
  6233. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6234. }
  6235. strcat(atcmd_output, atcmd_output2);
  6236. }
  6237. }
  6238. if (j == 0)
  6239. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6240. else
  6241. clif_displaymessage(fd, atcmd_output);
  6242. }
  6243. }
  6244. return 0;
  6245. }
  6246. /*=========================================
  6247. * @showmobs by KarLaeda
  6248. * => For 15 sec displays the mobs on minimap
  6249. *------------------------------------------*/
  6250. ACMD_FUNC(showmobs)
  6251. {
  6252. char mob_name[100];
  6253. int mob_id;
  6254. int number = 0;
  6255. struct s_mapiterator* it;
  6256. nullpo_retr(-1, sd);
  6257. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6258. return -1;
  6259. if((mob_id = atoi(mob_name)) == 0)
  6260. mob_id = mobdb_searchname(mob_name);
  6261. if(mobdb_checkid(mob_id) == 0){
  6262. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6263. clif_displaymessage(fd, atcmd_output);
  6264. return 0;
  6265. }
  6266. 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.
  6267. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6268. return 0;
  6269. }
  6270. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname[0])
  6271. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6272. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6273. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6274. mob_name, mapindex_id2name(sd->mapindex));
  6275. clif_displaymessage(fd, atcmd_output);
  6276. it = mapit_geteachmob();
  6277. for(;;)
  6278. {
  6279. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6280. if( md == NULL )
  6281. break;// no more mobs
  6282. if( md->bl.m != sd->bl.m )
  6283. continue;
  6284. if( mob_id != -1 && md->mob_id != mob_id )
  6285. continue;
  6286. if( md->special_state.ai || md->master_id )
  6287. continue; // hide slaves and player summoned mobs
  6288. if( md->spawn_timer != INVALID_TIMER )
  6289. continue; // hide mobs waiting for respawn
  6290. ++number;
  6291. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6292. }
  6293. mapit_free(it);
  6294. return 0;
  6295. }
  6296. /*==========================================
  6297. * homunculus level up [orn]
  6298. *------------------------------------------*/
  6299. ACMD_FUNC(homlevel)
  6300. {
  6301. TBL_HOM * hd;
  6302. int level = 0, i = 0;
  6303. nullpo_retr(-1, sd);
  6304. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6305. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6306. return -1;
  6307. }
  6308. if ( !hom_is_active(sd->hd) ) {
  6309. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6310. return -1;
  6311. }
  6312. hd = sd->hd;
  6313. for (i = 1; i <= level && hd->exp_next; i++){
  6314. hd->homunculus.exp += hd->exp_next;
  6315. if( !hom_levelup(hd) )
  6316. break;
  6317. }
  6318. status_calc_homunculus(hd, SCO_NONE);
  6319. status_percent_heal(&hd->bl, 100, 100);
  6320. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6321. return 0;
  6322. }
  6323. /*==========================================
  6324. * homunculus evolution H [orn]
  6325. *------------------------------------------*/
  6326. ACMD_FUNC(homevolution)
  6327. {
  6328. nullpo_retr(-1, sd);
  6329. if ( !hom_is_active(sd->hd) ) {
  6330. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6331. return -1;
  6332. }
  6333. if ( !hom_evolution(sd->hd) ) {
  6334. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6335. return -1;
  6336. }
  6337. clif_homskillinfoblock(sd);
  6338. return 0;
  6339. }
  6340. ACMD_FUNC(hommutate)
  6341. {
  6342. int homun_id, m_class = 0, m_id;
  6343. nullpo_retr(-1, sd);
  6344. if (!hom_is_active(sd->hd)) {
  6345. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6346. return -1;
  6347. }
  6348. if (!message || !*message) {
  6349. homun_id = 6048 + (rnd() % 4);
  6350. } else {
  6351. homun_id = atoi(message);
  6352. }
  6353. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6354. m_id = hom_class2mapid(homun_id);
  6355. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6356. hom_mutate(sd->hd, homun_id);
  6357. } else {
  6358. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6359. }
  6360. return 0;
  6361. }
  6362. /*==========================================
  6363. * call choosen homunculus [orn]
  6364. *------------------------------------------*/
  6365. ACMD_FUNC(makehomun)
  6366. {
  6367. int homunid;
  6368. nullpo_retr(-1, sd);
  6369. if ( sd->status.hom_id ) {
  6370. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6371. return -1;
  6372. }
  6373. if (!message || !*message) {
  6374. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6375. return -1;
  6376. }
  6377. homunid = atoi(message);
  6378. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6379. {
  6380. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6381. return -1;
  6382. }
  6383. hom_create_request(sd,homunid);
  6384. return 0;
  6385. }
  6386. /*==========================================
  6387. * modify homunculus intimacy [orn]
  6388. *------------------------------------------*/
  6389. ACMD_FUNC(homfriendly)
  6390. {
  6391. int friendly = 0;
  6392. nullpo_retr(-1, sd);
  6393. if ( !hom_is_active(sd->hd) ) {
  6394. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6395. return -1;
  6396. }
  6397. if (!message || !*message) {
  6398. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6399. return -1;
  6400. }
  6401. friendly = atoi(message);
  6402. friendly = cap_value(friendly, 0, 1000);
  6403. sd->hd->homunculus.intimacy = friendly * 100 ;
  6404. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6405. return 0;
  6406. }
  6407. /*==========================================
  6408. * modify homunculus hunger [orn]
  6409. *------------------------------------------*/
  6410. ACMD_FUNC(homhungry)
  6411. {
  6412. int hungry = 0;
  6413. nullpo_retr(-1, sd);
  6414. if ( !hom_is_active(sd->hd) ) {
  6415. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6416. return -1;
  6417. }
  6418. if (!message || !*message) {
  6419. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6420. return -1;
  6421. }
  6422. hungry = atoi(message);
  6423. hungry = cap_value(hungry, 0, 100);
  6424. sd->hd->homunculus.hunger = hungry;
  6425. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6426. return 0;
  6427. }
  6428. /*==========================================
  6429. * make the homunculus speak [orn]
  6430. *------------------------------------------*/
  6431. ACMD_FUNC(homtalk)
  6432. {
  6433. char mes[100],temp[100];
  6434. nullpo_retr(-1, sd);
  6435. if ( battle_config.min_chat_delay ) {
  6436. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6437. return 0;
  6438. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6439. }
  6440. if (sd->sc.cant.chat)
  6441. return -1; //no "chatting" while muted.
  6442. if ( !hom_is_active(sd->hd) ) {
  6443. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6444. return -1;
  6445. }
  6446. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6447. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6448. return -1;
  6449. }
  6450. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6451. clif_disp_overhead(&sd->hd->bl, temp);
  6452. return 0;
  6453. }
  6454. /*==========================================
  6455. * Show homunculus stats
  6456. *------------------------------------------*/
  6457. ACMD_FUNC(hominfo)
  6458. {
  6459. struct homun_data *hd;
  6460. struct status_data *status;
  6461. nullpo_retr(-1, sd);
  6462. if ( !hom_is_active(sd->hd) ) {
  6463. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6464. return -1;
  6465. }
  6466. hd = sd->hd;
  6467. status = status_get_status_data(&hd->bl);
  6468. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6469. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6470. status->hp, status->max_hp, status->sp, status->max_sp);
  6471. clif_displaymessage(fd, atcmd_output);
  6472. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6473. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6474. clif_displaymessage(fd, atcmd_output);
  6475. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6476. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6477. clif_displaymessage(fd, atcmd_output);
  6478. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6479. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6480. status->str, status->agi, status->vit,
  6481. status->int_, status->dex, status->luk);
  6482. clif_displaymessage(fd, atcmd_output);
  6483. return 0;
  6484. }
  6485. ACMD_FUNC(homstats)
  6486. {
  6487. struct homun_data *hd;
  6488. struct s_homunculus_db *db;
  6489. struct s_homunculus *hom;
  6490. int lv, min, max, evo;
  6491. nullpo_retr(-1, sd);
  6492. if ( !hom_is_active(sd->hd) ) {
  6493. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6494. return -1;
  6495. }
  6496. hd = sd->hd;
  6497. hom = &hd->homunculus;
  6498. db = hd->homunculusDB;
  6499. lv = hom->level;
  6500. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6501. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6502. clif_displaymessage(fd, atcmd_output);
  6503. lv--; //Since the first increase is at level 2.
  6504. evo = (hom->class_ == db->evo_class);
  6505. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6506. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6507. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6508. clif_displaymessage(fd, atcmd_output);
  6509. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6510. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6511. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6512. clif_displaymessage(fd, atcmd_output);
  6513. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6514. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6515. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6516. clif_displaymessage(fd, atcmd_output);
  6517. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6518. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6519. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6520. clif_displaymessage(fd, atcmd_output);
  6521. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6522. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6523. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6524. clif_displaymessage(fd, atcmd_output);
  6525. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6526. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6527. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6528. clif_displaymessage(fd, atcmd_output);
  6529. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6530. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6531. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6532. clif_displaymessage(fd, atcmd_output);
  6533. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6534. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6535. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6536. clif_displaymessage(fd, atcmd_output);
  6537. return 0;
  6538. }
  6539. ACMD_FUNC(homshuffle)
  6540. {
  6541. nullpo_retr(-1, sd);
  6542. if(!sd->hd)
  6543. return -1; // nothing to do
  6544. if(!hom_shuffle(sd->hd))
  6545. return -1;
  6546. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6547. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6548. return 0;
  6549. }
  6550. /*==========================================
  6551. * Show Items DB Info v 1.0
  6552. * originally by [Lupus]
  6553. *------------------------------------------*/
  6554. ACMD_FUNC(iteminfo)
  6555. {
  6556. struct item_data *item_array[MAX_SEARCH];
  6557. int i, count = 1;
  6558. if (!message || !*message) {
  6559. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6560. return -1;
  6561. }
  6562. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6563. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6564. if (!count) {
  6565. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6566. return -1;
  6567. }
  6568. if (count == MAX_SEARCH) {
  6569. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6570. clif_displaymessage(fd, atcmd_output);
  6571. }
  6572. for (i = 0; i < count; i++) {
  6573. struct item_data * item_data = item_array[i];
  6574. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6575. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6576. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6577. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6578. );
  6579. clif_displaymessage(fd, atcmd_output);
  6580. 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
  6581. clif_displaymessage(fd, atcmd_output);
  6582. if (item_data->maxchance == -1) {
  6583. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6584. clif_displaymessage(fd, atcmd_output);
  6585. }
  6586. else if (!battle_config.atcommand_mobinfo_type) {
  6587. if (item_data->maxchance)
  6588. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6589. else
  6590. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6591. clif_displaymessage(fd, atcmd_output);
  6592. }
  6593. }
  6594. return 0;
  6595. }
  6596. /*==========================================
  6597. * Show who drops the item.
  6598. *------------------------------------------*/
  6599. ACMD_FUNC(whodrops)
  6600. {
  6601. struct item_data *item_data, *item_array[MAX_SEARCH];
  6602. int i,j, count = 1;
  6603. if (!message || !*message) {
  6604. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6605. return -1;
  6606. }
  6607. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6608. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6609. if (!count) {
  6610. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6611. return -1;
  6612. }
  6613. if (count == MAX_SEARCH) {
  6614. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6615. clif_displaymessage(fd, atcmd_output);
  6616. }
  6617. for (i = 0; i < count; i++) {
  6618. item_data = item_array[i];
  6619. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6620. clif_displaymessage(fd, atcmd_output);
  6621. if (item_data->mob[0].chance == 0) {
  6622. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6623. clif_displaymessage(fd, atcmd_output);
  6624. } else {
  6625. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6626. clif_displaymessage(fd, atcmd_output);
  6627. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6628. {
  6629. int dropchance = item_data->mob[j].chance;
  6630. #ifdef RENEWAL_DROP
  6631. if( battle_config.atcommand_mobinfo_type )
  6632. 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;
  6633. #endif
  6634. if (pc_isvip(sd)) // Display item rate increase for VIP
  6635. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6636. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6637. clif_displaymessage(fd, atcmd_output);
  6638. }
  6639. }
  6640. }
  6641. return 0;
  6642. }
  6643. ACMD_FUNC(whereis)
  6644. {
  6645. uint16 mob_ids[MAX_SEARCH] = {0};
  6646. int count = 0;
  6647. if (!message || !*message) {
  6648. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6649. return -1;
  6650. }
  6651. int i_message = atoi(message);
  6652. if (mobdb_checkid(i_message)) {
  6653. // ID given
  6654. mob_ids[0] = i_message;
  6655. count = 1;
  6656. } else {
  6657. // Name given, get all monster associated whith this name
  6658. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6659. }
  6660. if (count <= 0) {
  6661. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6662. return -1;
  6663. }
  6664. if (count >= MAX_SEARCH) {
  6665. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6666. clif_displaymessage(fd, atcmd_output);
  6667. count = MAX_SEARCH;
  6668. }
  6669. for (int i = 0; i < count; i++) {
  6670. uint16 mob_id = mob_ids[i];
  6671. struct mob_db * mob = mob_db(mob_id);
  6672. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6673. clif_displaymessage(fd, atcmd_output);
  6674. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6675. if (spawns.size() <= 0) {
  6676. // This monster does not spawn normally.
  6677. clif_displaymessage(fd, msg_txt(sd,1290));
  6678. } else {
  6679. for(auto& spawn : spawns)
  6680. {
  6681. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6682. if (mapid < 0)
  6683. continue;
  6684. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map_getmapdata(mapid)->name, spawn.qty);
  6685. clif_displaymessage(fd, atcmd_output);
  6686. }
  6687. }
  6688. }
  6689. return 0;
  6690. }
  6691. ACMD_FUNC(version)
  6692. {
  6693. pc_show_version(sd);
  6694. return 0;
  6695. }
  6696. /*==========================================
  6697. * @mutearea by MouseJstr
  6698. *------------------------------------------*/
  6699. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6700. {
  6701. int time, id;
  6702. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6703. if (pl_sd == NULL)
  6704. return 0;
  6705. id = va_arg(ap, int);
  6706. time = va_arg(ap, int);
  6707. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6708. pl_sd->status.manner -= time;
  6709. if (pl_sd->status.manner < 0)
  6710. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6711. else
  6712. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6713. }
  6714. return 0;
  6715. }
  6716. ACMD_FUNC(mutearea)
  6717. {
  6718. int time;
  6719. nullpo_ret(sd);
  6720. if (!message || !*message) {
  6721. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6722. return -1;
  6723. }
  6724. time = atoi(message);
  6725. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6726. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6727. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6728. return 0;
  6729. }
  6730. ACMD_FUNC(rates)
  6731. {
  6732. char buf[CHAT_SIZE_MAX];
  6733. nullpo_ret(sd);
  6734. memset(buf, '\0', sizeof(buf));
  6735. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6736. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6737. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6738. clif_displaymessage(fd, buf);
  6739. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6740. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6741. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6742. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6743. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6744. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6745. clif_displaymessage(fd, buf);
  6746. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6747. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6748. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6749. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6750. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6751. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6752. clif_displaymessage(fd, buf);
  6753. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6754. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6755. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6756. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6757. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6758. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6759. clif_displaymessage(fd, buf);
  6760. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6761. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6762. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6763. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6764. clif_displaymessage(fd, buf);
  6765. return 0;
  6766. }
  6767. /*==========================================
  6768. * @me by lordalfa
  6769. * => Displays the OUTPUT string on top of the Visible players Heads.
  6770. *------------------------------------------*/
  6771. ACMD_FUNC(me)
  6772. {
  6773. char tempmes[CHAT_SIZE_MAX];
  6774. nullpo_retr(-1, sd);
  6775. memset(tempmes, '\0', sizeof(tempmes));
  6776. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6777. if (sd->sc.cant.chat)
  6778. return -1; //no "chatting" while muted.
  6779. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6780. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6781. return -1;
  6782. }
  6783. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6784. clif_disp_overhead(&sd->bl, atcmd_output);
  6785. return 0;
  6786. }
  6787. /*==========================================
  6788. * @size
  6789. * => Resize your character sprite. [Valaris]
  6790. *------------------------------------------*/
  6791. ACMD_FUNC(size)
  6792. {
  6793. int size = SZ_SMALL;
  6794. nullpo_retr(-1, sd);
  6795. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6796. if(sd->state.size) {
  6797. sd->state.size = SZ_SMALL;
  6798. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6799. }
  6800. sd->state.size = size;
  6801. if( size == SZ_MEDIUM )
  6802. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6803. else if( size == SZ_BIG )
  6804. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6805. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6806. return 0;
  6807. }
  6808. ACMD_FUNC(sizeall)
  6809. {
  6810. int size;
  6811. struct map_session_data *pl_sd;
  6812. struct s_mapiterator* iter;
  6813. size = atoi(message);
  6814. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6815. iter = mapit_getallusers();
  6816. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6817. if( pl_sd->state.size != size ) {
  6818. if( pl_sd->state.size ) {
  6819. pl_sd->state.size = SZ_SMALL;
  6820. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6821. }
  6822. pl_sd->state.size = size;
  6823. if( size == SZ_MEDIUM )
  6824. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6825. else if( size == SZ_BIG )
  6826. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6827. }
  6828. }
  6829. mapit_free(iter);
  6830. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6831. return 0;
  6832. }
  6833. ACMD_FUNC(sizeguild)
  6834. {
  6835. int size = SZ_SMALL, i;
  6836. char guild[NAME_LENGTH];
  6837. struct map_session_data *pl_sd;
  6838. struct guild *g;
  6839. nullpo_retr(-1, sd);
  6840. memset(guild, '\0', sizeof(guild));
  6841. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6842. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6843. return -1;
  6844. }
  6845. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6846. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6847. return -1;
  6848. }
  6849. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6850. for( i = 0; i < g->max_member; i++ ) {
  6851. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6852. if( pl_sd->state.size ) {
  6853. pl_sd->state.size = SZ_SMALL;
  6854. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6855. }
  6856. pl_sd->state.size = size;
  6857. if( size == SZ_MEDIUM )
  6858. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6859. else if( size == SZ_BIG )
  6860. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6861. }
  6862. }
  6863. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6864. return 0;
  6865. }
  6866. /*==========================================
  6867. * @monsterignore
  6868. * => Makes monsters ignore you. [Valaris]
  6869. *------------------------------------------*/
  6870. ACMD_FUNC(monsterignore)
  6871. {
  6872. nullpo_retr(-1, sd);
  6873. if (!sd->state.monster_ignore) {
  6874. sd->state.monster_ignore = 1;
  6875. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6876. } else {
  6877. sd->state.monster_ignore = 0;
  6878. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6879. }
  6880. return 0;
  6881. }
  6882. /*==========================================
  6883. * @fakename
  6884. * => Gives your character a fake name. [Valaris]
  6885. *------------------------------------------*/
  6886. ACMD_FUNC(fakename)
  6887. {
  6888. nullpo_retr(-1, sd);
  6889. if( !message || !*message )
  6890. {
  6891. if( sd->fakename[0] )
  6892. {
  6893. sd->fakename[0] = '\0';
  6894. clif_name_area(&sd->bl);
  6895. if (sd->disguise)
  6896. clif_name_self(&sd->bl);
  6897. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6898. return 0;
  6899. }
  6900. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6901. return -1;
  6902. }
  6903. if( strlen(message) < 2 )
  6904. {
  6905. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6906. return -1;
  6907. }
  6908. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6909. clif_name_area(&sd->bl);
  6910. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6911. clif_name_self(&sd->bl);
  6912. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6913. return 0;
  6914. }
  6915. /*==========================================
  6916. * Ragnarok Resources
  6917. *------------------------------------------*/
  6918. ACMD_FUNC(mapflag) {
  6919. char flag_name[CHAT_SIZE_MAX];
  6920. short flag = 0, i, j;
  6921. std::string buf;
  6922. nullpo_retr(-1, sd);
  6923. memset(flag_name, '\0', sizeof(flag_name));
  6924. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6925. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6926. clif_displaymessage(sd->fd,"----------------------------------");
  6927. for( i = MF_MIN; i < MF_MAX; i++ ){
  6928. union u_mapflag_args args = {};
  6929. if( map_getmapflag_name(static_cast<e_mapflag>(i), flag_name) && map_getmapflag_sub( sd->bl.m, static_cast<e_mapflag>(i), &args ) ){
  6930. clif_displaymessage(sd->fd, flag_name);
  6931. }
  6932. }
  6933. clif_displaymessage(sd->fd," ");
  6934. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6935. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6936. return 1;
  6937. }
  6938. // Check if the list of mapflags was requested
  6939. if( strcasecmp(flag_name,"available") ){
  6940. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6941. enum e_mapflag mapflag = map_getmapflag_by_name(flag_name);
  6942. if( mapflag != MF_INVALID ){
  6943. std::vector<e_mapflag> disabled_mf = { MF_NOSAVE,
  6944. MF_PVP_NIGHTMAREDROP,
  6945. MF_RESTRICTED,
  6946. MF_NOCOMMAND,
  6947. MF_BEXP,
  6948. MF_JEXP,
  6949. MF_BATTLEGROUND,
  6950. MF_SKILL_DAMAGE };
  6951. if (flag && std::find(disabled_mf.begin(), disabled_mf.end(), mapflag) != disabled_mf.end()) {
  6952. sprintf(atcmd_output,"[ @mapflag ] %s flag cannot be enabled as it requires unique values.", flag_name);
  6953. clif_displaymessage(sd->fd,atcmd_output);
  6954. } else {
  6955. map_setmapflag(sd->bl.m, mapflag, flag != 0);
  6956. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",flag_name,flag?"On":"Off",flag);
  6957. clif_displaymessage(sd->fd,atcmd_output);
  6958. }
  6959. return 0;
  6960. }else{
  6961. clif_displaymessage(sd->fd, msg_txt(sd, 1314)); // Invalid flag name or flag.
  6962. clif_displaymessage(sd->fd, msg_txt(sd, 1313)); // Type "@mapflag available" to list the available mapflags.
  6963. return 1;
  6964. }
  6965. }
  6966. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6967. clif_displaymessage(sd->fd,"----------------------------------");
  6968. for( i = MF_MIN, j = 0; i < MF_MAX; i++ ){
  6969. if( map_getmapflag_name( static_cast<e_mapflag>(i), flag_name ) ){
  6970. buf.append(flag_name);
  6971. if( (i + 1) < MF_MAX )
  6972. buf.append(", ");
  6973. j++;
  6974. }
  6975. if( i > MF_MIN && ( j == 6 || ( i + 1 ) == MF_MAX ) ){
  6976. clif_displaymessage(sd->fd, buf.c_str() );
  6977. buf.clear();
  6978. j = 0;
  6979. }
  6980. }
  6981. clif_displaymessage(sd->fd, msg_txt(sd, 1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6982. return 0;
  6983. }
  6984. /*===================================
  6985. * Remove some messages
  6986. *-----------------------------------*/
  6987. ACMD_FUNC(showexp)
  6988. {
  6989. if (sd->state.showexp) {
  6990. sd->state.showexp = 0;
  6991. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6992. return 0;
  6993. }
  6994. sd->state.showexp = 1;
  6995. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6996. return 0;
  6997. }
  6998. ACMD_FUNC(showzeny)
  6999. {
  7000. if (sd->state.showzeny) {
  7001. sd->state.showzeny = 0;
  7002. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7003. return 0;
  7004. }
  7005. sd->state.showzeny = 1;
  7006. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7007. return 0;
  7008. }
  7009. ACMD_FUNC(showdelay)
  7010. {
  7011. if (sd->state.showdelay) {
  7012. sd->state.showdelay = 0;
  7013. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7014. return 0;
  7015. }
  7016. sd->state.showdelay = 1;
  7017. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7018. return 0;
  7019. }
  7020. /*==========================================
  7021. * Duel organizing functions [LuzZza]
  7022. *
  7023. * @duel [limit|nick] - create a duel
  7024. * @invite <nick> - invite player
  7025. * @accept - accept invitation
  7026. * @reject - reject invitation
  7027. * @leave - leave duel
  7028. *------------------------------------------*/
  7029. ACMD_FUNC(invite)
  7030. {
  7031. unsigned int did = sd->duel_group;
  7032. struct map_session_data *target_sd = NULL;
  7033. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7034. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7035. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7036. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7037. clif_displaymessage(fd, atcmd_output);
  7038. return -1;
  7039. }
  7040. if(did == 0 || !duel_exist(did) ) {
  7041. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7042. return 0;
  7043. }
  7044. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7045. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7046. return 0;
  7047. }
  7048. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7049. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7050. return 0;
  7051. }
  7052. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7053. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7054. return 0;
  7055. }
  7056. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7057. {
  7058. 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.
  7059. clif_displaymessage(fd, atcmd_output);
  7060. return 0;
  7061. }
  7062. duel_invite(did, sd, target_sd);
  7063. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7064. return 0;
  7065. }
  7066. ACMD_FUNC(duel)
  7067. {
  7068. unsigned int maxpl = 0;
  7069. if(sd->duel_group > 0) {
  7070. duel_showinfo(sd->duel_group, sd);
  7071. return 0;
  7072. }
  7073. if(sd->duel_invite > 0) {
  7074. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7075. return 0;
  7076. }
  7077. if(!duel_checktime(sd)) {
  7078. char output[CHAT_SIZE_MAX];
  7079. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7080. clif_displaymessage(fd, output);
  7081. return 0;
  7082. }
  7083. if( message[0] ) {
  7084. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7085. if(maxpl < 2 || maxpl > 65535) {
  7086. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7087. return 0;
  7088. }
  7089. duel_create(sd, maxpl);
  7090. } else {
  7091. struct map_session_data *target_sd = NULL;
  7092. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7093. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7094. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7095. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7096. clif_displaymessage(fd, atcmd_output);
  7097. return -1;
  7098. }
  7099. target_sd = map_nick2sd(atcmd_player_name,true);
  7100. if(target_sd != NULL) {
  7101. unsigned int newduel;
  7102. if((newduel = duel_create(sd, 2)) != -1) {
  7103. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7104. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7105. return 0;
  7106. }
  7107. duel_invite(newduel, sd, target_sd);
  7108. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7109. }
  7110. } else {
  7111. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7112. return 0;
  7113. }
  7114. }
  7115. } else
  7116. duel_create(sd, 0);
  7117. return 0;
  7118. }
  7119. ACMD_FUNC(leave)
  7120. {
  7121. if(sd->duel_group <= 0) {
  7122. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7123. return 0;
  7124. }
  7125. duel_leave(sd->duel_group, sd);
  7126. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7127. return 0;
  7128. }
  7129. ACMD_FUNC(accept)
  7130. {
  7131. if(!duel_checktime(sd)) {
  7132. char output[CHAT_SIZE_MAX];
  7133. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7134. clif_displaymessage(fd, output);
  7135. return 0;
  7136. }
  7137. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7138. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7139. return 0;
  7140. }
  7141. if( !duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7142. {
  7143. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7144. return 0;
  7145. }
  7146. duel_accept(sd->duel_invite, sd);
  7147. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7148. return 0;
  7149. }
  7150. ACMD_FUNC(reject)
  7151. {
  7152. if(sd->duel_invite <= 0) {
  7153. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7154. return 0;
  7155. }
  7156. duel_reject(sd->duel_invite, sd);
  7157. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7158. return 0;
  7159. }
  7160. /*===================================
  7161. * Cash Points
  7162. *-----------------------------------*/
  7163. ACMD_FUNC(cash)
  7164. {
  7165. char output[128];
  7166. int value;
  7167. int ret=0;
  7168. nullpo_retr(-1, sd);
  7169. // Since there is no cashpoint update packet we need to force updating like this
  7170. if( sd->state.cashshop_open ){
  7171. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7172. return -1;
  7173. }
  7174. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7175. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7176. return -1;
  7177. }
  7178. parent_cmd = atcommand_checkalias(command+1);
  7179. if( !strcmpi(parent_cmd,"cash") )
  7180. {
  7181. if( value > 0 ) {
  7182. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7183. // If this option is set, the message is already sent by pc function
  7184. if( !battle_config.cashshop_show_points ){
  7185. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7186. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7187. }
  7188. }
  7189. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7190. } else {
  7191. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7192. value = -sd->cashPoints;
  7193. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7194. // If this option is set, the message is already sent by pc function
  7195. if( !battle_config.cashshop_show_points ){
  7196. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7197. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7198. }
  7199. }
  7200. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7201. }
  7202. }
  7203. else
  7204. { // @points
  7205. if( value > 0 ) {
  7206. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7207. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7208. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7209. }
  7210. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7211. } else {
  7212. if( (ret=pc_paycash(sd, 0, -value, LOG_TYPE_COMMAND)) >= 0){
  7213. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7214. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7215. }
  7216. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7217. }
  7218. }
  7219. return 0;
  7220. }
  7221. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7222. ACMD_FUNC(clone)
  7223. {
  7224. int x=0,y=0,flag=0,master=0,i=0;
  7225. struct map_session_data *pl_sd=NULL;
  7226. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7227. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7228. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7229. return 0;
  7230. }
  7231. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7232. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7233. return 0;
  7234. }
  7235. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7236. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7237. return 0;
  7238. }
  7239. parent_cmd = atcommand_checkalias(command+1);
  7240. if (strcmpi(parent_cmd, "clone") == 0)
  7241. flag = 1;
  7242. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7243. flag = 2;
  7244. if(pc_isdead(sd)){
  7245. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7246. return 0;
  7247. }
  7248. master = sd->bl.id;
  7249. if (battle_config.atc_slave_clone_limit
  7250. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7251. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7252. return 0;
  7253. }
  7254. }
  7255. do {
  7256. x = sd->bl.x + (rnd() % 10 - 5);
  7257. y = sd->bl.y + (rnd() % 10 - 5);
  7258. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7259. if (i >= 10) {
  7260. x = sd->bl.x;
  7261. y = sd->bl.y;
  7262. }
  7263. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7264. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7265. return 0;
  7266. }
  7267. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7268. return 0;
  7269. }
  7270. /*=====================================
  7271. * Autorejecting Invites/Deals [LuzZza]
  7272. * Usage: @noask
  7273. *-------------------------------------*/
  7274. ACMD_FUNC(noask)
  7275. {
  7276. if(sd->state.noask) {
  7277. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7278. sd->state.noask = 0;
  7279. } else {
  7280. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7281. sd->state.noask = 1;
  7282. }
  7283. return 0;
  7284. }
  7285. /*=====================================
  7286. * Send a @request message to all GMs of lowest_gm_level.
  7287. * Usage: @request <petition>
  7288. *-------------------------------------*/
  7289. ACMD_FUNC(request)
  7290. {
  7291. if (!message || !*message) {
  7292. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7293. return -1;
  7294. }
  7295. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7296. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7297. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7298. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7299. return 0;
  7300. }
  7301. /*==========================================
  7302. * Feel (SG save map) Reset [HiddenDragon]
  7303. *------------------------------------------*/
  7304. ACMD_FUNC(feelreset)
  7305. {
  7306. pc_resetfeel(sd);
  7307. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7308. return 0;
  7309. }
  7310. /*==========================================
  7311. * AUCTION SYSTEM
  7312. *------------------------------------------*/
  7313. ACMD_FUNC(auction)
  7314. {
  7315. nullpo_ret(sd);
  7316. if (!battle_config.feature_auction) {
  7317. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7318. return 0;
  7319. }
  7320. clif_Auction_openwindow(sd);
  7321. return 0;
  7322. }
  7323. /*==========================================
  7324. * Kill Steal Protection
  7325. *------------------------------------------*/
  7326. ACMD_FUNC(ksprotection)
  7327. {
  7328. nullpo_retr(-1,sd);
  7329. if( sd->state.noks ) {
  7330. sd->state.noks = 0;
  7331. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7332. }
  7333. else
  7334. {
  7335. if( !message || !*message || !strcmpi(message, "party") )
  7336. { // Default is Party
  7337. sd->state.noks = 2;
  7338. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7339. }
  7340. else if( !strcmpi(message, "self") )
  7341. {
  7342. sd->state.noks = 1;
  7343. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7344. }
  7345. else if( !strcmpi(message, "guild") )
  7346. {
  7347. sd->state.noks = 3;
  7348. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7349. }
  7350. else
  7351. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7352. }
  7353. return 0;
  7354. }
  7355. /*==========================================
  7356. * Map Kill Steal Protection Setting
  7357. *------------------------------------------*/
  7358. ACMD_FUNC(allowks)
  7359. {
  7360. nullpo_retr(-1,sd);
  7361. if( map_getmapflag(sd->bl.m, MF_ALLOWKS) ) {
  7362. map_setmapflag(sd->bl.m, MF_ALLOWKS, false);
  7363. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7364. } else {
  7365. map_setmapflag(sd->bl.m, MF_ALLOWKS, true);
  7366. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7367. }
  7368. return 0;
  7369. }
  7370. ACMD_FUNC(resetstat)
  7371. {
  7372. nullpo_retr(-1, sd);
  7373. pc_resetstate(sd);
  7374. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7375. clif_displaymessage(fd, atcmd_output);
  7376. return 0;
  7377. }
  7378. ACMD_FUNC(resetskill)
  7379. {
  7380. nullpo_retr(-1,sd);
  7381. pc_resetskill(sd,1);
  7382. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7383. clif_displaymessage(fd, atcmd_output);
  7384. return 0;
  7385. }
  7386. /*==========================================
  7387. * #storagelist: Displays the items list of a player's storage.
  7388. * #cartlist: Displays contents of target's cart.
  7389. * #itemlist: Displays contents of target's inventory.
  7390. *------------------------------------------*/
  7391. ACMD_FUNC(itemlist)
  7392. {
  7393. int i, j, count, counter;
  7394. const char* location;
  7395. const struct item* items;
  7396. int size;
  7397. StringBuf buf;
  7398. nullpo_retr(-1, sd);
  7399. parent_cmd = atcommand_checkalias(command+1);
  7400. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7401. location = "storage";
  7402. items = sd->storage.u.items_storage;
  7403. size = sd->storage.max_amount;
  7404. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7405. location = "cart";
  7406. items = sd->cart.u.items_cart;
  7407. size = MAX_CART;
  7408. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7409. location = "inventory";
  7410. items = sd->inventory.u.items_inventory;
  7411. size = MAX_INVENTORY;
  7412. } else
  7413. return 1;
  7414. StringBuf_Init(&buf);
  7415. count = 0; // total slots occupied
  7416. counter = 0; // total items found
  7417. for( i = 0; i < size; ++i ) {
  7418. const struct item* it = &items[i];
  7419. struct item_data* itd;
  7420. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7421. continue;
  7422. counter += it->amount;
  7423. count++;
  7424. if( count == 1 ) {
  7425. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7426. clif_displaymessage(fd, StringBuf_Value(&buf));
  7427. StringBuf_Clear(&buf);
  7428. }
  7429. if( it->refine )
  7430. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7431. else
  7432. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7433. if( it->equip ) {
  7434. char equipstr[CHAT_SIZE_MAX];
  7435. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7436. if( it->equip&EQP_GARMENT )
  7437. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7438. if( it->equip&EQP_ACC_L )
  7439. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7440. if( it->equip&EQP_ARMOR )
  7441. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7442. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7443. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7444. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7445. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7446. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7447. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7448. if( it->equip&EQP_SHOES )
  7449. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7450. if( it->equip&EQP_ACC_R )
  7451. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7452. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7453. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7454. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7455. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7456. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7457. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7458. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7459. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7460. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7461. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7462. if( (it->equip&EQP_HELM) == EQP_HELM )
  7463. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7464. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7465. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7466. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7467. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7468. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7469. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7470. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7471. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7472. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7473. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7474. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7475. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7476. if( it->equip&EQP_COSTUME_GARMENT )
  7477. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7478. //if( it->equip&EQP_COSTUME_FLOOR )
  7479. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7480. if( it->equip&EQP_AMMO )
  7481. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7482. if( it->equip&EQP_SHADOW_ARMOR )
  7483. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7484. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7485. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7486. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7487. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7488. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7489. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7490. if( it->equip&EQP_SHADOW_SHOES )
  7491. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7492. if( it->equip&EQP_SHADOW_ACC_R )
  7493. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7494. if( it->equip&EQP_SHADOW_ACC_L )
  7495. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7496. // remove final ', '
  7497. equipstr[strlen(equipstr) - 2] = '\0';
  7498. StringBuf_AppendStr(&buf, equipstr);
  7499. }
  7500. clif_displaymessage(fd, StringBuf_Value(&buf));
  7501. StringBuf_Clear(&buf);
  7502. if( it->card[0] == CARD0_PET ) { // pet egg
  7503. if (it->card[3])
  7504. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7505. else
  7506. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7507. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7508. 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)
  7509. } else if(it->card[0] == CARD0_CREATE) { // created item
  7510. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7511. } else { // normal item
  7512. int counter2 = 0;
  7513. for( j = 0; j < itd->slot; ++j ) {
  7514. struct item_data* card;
  7515. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7516. continue;
  7517. counter2++;
  7518. if( counter2 == 1 )
  7519. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7520. if( counter2 != 1 )
  7521. StringBuf_AppendStr(&buf, ", ");
  7522. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7523. }
  7524. if( counter2 > 0 )
  7525. StringBuf_AppendStr(&buf, ")");
  7526. }
  7527. if( StringBuf_Length(&buf) > 0 )
  7528. clif_displaymessage(fd, StringBuf_Value(&buf));
  7529. StringBuf_Clear(&buf);
  7530. }
  7531. if( count == 0 )
  7532. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7533. else
  7534. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7535. clif_displaymessage(fd, StringBuf_Value(&buf));
  7536. StringBuf_Destroy(&buf);
  7537. return 0;
  7538. }
  7539. ACMD_FUNC(stats)
  7540. {
  7541. char job_jobname[100];
  7542. char output[CHAT_SIZE_MAX];
  7543. int i;
  7544. struct {
  7545. const char* format;
  7546. int value;
  7547. } output_table[] = {
  7548. { "Base Level - %d", 0 },
  7549. { NULL, 0 },
  7550. { "Hp - %d", 0 },
  7551. { "MaxHp - %d", 0 },
  7552. { "Sp - %d", 0 },
  7553. { "MaxSp - %d", 0 },
  7554. { "Str - %3d", 0 },
  7555. { "Agi - %3d", 0 },
  7556. { "Vit - %3d", 0 },
  7557. { "Int - %3d", 0 },
  7558. { "Dex - %3d", 0 },
  7559. { "Luk - %3d", 0 },
  7560. { "Zeny - %d", 0 },
  7561. { "Free SK Points - %d", 0 },
  7562. { "JobChangeLvl (2nd) - %d", 0 },
  7563. { "JobChangeLvl (3rd) - %d", 0 },
  7564. { NULL, 0 }
  7565. };
  7566. memset(job_jobname, '\0', sizeof(job_jobname));
  7567. memset(output, '\0', sizeof(output));
  7568. //direct array initialization with variables is not standard C compliant.
  7569. output_table[0].value = sd->status.base_level;
  7570. output_table[1].format = job_jobname;
  7571. output_table[1].value = sd->status.job_level;
  7572. output_table[2].value = sd->status.hp;
  7573. output_table[3].value = sd->status.max_hp;
  7574. output_table[4].value = sd->status.sp;
  7575. output_table[5].value = sd->status.max_sp;
  7576. output_table[6].value = sd->status.str;
  7577. output_table[7].value = sd->status.agi;
  7578. output_table[8].value = sd->status.vit;
  7579. output_table[9].value = sd->status.int_;
  7580. output_table[10].value = sd->status.dex;
  7581. output_table[11].value = sd->status.luk;
  7582. output_table[12].value = sd->status.zeny;
  7583. output_table[13].value = sd->status.skill_point;
  7584. output_table[14].value = sd->change_level_2nd;
  7585. output_table[15].value = sd->change_level_3rd;
  7586. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7587. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7588. clif_displaymessage(fd, output);
  7589. for (i = 0; output_table[i].format != NULL; i++) {
  7590. sprintf(output, output_table[i].format, output_table[i].value);
  7591. clif_displaymessage(fd, output);
  7592. }
  7593. return 0;
  7594. }
  7595. ACMD_FUNC(delitem)
  7596. {
  7597. char item_name[100];
  7598. unsigned short nameid;
  7599. int amount = 0, total, idx;
  7600. struct item_data* id;
  7601. nullpo_retr(-1, sd);
  7602. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7603. {
  7604. 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>).
  7605. return -1;
  7606. }
  7607. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7608. {
  7609. nameid = id->nameid;
  7610. }
  7611. else
  7612. {
  7613. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7614. return -1;
  7615. }
  7616. total = amount;
  7617. // delete items
  7618. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7619. {
  7620. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7621. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7622. {// delete pet
  7623. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7624. }
  7625. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7626. amount-= delamount;
  7627. }
  7628. // notify target
  7629. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7630. clif_displaymessage(sd->fd, atcmd_output);
  7631. // notify source
  7632. if( amount == total )
  7633. {
  7634. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7635. }
  7636. else if( amount )
  7637. {
  7638. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7639. clif_displaymessage(fd, atcmd_output);
  7640. }
  7641. else
  7642. {
  7643. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7644. clif_displaymessage(fd, atcmd_output);
  7645. }
  7646. return 0;
  7647. }
  7648. /*==========================================
  7649. * Custom Fonts
  7650. *------------------------------------------*/
  7651. ACMD_FUNC(font)
  7652. {
  7653. int font_id;
  7654. nullpo_retr(-1,sd);
  7655. font_id = atoi(message);
  7656. if( font_id == 0 ) {
  7657. if( sd->status.font ) {
  7658. sd->status.font = 0;
  7659. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7660. clif_font(sd);
  7661. } else {
  7662. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7663. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7664. }
  7665. } else if( font_id < 0 || font_id > 9 )
  7666. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7667. else if( font_id != sd->status.font ) {
  7668. sd->status.font = font_id;
  7669. clif_font(sd);
  7670. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7671. } else
  7672. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7673. return 0;
  7674. }
  7675. /*==========================================
  7676. * type: 1 = commands (@), 2 = charcommands (#)
  7677. *------------------------------------------*/
  7678. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7679. {
  7680. char line_buff[CHATBOX_SIZE];
  7681. char* cur = line_buff;
  7682. AtCommandInfo* cmd;
  7683. DBIterator *iter = db_iterator(atcommand_db);
  7684. int count = 0;
  7685. memset(line_buff,' ',CHATBOX_SIZE);
  7686. line_buff[CHATBOX_SIZE-1] = 0;
  7687. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7688. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7689. unsigned int slen = 0;
  7690. switch( type ) {
  7691. case COMMAND_CHARCOMMAND:
  7692. if( cmd->char_groups[sd->group_pos] == 0 )
  7693. continue;
  7694. break;
  7695. case COMMAND_ATCOMMAND:
  7696. if( cmd->at_groups[sd->group_pos] == 0 )
  7697. continue;
  7698. break;
  7699. default:
  7700. continue;
  7701. }
  7702. slen = strlen(cmd->command);
  7703. // flush the text buffer if this command won't fit into it
  7704. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7705. clif_displaymessage(fd,line_buff);
  7706. cur = line_buff;
  7707. memset(line_buff,' ',CHATBOX_SIZE);
  7708. line_buff[CHATBOX_SIZE-1] = 0;
  7709. }
  7710. memcpy(cur,cmd->command,slen);
  7711. cur += slen+(10-slen%10);
  7712. count++;
  7713. }
  7714. dbi_destroy(iter);
  7715. clif_displaymessage(fd,line_buff);
  7716. if ( atcmd_binding_count ) {
  7717. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7718. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7719. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7720. unsigned int slen = strlen(atcmd_binding[i]->command);
  7721. if ( count_bind == 0 ) {
  7722. cur = line_buff;
  7723. memset(line_buff,' ',CHATBOX_SIZE);
  7724. line_buff[CHATBOX_SIZE-1] = 0;
  7725. clif_displaymessage(fd, "-----------------");
  7726. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7727. }
  7728. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7729. clif_displaymessage(fd,line_buff);
  7730. cur = line_buff;
  7731. memset(line_buff,' ',CHATBOX_SIZE);
  7732. line_buff[CHATBOX_SIZE-1] = 0;
  7733. }
  7734. memcpy(cur,atcmd_binding[i]->command,slen);
  7735. cur += slen+(10-slen%10);
  7736. count_bind++;
  7737. }
  7738. }
  7739. if ( count_bind )
  7740. clif_displaymessage(fd,line_buff);// last one
  7741. count += count_bind;
  7742. }
  7743. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7744. clif_displaymessage(fd, atcmd_output);
  7745. return;
  7746. }
  7747. /*==========================================
  7748. * @commands Lists available @ commands to you
  7749. *------------------------------------------*/
  7750. ACMD_FUNC(commands)
  7751. {
  7752. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7753. return 0;
  7754. }
  7755. /*==========================================
  7756. * @charcommands Lists available # commands to you
  7757. *------------------------------------------*/
  7758. ACMD_FUNC(charcommands) {
  7759. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7760. return 0;
  7761. }
  7762. /* for new mounts */
  7763. ACMD_FUNC(mount2) {
  7764. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7765. if (!sd->sc.data[SC_ALL_RIDING]) {
  7766. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7767. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7768. } else {
  7769. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7770. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7771. }
  7772. return 0;
  7773. }
  7774. ACMD_FUNC(accinfo) {
  7775. char query[NAME_LENGTH];
  7776. char type = 0; // type = 1, get only account name
  7777. if (!message || !*message || strlen(message) > NAME_LENGTH
  7778. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7779. {
  7780. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7781. 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".
  7782. return -1;
  7783. } else if (type != 0) {
  7784. type = type-'0'; //make it int
  7785. if (type != 1) {
  7786. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7787. return -1;
  7788. }
  7789. }
  7790. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7791. return 0;
  7792. }
  7793. /**
  7794. * @set <variable name{[index]}>{ <value>}
  7795. *
  7796. * Gets or sets a value of a non server variable.
  7797. * If a value is specified it is used to set the variable's value,
  7798. * if not the variable's value is read.
  7799. * In any case it reads and displays the variable's value.
  7800. *
  7801. * Original implementation by Ind
  7802. */
  7803. ACMD_FUNC(set) {
  7804. char reg[46], val[128], name[32];
  7805. int toset = 0, len, index;
  7806. bool is_str = false;
  7807. int64 uid;
  7808. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7809. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7810. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7811. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7812. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7813. return -1;
  7814. }
  7815. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7816. if( reg[0] == '.' ) {
  7817. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7818. return -1;
  7819. } else if( reg[0] == '\'' ) {
  7820. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7821. return -1;
  7822. }
  7823. // Check if the user wanted to set an array
  7824. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7825. // The user did not specify array brackets, so we set the index to zero
  7826. index = 0;
  7827. }
  7828. is_str = is_string_variable(name);
  7829. if( ( len = strlen(val) ) > 1 ) {
  7830. if( val[0] == '"' && val[len-1] == '"') {
  7831. val[len-1] = '\0'; //Strip quotes.
  7832. memmove(val, val+1, len-1);
  7833. }
  7834. }
  7835. // Only set the variable if there is a value for it
  7836. if( toset >= 2 ){
  7837. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7838. }
  7839. uid = reference_uid( add_str( name ), index );
  7840. if( is_str ) {// string variable
  7841. char* value;
  7842. switch( reg[0] ) {
  7843. case '@':
  7844. value = pc_readregstr(sd, uid);
  7845. break;
  7846. case '$':
  7847. value = mapreg_readregstr(uid);
  7848. break;
  7849. case '#':
  7850. if( reg[1] == '#' )
  7851. value = pc_readaccountreg2str(sd, uid);// global
  7852. else
  7853. value = pc_readaccountregstr(sd, uid);// local
  7854. break;
  7855. default:
  7856. value = pc_readglobalreg_str(sd, uid);
  7857. break;
  7858. }
  7859. if( value == NULL || *value == '\0' ){// empty string
  7860. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7861. }else{
  7862. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7863. }
  7864. } else {// integer variable
  7865. int value;
  7866. switch( reg[0] ) {
  7867. case '@':
  7868. value = pc_readreg(sd, uid);
  7869. break;
  7870. case '$':
  7871. value = mapreg_readreg(uid);
  7872. break;
  7873. case '#':
  7874. if( reg[1] == '#' )
  7875. value = pc_readaccountreg2(sd, uid);// global
  7876. else
  7877. value = pc_readaccountreg(sd, uid);// local
  7878. break;
  7879. default:
  7880. value = pc_readglobalreg(sd, uid);
  7881. break;
  7882. }
  7883. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7884. }
  7885. clif_displaymessage(fd, atcmd_output);
  7886. return 0;
  7887. }
  7888. ACMD_FUNC(addperm) {
  7889. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7890. bool add;
  7891. int i;
  7892. parent_cmd = atcommand_checkalias(command+1);
  7893. add = (strcmpi(parent_cmd, "addperm") == 0);
  7894. if( !message || !*message ) {
  7895. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7896. clif_displaymessage(fd, atcmd_output);
  7897. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7898. for( i = 0; i < perm_size; i++ ) {
  7899. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7900. clif_displaymessage(fd, atcmd_output);
  7901. }
  7902. return -1;
  7903. }
  7904. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7905. if( i == perm_size ) {
  7906. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7907. clif_displaymessage(fd, atcmd_output);
  7908. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7909. for( i = 0; i < perm_size; i++ ) {
  7910. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7911. clif_displaymessage(fd, atcmd_output);
  7912. }
  7913. return -1;
  7914. }
  7915. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7916. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7917. clif_displaymessage(fd, atcmd_output);
  7918. return -1;
  7919. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7920. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7921. clif_displaymessage(fd, atcmd_output);
  7922. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7923. clif_displaymessage(fd, atcmd_output);
  7924. for( i = 0; i < perm_size; i++ ) {
  7925. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7926. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7927. clif_displaymessage(fd, atcmd_output);
  7928. }
  7929. }
  7930. return -1;
  7931. }
  7932. if( add )
  7933. sd->permissions |= pc_g_permission_name[i].permission;
  7934. else
  7935. sd->permissions &=~ pc_g_permission_name[i].permission;
  7936. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7937. clif_displaymessage(fd, atcmd_output);
  7938. return 0;
  7939. }
  7940. ACMD_FUNC(unloadnpcfile) {
  7941. if( !message || !*message ) {
  7942. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7943. return -1;
  7944. }
  7945. if( npc_unloadfile(message) )
  7946. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7947. else {
  7948. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7949. return -1;
  7950. }
  7951. return 0;
  7952. }
  7953. ACMD_FUNC(cart) {
  7954. #define MC_CART_MDFY(idx, x) \
  7955. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7956. sd->status.skill[(idx)].lv = (x)?1:0; \
  7957. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7958. int val = atoi(message);
  7959. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7960. uint16 sk_idx = 0;
  7961. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7962. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7963. clif_displaymessage(fd, atcmd_output);
  7964. return -1;
  7965. }
  7966. if( val == 0 && !pc_iscarton(sd) ) {
  7967. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7968. return -1;
  7969. }
  7970. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7971. return -1;
  7972. if( need_skill ) {
  7973. MC_CART_MDFY(sk_idx,1);
  7974. }
  7975. if( !pc_setcart(sd, val) ) {
  7976. if( need_skill ) {
  7977. MC_CART_MDFY(sk_idx,0);
  7978. }
  7979. return -1;/* @cart failed */
  7980. }
  7981. if( need_skill ) {
  7982. MC_CART_MDFY(sk_idx,0);
  7983. }
  7984. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7985. return 0;
  7986. #undef MC_CART_MDFY
  7987. }
  7988. /* Channel System [Ind] */
  7989. ACMD_FUNC(join){
  7990. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7991. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7992. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7993. clif_displaymessage(fd, atcmd_output);
  7994. return -1;
  7995. }
  7996. return channel_pcjoin(sd, chname, pass);
  7997. }
  7998. /*
  7999. * Display available option for @channel command
  8000. * @command : the name of used command (for alias case)
  8001. */
  8002. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8003. {
  8004. int fd = sd->fd;
  8005. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8006. bool can_create = (can_delete || channel_config.private_channel.allow);
  8007. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8008. //option create
  8009. if( can_create ) {
  8010. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8011. clif_displaymessage(fd, atcmd_output);
  8012. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8013. }
  8014. //option delete
  8015. if(can_delete){
  8016. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8017. clif_displaymessage(fd, atcmd_output);
  8018. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8019. }
  8020. //option list
  8021. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8022. clif_displaymessage(fd, atcmd_output);
  8023. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8024. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8025. clif_displaymessage(fd, atcmd_output);
  8026. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8027. if( can_create ) {
  8028. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8029. clif_displaymessage(fd, atcmd_output);
  8030. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8031. }
  8032. //option setcolor
  8033. if(can_create){
  8034. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8035. clif_displaymessage(fd, atcmd_output);
  8036. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8037. }
  8038. //option join
  8039. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8040. clif_displaymessage(fd, atcmd_output);
  8041. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8042. //option leave
  8043. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8044. clif_displaymessage(fd, atcmd_output);
  8045. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8046. //option bindto
  8047. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8048. clif_displaymessage(fd, atcmd_output);
  8049. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8050. //option unbind
  8051. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8052. clif_displaymessage(fd, atcmd_output);
  8053. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8054. //option ban/unban/banlist
  8055. if( can_create ) {
  8056. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8057. clif_displaymessage(fd, atcmd_output);
  8058. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8059. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8060. clif_displaymessage(fd, atcmd_output);
  8061. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8062. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8063. clif_displaymessage(fd, atcmd_output);
  8064. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8065. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8066. clif_displaymessage(fd, atcmd_output);
  8067. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8068. }
  8069. //option setopt
  8070. if(can_create){
  8071. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8072. clif_displaymessage(fd, atcmd_output);
  8073. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8074. }
  8075. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8076. clif_displaymessage(fd, atcmd_output);
  8077. }
  8078. ACMD_FUNC(channel) {
  8079. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8080. sub1[0] = sub2[0] = '\0';
  8081. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8082. atcmd_channel_help(sd,command);
  8083. return 0;
  8084. }
  8085. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8086. return channel_pcdelete(sd,sub1);
  8087. } else if ( strcmpi(key,"list") == 0 ) {
  8088. return channel_display_list(sd,sub1);
  8089. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8090. return channel_pccolor(sd, sub1, sub2);
  8091. } else if ( strcmpi(key,"join") == 0 ) {
  8092. return channel_pcjoin(sd, sub1, sub2);
  8093. }else if ( strcmpi(key,"leave") == 0 ) {
  8094. return channel_pcleave(sd, sub1);
  8095. } else if ( strcmpi(key,"bindto") == 0 ) {
  8096. return channel_pcbind(sd, sub1);
  8097. } else if ( strcmpi(key,"unbind") == 0 ) {
  8098. return channel_pcunbind(sd);
  8099. } else if ( strcmpi(key,"ban") == 0 ) {
  8100. return channel_pcban(sd,sub1,sub2,0);
  8101. } else if ( strcmpi(key,"kick") == 0 ) {
  8102. return channel_pckick(sd,sub1,sub2);
  8103. } else if ( strcmpi(key,"banlist") == 0 ) {
  8104. return channel_pcban(sd,sub1,NULL,3);
  8105. } else if ( strcmpi(key,"unban") == 0 ) {
  8106. return channel_pcban(sd,sub1,sub2,1);
  8107. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8108. return channel_pcban(sd,sub1,NULL,2);
  8109. } else {
  8110. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8111. sub3[0] = sub4[0] = '\0';
  8112. sscanf(sub2, "%19s %19s", sub3, sub4);
  8113. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8114. if (sub4[0] != '\0') {
  8115. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8116. return -1;
  8117. }
  8118. return channel_pccreate(sd,sub1,sub3);
  8119. } else if ( strcmpi(key,"setopt") == 0 ) {
  8120. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8121. }
  8122. atcmd_channel_help(sd,command);
  8123. }
  8124. return 0;
  8125. }
  8126. ACMD_FUNC(fontcolor)
  8127. {
  8128. if( !message || !*message ) {
  8129. channel_display_list(sd,"colors");
  8130. return -1;
  8131. }
  8132. if( strcmpi(message,"Normal") == 0 ) {
  8133. sd->fontcolor = 0;
  8134. } else {
  8135. unsigned char k;
  8136. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8137. if( k == channel_config.colors_count ) {
  8138. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8139. clif_displaymessage(fd, atcmd_output);
  8140. return -1;
  8141. }
  8142. sd->fontcolor = k;
  8143. }
  8144. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8145. clif_displaymessage(fd, atcmd_output);
  8146. return 0;
  8147. }
  8148. ACMD_FUNC(langtype)
  8149. {
  8150. char langstr[8];
  8151. int i=0, fail=0;
  8152. memset(langstr, '\0', sizeof(langstr));
  8153. if(sscanf(message, "%3s", langstr) >= 1){
  8154. int lang=0;
  8155. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8156. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8157. char output[100];
  8158. pc_setaccountreg(sd, add_str(LANGTYPE_VAR), lang); //For login/char
  8159. sd->langtype = lang;
  8160. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8161. clif_displaymessage(fd,output);
  8162. return 0;
  8163. } else if (lang != -1) { //defined langage but failed check
  8164. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8165. return -1;
  8166. }
  8167. }
  8168. //wrong or no entry
  8169. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8170. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8171. while(fail != -1){ //out of range
  8172. fail = msg_checklangtype(i,false);
  8173. if(fail == 1)
  8174. clif_displaymessage(fd,msg_langtype2langstr(i));
  8175. i++;
  8176. }
  8177. return -1;
  8178. }
  8179. #ifdef VIP_ENABLE
  8180. ACMD_FUNC(vip) {
  8181. struct map_session_data *pl_sd = NULL;
  8182. char * modif_p;
  8183. int32 vipdifftime = 0;
  8184. time_t now=time(NULL);
  8185. nullpo_retr(-1, sd);
  8186. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8187. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8188. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8189. return -1;
  8190. }
  8191. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8192. modif_p = atcmd_output;
  8193. vipdifftime = (int32)solve_time(modif_p);
  8194. if (vipdifftime == 0) {
  8195. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8196. 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.
  8197. return -1;
  8198. }
  8199. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8200. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8201. return -1;
  8202. }
  8203. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8204. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8205. return -1;
  8206. }
  8207. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8208. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8209. if (pl_sd->vip.time <= now) {
  8210. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8211. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8212. } else {
  8213. int year,month,day,hour,minute,second;
  8214. char timestr[21];
  8215. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8216. 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.
  8217. clif_displaymessage(pl_sd->fd,atcmd_output);
  8218. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8219. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8220. clif_displaymessage(pl_sd->fd,atcmd_output);
  8221. if (pl_sd != sd) {
  8222. 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.
  8223. clif_displaymessage(fd,atcmd_output);
  8224. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8225. clif_displaymessage(fd,atcmd_output);
  8226. }
  8227. }
  8228. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8229. return 0;
  8230. }
  8231. /** Enable/disable rate info */
  8232. ACMD_FUNC(showrate) {
  8233. nullpo_retr(-1,sd);
  8234. if (!sd->vip.disableshowrate) {
  8235. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8236. sd->vip.disableshowrate = 1;
  8237. } else {
  8238. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8239. sd->vip.disableshowrate = 0;
  8240. }
  8241. clif_displaymessage(fd,atcmd_output);
  8242. return 0;
  8243. }
  8244. #endif
  8245. ACMD_FUNC(fullstrip) {
  8246. int i;
  8247. TBL_PC *tsd;
  8248. nullpo_retr(-1,sd);
  8249. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8250. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8251. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8252. return -1;
  8253. }
  8254. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8255. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8256. return -1;
  8257. }
  8258. for( i = 0; i < EQI_MAX; i++ ) {
  8259. if( tsd->equip_index[ i ] >= 0 )
  8260. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8261. }
  8262. return 0;
  8263. }
  8264. ACMD_FUNC(changedress){
  8265. sc_type name2id[] = {
  8266. SC_WEDDING,
  8267. SC_XMAS,
  8268. SC_SUMMER,
  8269. SC_DRESSUP,
  8270. SC_HANBOK,
  8271. SC_OKTOBERFEST
  8272. };
  8273. for( sc_type type : name2id ) {
  8274. if( sd->sc.data[type] ) {
  8275. status_change_end( &sd->bl, type, INVALID_TIMER );
  8276. // You should only be able to have one - so we cancel here
  8277. return 0;
  8278. }
  8279. }
  8280. return -1;
  8281. }
  8282. ACMD_FUNC(costume) {
  8283. const char* names[] = {
  8284. "Wedding",
  8285. "Xmas",
  8286. "Summer",
  8287. "Summer2",
  8288. "Hanbok",
  8289. "Oktoberfest"
  8290. };
  8291. const int name2id[] = {
  8292. SC_WEDDING,
  8293. SC_XMAS,
  8294. SC_SUMMER,
  8295. SC_DRESSUP,
  8296. SC_HANBOK,
  8297. SC_OKTOBERFEST
  8298. };
  8299. unsigned short k = 0, len = ARRAYLENGTH(names);
  8300. if( !message || !*message ) {
  8301. for( k = 0; k < len; k++ ) {
  8302. if( sd->sc.data[name2id[k]] ) {
  8303. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8304. clif_displaymessage(sd->fd, atcmd_output);
  8305. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8306. return 0;
  8307. }
  8308. }
  8309. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8310. for( k = 0; k < len; k++ ) {
  8311. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8312. clif_displaymessage(sd->fd, atcmd_output);
  8313. }
  8314. return -1;
  8315. }
  8316. for( k = 0; k < len; k++ ) {
  8317. if( sd->sc.data[name2id[k]] ) {
  8318. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8319. clif_displaymessage(sd->fd, atcmd_output);
  8320. return -1;
  8321. }
  8322. }
  8323. for( k = 0; k < len; k++ )
  8324. if( strcmpi(message, names[k]) == 0 )
  8325. break;
  8326. if( k == len ) {
  8327. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8328. clif_displaymessage(sd->fd, atcmd_output);
  8329. return -1;
  8330. }
  8331. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, name2id[k] == SC_DRESSUP ? 1 : 0, -1);
  8332. return 0;
  8333. }
  8334. /**
  8335. * Clone other player's equipments
  8336. * Usage: @cloneequip <char name/ID>
  8337. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8338. * @author [Cydh], [Antares]
  8339. */
  8340. ACMD_FUNC(cloneequip) {
  8341. struct map_session_data *pl_sd;
  8342. nullpo_retr(-1, sd);
  8343. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8344. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8345. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8346. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8347. clif_displaymessage(fd, atcmd_output);
  8348. return -1;
  8349. }
  8350. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8351. clif_displaymessage(fd, msg_txt(sd, 3));
  8352. return -1;
  8353. }
  8354. if (sd == pl_sd) {
  8355. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8356. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8357. clif_displaymessage(fd, atcmd_output);
  8358. return -1;
  8359. }
  8360. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8361. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8362. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8363. clif_displaymessage(fd, atcmd_output);
  8364. return -1;
  8365. }
  8366. else {
  8367. int8 i;
  8368. for (i = 0; i < EQI_MAX; i++) {
  8369. short idx;
  8370. char flag = 0;
  8371. struct item tmp_item;
  8372. if ((idx = pl_sd->equip_index[i]) < 0)
  8373. continue;
  8374. if (i == EQI_AMMO)
  8375. continue;
  8376. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8377. continue;
  8378. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8379. if (itemdb_isspecial(tmp_item.card[0]))
  8380. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8381. tmp_item.bound = 0;
  8382. tmp_item.expire_time = 0;
  8383. tmp_item.unique_id = 0;
  8384. tmp_item.favorite = 0;
  8385. tmp_item.amount = 1;
  8386. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8387. clif_additem(sd, 0, 0, flag);
  8388. else
  8389. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8390. }
  8391. }
  8392. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8393. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8394. clif_displaymessage(fd, atcmd_output);
  8395. return 0;
  8396. }
  8397. /**
  8398. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8399. * Usage: @clonestat <char name/ID>
  8400. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8401. * @author [Cydh], [Antares]
  8402. */
  8403. ACMD_FUNC(clonestat) {
  8404. struct map_session_data *pl_sd;
  8405. nullpo_retr(-1, sd);
  8406. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8407. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8408. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8409. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8410. clif_displaymessage(fd, atcmd_output);
  8411. return -1;
  8412. }
  8413. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8414. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8415. return -1;
  8416. }
  8417. if (sd == pl_sd) {
  8418. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8419. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8420. clif_displaymessage(fd, atcmd_output);
  8421. return -1;
  8422. }
  8423. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8424. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8425. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8426. clif_displaymessage(fd, atcmd_output);
  8427. return -1;
  8428. }
  8429. else {
  8430. uint8 i;
  8431. short max_status[6];
  8432. pc_resetstate(sd);
  8433. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8434. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8435. else {
  8436. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8437. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8438. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8439. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8440. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8441. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8442. }
  8443. #define clonestat_check(cmd,stat)\
  8444. {\
  8445. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8446. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8447. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8448. clif_displaymessage(fd, atcmd_output);\
  8449. sd->status.cmd = max_status[(stat)];\
  8450. }\
  8451. else\
  8452. sd->status.cmd = pl_sd->status.cmd;\
  8453. }
  8454. clonestat_check(str, PARAM_STR);
  8455. clonestat_check(agi, PARAM_AGI);
  8456. clonestat_check(vit, PARAM_VIT);
  8457. clonestat_check(int_, PARAM_INT);
  8458. clonestat_check(dex, PARAM_DEX);
  8459. clonestat_check(luk, PARAM_LUK);
  8460. for (i = 0; i < PARAM_MAX; i++) {
  8461. clif_updatestatus(sd, SP_STR + i);
  8462. clif_updatestatus(sd, SP_USTR + i);
  8463. }
  8464. status_calc_pc(sd, SCO_FORCE);
  8465. }
  8466. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8467. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8468. clif_displaymessage(fd, atcmd_output);
  8469. #undef clonestat_check
  8470. return 0;
  8471. }
  8472. /**
  8473. * Adopt a character.
  8474. * Usage: @adopt <char name>
  8475. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8476. */
  8477. ACMD_FUNC(adopt)
  8478. {
  8479. TBL_PC *b_sd;
  8480. enum adopt_responses response;
  8481. nullpo_retr(-1, sd);
  8482. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8483. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8484. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8485. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8486. clif_displaymessage(fd, atcmd_output);
  8487. return -1;
  8488. }
  8489. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8490. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8491. return -1;
  8492. }
  8493. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8494. if (response == ADOPT_ALLOWED) {
  8495. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8496. b_sd->adopt_invite = sd->status.account_id;
  8497. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8498. return 0;
  8499. }
  8500. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8501. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8502. return -1;
  8503. }
  8504. /**
  8505. * Opens the limited sale window.
  8506. * Usage: @limitedsale or client command /limitedsale on supported clients
  8507. */
  8508. ACMD_FUNC(limitedsale){
  8509. nullpo_retr(-1, sd);
  8510. clif_sale_open(sd);
  8511. return 0;
  8512. }
  8513. #include "../custom/atcommand.inc"
  8514. /**
  8515. * Fills the reference of available commands in atcommand DBMap
  8516. **/
  8517. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8518. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8519. // Define with restriction
  8520. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8521. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8522. void atcommand_basecommands(void) {
  8523. /**
  8524. * Command reference list, place the base of your commands here
  8525. * TODO: List all commands that causing crash
  8526. **/
  8527. AtCommandInfo atcommand_base[] = {
  8528. #include "../custom/atcommand_def.inc"
  8529. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8530. ACMD_DEF(where),
  8531. ACMD_DEF(jumpto),
  8532. ACMD_DEF(jump),
  8533. ACMD_DEF(who),
  8534. ACMD_DEF2("who2", who),
  8535. ACMD_DEF2("who3", who),
  8536. ACMD_DEF2("whomap", who),
  8537. ACMD_DEF2("whomap2", who),
  8538. ACMD_DEF2("whomap3", who),
  8539. ACMD_DEF(whogm),
  8540. ACMD_DEF(save),
  8541. ACMD_DEF(load),
  8542. ACMD_DEF(speed),
  8543. ACMD_DEF(storage),
  8544. ACMD_DEF(guildstorage),
  8545. ACMD_DEF(option),
  8546. ACMD_DEF(hide), // + /hide
  8547. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8548. ACMD_DEF(kill),
  8549. ACMD_DEF(alive),
  8550. ACMD_DEF(kami),
  8551. ACMD_DEF2("kamib", kami),
  8552. ACMD_DEF2("kamic", kami),
  8553. ACMD_DEF2("lkami", kami),
  8554. ACMD_DEF(heal),
  8555. ACMD_DEF(item),
  8556. ACMD_DEF(item2),
  8557. ACMD_DEF2("itembound",item),
  8558. ACMD_DEF2("itembound2",item2),
  8559. ACMD_DEF(itemreset),
  8560. ACMD_DEF(clearstorage),
  8561. ACMD_DEF(cleargstorage),
  8562. ACMD_DEF(clearcart),
  8563. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8564. ACMD_DEF2("jlvl", joblevelup),
  8565. ACMD_DEF(help),
  8566. ACMD_DEF(pvpoff),
  8567. ACMD_DEF(pvpon),
  8568. ACMD_DEF(gvgoff),
  8569. ACMD_DEF(gvgon),
  8570. ACMD_DEF(model),
  8571. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8572. ACMD_DEF(monster),
  8573. ACMD_DEF2("monstersmall", monster),
  8574. ACMD_DEF2("monsterbig", monster),
  8575. ACMD_DEF(killmonster),
  8576. ACMD_DEF2("killmonster2", killmonster),
  8577. ACMD_DEF(refine),
  8578. ACMD_DEF(produce),
  8579. ACMD_DEF(memo),
  8580. ACMD_DEF(gat),
  8581. ACMD_DEF(displaystatus),
  8582. ACMD_DEF2("stpoint", statuspoint),
  8583. ACMD_DEF2("skpoint", skillpoint),
  8584. ACMD_DEF(zeny),
  8585. ACMD_DEF2("str", param),
  8586. ACMD_DEF2("agi", param),
  8587. ACMD_DEF2("vit", param),
  8588. ACMD_DEF2("int", param),
  8589. ACMD_DEF2("dex", param),
  8590. ACMD_DEF2("luk", param),
  8591. ACMD_DEF2("glvl", guildlevelup),
  8592. ACMD_DEF(makeegg),
  8593. ACMD_DEF(hatch),
  8594. ACMD_DEF(petfriendly),
  8595. ACMD_DEF(pethungry),
  8596. ACMD_DEF(petrename),
  8597. ACMD_DEF(recall), // + /recall
  8598. ACMD_DEF(night),
  8599. ACMD_DEF(day),
  8600. ACMD_DEF(doom),
  8601. ACMD_DEF(doommap),
  8602. ACMD_DEF(raise),
  8603. ACMD_DEF(raisemap),
  8604. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8605. ACMD_DEF(kickall),
  8606. ACMD_DEF(allskill),
  8607. ACMD_DEF(questskill),
  8608. ACMD_DEF(lostskill),
  8609. ACMD_DEF(spiritball),
  8610. ACMD_DEF(party),
  8611. ACMD_DEF(guild),
  8612. ACMD_DEF(breakguild),
  8613. ACMD_DEF(agitstart),
  8614. ACMD_DEF(agitend),
  8615. ACMD_DEF(mapexit),
  8616. ACMD_DEF(idsearch),
  8617. ACMD_DEF(broadcast), // + /b and /nb
  8618. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8619. ACMD_DEF(recallall),
  8620. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8621. ACMD_DEF2("reloaditemdb", reload),
  8622. ACMD_DEF2("reloadmobdb", reload),
  8623. ACMD_DEF2("reloadskilldb", reload),
  8624. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8625. ACMD_DEF2("reloadatcommand", reload),
  8626. ACMD_DEF2("reloadbattleconf", reload),
  8627. ACMD_DEF2("reloadstatusdb", reload),
  8628. ACMD_DEF2("reloadpcdb", reload),
  8629. ACMD_DEF2("reloadmotd", reload),
  8630. ACMD_DEF2("reloadquestdb", reload),
  8631. ACMD_DEF2("reloadmsgconf", reload),
  8632. ACMD_DEF2("reloadinstancedb", reload),
  8633. ACMD_DEF2("reloadachievementdb",reload),
  8634. ACMD_DEF(partysharelvl),
  8635. ACMD_DEF(mapinfo),
  8636. ACMD_DEF(dye),
  8637. ACMD_DEF2("hairstyle", hair_style),
  8638. ACMD_DEF2("haircolor", hair_color),
  8639. ACMD_DEF2("allstats", stat_all),
  8640. ACMD_DEF2("block", char_block),
  8641. ACMD_DEF2("ban", char_ban),
  8642. ACMD_DEF2("unblock", char_unblock),
  8643. ACMD_DEF2("unban", char_unban),
  8644. ACMD_DEF2("charban", char_ban),
  8645. ACMD_DEF2("charunban", char_unban),
  8646. ACMD_DEF2("mount", mount_peco),
  8647. ACMD_DEF(guildspy),
  8648. ACMD_DEF(partyspy),
  8649. ACMD_DEF(clanspy),
  8650. ACMD_DEF(repairall),
  8651. ACMD_DEF(guildrecall),
  8652. ACMD_DEF(partyrecall),
  8653. ACMD_DEF(nuke),
  8654. ACMD_DEF(shownpc),
  8655. ACMD_DEF(hidenpc),
  8656. ACMD_DEF(loadnpc),
  8657. ACMD_DEF(unloadnpc),
  8658. ACMD_DEF(reloadnpcfile),
  8659. ACMD_DEF2("time", servertime),
  8660. ACMD_DEF(jail),
  8661. ACMD_DEF(unjail),
  8662. ACMD_DEF(jailfor),
  8663. ACMD_DEF(jailtime),
  8664. ACMD_DEF(disguise),
  8665. ACMD_DEF(undisguise),
  8666. ACMD_DEF(email),
  8667. ACMD_DEF(effect),
  8668. ACMD_DEF(follow),
  8669. ACMD_DEF(addwarp),
  8670. ACMD_DEF(skillon),
  8671. ACMD_DEF(skilloff),
  8672. ACMD_DEF(killer),
  8673. ACMD_DEF(npcmove),
  8674. ACMD_DEF(killable),
  8675. ACMD_DEF(dropall),
  8676. ACMD_DEF(storeall),
  8677. ACMD_DEF(skillid),
  8678. ACMD_DEF(useskill),
  8679. ACMD_DEF(displayskill),
  8680. ACMD_DEF(snow),
  8681. ACMD_DEF(sakura),
  8682. ACMD_DEF(clouds),
  8683. ACMD_DEF(clouds2),
  8684. ACMD_DEF(fog),
  8685. ACMD_DEF(fireworks),
  8686. ACMD_DEF(leaves),
  8687. ACMD_DEF(summon),
  8688. ACMD_DEF(adjgroup),
  8689. ACMD_DEF(trade),
  8690. ACMD_DEF(send),
  8691. ACMD_DEF(setbattleflag),
  8692. ACMD_DEF(unmute),
  8693. ACMD_DEF(clearweather),
  8694. ACMD_DEF(uptime),
  8695. ACMD_DEF(changesex),
  8696. ACMD_DEF(changecharsex),
  8697. ACMD_DEF(mute),
  8698. ACMD_DEF(refresh),
  8699. ACMD_DEF(refreshall),
  8700. ACMD_DEF(identify),
  8701. ACMD_DEF(identifyall),
  8702. ACMD_DEF(gmotd),
  8703. ACMD_DEF(misceffect),
  8704. ACMD_DEF(mobsearch),
  8705. ACMD_DEF(cleanmap),
  8706. ACMD_DEF(cleanarea),
  8707. ACMD_DEF(npctalk),
  8708. ACMD_DEF(pettalk),
  8709. ACMD_DEF(users),
  8710. ACMD_DEF(reset),
  8711. ACMD_DEF(skilltree),
  8712. ACMD_DEF(marry),
  8713. ACMD_DEF(divorce),
  8714. ACMD_DEF(sound),
  8715. ACMD_DEF(undisguiseall),
  8716. ACMD_DEF(disguiseall),
  8717. ACMD_DEF(changelook),
  8718. ACMD_DEF(autoloot),
  8719. ACMD_DEF2("alootid", autolootitem),
  8720. ACMD_DEF(autoloottype),
  8721. ACMD_DEF(mobinfo),
  8722. ACMD_DEF(exp),
  8723. ACMD_DEF(version),
  8724. ACMD_DEF(mutearea),
  8725. ACMD_DEF(rates),
  8726. ACMD_DEF(iteminfo),
  8727. ACMD_DEF(whodrops),
  8728. ACMD_DEF(whereis),
  8729. ACMD_DEF(mapflag),
  8730. ACMD_DEF(me),
  8731. ACMD_DEF(monsterignore),
  8732. ACMD_DEF(fakename),
  8733. ACMD_DEF(size),
  8734. ACMD_DEF(showexp),
  8735. ACMD_DEF(showzeny),
  8736. ACMD_DEF(showdelay),
  8737. ACMD_DEF(autotrade),
  8738. ACMD_DEF(changegm),
  8739. ACMD_DEF(changeleader),
  8740. ACMD_DEF(partyoption),
  8741. ACMD_DEF(invite),
  8742. ACMD_DEF(duel),
  8743. ACMD_DEF(leave),
  8744. ACMD_DEF(accept),
  8745. ACMD_DEF(reject),
  8746. ACMD_DEF(clone),
  8747. ACMD_DEF2("slaveclone", clone),
  8748. ACMD_DEF2("evilclone", clone),
  8749. ACMD_DEF(tonpc),
  8750. ACMD_DEF(commands),
  8751. ACMD_DEF(noask),
  8752. ACMD_DEF(request),
  8753. ACMD_DEF(homlevel),
  8754. ACMD_DEF(homevolution),
  8755. ACMD_DEF(hommutate),
  8756. ACMD_DEF(makehomun),
  8757. ACMD_DEF(homfriendly),
  8758. ACMD_DEF(homhungry),
  8759. ACMD_DEF(homtalk),
  8760. ACMD_DEF(hominfo),
  8761. ACMD_DEF(homstats),
  8762. ACMD_DEF(homshuffle),
  8763. ACMD_DEF(showmobs),
  8764. ACMD_DEF(feelreset),
  8765. ACMD_DEF(auction),
  8766. ACMD_DEF(mail),
  8767. ACMD_DEF2("noks", ksprotection),
  8768. ACMD_DEF(allowks),
  8769. ACMD_DEF(cash),
  8770. ACMD_DEF2("points", cash),
  8771. ACMD_DEF(agitstart2),
  8772. ACMD_DEF(agitend2),
  8773. ACMD_DEF(resetskill),
  8774. ACMD_DEF(resetstat),
  8775. ACMD_DEF2("storagelist", itemlist),
  8776. ACMD_DEF2("cartlist", itemlist),
  8777. ACMD_DEF2("itemlist", itemlist),
  8778. ACMD_DEF(stats),
  8779. ACMD_DEF(delitem),
  8780. ACMD_DEF(charcommands),
  8781. ACMD_DEF(font),
  8782. ACMD_DEF(accinfo),
  8783. ACMD_DEF(set),
  8784. ACMD_DEF(undisguiseguild),
  8785. ACMD_DEF(disguiseguild),
  8786. ACMD_DEF(sizeall),
  8787. ACMD_DEF(sizeguild),
  8788. ACMD_DEF(addperm),
  8789. ACMD_DEF2("rmvperm", addperm),
  8790. ACMD_DEF(unloadnpcfile),
  8791. ACMD_DEF(cart),
  8792. ACMD_DEF(mount2),
  8793. ACMD_DEF(join),
  8794. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8795. ACMD_DEF(fontcolor),
  8796. ACMD_DEF(langtype),
  8797. #ifdef VIP_ENABLE
  8798. ACMD_DEF(vip),
  8799. ACMD_DEF(showrate),
  8800. #endif
  8801. ACMD_DEF(fullstrip),
  8802. ACMD_DEF(costume),
  8803. ACMD_DEF(cloneequip),
  8804. ACMD_DEF(clonestat),
  8805. ACMD_DEF(bodystyle),
  8806. ACMD_DEF(adopt),
  8807. ACMD_DEF(agitstart3),
  8808. ACMD_DEF(agitend3),
  8809. ACMD_DEFR(limitedsale, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8810. ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
  8811. };
  8812. AtCommandInfo* atcommand;
  8813. int i;
  8814. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8815. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8816. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8817. continue;
  8818. }
  8819. CREATE(atcommand, AtCommandInfo, 1);
  8820. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8821. atcommand->func = atcommand_base[i].func;
  8822. atcommand->restriction = atcommand_base[i].restriction;
  8823. strdb_put(atcommand_db, atcommand->command, atcommand);
  8824. }
  8825. return;
  8826. }
  8827. /*==========================================
  8828. * Command lookup functions
  8829. *------------------------------------------*/
  8830. bool atcommand_exists(const char* name)
  8831. {
  8832. return strdb_exists(atcommand_db, name);
  8833. }
  8834. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8835. {
  8836. if (strdb_exists(atcommand_db, name))
  8837. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8838. return NULL;
  8839. }
  8840. static const char* atcommand_checkalias(const char *aliasname)
  8841. {
  8842. AliasInfo *alias_info = NULL;
  8843. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8844. return alias_info->command->command;
  8845. return aliasname;
  8846. }
  8847. /// AtCommand suggestion
  8848. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8849. DBIterator* atcommand_iter;
  8850. DBIterator* alias_iter;
  8851. AtCommandInfo* command_info = NULL;
  8852. AliasInfo* alias_info = NULL;
  8853. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8854. char* full_match[MAX_SUGGESTIONS];
  8855. char* suggestions[MAX_SUGGESTIONS];
  8856. char* match;
  8857. int prefix_count = 0, full_count = 0;
  8858. bool can_use;
  8859. if (!battle_config.atcommand_suggestions_enabled)
  8860. return;
  8861. atcommand_iter = db_iterator(atcommand_db);
  8862. alias_iter = db_iterator(atcommand_alias_db);
  8863. // Build the matches
  8864. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8865. match = strstr(command_info->command, name);
  8866. can_use = pc_can_use_command(sd, command_info->command, type);
  8867. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8868. suggestions[prefix_count] = command_info->command;
  8869. ++prefix_count;
  8870. }
  8871. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8872. full_match[full_count] = command_info->command;
  8873. ++full_count;
  8874. }
  8875. }
  8876. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8877. match = strstr(alias_info->alias, name);
  8878. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8879. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8880. suggestions[prefix_count] = alias_info->alias;
  8881. ++prefix_count;
  8882. }
  8883. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8884. full_match[full_count] = alias_info->alias;
  8885. ++full_count;
  8886. }
  8887. }
  8888. if ((full_count+prefix_count) > 0) {
  8889. char buffer[512];
  8890. int i;
  8891. // Merge full match and prefix match results
  8892. if (prefix_count < MAX_SUGGESTIONS) {
  8893. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8894. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8895. }
  8896. // Build the suggestion string
  8897. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  8898. strcat(buffer,"\n");
  8899. for(i=0; i < prefix_count; ++i) {
  8900. strcat(buffer,suggestions[i]);
  8901. strcat(buffer," ");
  8902. }
  8903. clif_displaymessage(sd->fd, buffer);
  8904. }
  8905. dbi_destroy(atcommand_iter);
  8906. dbi_destroy(alias_iter);
  8907. }
  8908. /**
  8909. * Executes an at-command
  8910. * @param fd
  8911. * @param sd
  8912. * @param message
  8913. * @param type
  8914. * 0 : script call (atcommand)
  8915. * 1 : normal player @atcommand
  8916. * 2 : console (admin:@atcommand)
  8917. * 3 : script call (useatcmd)
  8918. */
  8919. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8920. {
  8921. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8922. char output[CHAT_SIZE_MAX];
  8923. //Reconstructed message
  8924. char atcmd_msg[CHAT_SIZE_MAX];
  8925. TBL_PC * ssd = NULL; //sd for target
  8926. AtCommandInfo * info;
  8927. bool is_atcommand = true; // false if it's a charcommand
  8928. nullpo_retr(false, sd);
  8929. //Shouldn't happen
  8930. if ( !message || !*message )
  8931. return false;
  8932. //If cannot use atcomamnd while talking with NPC [Kichi]
  8933. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8934. return false;
  8935. //Block NOCHAT but do not display it as a normal message
  8936. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8937. return true;
  8938. // skip 10/11-langtype's codepage indicator, if detected
  8939. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8940. message += 3;
  8941. //Should display as a normal message
  8942. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8943. return false;
  8944. // type value 0|2 = script|console invoked: bypass restrictions
  8945. if ( type == 1 || type == 3) {
  8946. //Commands are disabled on maps flagged as 'nocommand'
  8947. if ( pc_get_group_level(sd) < map_getmapflag(sd->bl.m, MF_NOCOMMAND) ) {
  8948. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  8949. return false;
  8950. }
  8951. }
  8952. if (*message == charcommand_symbol)
  8953. is_atcommand = false;
  8954. if (is_atcommand) { // @command
  8955. sprintf(atcmd_msg, "%s", message);
  8956. ssd = sd;
  8957. } else { // #command
  8958. char charname[NAME_LENGTH];
  8959. int n;
  8960. //Checks to see if #command has a name or a name + parameters.
  8961. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8962. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8963. ) {
  8964. if (pc_get_group_level(sd) == 0) {
  8965. if (n < 1)
  8966. return false; // No command found. Display as normal message.
  8967. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8968. 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
  8969. return false;
  8970. }
  8971. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8972. clif_displaymessage(fd, output);
  8973. return true;
  8974. }
  8975. ssd = map_nick2sd(charname,true);
  8976. if (ssd == NULL) {
  8977. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8978. clif_displaymessage(fd, output);
  8979. return true;
  8980. }
  8981. if (n > 2)
  8982. sprintf(atcmd_msg, "%s %s", command, params);
  8983. else
  8984. sprintf(atcmd_msg, "%s", command);
  8985. }
  8986. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8987. sd->idletime = last_tick;
  8988. //Clearing these to be used once more.
  8989. memset(command, '\0', sizeof(command));
  8990. memset(params, '\0', sizeof(params));
  8991. //check to see if any params exist within this command
  8992. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  8993. params[0] = '\0';
  8994. // @commands (script based)
  8995. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8996. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  8997. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8998. if( binding != NULL && binding->npc_event[0] &&
  8999. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9000. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9001. {
  9002. // Check if self or character invoking; if self == character invoked, then self invoke.
  9003. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9004. return true;
  9005. }
  9006. }
  9007. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9008. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9009. if (info == NULL) {
  9010. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9011. return false;
  9012. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9013. clif_displaymessage(fd, output);
  9014. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9015. return true;
  9016. }
  9017. //check restriction
  9018. if (info->restriction) {
  9019. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9020. return true;
  9021. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9022. return true;
  9023. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9024. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9025. return true;
  9026. }
  9027. // type == 1 : player invoked
  9028. if (type == 1) {
  9029. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9030. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9031. return false;
  9032. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9033. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9034. return true;
  9035. }
  9036. }
  9037. //Attempt to use the command
  9038. if ( (info->func(fd, ssd, command, params) != 0) )
  9039. {
  9040. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9041. clif_displaymessage(fd, output);
  9042. return true;
  9043. }
  9044. //Log only if successful.
  9045. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9046. return true;
  9047. }
  9048. /*==========================================
  9049. *
  9050. *------------------------------------------*/
  9051. static void atcommand_config_read(const char* config_filename)
  9052. {
  9053. config_setting_t *aliases = NULL, *help = NULL;
  9054. const char *symbol = NULL;
  9055. int num_aliases = 0;
  9056. if (conf_read_file(&atcommand_config, config_filename))
  9057. return;
  9058. // Command symbols
  9059. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9060. if (ISPRINT(*symbol) && // no control characters
  9061. *symbol != '/' && // symbol of client commands
  9062. *symbol != '%' && // symbol of party chat
  9063. *symbol != '$' && // symbol of guild chat
  9064. *symbol != charcommand_symbol)
  9065. atcommand_symbol = *symbol;
  9066. }
  9067. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9068. if (ISPRINT(*symbol) && // no control characters
  9069. *symbol != '/' && // symbol of client commands
  9070. *symbol != '%' && // symbol of party chat
  9071. *symbol != '$' && // symbol of guild chat
  9072. *symbol != atcommand_symbol)
  9073. charcommand_symbol = *symbol;
  9074. }
  9075. // Command aliases
  9076. aliases = config_lookup(&atcommand_config, "aliases");
  9077. if (aliases != NULL) {
  9078. int i = 0;
  9079. int count = config_setting_length(aliases);
  9080. for (i = 0; i < count; ++i) {
  9081. config_setting_t *command;
  9082. const char *commandname = NULL;
  9083. int j = 0, alias_count = 0;
  9084. AtCommandInfo *commandinfo = NULL;
  9085. command = config_setting_get_elem(aliases, i);
  9086. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9087. continue;
  9088. commandname = config_setting_name(command);
  9089. if (!atcommand_exists(commandname)) {
  9090. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9091. continue;
  9092. }
  9093. commandinfo = get_atcommandinfo_byname(commandname);
  9094. alias_count = config_setting_length(command);
  9095. for (j = 0; j < alias_count; ++j) {
  9096. const char *alias = config_setting_get_string_elem(command, j);
  9097. if (alias != NULL) {
  9098. AliasInfo *alias_info;
  9099. if (strdb_exists(atcommand_alias_db, alias)) {
  9100. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9101. continue;
  9102. }
  9103. CREATE(alias_info, AliasInfo, 1);
  9104. alias_info->command = commandinfo;
  9105. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9106. strdb_put(atcommand_alias_db, alias, alias_info);
  9107. ++num_aliases;
  9108. }
  9109. }
  9110. }
  9111. }
  9112. // Commands help
  9113. // We only check if all commands exist
  9114. help = config_lookup(&atcommand_config, "help");
  9115. if (help != NULL) {
  9116. int count = config_setting_length(help);
  9117. int i;
  9118. for (i = 0; i < count; ++i) {
  9119. config_setting_t *command;
  9120. const char *commandname;
  9121. command = config_setting_get_elem(help, i);
  9122. commandname = config_setting_name(command);
  9123. if (!atcommand_exists(commandname))
  9124. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9125. }
  9126. }
  9127. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' command aliases in '" CL_WHITE "%s" CL_RESET "'.\n", num_aliases, config_filename);
  9128. return;
  9129. }
  9130. void atcommand_db_load_groups(int* group_ids) {
  9131. DBIterator *iter = db_iterator(atcommand_db);
  9132. AtCommandInfo* cmd;
  9133. int i;
  9134. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9135. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9136. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9137. for(i = 0; i < pc_group_max; i++) {
  9138. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9139. cmd->at_groups[i] = 1;
  9140. else
  9141. cmd->at_groups[i] = 0;
  9142. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9143. cmd->char_groups[i] = 1;
  9144. else
  9145. cmd->char_groups[i] = 0;
  9146. }
  9147. }
  9148. dbi_destroy(iter);
  9149. return;
  9150. }
  9151. void atcommand_db_clear(void) {
  9152. if (atcommand_db != NULL) {
  9153. DBIterator *iter = db_iterator(atcommand_db);
  9154. AtCommandInfo* cmd;
  9155. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9156. aFree(cmd->at_groups);
  9157. aFree(cmd->char_groups);
  9158. }
  9159. dbi_destroy(iter);
  9160. db_destroy(atcommand_db);
  9161. }
  9162. if (atcommand_alias_db != NULL)
  9163. db_destroy(atcommand_alias_db);
  9164. config_destroy(&atcommand_config);
  9165. }
  9166. void atcommand_doload(void) {
  9167. atcommand_db_clear();
  9168. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9169. atcommand_alias_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9170. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9171. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9172. }
  9173. void do_init_atcommand(void) {
  9174. atcommand_doload();
  9175. }
  9176. void do_final_atcommand(void) {
  9177. atcommand_db_clear();
  9178. }