atcommand.cpp 327 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "atcommand.hpp"
  4. #include <stdlib.h>
  5. #include <math.h>
  6. #include "../common/cbasetypes.h"
  7. #include "../common/mmo.h"
  8. #include "../common/timer.h"
  9. #include "../common/nullpo.h"
  10. #include "../common/showmsg.h"
  11. #include "../common/malloc.h"
  12. #include "../common/random.h"
  13. #include "../common/socket.h"
  14. #include "../common/strlib.h"
  15. #include "../common/utils.h"
  16. #include "../common/utilities.hpp"
  17. #include "../common/conf.h"
  18. #include "map.hpp"
  19. #include "battle.hpp"
  20. #include "chat.hpp"
  21. #include "channel.hpp"
  22. #include "chrif.hpp"
  23. #include "duel.hpp"
  24. #include "instance.hpp"
  25. #include "intif.hpp"
  26. #include "pet.hpp"
  27. #include "homunculus.hpp"
  28. #include "mail.hpp"
  29. #include "mercenary.hpp"
  30. #include "elemental.hpp"
  31. #include "party.hpp"
  32. #include "script.hpp"
  33. #include "storage.hpp"
  34. #include "trade.hpp"
  35. #include "mapreg.hpp"
  36. #include "quest.hpp"
  37. #include "pc.hpp"
  38. #include "pc_groups.hpp"
  39. #include "npc.hpp"
  40. #include "guild.hpp"
  41. #include "clif.hpp"
  42. #include "log.hpp"
  43. #include "itemdb.hpp" // MAX_ITEMGROUP
  44. #include "mob.hpp"
  45. #include "achievement.hpp"
  46. #include "clan.hpp"
  47. #define ATCOMMAND_LENGTH 50
  48. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  49. typedef struct AtCommandInfo AtCommandInfo;
  50. typedef struct AliasInfo AliasInfo;
  51. int atcmd_binding_count = 0;
  52. /// Atcommand restriction usage
  53. enum e_atcmd_restict {
  54. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  55. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  56. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  57. };
  58. struct AtCommandInfo {
  59. char command[ATCOMMAND_LENGTH];
  60. AtCommandFunc func;
  61. char* at_groups; /// Quick @commands "can-use" lookup
  62. char* char_groups; /// Quick @charcommands "can-use" lookup
  63. uint8 restriction; /// Restrictions see enum e_restict
  64. };
  65. struct AliasInfo {
  66. AtCommandInfo *command;
  67. char alias[ATCOMMAND_LENGTH];
  68. };
  69. char atcommand_symbol = '@'; // first char of the commands
  70. char charcommand_symbol = '#';
  71. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  72. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  73. static config_t atcommand_config;
  74. static char atcmd_output[CHAT_SIZE_MAX];
  75. static char atcmd_player_name[NAME_LENGTH];
  76. const char *parent_cmd;
  77. struct atcmd_binding_data** atcmd_binding;
  78. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  79. static const char* atcommand_checkalias(const char *aliasname); // @help
  80. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  81. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  82. // @commands (script-based)
  83. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  84. int i = 0;
  85. if( *name == atcommand_symbol || *name == charcommand_symbol )
  86. name++; // for backwards compatibility
  87. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  88. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  89. }
  90. /**
  91. * retrieves the help string associated with a given command.
  92. *
  93. * @param name the name of the command to retrieve help information for
  94. * @return the string associated with the command, or NULL
  95. */
  96. static const char* atcommand_help_string(const char* command)
  97. {
  98. const char* str = NULL;
  99. config_setting_t* info;
  100. if( *command == atcommand_symbol || *command == charcommand_symbol )
  101. {// remove the prefix symbol for the raw name of the command
  102. command ++;
  103. }
  104. // convert alias to the real command name
  105. command = atcommand_checkalias(command);
  106. // attempt to find the first default help command
  107. info = config_lookup(&atcommand_config, "help");
  108. if( info == NULL )
  109. {// failed to find the help property in the configuration file
  110. return NULL;
  111. }
  112. if( !config_setting_lookup_string( info, command, &str ) )
  113. {// failed to find the matching help string
  114. return NULL;
  115. }
  116. // push the result from the method
  117. return str;
  118. }
  119. /*==========================================
  120. * @send (used for testing packet sends from the client)
  121. *------------------------------------------*/
  122. ACMD_FUNC(send)
  123. {
  124. int len=0,type;
  125. // read message type as hex number (without the 0x)
  126. if(!message || !*message ||
  127. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  128. || sscanf(message, "%8x", &type)==1) )
  129. {
  130. int i;
  131. for (i = 900; i <= 903; ++i)
  132. clif_displaymessage(fd, msg_txt(sd,i));
  133. return -1;
  134. }
  135. #define PARSE_ERROR(error,p) \
  136. {\
  137. clif_displaymessage(fd, (error));\
  138. sprintf(atcmd_output, ">%s", (p));\
  139. clif_displaymessage(fd, atcmd_output);\
  140. }
  141. //define PARSE_ERROR
  142. #define CHECK_EOS(p) \
  143. if(*(p) == 0){\
  144. clif_displaymessage(fd, "Unexpected end of string");\
  145. return -1;\
  146. }
  147. //define CHECK_EOS
  148. #define SKIP_VALUE(p) \
  149. {\
  150. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  151. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  152. }
  153. //define SKIP_VALUE
  154. #define GET_VALUE(p,num) \
  155. {\
  156. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  157. PARSE_ERROR("Invalid number in:",(p));\
  158. return -1;\
  159. }\
  160. }
  161. //define GET_VALUE
  162. if (type > 0 && type < MAX_PACKET_DB) {
  163. int off,end;
  164. long num;
  165. if(len)
  166. {// show packet length
  167. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[type].len); // Packet 0x%x length: %d
  168. clif_displaymessage(fd, atcmd_output);
  169. return 0;
  170. }
  171. len=packet_db[type].len;
  172. off=2;
  173. if(len == 0)
  174. {// unknown packet - ERROR
  175. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  176. clif_displaymessage(fd, atcmd_output);
  177. return -1;
  178. } else if(len == -1)
  179. {// dynamic packet
  180. len=SHRT_MAX-4; // maximum length
  181. off=4;
  182. }
  183. WFIFOHEAD(fd, len);
  184. WFIFOW(fd,0)=TOW(type);
  185. // parse packet contents
  186. SKIP_VALUE(message);
  187. while(*message != 0 && off < len){
  188. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  189. {// default (byte)
  190. GET_VALUE(message,num);
  191. WFIFOB(fd,off)=TOB(num);
  192. ++off;
  193. } else if(TOUPPER(*message) == 'B')
  194. {// byte
  195. ++message;
  196. GET_VALUE(message,num);
  197. WFIFOB(fd,off)=TOB(num);
  198. ++off;
  199. } else if(TOUPPER(*message) == 'W')
  200. {// word (2 bytes)
  201. ++message;
  202. GET_VALUE(message,num);
  203. WFIFOW(fd,off)=TOW(num);
  204. off+=2;
  205. } else if(TOUPPER(*message) == 'L')
  206. {// long word (4 bytes)
  207. ++message;
  208. GET_VALUE(message,num);
  209. WFIFOL(fd,off)=TOL(num);
  210. off+=4;
  211. } else if(TOUPPER(*message) == 'S')
  212. {// string - escapes are valid
  213. // get string length - num <= 0 means not fixed length (default)
  214. ++message;
  215. if(*message == '"'){
  216. num=0;
  217. } else {
  218. GET_VALUE(message,num);
  219. while(*message != '"')
  220. {// find start of string
  221. if(*message == 0 || ISSPACE(*message)){
  222. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  223. return -1;
  224. }
  225. ++message;
  226. }
  227. }
  228. // parse string
  229. ++message;
  230. CHECK_EOS(message);
  231. end=(num<=0? 0: min(off+((int)num),len));
  232. for(; *message != '"' && (off < end || end == 0); ++off){
  233. if(*message == '\\'){
  234. ++message;
  235. CHECK_EOS(message);
  236. switch(*message){
  237. case 'a': num=0x07; break; // Bell
  238. case 'b': num=0x08; break; // Backspace
  239. case 't': num=0x09; break; // Horizontal tab
  240. case 'n': num=0x0A; break; // Line feed
  241. case 'v': num=0x0B; break; // Vertical tab
  242. case 'f': num=0x0C; break; // Form feed
  243. case 'r': num=0x0D; break; // Carriage return
  244. case 'e': num=0x1B; break; // Escape
  245. default: num=*message; break;
  246. case 'x': // Hexadecimal
  247. {
  248. ++message;
  249. CHECK_EOS(message);
  250. if(!ISXDIGIT(*message)){
  251. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  252. return -1;
  253. }
  254. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  255. if(ISXDIGIT(*message)){
  256. ++message;
  257. CHECK_EOS(message);
  258. num<<=8;
  259. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  260. }
  261. WFIFOB(fd,off)=TOB(num);
  262. ++message;
  263. CHECK_EOS(message);
  264. continue;
  265. }
  266. case '0':
  267. case '1':
  268. case '2':
  269. case '3':
  270. case '4':
  271. case '5':
  272. case '6':
  273. case '7': // Octal
  274. {
  275. num=*message-'0'; // 1st octal digit
  276. ++message;
  277. CHECK_EOS(message);
  278. if(ISDIGIT(*message) && *message < '8'){
  279. num<<=3;
  280. num+=*message-'0'; // 2nd octal digit
  281. ++message;
  282. CHECK_EOS(message);
  283. if(ISDIGIT(*message) && *message < '8'){
  284. num<<=3;
  285. num+=*message-'0'; // 3rd octal digit
  286. ++message;
  287. CHECK_EOS(message);
  288. }
  289. }
  290. WFIFOB(fd,off)=TOB(num);
  291. continue;
  292. }
  293. }
  294. } else
  295. num=*message;
  296. WFIFOB(fd,off)=TOB(num);
  297. ++message;
  298. CHECK_EOS(message);
  299. }//for
  300. while(*message != '"')
  301. {// ignore extra characters
  302. ++message;
  303. CHECK_EOS(message);
  304. }
  305. // terminate the string
  306. if(off < end)
  307. {// fill the rest with 0's
  308. memset(WFIFOP(fd,off),0,end-off);
  309. off=end;
  310. }
  311. } else
  312. {// unknown
  313. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  314. return -1;
  315. }
  316. SKIP_VALUE(message);
  317. }
  318. if(packet_db[type].len == -1)
  319. {// send dynamic packet
  320. WFIFOW(fd,2)=TOW(off);
  321. WFIFOSET(fd,off);
  322. } else
  323. {// send static packet
  324. if(off < len)
  325. memset(WFIFOP(fd,off),0,len-off);
  326. WFIFOSET(fd,len);
  327. }
  328. } else {
  329. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  330. return -1;
  331. }
  332. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  333. clif_displaymessage(fd, atcmd_output);
  334. return 0;
  335. #undef PARSE_ERROR
  336. #undef CHECK_EOS
  337. #undef SKIP_VALUE
  338. #undef GET_VALUE
  339. }
  340. /**
  341. * Retrieves map name suggestions for a given string.
  342. * This will first check if any map names contain the given string, and will
  343. * print out MAX_SUGGESTIONS results if any maps are found.
  344. * Otherwise, suggestions will be calculated through Levenshtein distance,
  345. * and up to 5 of the closest matches will be printed.
  346. *
  347. * @author Euphy
  348. */
  349. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  350. char buffer[512];
  351. int i, count = 0;
  352. if (strlen(name) < 2)
  353. return;
  354. // build the suggestion string
  355. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  356. strcat(buffer, "\n");
  357. // check for maps that contain string
  358. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  359. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  360. strcat(buffer, map[i].name);
  361. strcat(buffer, " ");
  362. if (++count >= MAX_SUGGESTIONS)
  363. break;
  364. }
  365. }
  366. // if no maps found, search by edit distance
  367. if (!count) {
  368. unsigned int distance[MAX_MAP_PER_SERVER][2];
  369. int j;
  370. // calculate Levenshtein distance for all maps
  371. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  372. if (strlen(map[i].name) < 4) // invalid map name?
  373. distance[i][0] = INT_MAX;
  374. else {
  375. distance[i][0] = levenshtein(map[i].name, name);
  376. distance[i][1] = i;
  377. }
  378. }
  379. // selection sort elements as needed
  380. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  381. for (i = 0; i < count; i++) {
  382. int min = i;
  383. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  384. if (distance[j][0] < distance[min][0])
  385. min = j;
  386. }
  387. // print map name
  388. if (distance[min][0] > 4) { // awful results, don't bother
  389. if (!i) return;
  390. break;
  391. }
  392. strcat(buffer, map[distance[min][1]].name);
  393. strcat(buffer, " ");
  394. // swap elements
  395. SWAP(distance[i][0], distance[min][0]);
  396. SWAP(distance[i][1], distance[min][1]);
  397. }
  398. }
  399. clif_displaymessage(sd->fd, buffer);
  400. }
  401. /*==========================================
  402. * @rura, @warp, @mapmove
  403. *------------------------------------------*/
  404. ACMD_FUNC(mapmove)
  405. {
  406. char map_name[MAP_NAME_LENGTH_EXT];
  407. unsigned short mapindex;
  408. short x = 0, y = 0;
  409. int16 m = -1;
  410. nullpo_retr(-1, sd);
  411. memset(map_name, '\0', sizeof(map_name));
  412. if (!message || !*message ||
  413. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  414. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  415. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  416. return -1;
  417. }
  418. mapindex = mapindex_name2id(map_name);
  419. if (mapindex)
  420. m = map_mapindex2mapid(mapindex);
  421. if (!mapindex) { // m < 0 means on different server! [Kevin]
  422. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  423. if (battle_config.warp_suggestions_enabled)
  424. warp_get_suggestions(sd, map_name);
  425. return -1;
  426. }
  427. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  428. { //This is to prevent the pc_setpos call from printing an error.
  429. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  430. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  431. x = y = 0; //Invalid cell, use random spot.
  432. }
  433. if ((map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, sd->group_level)) {
  434. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  435. return -1;
  436. }
  437. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  438. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  439. return -1;
  440. }
  441. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != SETPOS_OK) {
  442. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  443. return -1;
  444. }
  445. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  446. return 0;
  447. }
  448. /*==========================================
  449. * Displays where a character is. Corrected version by Silent. [Skotlex]
  450. *------------------------------------------*/
  451. ACMD_FUNC(where)
  452. {
  453. struct map_session_data* pl_sd;
  454. nullpo_retr(-1, sd);
  455. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  456. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  457. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  458. return -1;
  459. }
  460. pl_sd = map_nick2sd(atcmd_player_name,true);
  461. if (pl_sd == NULL ||
  462. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  463. (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))
  464. ) {
  465. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  466. return -1;
  467. }
  468. 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);
  469. clif_displaymessage(fd, atcmd_output);
  470. return 0;
  471. }
  472. /*==========================================
  473. *
  474. *------------------------------------------*/
  475. ACMD_FUNC(jumpto)
  476. {
  477. struct map_session_data *pl_sd = NULL;
  478. nullpo_retr(-1, sd);
  479. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  480. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  481. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  482. return -1;
  483. }
  484. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  485. {
  486. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  487. return -1;
  488. }
  489. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  490. {
  491. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  492. return -1;
  493. }
  494. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  495. {
  496. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  497. return -1;
  498. }
  499. if( pc_isdead(sd) )
  500. {
  501. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  502. return -1;
  503. }
  504. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  505. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  506. clif_displaymessage(fd, atcmd_output);
  507. return 0;
  508. }
  509. /*==========================================
  510. *
  511. *------------------------------------------*/
  512. ACMD_FUNC(jump)
  513. {
  514. short x = 0, y = 0;
  515. nullpo_retr(-1, sd);
  516. memset(atcmd_output, '\0', sizeof(atcmd_output));
  517. sscanf(message, "%6hd %6hd", &x, &y);
  518. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  519. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  520. return -1;
  521. }
  522. if( pc_isdead(sd) )
  523. {
  524. clif_displaymessage(fd, msg_txt(sd,664)); // You cannot use this command when dead.
  525. return -1;
  526. }
  527. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  528. { //This is to prevent the pc_setpos call from printing an error.
  529. clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
  530. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  531. x = y = 0; //Invalid cell, use random spot.
  532. }
  533. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  534. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  535. clif_displaymessage(fd, atcmd_output);
  536. return 0;
  537. }
  538. /*==========================================
  539. * Display list of online characters with
  540. * various info.
  541. *------------------------------------------*/
  542. ACMD_FUNC(who) {
  543. struct map_session_data *pl_sd = NULL;
  544. struct s_mapiterator *iter = NULL;
  545. char player_name[NAME_LENGTH] = "";
  546. int count = 0;
  547. int level = 0;
  548. StringBuf buf;
  549. /**
  550. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  551. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  552. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  553. */
  554. int display_type = 1;
  555. int map_id = -1;
  556. nullpo_retr(-1, sd);
  557. if (strstr(command, "map") != NULL) {
  558. char map_name[MAP_NAME_LENGTH_EXT] = "";
  559. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  560. map_id = sd->bl.m;
  561. } else {
  562. sscanf(message, "%23s", player_name);
  563. }
  564. if (strstr(command, "2") != NULL)
  565. display_type = 2;
  566. else if (strstr(command, "3") != NULL)
  567. display_type = 3;
  568. level = pc_get_group_level(sd);
  569. StringBuf_Init(&buf);
  570. iter = mapit_getallusers();
  571. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  572. 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
  573. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  574. || (map_id >= 0 && pl_sd->bl.m != map_id))
  575. continue;
  576. switch (display_type) {
  577. case 2: {
  578. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  579. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  580. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  581. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  582. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  583. break;
  584. }
  585. case 3: {
  586. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  587. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  588. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  589. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  590. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  591. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  592. break;
  593. }
  594. default: {
  595. struct party_data *p = party_search(pl_sd->status.party_id);
  596. struct guild *g = pl_sd->guild;
  597. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  598. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  599. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  600. if (p != NULL)
  601. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  602. if (g != NULL)
  603. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  604. break;
  605. }
  606. }
  607. clif_displaymessage(fd, StringBuf_Value(&buf));
  608. StringBuf_Clear(&buf);
  609. count++;
  610. }
  611. }
  612. mapit_free(iter);
  613. if (map_id < 0) {
  614. if (count == 0)
  615. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  616. else if (count == 1)
  617. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  618. else
  619. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  620. } else {
  621. if (count == 0)
  622. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  623. else if (count == 1)
  624. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  625. else
  626. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  627. }
  628. clif_displaymessage(fd, StringBuf_Value(&buf));
  629. StringBuf_Destroy(&buf);
  630. return 0;
  631. }
  632. /*==========================================
  633. *
  634. *------------------------------------------*/
  635. ACMD_FUNC(whogm)
  636. {
  637. struct map_session_data* pl_sd;
  638. struct s_mapiterator* iter;
  639. int j, count;
  640. int level;
  641. char match_text[CHAT_SIZE_MAX];
  642. char player_name[NAME_LENGTH];
  643. struct guild *g;
  644. struct party_data *p;
  645. nullpo_retr(-1, sd);
  646. memset(atcmd_output, '\0', sizeof(atcmd_output));
  647. memset(match_text, '\0', sizeof(match_text));
  648. memset(player_name, '\0', sizeof(player_name));
  649. if (sscanf(message, "%255[^\n]", match_text) < 1)
  650. strcpy(match_text, "");
  651. for (j = 0; match_text[j]; j++)
  652. match_text[j] = TOLOWER(match_text[j]);
  653. count = 0;
  654. level = pc_get_group_level(sd);
  655. iter = mapit_getallusers();
  656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  657. {
  658. int pl_level = pc_get_group_level(pl_sd);
  659. if (!pl_level)
  660. continue;
  661. if (match_text[0])
  662. {
  663. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  664. for (j = 0; player_name[j]; j++)
  665. player_name[j] = TOLOWER(player_name[j]);
  666. // search with no case sensitive
  667. if (strstr(player_name, match_text) == NULL)
  668. continue;
  669. }
  670. if (pl_level > level) {
  671. if (pc_isinvisible(pl_sd))
  672. continue;
  673. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  674. clif_displaymessage(fd, atcmd_output);
  675. count++;
  676. continue;
  677. }
  678. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  679. pl_sd->status.name, pl_level,
  680. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  681. clif_displaymessage(fd, atcmd_output);
  682. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  683. pl_sd->status.base_level,
  684. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  685. clif_displaymessage(fd, atcmd_output);
  686. p = party_search(pl_sd->status.party_id);
  687. g = pl_sd->guild;
  688. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  689. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  690. clif_displaymessage(fd, atcmd_output);
  691. count++;
  692. }
  693. mapit_free(iter);
  694. if (count == 0)
  695. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  696. else if (count == 1)
  697. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  698. else {
  699. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  700. clif_displaymessage(fd, atcmd_output);
  701. }
  702. return 0;
  703. }
  704. /*==========================================
  705. *
  706. *------------------------------------------*/
  707. ACMD_FUNC(save)
  708. {
  709. nullpo_retr(-1, sd);
  710. if( map[sd->bl.m].instance_id ) {
  711. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  712. return 1;
  713. }
  714. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  715. if (sd->status.pet_id > 0 && sd->pd)
  716. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  717. chrif_save(sd, CSAVE_NORMAL);
  718. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  719. return 0;
  720. }
  721. /*==========================================
  722. *
  723. *------------------------------------------*/
  724. ACMD_FUNC(load)
  725. {
  726. int16 m;
  727. nullpo_retr(-1, sd);
  728. m = map_mapindex2mapid(sd->status.save_point.map);
  729. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  730. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  731. return -1;
  732. }
  733. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  734. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  735. return -1;
  736. }
  737. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  738. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  739. return 0;
  740. }
  741. /*==========================================
  742. *
  743. *------------------------------------------*/
  744. ACMD_FUNC(speed)
  745. {
  746. short speed;
  747. nullpo_retr(-1, sd);
  748. memset(atcmd_output, '\0', sizeof(atcmd_output));
  749. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  750. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  751. clif_displaymessage(fd, atcmd_output);
  752. return -1;
  753. }
  754. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  755. if (speed < 0)
  756. sd->base_status.speed = DEFAULT_WALK_SPEED;
  757. else
  758. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  759. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  760. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  761. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  762. } else
  763. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  764. status_calc_bl(&sd->bl, SCB_SPEED);
  765. return 0;
  766. }
  767. /*==========================================
  768. *
  769. *------------------------------------------*/
  770. ACMD_FUNC(storage)
  771. {
  772. nullpo_retr(-1, sd);
  773. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  774. return -1;
  775. if (storage_storageopen(sd) == 1)
  776. { //Already open.
  777. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  778. return -1;
  779. }
  780. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  781. return 0;
  782. }
  783. /*==========================================
  784. *
  785. *------------------------------------------*/
  786. ACMD_FUNC(guildstorage)
  787. {
  788. nullpo_retr(-1, sd);
  789. if (!sd->status.guild_id) {
  790. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  791. return -1;
  792. }
  793. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  794. return -1;
  795. if (sd->state.storage_flag == 1) {
  796. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  797. return -1;
  798. }
  799. if (sd->state.storage_flag == 2) {
  800. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  801. return -1;
  802. }
  803. if (sd->state.storage_flag == 3) {
  804. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  805. return -1;
  806. }
  807. storage_guild_storageopen(sd);
  808. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  809. return 0;
  810. }
  811. /*==========================================
  812. *
  813. *------------------------------------------*/
  814. ACMD_FUNC(option)
  815. {
  816. int param1 = 0, param2 = 0, param3 = 0;
  817. nullpo_retr(-1, sd);
  818. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  819. {// failed to match the parameters so inform the user of the options
  820. const char* text;
  821. // attempt to find the setting information for this command
  822. text = atcommand_help_string( command );
  823. // notify the user of the requirement to enter an option
  824. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  825. if( text )
  826. {// send the help text associated with this command
  827. clif_displaymessage( fd, text );
  828. }
  829. return -1;
  830. }
  831. sd->sc.opt1 = param1;
  832. sd->sc.opt2 = param2;
  833. pc_setoption(sd, param3);
  834. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  835. return 0;
  836. }
  837. /*==========================================
  838. *
  839. *------------------------------------------*/
  840. ACMD_FUNC(hide)
  841. {
  842. nullpo_retr(-1, sd);
  843. if (pc_isinvisible(sd)) {
  844. sd->sc.option &= ~OPTION_INVISIBLE;
  845. if (sd->disguise)
  846. status_set_viewdata(&sd->bl, sd->disguise);
  847. else
  848. status_set_viewdata(&sd->bl, sd->status.class_);
  849. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  850. // increment the number of pvp players on the map
  851. map[sd->bl.m].users_pvp++;
  852. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  853. {// register the player for ranking calculations
  854. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  855. }
  856. //bugreport:2266
  857. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  858. } else {
  859. sd->sc.option |= OPTION_INVISIBLE;
  860. sd->vd.class_ = JT_INVISIBLE;
  861. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  862. // decrement the number of pvp players on the map
  863. map[sd->bl.m].users_pvp--;
  864. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  865. {// unregister the player for ranking
  866. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  867. sd->pvp_timer = INVALID_TIMER;
  868. }
  869. }
  870. clif_changeoption(&sd->bl);
  871. return 0;
  872. }
  873. /*==========================================
  874. * Changes a character's class
  875. *------------------------------------------*/
  876. ACMD_FUNC(jobchange)
  877. {
  878. int job = 0, upper = 0;
  879. const char* text;
  880. nullpo_retr(-1, sd);
  881. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  882. int i;
  883. bool found = false;
  884. upper = 0;
  885. // Normal Jobs
  886. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  887. if (strncmpi(message, job_name(i), 16) == 0) {
  888. job = i;
  889. found = true;
  890. }
  891. }
  892. // High Jobs, Babys and Third
  893. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  894. if (strncmpi(message, job_name(i), 16) == 0) {
  895. job = i;
  896. found = true;
  897. }
  898. }
  899. if (!found) {
  900. text = atcommand_help_string(command);
  901. if (text)
  902. clif_displaymessage(fd, text);
  903. return -1;
  904. }
  905. }
  906. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  907. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  908. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) || job == JOB_BABY_STAR_GLADIATOR2)
  909. { // Deny direct transformation into dummy jobs
  910. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  911. return 0;
  912. }
  913. if (pcdb_checkid(job))
  914. {
  915. if (pc_jobchange(sd, job, upper))
  916. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  917. else {
  918. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  919. return -1;
  920. }
  921. } else {
  922. text = atcommand_help_string(command);
  923. if (text)
  924. clif_displaymessage(fd, text);
  925. return -1;
  926. }
  927. return 0;
  928. }
  929. /*==========================================
  930. *
  931. *------------------------------------------*/
  932. ACMD_FUNC(kill)
  933. {
  934. nullpo_retr(-1, sd);
  935. status_kill(&sd->bl);
  936. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  937. if (fd != sd->fd)
  938. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  939. return 0;
  940. }
  941. /*==========================================
  942. *
  943. *------------------------------------------*/
  944. ACMD_FUNC(alive)
  945. {
  946. nullpo_retr(-1, sd);
  947. if (!status_revive(&sd->bl, 100, 100))
  948. {
  949. clif_displaymessage(fd, msg_txt(sd,667)); // You're not dead.
  950. return -1;
  951. }
  952. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  953. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  954. return 0;
  955. }
  956. /*==========================================
  957. * +kamic [LuzZza]
  958. *------------------------------------------*/
  959. ACMD_FUNC(kami)
  960. {
  961. unsigned long color=0;
  962. nullpo_retr(-1, sd);
  963. memset(atcmd_output, '\0', sizeof(atcmd_output));
  964. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  965. if (!message || !*message) {
  966. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  967. return -1;
  968. }
  969. sscanf(message, "%255[^\n]", atcmd_output);
  970. if (strstr(command, "l") != NULL)
  971. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  972. else
  973. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  974. } else {
  975. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  976. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  977. return -1;
  978. }
  979. if(color > 0xFFFFFF) {
  980. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  981. return -1;
  982. }
  983. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  984. }
  985. return 0;
  986. }
  987. /*==========================================
  988. *
  989. *------------------------------------------*/
  990. ACMD_FUNC(heal)
  991. {
  992. int hp = 0, sp = 0; // [Valaris] thanks to fov
  993. nullpo_retr(-1, sd);
  994. sscanf(message, "%11d %11d", &hp, &sp);
  995. // some overflow checks
  996. if( hp == INT_MIN ) hp++;
  997. if( sp == INT_MIN ) sp++;
  998. if ( hp == 0 && sp == 0 ) {
  999. if (!status_percent_heal(&sd->bl, 100, 100))
  1000. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  1001. else
  1002. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1003. return 0;
  1004. }
  1005. if ( hp > 0 && sp >= 0 ) {
  1006. if(!status_heal(&sd->bl, hp, sp, 0))
  1007. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  1008. else
  1009. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1010. return 0;
  1011. }
  1012. if ( hp < 0 && sp <= 0 ) {
  1013. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1014. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1015. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1016. return 0;
  1017. }
  1018. //Opposing signs.
  1019. if ( hp ) {
  1020. if (hp > 0)
  1021. status_heal(&sd->bl, hp, 0, 0);
  1022. else {
  1023. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1024. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
  1025. }
  1026. }
  1027. if ( sp ) {
  1028. if (sp > 0)
  1029. status_heal(&sd->bl, 0, sp, 0);
  1030. else
  1031. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1032. }
  1033. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1034. return 0;
  1035. }
  1036. /*==========================================
  1037. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1038. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1039. *------------------------------------------*/
  1040. ACMD_FUNC(item)
  1041. {
  1042. char item_name[100];
  1043. int number = 0, bound = BOUND_NONE;
  1044. char flag = 0;
  1045. struct item item_tmp;
  1046. struct item_data *item_data[10];
  1047. int get_count, i, j=0;
  1048. char *itemlist;
  1049. nullpo_retr(-1, sd);
  1050. memset(item_name, '\0', sizeof(item_name));
  1051. parent_cmd = atcommand_checkalias(command+1);
  1052. if (!strcmpi(parent_cmd,"itembound")) {
  1053. if (!message || !*message || (
  1054. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1055. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1056. {
  1057. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1058. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1059. return -1;
  1060. }
  1061. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1062. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1063. return -1;
  1064. }
  1065. } else if (!message || !*message || (
  1066. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1067. sscanf(message, "%99s %11d", item_name, &number) < 1
  1068. )) {
  1069. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1070. return -1;
  1071. }
  1072. itemlist = strtok(item_name, ":");
  1073. while (itemlist != NULL && j<10) {
  1074. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1075. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1076. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1077. return -1;
  1078. }
  1079. itemlist = strtok(NULL, ":"); //next itemline
  1080. j++;
  1081. }
  1082. if (number <= 0)
  1083. number = 1;
  1084. get_count = number;
  1085. for(j--; j>=0; j--){ //produce items in list
  1086. unsigned short item_id = item_data[j]->nameid;
  1087. //Check if it's stackable.
  1088. if (!itemdb_isstackable2(item_data[j]))
  1089. get_count = 1;
  1090. for (i = 0; i < number; i += get_count) {
  1091. // if not pet egg
  1092. if (!pet_create_egg(sd, item_id)) {
  1093. memset(&item_tmp, 0, sizeof(item_tmp));
  1094. item_tmp.nameid = item_id;
  1095. item_tmp.identify = 1;
  1096. item_tmp.bound = bound;
  1097. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1098. clif_additem(sd, 0, 0, flag);
  1099. }
  1100. }
  1101. }
  1102. if (flag == 0)
  1103. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1104. return 0;
  1105. }
  1106. /*==========================================
  1107. *
  1108. *------------------------------------------*/
  1109. ACMD_FUNC(item2)
  1110. {
  1111. struct item item_tmp;
  1112. struct item_data *item_data;
  1113. char item_name[100];
  1114. unsigned short item_id;
  1115. int number = 0, bound = BOUND_NONE;
  1116. int identify = 0, refine = 0, attr = 0;
  1117. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1118. nullpo_retr(-1, sd);
  1119. memset(item_name, '\0', sizeof(item_name));
  1120. parent_cmd = atcommand_checkalias(command+1);
  1121. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1122. if (!message || !*message || (
  1123. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1124. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1125. {
  1126. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1127. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1128. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1129. return -1;
  1130. }
  1131. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1132. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1133. return -1;
  1134. }
  1135. } else if ( !message || !*message || (
  1136. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1137. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1138. )) {
  1139. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1140. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1141. return -1;
  1142. }
  1143. if (number <= 0)
  1144. number = 1;
  1145. item_id = 0;
  1146. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1147. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1148. item_id = item_data->nameid;
  1149. if (item_id > 500) {
  1150. int loop, get_count, i;
  1151. char flag = 0;
  1152. //Check if it's stackable.
  1153. if(!itemdb_isstackable2(item_data)){
  1154. loop = number;
  1155. get_count = 1;
  1156. }else{
  1157. loop = 1;
  1158. get_count = number;
  1159. }
  1160. if( itemdb_isequip2(item_data ) ){
  1161. refine = cap_value( refine, 0, MAX_REFINE );
  1162. }else{
  1163. // All other items cannot be refined and are always identified
  1164. identify = 1;
  1165. refine = attr = 0;
  1166. }
  1167. for (i = 0; i < loop; i++) {
  1168. // if not pet egg
  1169. if (!pet_create_egg(sd, item_id)) {
  1170. memset(&item_tmp, 0, sizeof(item_tmp));
  1171. item_tmp.nameid = item_id;
  1172. item_tmp.identify = identify;
  1173. item_tmp.refine = refine;
  1174. item_tmp.attribute = attr;
  1175. item_tmp.card[0] = c1;
  1176. item_tmp.card[1] = c2;
  1177. item_tmp.card[2] = c3;
  1178. item_tmp.card[3] = c4;
  1179. item_tmp.bound = bound;
  1180. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1181. clif_additem(sd, 0, 0, flag);
  1182. }
  1183. }
  1184. if (flag == 0)
  1185. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1186. } else {
  1187. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1188. return -1;
  1189. }
  1190. return 0;
  1191. }
  1192. /*==========================================
  1193. *
  1194. *------------------------------------------*/
  1195. ACMD_FUNC(itemreset)
  1196. {
  1197. int i;
  1198. nullpo_retr(-1, sd);
  1199. for (i = 0; i < MAX_INVENTORY; i++) {
  1200. if (sd->inventory.u.items_inventory[i].amount && sd->inventory.u.items_inventory[i].equip == 0) {
  1201. pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1202. }
  1203. }
  1204. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1205. return 0;
  1206. }
  1207. /*==========================================
  1208. * Atcommand @lvlup
  1209. *------------------------------------------*/
  1210. ACMD_FUNC(baselevelup)
  1211. {
  1212. int level=0, i=0, status_point=0;
  1213. nullpo_retr(-1, sd);
  1214. level = atoi(message);
  1215. if (!message || !*message || !level) {
  1216. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1217. return -1;
  1218. }
  1219. if (level > 0) {
  1220. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1221. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1222. return -1;
  1223. } // End Addition
  1224. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1225. level = pc_maxbaselv(sd) - sd->status.base_level;
  1226. for (i = 0; i < level; i++)
  1227. status_point += pc_gets_status_point(sd->status.base_level + i);
  1228. sd->status.status_point += status_point;
  1229. sd->status.base_level += (unsigned int)level;
  1230. status_calc_pc(sd, SCO_FORCE);
  1231. status_percent_heal(&sd->bl, 100, 100);
  1232. clif_misceffect(&sd->bl, 0);
  1233. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.base_level);
  1234. achievement_update_objective(sd, AG_GOAL_STATUS, 2, sd->status.base_level, sd->status.class_);
  1235. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1236. } else {
  1237. if (sd->status.base_level == 1) {
  1238. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1239. return -1;
  1240. }
  1241. level*=-1;
  1242. if ((unsigned int)level >= sd->status.base_level)
  1243. level = sd->status.base_level-1;
  1244. for (i = 0; i > -level; i--)
  1245. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1246. if (sd->status.status_point < status_point)
  1247. pc_resetstate(sd);
  1248. if (sd->status.status_point < status_point)
  1249. sd->status.status_point = 0;
  1250. else
  1251. sd->status.status_point -= status_point;
  1252. sd->status.base_level -= (unsigned int)level;
  1253. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1254. status_calc_pc(sd, SCO_FORCE);
  1255. level*=-1;
  1256. }
  1257. sd->status.base_exp = 0;
  1258. clif_updatestatus(sd, SP_STATUSPOINT);
  1259. clif_updatestatus(sd, SP_BASELEVEL);
  1260. clif_updatestatus(sd, SP_BASEEXP);
  1261. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1262. pc_baselevelchanged(sd);
  1263. if(sd->status.party_id)
  1264. party_send_levelup(sd);
  1265. if( level > 0 && battle_config.atcommand_levelup_events )
  1266. npc_script_event(sd,NPCE_BASELVUP);
  1267. return 0;
  1268. }
  1269. /*==========================================
  1270. *
  1271. *------------------------------------------*/
  1272. ACMD_FUNC(joblevelup)
  1273. {
  1274. int level=0;
  1275. nullpo_retr(-1, sd);
  1276. level = atoi(message);
  1277. if (!message || !*message || !level) {
  1278. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1279. return -1;
  1280. }
  1281. if (level > 0) {
  1282. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1283. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1284. return -1;
  1285. }
  1286. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1287. level = pc_maxjoblv(sd) - sd->status.job_level;
  1288. sd->status.job_level += (unsigned int)level;
  1289. sd->status.skill_point += level;
  1290. clif_misceffect(&sd->bl, 1);
  1291. achievement_update_objective(sd, AG_GOAL_LEVEL, 1, sd->status.job_level);
  1292. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1293. } else {
  1294. if (sd->status.job_level == 1) {
  1295. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1296. return -1;
  1297. }
  1298. level *=-1;
  1299. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1300. level = sd->status.job_level-1;
  1301. sd->status.job_level -= (unsigned int)level;
  1302. if (sd->status.skill_point < level)
  1303. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1304. if (sd->status.skill_point < level)
  1305. sd->status.skill_point = 0;
  1306. else
  1307. sd->status.skill_point -= level;
  1308. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1309. level *=-1;
  1310. }
  1311. sd->status.job_exp = 0;
  1312. clif_updatestatus(sd, SP_JOBLEVEL);
  1313. clif_updatestatus(sd, SP_JOBEXP);
  1314. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1315. clif_updatestatus(sd, SP_SKILLPOINT);
  1316. status_calc_pc(sd, SCO_FORCE);
  1317. if( level > 0 && battle_config.atcommand_levelup_events )
  1318. npc_script_event(sd,NPCE_JOBLVUP);
  1319. return 0;
  1320. }
  1321. /*==========================================
  1322. * @help
  1323. *------------------------------------------*/
  1324. ACMD_FUNC(help)
  1325. {
  1326. config_setting_t *help;
  1327. const char *text = NULL;
  1328. const char *command_name = NULL;
  1329. const char *default_command = "help";
  1330. nullpo_retr(-1, sd);
  1331. help = config_lookup(&atcommand_config, "help");
  1332. if (help == NULL) {
  1333. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1334. return -1;
  1335. }
  1336. if (!message || !*message) {
  1337. command_name = default_command; // If no command_name specified, display help for @help.
  1338. } else {
  1339. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1340. ++message;
  1341. command_name = atcommand_checkalias(message);
  1342. }
  1343. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1344. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1345. clif_displaymessage(fd, atcmd_output);
  1346. atcommand_get_suggestions(sd, command_name, true);
  1347. return -1;
  1348. }
  1349. if (!config_setting_lookup_string(help, command_name, &text)) {
  1350. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1351. clif_displaymessage(fd, atcmd_output);
  1352. atcommand_get_suggestions(sd, command_name, true);
  1353. return -1;
  1354. }
  1355. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1356. clif_displaymessage(fd, atcmd_output);
  1357. { // Display aliases
  1358. DBIterator* iter;
  1359. AtCommandInfo *command_info;
  1360. AliasInfo *alias_info = NULL;
  1361. StringBuf buf;
  1362. bool has_aliases = false;
  1363. StringBuf_Init(&buf);
  1364. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1365. command_info = get_atcommandinfo_byname(command_name);
  1366. iter = db_iterator(atcommand_alias_db);
  1367. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1368. if (alias_info->command == command_info) {
  1369. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1370. has_aliases = true;
  1371. }
  1372. }
  1373. dbi_destroy(iter);
  1374. if (has_aliases)
  1375. clif_displaymessage(fd, StringBuf_Value(&buf));
  1376. StringBuf_Destroy(&buf);
  1377. }
  1378. // Display help contents
  1379. clif_displaymessage(fd, text);
  1380. return 0;
  1381. }
  1382. // helper function, used in foreach calls to stop auto-attack timers
  1383. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1384. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1385. {
  1386. struct unit_data *ud = unit_bl2ud(bl);
  1387. int id = va_arg(ap, int);
  1388. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1389. {
  1390. unit_stop_attack(bl);
  1391. return 1;
  1392. }
  1393. return 0;
  1394. }
  1395. /*==========================================
  1396. *
  1397. *------------------------------------------*/
  1398. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1399. {
  1400. TBL_PC* sd = (TBL_PC*)bl;
  1401. clif_pvpset(sd, 0, 0, 2);
  1402. if (sd->pvp_timer != INVALID_TIMER) {
  1403. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1404. sd->pvp_timer = INVALID_TIMER;
  1405. }
  1406. return 0;
  1407. }
  1408. ACMD_FUNC(pvpoff)
  1409. {
  1410. nullpo_retr(-1, sd);
  1411. if (!map[sd->bl.m].flag.pvp) {
  1412. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1413. return -1;
  1414. }
  1415. map[sd->bl.m].flag.pvp = 0;
  1416. if (!battle_config.pk_mode){
  1417. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1418. }
  1419. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1420. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1421. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1422. return 0;
  1423. }
  1424. /*==========================================
  1425. *
  1426. *------------------------------------------*/
  1427. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1428. {
  1429. TBL_PC* sd = (TBL_PC*)bl;
  1430. if (sd->pvp_timer == INVALID_TIMER) {
  1431. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1432. sd->pvp_rank = 0;
  1433. sd->pvp_lastusers = 0;
  1434. sd->pvp_point = 5;
  1435. sd->pvp_won = 0;
  1436. sd->pvp_lost = 0;
  1437. }
  1438. return 0;
  1439. }
  1440. ACMD_FUNC(pvpon)
  1441. {
  1442. nullpo_retr(-1, sd);
  1443. if (map[sd->bl.m].flag.pvp) {
  1444. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1445. return -1;
  1446. }
  1447. map[sd->bl.m].flag.pvp = 1;
  1448. if (!battle_config.pk_mode) {// display pvp circle and rank
  1449. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1450. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1451. }
  1452. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1453. return 0;
  1454. }
  1455. /*==========================================
  1456. *
  1457. *------------------------------------------*/
  1458. ACMD_FUNC(gvgoff)
  1459. {
  1460. nullpo_retr(-1, sd);
  1461. if (!map[sd->bl.m].flag.gvg) {
  1462. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1463. return -1;
  1464. }
  1465. map[sd->bl.m].flag.gvg = 0;
  1466. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1467. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1468. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. *
  1473. *------------------------------------------*/
  1474. ACMD_FUNC(gvgon)
  1475. {
  1476. nullpo_retr(-1, sd);
  1477. if (map[sd->bl.m].flag.gvg) {
  1478. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1479. return -1;
  1480. }
  1481. map[sd->bl.m].flag.gvg = 1;
  1482. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1483. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1484. return 0;
  1485. }
  1486. /*==========================================
  1487. *
  1488. *------------------------------------------*/
  1489. ACMD_FUNC(model)
  1490. {
  1491. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1492. nullpo_retr(-1, sd);
  1493. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1494. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1495. 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>).
  1496. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1497. clif_displaymessage(fd, atcmd_output);
  1498. return -1;
  1499. }
  1500. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1501. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1502. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1503. pc_changelook(sd, LOOK_HAIR, hair_style);
  1504. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1505. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1506. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1507. } else {
  1508. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1509. return -1;
  1510. }
  1511. return 0;
  1512. }
  1513. /*==========================================
  1514. * @bodystyle [Rytech]
  1515. *------------------------------------------*/
  1516. ACMD_FUNC(bodystyle)
  1517. {
  1518. int body_style = 0;
  1519. nullpo_retr(-1, sd);
  1520. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1521. if (!(sd->class_&JOBL_THIRD)) {
  1522. clif_displaymessage(fd, msg_txt(sd,740)); // This job has no alternate body styles.
  1523. return -1;
  1524. }
  1525. if (!message || !*message || sscanf(message, "%d", &body_style) < 1) {
  1526. sprintf(atcmd_output, msg_txt(sd,739), MIN_BODY_STYLE, MAX_BODY_STYLE); // Please enter a body style (usage: @bodystyle <body ID: %d-%d>).
  1527. clif_displaymessage(fd, atcmd_output);
  1528. return -1;
  1529. }
  1530. if (body_style >= MIN_BODY_STYLE && body_style <= MAX_BODY_STYLE) {
  1531. pc_changelook(sd, LOOK_BODY2, body_style);
  1532. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1533. } else {
  1534. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1535. return -1;
  1536. }
  1537. return 0;
  1538. }
  1539. /*==========================================
  1540. * @dye && @ccolor
  1541. *------------------------------------------*/
  1542. ACMD_FUNC(dye)
  1543. {
  1544. int cloth_color = 0;
  1545. nullpo_retr(-1, sd);
  1546. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1547. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1548. 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>).
  1549. clif_displaymessage(fd, atcmd_output);
  1550. return -1;
  1551. }
  1552. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1553. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1554. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1555. } else {
  1556. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1557. return -1;
  1558. }
  1559. return 0;
  1560. }
  1561. /*==========================================
  1562. * @hairstyle && @hstyle
  1563. *------------------------------------------*/
  1564. ACMD_FUNC(hair_style)
  1565. {
  1566. int hair_style = 0;
  1567. nullpo_retr(-1, sd);
  1568. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1569. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1570. 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>).
  1571. clif_displaymessage(fd, atcmd_output);
  1572. return -1;
  1573. }
  1574. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1575. pc_changelook(sd, LOOK_HAIR, hair_style);
  1576. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1577. } else {
  1578. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1579. return -1;
  1580. }
  1581. return 0;
  1582. }
  1583. /*==========================================
  1584. * @haircolor && @hcolor
  1585. *------------------------------------------*/
  1586. ACMD_FUNC(hair_color)
  1587. {
  1588. int hair_color = 0;
  1589. nullpo_retr(-1, sd);
  1590. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1591. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1592. 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>).
  1593. clif_displaymessage(fd, atcmd_output);
  1594. return -1;
  1595. }
  1596. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1597. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1598. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1599. } else {
  1600. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1601. return -1;
  1602. }
  1603. return 0;
  1604. }
  1605. /*==========================================
  1606. * @go [city_number or city_name] - Updated by Harbin
  1607. *------------------------------------------*/
  1608. ACMD_FUNC(go)
  1609. {
  1610. int i;
  1611. int town;
  1612. char map_name[MAP_NAME_LENGTH];
  1613. const struct {
  1614. char map[MAP_NAME_LENGTH];
  1615. int x, y;
  1616. } data[] = {
  1617. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1618. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1619. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1620. { MAP_PAYON, 162, 233 }, // 3=Payon
  1621. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1622. #ifdef RENEWAL
  1623. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1624. #else
  1625. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1626. #endif
  1627. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1628. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1629. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1630. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1631. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1632. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1633. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1634. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1635. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1636. #ifdef RENEWAL
  1637. { MAP_NOVICE, 18, 26 }, // 15=Training Grounds (Renewal)
  1638. #else
  1639. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1640. #endif
  1641. { MAP_JAIL, 23, 61 }, // 16=Prison
  1642. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1643. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1644. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1645. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1646. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1647. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1648. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1649. { MAP_VEINS, 216, 123 }, // 24=Veins
  1650. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1651. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1652. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1653. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1654. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1655. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1656. { MAP_MORA, 44, 151 }, // 31=Mora
  1657. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1658. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1659. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1660. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1661. { MAP_LASAGNA, 193, 182 }, // 36=Lasagna
  1662. };
  1663. nullpo_retr(-1, sd);
  1664. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1665. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1666. return 0;
  1667. }
  1668. memset(map_name, '\0', sizeof(map_name));
  1669. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1670. // get the number
  1671. town = atoi(message);
  1672. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1673. {// no value matched so send the list of locations
  1674. const char* text;
  1675. // attempt to find the text help string
  1676. text = atcommand_help_string( command );
  1677. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1678. if( text )
  1679. {// send the text to the client
  1680. clif_displaymessage( fd, text );
  1681. }
  1682. return -1;
  1683. }
  1684. // get possible name of the city
  1685. map_name[MAP_NAME_LENGTH-1] = '\0';
  1686. for (i = 0; map_name[i]; i++)
  1687. map_name[i] = TOLOWER(map_name[i]);
  1688. // try to identify the map name
  1689. if (strncmp(map_name, "prontera", 3) == 0) {
  1690. town = 0;
  1691. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1692. strncmp(map_name, "morroc", 4) == 0) {
  1693. town = 1;
  1694. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1695. town = 2;
  1696. } else if (strncmp(map_name, "payon", 3) == 0) {
  1697. town = 3;
  1698. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1699. town = 4;
  1700. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1701. town = 5;
  1702. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1703. town = 6;
  1704. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1705. strcmp(map_name, "christmas") == 0 ||
  1706. strncmp(map_name, "xmas", 3) == 0 ||
  1707. strncmp(map_name, "x-mas", 3) == 0) {
  1708. town = 7;
  1709. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1710. town = 8;
  1711. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1712. strncmp(map_name, "yuno", 3) == 0) {
  1713. town = 9;
  1714. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1715. town = 10;
  1716. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1717. strncmp(map_name, "gonryun", 3) == 0) {
  1718. town = 11;
  1719. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1720. town = 12;
  1721. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1722. town = 13;
  1723. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1724. town = 14;
  1725. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1726. strncmp(map_name, "startpoint", 3) == 0 ||
  1727. strncmp(map_name, "beginning", 3) == 0) {
  1728. town = 15;
  1729. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1730. strncmp(map_name, "prison", 3) == 0 ||
  1731. strncmp(map_name, "jail", 3) == 0) {
  1732. town = 16;
  1733. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1734. town = 17;
  1735. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1736. town = 18;
  1737. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1738. town = 19;
  1739. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1740. town = 20;
  1741. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1742. town = 21;
  1743. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1744. town = 22;
  1745. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1746. town = 23;
  1747. } else if (strncmp(map_name, "veins", 3) == 0) {
  1748. town = 24;
  1749. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1750. town = 25;
  1751. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1752. town = 26;
  1753. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1754. town = 27;
  1755. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1756. town = 28;
  1757. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1758. town = 29;
  1759. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1760. town = 30;
  1761. } else if (strcmp(map_name, "mora") == 0) {
  1762. town = 31;
  1763. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1764. town = 32;
  1765. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1766. town = 33;
  1767. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1768. town = 34;
  1769. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1770. town = 35;
  1771. } else if (strncmp(map_name, "lasagna", 2) == 0) {
  1772. town = 36;
  1773. }
  1774. if (town >= 0 && town < ARRAYLENGTH(data))
  1775. {
  1776. int16 m = map_mapname2mapid(data[town].map);
  1777. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1778. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  1779. return -1;
  1780. }
  1781. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1782. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  1783. return -1;
  1784. }
  1785. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == SETPOS_OK) {
  1786. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1787. } else {
  1788. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1789. return -1;
  1790. }
  1791. } else { // if you arrive here, you have an error in town variable when reading of names
  1792. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1793. return -1;
  1794. }
  1795. return 0;
  1796. }
  1797. /*==========================================
  1798. *
  1799. *------------------------------------------*/
  1800. ACMD_FUNC(monster)
  1801. {
  1802. char name[NAME_LENGTH];
  1803. char monster[NAME_LENGTH];
  1804. char eventname[EVENT_NAME_LENGTH] = "";
  1805. int mob_id;
  1806. int number = 0;
  1807. int count;
  1808. int i, range;
  1809. short mx, my;
  1810. unsigned int size;
  1811. nullpo_retr(-1, sd);
  1812. memset(name, '\0', sizeof(name));
  1813. memset(monster, '\0', sizeof(monster));
  1814. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1815. if (!message || !*message) {
  1816. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1817. return -1;
  1818. }
  1819. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1820. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1821. //All data can be left as it is.
  1822. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1823. //Here, it is possible name was not given and we are using monster for it.
  1824. if (count < 3) //Blank mob's name.
  1825. name[0] = '\0';
  1826. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1827. //All data can be left as it is.
  1828. } else if (sscanf(message, "%23s", monster) > 0) {
  1829. //As before, name may be already filled.
  1830. name[0] = '\0';
  1831. } else {
  1832. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1833. return -1;
  1834. }
  1835. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1836. mob_id = mobdb_checkid(atoi(monster));
  1837. if (mob_id == 0) {
  1838. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1839. return -1;
  1840. }
  1841. if (mob_id == MOBID_EMPERIUM) {
  1842. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1843. return -1;
  1844. }
  1845. if (number <= 0)
  1846. number = 1;
  1847. if( !name[0] )
  1848. strcpy(name, "--ja--");
  1849. // 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
  1850. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1851. number = battle_config.atc_spawn_quantity_limit;
  1852. parent_cmd = atcommand_checkalias(command+1);
  1853. if (strcmp(parent_cmd, "monstersmall") == 0)
  1854. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1855. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1856. size = SZ_BIG;
  1857. else
  1858. size = SZ_SMALL;
  1859. if (battle_config.etc_log)
  1860. 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);
  1861. count = 0;
  1862. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1863. for (i = 0; i < number; i++) {
  1864. int k;
  1865. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1866. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1867. if(k) {
  1868. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1869. count ++;
  1870. }
  1871. }
  1872. if (count != 0)
  1873. if (number == count)
  1874. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1875. else {
  1876. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1877. clif_displaymessage(fd, atcmd_output);
  1878. }
  1879. else {
  1880. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1881. return -1;
  1882. }
  1883. return 0;
  1884. }
  1885. /*==========================================
  1886. *
  1887. *------------------------------------------*/
  1888. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1889. {
  1890. struct mob_data *md;
  1891. int flag;
  1892. nullpo_ret(md=(struct mob_data *)bl);
  1893. flag = va_arg(ap, int);
  1894. if (md->guardian_data)
  1895. return 0; //Do not touch WoE mobs!
  1896. if (flag)
  1897. status_zap(bl,md->status.hp, 0);
  1898. else
  1899. status_kill(bl);
  1900. return 1;
  1901. }
  1902. ACMD_FUNC(killmonster)
  1903. {
  1904. int map_id, drop_flag;
  1905. char map_name[MAP_NAME_LENGTH_EXT];
  1906. nullpo_retr(-1, sd);
  1907. memset(map_name, '\0', sizeof(map_name));
  1908. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1909. map_id = sd->bl.m;
  1910. else {
  1911. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1912. map_id = sd->bl.m;
  1913. }
  1914. parent_cmd = atcommand_checkalias(command+1);
  1915. drop_flag = strcmp(parent_cmd, "killmonster2");
  1916. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1917. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1918. return 0;
  1919. }
  1920. /*==========================================
  1921. *
  1922. *------------------------------------------*/
  1923. ACMD_FUNC(refine)
  1924. {
  1925. int j, position = 0, refine = 0, current_position, final_refine;
  1926. int count;
  1927. nullpo_retr(-1, sd);
  1928. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1929. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1930. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1931. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1932. clif_displaymessage(fd, atcmd_output);
  1933. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1934. clif_displaymessage(fd, atcmd_output);
  1935. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1936. clif_displaymessage(fd, atcmd_output);
  1937. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1938. clif_displaymessage(fd, atcmd_output);
  1939. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1940. clif_displaymessage(fd, atcmd_output);
  1941. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1942. clif_displaymessage(fd, atcmd_output);
  1943. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1944. clif_displaymessage(fd, atcmd_output);
  1945. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1946. clif_displaymessage(fd, atcmd_output);
  1947. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1948. clif_displaymessage(fd, atcmd_output);
  1949. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1950. clif_displaymessage(fd, atcmd_output);
  1951. return -1;
  1952. }
  1953. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1954. count = 0;
  1955. for (j = 0; j < EQI_MAX; j++) {
  1956. int i;
  1957. if ((i = sd->equip_index[j]) < 0)
  1958. continue;
  1959. if(j == EQI_AMMO)
  1960. continue;
  1961. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1962. continue;
  1963. if(position && !(sd->inventory.u.items_inventory[i].equip & position))
  1964. continue;
  1965. final_refine = cap_value(sd->inventory.u.items_inventory[i].refine + refine, 0, MAX_REFINE);
  1966. if (sd->inventory.u.items_inventory[i].refine != final_refine) {
  1967. sd->inventory.u.items_inventory[i].refine = final_refine;
  1968. current_position = sd->inventory.u.items_inventory[i].equip;
  1969. pc_unequipitem(sd, i, 3);
  1970. clif_refine(fd, 0, i, sd->inventory.u.items_inventory[i].refine);
  1971. clif_delitem(sd, i, 1, 3);
  1972. clif_additem(sd, i, 1, 0);
  1973. pc_equipitem(sd, i, current_position);
  1974. clif_misceffect(&sd->bl, 3);
  1975. achievement_update_objective(sd, AG_REFINE_SUCCESS, 2, sd->inventory_data[i]->wlv, sd->inventory.u.items_inventory[i].refine);
  1976. count++;
  1977. }
  1978. }
  1979. if (count == 0)
  1980. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1981. else if (count == 1)
  1982. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1983. else {
  1984. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1985. clif_displaymessage(fd, atcmd_output);
  1986. }
  1987. return 0;
  1988. }
  1989. /*==========================================
  1990. *
  1991. *------------------------------------------*/
  1992. ACMD_FUNC(produce)
  1993. {
  1994. char item_name[100];
  1995. unsigned short item_id;
  1996. int attribute = 0, star = 0;
  1997. struct item_data *item_data;
  1998. struct item tmp_item;
  1999. nullpo_retr(-1, sd);
  2000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2001. memset(item_name, '\0', sizeof(item_name));
  2002. if (!message || !*message || (
  2003. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  2004. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  2005. )) {
  2006. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  2007. return -1;
  2008. }
  2009. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  2010. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  2011. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  2012. return -1;
  2013. }
  2014. item_id = item_data->nameid;
  2015. if (itemdb_isequip2(item_data)) {
  2016. char flag = 0;
  2017. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  2018. attribute = ATTRIBUTE_NORMAL;
  2019. if (star < MIN_STAR || star > MAX_STAR)
  2020. star = 0;
  2021. memset(&tmp_item, 0, sizeof tmp_item);
  2022. tmp_item.nameid = item_id;
  2023. tmp_item.amount = 1;
  2024. tmp_item.identify = 1;
  2025. tmp_item.card[0] = CARD0_FORGE;
  2026. tmp_item.card[1] = item_data->type==IT_WEAPON?
  2027. ((star*5) << 8) + attribute:0;
  2028. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  2029. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  2030. clif_produceeffect(sd, 0, item_id);
  2031. clif_misceffect(&sd->bl, 3);
  2032. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  2033. clif_additem(sd, 0, 0, flag);
  2034. } else {
  2035. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  2036. clif_displaymessage(fd, atcmd_output);
  2037. return -1;
  2038. }
  2039. return 0;
  2040. }
  2041. /*==========================================
  2042. *
  2043. *------------------------------------------*/
  2044. ACMD_FUNC(memo)
  2045. {
  2046. int position = 0;
  2047. nullpo_retr(-1, sd);
  2048. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2049. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2050. {
  2051. int i;
  2052. clif_displaymessage(sd->fd, msg_txt(sd,668)); // Your actual memo positions are:
  2053. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2054. {
  2055. if( sd->status.memo_point[i].map )
  2056. 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);
  2057. else
  2058. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2059. clif_displaymessage(sd->fd, atcmd_output);
  2060. }
  2061. return 0;
  2062. }
  2063. if( position < 0 || position >= MAX_MEMOPOINTS )
  2064. {
  2065. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2066. clif_displaymessage(fd, atcmd_output);
  2067. return -1;
  2068. }
  2069. return !pc_memo( sd, position );
  2070. }
  2071. /*==========================================
  2072. *
  2073. *------------------------------------------*/
  2074. ACMD_FUNC(gat)
  2075. {
  2076. int y;
  2077. nullpo_retr(-1, sd);
  2078. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2079. for (y = 2; y >= -2; y--) {
  2080. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2081. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2082. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2083. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2084. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2085. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2086. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2087. clif_displaymessage(fd, atcmd_output);
  2088. }
  2089. return 0;
  2090. }
  2091. /*==========================================
  2092. *
  2093. *------------------------------------------*/
  2094. ACMD_FUNC(displaystatus)
  2095. {
  2096. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2097. nullpo_retr(-1, sd);
  2098. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2099. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2100. return -1;
  2101. }
  2102. if (i < 2) flag = 1;
  2103. if (i < 3) tick = 0;
  2104. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2105. return 0;
  2106. }
  2107. /*==========================================
  2108. * @stpoint (Rewritten by [Yor])
  2109. *------------------------------------------*/
  2110. ACMD_FUNC(statuspoint)
  2111. {
  2112. int point;
  2113. unsigned int new_status_point;
  2114. if (!message || !*message || (point = atoi(message)) == 0) {
  2115. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2116. return -1;
  2117. }
  2118. if(point < 0)
  2119. {
  2120. if(sd->status.status_point < (unsigned int)(-point))
  2121. {
  2122. new_status_point = 0;
  2123. }
  2124. else
  2125. {
  2126. new_status_point = sd->status.status_point + point;
  2127. }
  2128. }
  2129. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2130. {
  2131. new_status_point = UINT_MAX;
  2132. }
  2133. else
  2134. {
  2135. new_status_point = sd->status.status_point + point;
  2136. }
  2137. if (new_status_point != sd->status.status_point) {
  2138. sd->status.status_point = new_status_point;
  2139. clif_updatestatus(sd, SP_STATUSPOINT);
  2140. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2141. } else {
  2142. if (point < 0)
  2143. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2144. else
  2145. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2146. return -1;
  2147. }
  2148. return 0;
  2149. }
  2150. /*==========================================
  2151. * @skpoint (Rewritten by [Yor])
  2152. *------------------------------------------*/
  2153. ACMD_FUNC(skillpoint)
  2154. {
  2155. int point;
  2156. unsigned int new_skill_point;
  2157. nullpo_retr(-1, sd);
  2158. if (!message || !*message || (point = atoi(message)) == 0) {
  2159. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2160. return -1;
  2161. }
  2162. if(point < 0)
  2163. {
  2164. if(sd->status.skill_point < (unsigned int)(-point))
  2165. {
  2166. new_skill_point = 0;
  2167. }
  2168. else
  2169. {
  2170. new_skill_point = sd->status.skill_point + point;
  2171. }
  2172. }
  2173. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2174. {
  2175. new_skill_point = UINT_MAX;
  2176. }
  2177. else
  2178. {
  2179. new_skill_point = sd->status.skill_point + point;
  2180. }
  2181. if (new_skill_point != sd->status.skill_point) {
  2182. sd->status.skill_point = new_skill_point;
  2183. clif_updatestatus(sd, SP_SKILLPOINT);
  2184. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2185. } else {
  2186. if (point < 0)
  2187. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2188. else
  2189. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2190. return -1;
  2191. }
  2192. return 0;
  2193. }
  2194. /*==========================================
  2195. * @zeny
  2196. *------------------------------------------*/
  2197. ACMD_FUNC(zeny)
  2198. {
  2199. int zeny=0, ret=-1;
  2200. nullpo_retr(-1, sd);
  2201. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2202. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2203. return -1;
  2204. }
  2205. if(zeny > 0){
  2206. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2207. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2208. }
  2209. else {
  2210. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2211. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2212. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2213. }
  2214. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2215. return 0;
  2216. }
  2217. /*==========================================
  2218. *
  2219. *------------------------------------------*/
  2220. ACMD_FUNC(param)
  2221. {
  2222. uint8 i;
  2223. int value = 0;
  2224. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2225. unsigned short new_value, *status[6], max_status[6];
  2226. //we don't use direct initialization because it isn't part of the c standard.
  2227. nullpo_retr(-1, sd);
  2228. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2229. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2230. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2231. return -1;
  2232. }
  2233. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2234. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2235. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2236. return -1;
  2237. }
  2238. status[0] = &sd->status.str;
  2239. status[1] = &sd->status.agi;
  2240. status[2] = &sd->status.vit;
  2241. status[3] = &sd->status.int_;
  2242. status[4] = &sd->status.dex;
  2243. status[5] = &sd->status.luk;
  2244. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2245. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2246. else {
  2247. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2248. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2249. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2250. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2251. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2252. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2253. }
  2254. if(value > 0 && *status[i] + value >= max_status[i])
  2255. new_value = max_status[i];
  2256. else if(value < 0 && *status[i] <= -value)
  2257. new_value = 1;
  2258. else
  2259. new_value = *status[i] + value;
  2260. if (new_value != *status[i]) {
  2261. *status[i] = new_value;
  2262. clif_updatestatus(sd, SP_STR + i);
  2263. clif_updatestatus(sd, SP_USTR + i);
  2264. status_calc_pc(sd, SCO_FORCE);
  2265. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2266. } else {
  2267. if (value < 0)
  2268. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2269. else
  2270. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2271. return -1;
  2272. }
  2273. return 0;
  2274. }
  2275. /*==========================================
  2276. * Stat all by fritz (rewritten by [Yor])
  2277. *------------------------------------------*/
  2278. ACMD_FUNC(stat_all)
  2279. {
  2280. int value = 0;
  2281. uint8 count, i;
  2282. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2283. //we don't use direct initialization because it isn't part of the c standard.
  2284. nullpo_retr(-1, sd);
  2285. status[0] = &sd->status.str;
  2286. status[1] = &sd->status.agi;
  2287. status[2] = &sd->status.vit;
  2288. status[3] = &sd->status.int_;
  2289. status[4] = &sd->status.dex;
  2290. status[5] = &sd->status.luk;
  2291. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2292. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2293. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2294. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2295. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2296. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2297. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2298. value = SHRT_MAX;
  2299. } else {
  2300. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2301. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2302. else {
  2303. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2304. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2305. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2306. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2307. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2308. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2309. }
  2310. }
  2311. count = 0;
  2312. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2313. short new_value;
  2314. if (value > 0 && *status[i] + value >= max_status[i])
  2315. new_value = max_status[i];
  2316. else if (value < 0 && *status[i] <= -value)
  2317. new_value = 1;
  2318. else
  2319. new_value = *status[i] + value;
  2320. if (new_value != *status[i]) {
  2321. *status[i] = new_value;
  2322. clif_updatestatus(sd, SP_STR + i);
  2323. clif_updatestatus(sd, SP_USTR + i);
  2324. count++;
  2325. }
  2326. }
  2327. if (count > 0) { // if at least 1 stat modified
  2328. status_calc_pc(sd, SCO_FORCE);
  2329. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2330. } else {
  2331. if (value < 0)
  2332. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2333. else
  2334. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2335. return -1;
  2336. }
  2337. return 0;
  2338. }
  2339. /*==========================================
  2340. *
  2341. *------------------------------------------*/
  2342. ACMD_FUNC(guildlevelup) {
  2343. int level = 0;
  2344. short added_level;
  2345. struct guild *guild_info;
  2346. nullpo_retr(-1, sd);
  2347. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2348. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2349. return -1;
  2350. }
  2351. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2352. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2353. return -1;
  2354. }
  2355. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2356. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2357. // return -1;
  2358. //}
  2359. added_level = (short)level;
  2360. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2361. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2362. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2363. added_level = 1 - guild_info->guild_lv;
  2364. if (added_level != 0) {
  2365. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2366. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2367. } else {
  2368. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2369. return -1;
  2370. }
  2371. return 0;
  2372. }
  2373. /*==========================================
  2374. *
  2375. *------------------------------------------*/
  2376. ACMD_FUNC(makeegg) {
  2377. struct item_data *item_data;
  2378. int id, pet_id;
  2379. nullpo_retr(-1, sd);
  2380. if (!message || !*message) {
  2381. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2382. return -1;
  2383. }
  2384. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2385. id = item_data->nameid;
  2386. else
  2387. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2388. ;
  2389. else
  2390. id = atoi(message);
  2391. pet_id = search_petDB_index(id, PET_CLASS);
  2392. if (pet_id < 0)
  2393. pet_id = search_petDB_index(id, PET_EGG);
  2394. if (pet_id >= 0) {
  2395. sd->catch_target_class = pet_db[pet_id].class_;
  2396. intif_create_pet(sd->status.account_id, sd->status.char_id, pet_db[pet_id].class_, mob_db(pet_db[pet_id].class_)->lv, pet_db[pet_id].EggID, 0, pet_db[pet_id].intimate, 100, 0, 1, pet_db[pet_id].jname);
  2397. } else {
  2398. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2399. return -1;
  2400. }
  2401. return 0;
  2402. }
  2403. /*==========================================
  2404. *
  2405. *------------------------------------------*/
  2406. ACMD_FUNC(hatch) {
  2407. nullpo_retr(-1, sd);
  2408. if (sd->status.pet_id <= 0)
  2409. clif_sendegg(sd);
  2410. else {
  2411. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2412. return -1;
  2413. }
  2414. return 0;
  2415. }
  2416. /*==========================================
  2417. *
  2418. *------------------------------------------*/
  2419. ACMD_FUNC(petfriendly) {
  2420. int friendly;
  2421. struct pet_data *pd;
  2422. nullpo_retr(-1, sd);
  2423. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2424. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2425. return -1;
  2426. }
  2427. pd = sd->pd;
  2428. if (!pd) {
  2429. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2430. return -1;
  2431. }
  2432. if (friendly < 0 || friendly > 1000)
  2433. {
  2434. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2435. return -1;
  2436. }
  2437. if (friendly == pd->pet.intimate) {
  2438. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2439. return -1;
  2440. }
  2441. pet_set_intimate(pd, friendly);
  2442. clif_send_petstatus(sd);
  2443. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2444. return 0;
  2445. }
  2446. /*==========================================
  2447. *
  2448. *------------------------------------------*/
  2449. ACMD_FUNC(pethungry)
  2450. {
  2451. int hungry;
  2452. struct pet_data *pd;
  2453. nullpo_retr(-1, sd);
  2454. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2455. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2456. return -1;
  2457. }
  2458. pd = sd->pd;
  2459. if (!sd->status.pet_id || !pd) {
  2460. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2461. return -1;
  2462. }
  2463. if (hungry < 0 || hungry > 100) {
  2464. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2465. return -1;
  2466. }
  2467. if (hungry == pd->pet.hungry) {
  2468. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2469. return -1;
  2470. }
  2471. pd->pet.hungry = hungry;
  2472. clif_send_petstatus(sd);
  2473. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2474. return 0;
  2475. }
  2476. /*==========================================
  2477. *
  2478. *------------------------------------------*/
  2479. ACMD_FUNC(petrename)
  2480. {
  2481. struct pet_data *pd;
  2482. nullpo_retr(-1, sd);
  2483. if (!sd->status.pet_id || !sd->pd) {
  2484. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2485. return -1;
  2486. }
  2487. pd = sd->pd;
  2488. if (!pd->pet.rename_flag) {
  2489. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2490. return -1;
  2491. }
  2492. pd->pet.rename_flag = 0;
  2493. intif_save_petdata(sd->status.account_id, &pd->pet);
  2494. clif_send_petstatus(sd);
  2495. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2496. return 0;
  2497. }
  2498. /*==========================================
  2499. *
  2500. *------------------------------------------*/
  2501. ACMD_FUNC(recall) {
  2502. struct map_session_data *pl_sd = NULL;
  2503. nullpo_retr(-1, sd);
  2504. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2505. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2506. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2507. return -1;
  2508. }
  2509. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2510. {
  2511. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2512. return -1;
  2513. }
  2514. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2515. {
  2516. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2517. return -1;
  2518. }
  2519. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2520. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2521. return -1;
  2522. }
  2523. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2524. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2525. return -1;
  2526. }
  2527. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2528. return -1;
  2529. }
  2530. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  2531. clif_displaymessage(fd, msg_txt(sd,1025)); // The player is currently autotrading and cannot be recalled.
  2532. return -1;
  2533. }
  2534. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2535. clif_displaymessage(fd, atcmd_output);
  2536. return 0;
  2537. }
  2538. /*==========================================
  2539. * charblock command (usage: charblock <player_name>)
  2540. * This command do a definitiv ban on a player
  2541. *------------------------------------------*/
  2542. ACMD_FUNC(char_block)
  2543. {
  2544. nullpo_retr(-1, sd);
  2545. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2546. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2547. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2548. clif_displaymessage(fd, atcmd_output);
  2549. return -1;
  2550. }
  2551. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2552. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2553. clif_displaymessage(fd, atcmd_output);
  2554. return 0;
  2555. }
  2556. /*==========================================
  2557. * accountban command (usage: ban <%time> <player_name>)
  2558. * charban command (usage: charban <%time> <player_name>)
  2559. * %time see common/timer.c::solve_time()
  2560. *------------------------------------------*/
  2561. ACMD_FUNC(char_ban)
  2562. {
  2563. char *modif_p, output[CHAT_SIZE_MAX];
  2564. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2565. enum chrif_req_op bantype;
  2566. nullpo_retr(-1, sd);
  2567. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2568. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2569. parent_cmd = atcommand_checkalias(command+1);
  2570. if (strcmpi(parent_cmd,"charban") == 0)
  2571. bantype = CHRIF_OP_BAN;
  2572. else if (strcmpi(parent_cmd,"ban") == 0)
  2573. bantype = CHRIF_OP_LOGIN_BAN;
  2574. else
  2575. return -1;
  2576. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2577. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2578. clif_displaymessage(fd, output);
  2579. return -1;
  2580. }
  2581. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2582. modif_p = atcmd_output;
  2583. timediff = (int32)solve_time(modif_p); //discard seconds
  2584. if (timediff == 0) { //allow negative ?
  2585. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2586. clif_displaymessage(fd, output);
  2587. 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.
  2588. return -1;
  2589. }
  2590. if( timediff < 0 && (
  2591. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2592. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2593. ))
  2594. {
  2595. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2596. return -1;
  2597. }
  2598. if (bantype == CHRIF_OP_BAN)
  2599. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2600. else
  2601. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2602. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2603. clif_displaymessage(fd, output);
  2604. return 0;
  2605. }
  2606. /*==========================================
  2607. * charunblock command (usage: charunblock <player_name>)
  2608. *------------------------------------------*/
  2609. ACMD_FUNC(char_unblock)
  2610. {
  2611. nullpo_retr(-1, sd);
  2612. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2613. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2614. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2615. clif_displaymessage(fd, atcmd_output);
  2616. return -1;
  2617. }
  2618. // send answer to login server via char-server
  2619. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2620. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2621. clif_displaymessage(fd, atcmd_output);
  2622. return 0;
  2623. }
  2624. /*==========================================
  2625. * acc unban command (usage: unban <player_name>)
  2626. * char unban command (usage: charunban <player_name>)
  2627. *------------------------------------------*/
  2628. ACMD_FUNC(char_unban){
  2629. enum chrif_req_op unbantype;
  2630. nullpo_retr(-1, sd);
  2631. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2632. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2633. parent_cmd = atcommand_checkalias(command+1);
  2634. if (strcmpi(parent_cmd,"charunban") == 0)
  2635. unbantype = CHRIF_OP_UNBAN;
  2636. else if (strcmpi(parent_cmd,"unban") == 0)
  2637. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2638. else
  2639. return -1;
  2640. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2641. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2642. clif_displaymessage(fd, atcmd_output);
  2643. return -1;
  2644. }
  2645. if (unbantype == CHRIF_OP_UNBAN)
  2646. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2647. else
  2648. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2649. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2650. clif_displaymessage(fd, atcmd_output);
  2651. return 0;
  2652. }
  2653. /*==========================================
  2654. *
  2655. *------------------------------------------*/
  2656. ACMD_FUNC(night)
  2657. {
  2658. nullpo_retr(-1, sd);
  2659. if (night_flag != 1) {
  2660. map_night_timer(night_timer_tid, 0, 0, 1);
  2661. } else {
  2662. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2663. return -1;
  2664. }
  2665. return 0;
  2666. }
  2667. /*==========================================
  2668. *
  2669. *------------------------------------------*/
  2670. ACMD_FUNC(day)
  2671. {
  2672. nullpo_retr(-1, sd);
  2673. if (night_flag != 0) {
  2674. map_day_timer(day_timer_tid, 0, 0, 1);
  2675. } else {
  2676. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2677. return -1;
  2678. }
  2679. return 0;
  2680. }
  2681. /*==========================================
  2682. *
  2683. *------------------------------------------*/
  2684. ACMD_FUNC(doom)
  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 && 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. ACMD_FUNC(doommap)
  2707. {
  2708. struct map_session_data* pl_sd;
  2709. struct s_mapiterator* iter;
  2710. nullpo_retr(-1, sd);
  2711. iter = mapit_getallusers();
  2712. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2713. {
  2714. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2715. {
  2716. status_kill(&pl_sd->bl);
  2717. clif_specialeffect(&pl_sd->bl,EF_GRANDCROSS2,AREA);
  2718. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2719. }
  2720. }
  2721. mapit_free(iter);
  2722. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2723. return 0;
  2724. }
  2725. /*==========================================
  2726. *
  2727. *------------------------------------------*/
  2728. static void atcommand_raise_sub(struct map_session_data* sd) {
  2729. status_revive(&sd->bl, 100, 100);
  2730. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2731. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2732. }
  2733. /*==========================================
  2734. *
  2735. *------------------------------------------*/
  2736. ACMD_FUNC(raise)
  2737. {
  2738. struct map_session_data* pl_sd;
  2739. struct s_mapiterator* iter;
  2740. nullpo_retr(-1, sd);
  2741. iter = mapit_getallusers();
  2742. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2743. if( pc_isdead(pl_sd) )
  2744. atcommand_raise_sub(pl_sd);
  2745. mapit_free(iter);
  2746. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2747. return 0;
  2748. }
  2749. /*==========================================
  2750. *
  2751. *------------------------------------------*/
  2752. ACMD_FUNC(raisemap)
  2753. {
  2754. struct map_session_data* pl_sd;
  2755. struct s_mapiterator* iter;
  2756. nullpo_retr(-1, sd);
  2757. iter = mapit_getallusers();
  2758. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2759. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2760. atcommand_raise_sub(pl_sd);
  2761. mapit_free(iter);
  2762. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2763. return 0;
  2764. }
  2765. /*==========================================
  2766. *
  2767. *------------------------------------------*/
  2768. ACMD_FUNC(kick)
  2769. {
  2770. struct map_session_data *pl_sd;
  2771. nullpo_retr(-1, sd);
  2772. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2773. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2774. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2775. return -1;
  2776. }
  2777. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
  2778. {
  2779. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2780. return -1;
  2781. }
  2782. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2783. {
  2784. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2785. return -1;
  2786. }
  2787. clif_GM_kick(sd, pl_sd);
  2788. return 0;
  2789. }
  2790. /*==========================================
  2791. *
  2792. *------------------------------------------*/
  2793. ACMD_FUNC(kickall)
  2794. {
  2795. struct map_session_data* pl_sd;
  2796. struct s_mapiterator* iter;
  2797. nullpo_retr(-1, sd);
  2798. iter = mapit_getallusers();
  2799. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2800. {
  2801. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2802. if (sd->status.account_id != pl_sd->status.account_id)
  2803. clif_GM_kick(NULL, pl_sd);
  2804. }
  2805. }
  2806. mapit_free(iter);
  2807. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2808. return 0;
  2809. }
  2810. /*==========================================
  2811. *
  2812. *------------------------------------------*/
  2813. ACMD_FUNC(allskill)
  2814. {
  2815. nullpo_retr(-1, sd);
  2816. pc_allskillup(sd); // all skills
  2817. sd->status.skill_point = 0; // 0 skill points
  2818. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2819. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2820. return 0;
  2821. }
  2822. /*==========================================
  2823. *
  2824. *------------------------------------------*/
  2825. ACMD_FUNC(questskill)
  2826. {
  2827. uint16 skill_id;
  2828. nullpo_retr(-1, sd);
  2829. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2830. {// also send a list of skills applicable to this command
  2831. const char* text;
  2832. // attempt to find the text corresponding to this command
  2833. text = atcommand_help_string( command );
  2834. // send the error message as always
  2835. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2836. if( text )
  2837. {// send the skill ID list associated with this command
  2838. clif_displaymessage( fd, text );
  2839. }
  2840. return -1;
  2841. }
  2842. if (skill_id >= MAX_SKILL_ID) {
  2843. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2844. return -1;
  2845. }
  2846. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2847. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2848. return -1;
  2849. }
  2850. if (pc_checkskill(sd, skill_id) > 0) {
  2851. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2852. return -1;
  2853. }
  2854. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2855. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2856. return 0;
  2857. }
  2858. /*==========================================
  2859. *
  2860. *------------------------------------------*/
  2861. ACMD_FUNC(lostskill)
  2862. {
  2863. uint16 skill_id = 0, sk_idx = 0;
  2864. nullpo_retr(-1, sd);
  2865. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2866. {// also send a list of skills applicable to this command
  2867. const char* text;
  2868. // attempt to find the text corresponding to this command
  2869. text = atcommand_help_string( command );
  2870. // send the error message as always
  2871. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2872. if( text )
  2873. {// send the skill ID list associated with this command
  2874. clif_displaymessage( fd, text );
  2875. }
  2876. return -1;
  2877. }
  2878. if (!(sk_idx = skill_get_index(skill_id))) {
  2879. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2880. return -1;
  2881. }
  2882. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2883. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2884. return -1;
  2885. }
  2886. if (pc_checkskill(sd, skill_id) == 0) {
  2887. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2888. return -1;
  2889. }
  2890. sd->status.skill[sk_idx].lv = 0;
  2891. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2892. clif_deleteskill(sd,skill_id);
  2893. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2894. return 0;
  2895. }
  2896. /*==========================================
  2897. *
  2898. *------------------------------------------*/
  2899. ACMD_FUNC(spiritball)
  2900. {
  2901. uint32 max_spiritballs;
  2902. int number;
  2903. nullpo_retr(-1, sd);
  2904. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2905. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2906. {
  2907. char msg[CHAT_SIZE_MAX];
  2908. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2909. clif_displaymessage(fd, msg);
  2910. return -1;
  2911. }
  2912. if( sd->spiritball > 0 )
  2913. pc_delspiritball(sd, sd->spiritball, 1);
  2914. sd->spiritball = number;
  2915. clif_spiritball(&sd->bl);
  2916. // no message, player can look the difference
  2917. return 0;
  2918. }
  2919. /*==========================================
  2920. *
  2921. *------------------------------------------*/
  2922. ACMD_FUNC(party)
  2923. {
  2924. char party[NAME_LENGTH];
  2925. nullpo_retr(-1, sd);
  2926. memset(party, '\0', sizeof(party));
  2927. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2928. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2929. return -1;
  2930. }
  2931. party_create(sd, party, 0, 0);
  2932. return 0;
  2933. }
  2934. /*==========================================
  2935. *
  2936. *------------------------------------------*/
  2937. ACMD_FUNC(guild)
  2938. {
  2939. char guild[NAME_LENGTH];
  2940. int prev;
  2941. nullpo_retr(-1, sd);
  2942. memset(guild, '\0', sizeof(guild));
  2943. if (sd->clan) {
  2944. clif_displaymessage(fd, msg_txt(sd, 1498)); // You cannot create a guild because you are in a clan.
  2945. return -1;
  2946. }
  2947. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2948. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2949. return -1;
  2950. }
  2951. prev = battle_config.guild_emperium_check;
  2952. battle_config.guild_emperium_check = 0;
  2953. guild_create(sd, guild);
  2954. battle_config.guild_emperium_check = prev;
  2955. return 0;
  2956. }
  2957. ACMD_FUNC(breakguild)
  2958. {
  2959. nullpo_retr(-1, sd);
  2960. if (sd->status.guild_id) { // Check if the player has a guild
  2961. struct guild *g;
  2962. g = sd->guild; // Search the guild
  2963. if (g) { // Check if guild was found
  2964. if (sd->state.gmaster_flag) { // Check if player is guild master
  2965. int ret = 0;
  2966. ret = guild_break(sd, g->name); // Break guild
  2967. if (ret) { // Check if anything went wrong
  2968. return 0; // Guild was broken
  2969. } else {
  2970. return -1; // Something went wrong
  2971. }
  2972. } else { // Not guild master
  2973. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2974. return -1;
  2975. }
  2976. } else { // Guild was not found. HOW?
  2977. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2978. return -1;
  2979. }
  2980. } else { // Player does not have a guild
  2981. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2982. return -1;
  2983. }
  2984. }
  2985. /**
  2986. * Start WoE:FE
  2987. */
  2988. ACMD_FUNC(agitstart)
  2989. {
  2990. nullpo_retr(-1, sd);
  2991. if( guild_agit_start() ){
  2992. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2993. return 0;
  2994. }else{
  2995. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2996. return -1;
  2997. }
  2998. }
  2999. /**
  3000. * Start WoE:SE
  3001. */
  3002. ACMD_FUNC(agitstart2)
  3003. {
  3004. nullpo_retr(-1, sd);
  3005. if( guild_agit2_start() ){
  3006. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  3007. return 0;
  3008. }else{
  3009. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  3010. return -1;
  3011. }
  3012. }
  3013. /**
  3014. * Start WoE:TE
  3015. */
  3016. ACMD_FUNC(agitstart3)
  3017. {
  3018. nullpo_retr(-1, sd);
  3019. if( guild_agit3_start() ){
  3020. clif_displaymessage(fd, msg_txt(sd,749)); // "War of Emperium TE has been initiated."
  3021. return 0;
  3022. }else{
  3023. clif_displaymessage(fd, msg_txt(sd,750)); // "War of Emperium TE is currently in progress."
  3024. return -1;
  3025. }
  3026. }
  3027. /**
  3028. * End WoE:FE
  3029. */
  3030. ACMD_FUNC(agitend)
  3031. {
  3032. nullpo_retr(-1, sd);
  3033. if( guild_agit_end() ){
  3034. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  3035. return 0;
  3036. }else{
  3037. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  3038. return -1;
  3039. }
  3040. }
  3041. /**
  3042. * End WoE:SE
  3043. */
  3044. ACMD_FUNC(agitend2)
  3045. {
  3046. nullpo_retr(-1, sd);
  3047. if( guild_agit2_end() ){
  3048. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  3049. return 0;
  3050. }else{
  3051. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  3052. return -1;
  3053. }
  3054. }
  3055. /**
  3056. * End WoE:TE
  3057. */
  3058. ACMD_FUNC(agitend3)
  3059. {
  3060. nullpo_retr(-1, sd);
  3061. if( guild_agit3_end() ){
  3062. clif_displaymessage(fd, msg_txt(sd,751));// War of Emperium TE has been ended.
  3063. return 0;
  3064. }else{
  3065. clif_displaymessage(fd, msg_txt(sd,752));// War of Emperium TE is currently not in progress.
  3066. return -1;
  3067. }
  3068. }
  3069. /*==========================================
  3070. * @mapexit - shuts down the map server
  3071. *------------------------------------------*/
  3072. ACMD_FUNC(mapexit)
  3073. {
  3074. nullpo_retr(-1, sd);
  3075. do_shutdown();
  3076. return 0;
  3077. }
  3078. /*==========================================
  3079. * idsearch <part_of_name>: revrited by [Yor]
  3080. *------------------------------------------*/
  3081. ACMD_FUNC(idsearch)
  3082. {
  3083. char item_name[100];
  3084. unsigned int i, match;
  3085. struct item_data *item_array[MAX_SEARCH];
  3086. nullpo_retr(-1, sd);
  3087. memset(item_name, '\0', sizeof(item_name));
  3088. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3089. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3090. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3091. return -1;
  3092. }
  3093. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3094. clif_displaymessage(fd, atcmd_output);
  3095. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3096. if (match == MAX_SEARCH) {
  3097. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  3098. clif_displaymessage(fd, atcmd_output);
  3099. }
  3100. for(i = 0; i < match; i++) {
  3101. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3102. clif_displaymessage(fd, atcmd_output);
  3103. }
  3104. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3105. clif_displaymessage(fd, atcmd_output);
  3106. return 0;
  3107. }
  3108. /*==========================================
  3109. * Recall All Characters Online To Your Location
  3110. *------------------------------------------*/
  3111. ACMD_FUNC(recallall)
  3112. {
  3113. struct map_session_data* pl_sd;
  3114. struct s_mapiterator* iter;
  3115. int count;
  3116. nullpo_retr(-1, sd);
  3117. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3118. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3119. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3120. return -1;
  3121. }
  3122. count = 0;
  3123. iter = mapit_getallusers();
  3124. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3125. {
  3126. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3127. {
  3128. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3129. continue; // Don't waste time warping the character to the same place.
  3130. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3131. count++;
  3132. else {
  3133. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3134. count++;
  3135. }
  3136. }
  3137. }
  3138. }
  3139. mapit_free(iter);
  3140. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3141. if (count) {
  3142. 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.
  3143. clif_displaymessage(fd, atcmd_output);
  3144. }
  3145. return 0;
  3146. }
  3147. /*==========================================
  3148. * Recall online characters of a guild to your location
  3149. *------------------------------------------*/
  3150. ACMD_FUNC(guildrecall)
  3151. {
  3152. struct map_session_data* pl_sd;
  3153. struct s_mapiterator* iter;
  3154. int count;
  3155. char guild_name[NAME_LENGTH];
  3156. struct guild *g;
  3157. nullpo_retr(-1, sd);
  3158. memset(guild_name, '\0', sizeof(guild_name));
  3159. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3160. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3161. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3162. return -1;
  3163. }
  3164. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3165. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3166. return -1;
  3167. }
  3168. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3169. (g = guild_search(atoi(message))) == NULL)
  3170. {
  3171. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3172. return -1;
  3173. }
  3174. count = 0;
  3175. iter = mapit_getallusers();
  3176. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3177. {
  3178. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3179. {
  3180. 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))
  3181. continue; // Skip GMs greater than you... or chars already on the cell
  3182. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3183. count++;
  3184. else{
  3185. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3186. count++;
  3187. }
  3188. }
  3189. }
  3190. }
  3191. mapit_free(iter);
  3192. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3193. clif_displaymessage(fd, atcmd_output);
  3194. if (count) {
  3195. 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.
  3196. clif_displaymessage(fd, atcmd_output);
  3197. }
  3198. return 0;
  3199. }
  3200. /*==========================================
  3201. * Recall online characters of a party to your location
  3202. *------------------------------------------*/
  3203. ACMD_FUNC(partyrecall)
  3204. {
  3205. struct map_session_data* pl_sd;
  3206. struct s_mapiterator* iter;
  3207. char party_name[NAME_LENGTH];
  3208. struct party_data *p;
  3209. int count;
  3210. nullpo_retr(-1, sd);
  3211. memset(party_name, '\0', sizeof(party_name));
  3212. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3213. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3214. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3215. return -1;
  3216. }
  3217. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3218. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3219. return -1;
  3220. }
  3221. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3222. (p = party_search(atoi(message))) == NULL)
  3223. {
  3224. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3225. return -1;
  3226. }
  3227. count = 0;
  3228. iter = mapit_getallusers();
  3229. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3230. {
  3231. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3232. {
  3233. 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))
  3234. continue; // Skip GMs greater than you... or chars already on the cell
  3235. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3236. count++;
  3237. else{
  3238. if( pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN) == SETPOS_AUTOTRADE ){
  3239. count++;
  3240. }
  3241. }
  3242. }
  3243. }
  3244. mapit_free(iter);
  3245. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3246. clif_displaymessage(fd, atcmd_output);
  3247. if (count) {
  3248. 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.
  3249. clif_displaymessage(fd, atcmd_output);
  3250. }
  3251. return 0;
  3252. }
  3253. /*==========================================
  3254. *
  3255. *------------------------------------------*/
  3256. void atcommand_doload();
  3257. ACMD_FUNC(reload) {
  3258. nullpo_retr(-1, sd);
  3259. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3260. const char* text;
  3261. text = atcommand_help_string( command );
  3262. if(text)
  3263. clif_displaymessage( fd, text );
  3264. return -1;
  3265. }
  3266. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3267. itemdb_reload();
  3268. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3269. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3270. mob_reload();
  3271. read_petdb();
  3272. hom_reload();
  3273. mercenary_readdb();
  3274. mercenary_read_skilldb();
  3275. reload_elementaldb();
  3276. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3277. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3278. skill_reload();
  3279. hom_reload_skill();
  3280. reload_elemental_skilldb();
  3281. mercenary_read_skilldb();
  3282. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3283. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3284. config_t run_test;
  3285. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3286. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3287. return -1;
  3288. }
  3289. config_destroy(&run_test);
  3290. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3291. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3292. return -1;
  3293. }
  3294. config_destroy(&run_test);
  3295. atcommand_doload();
  3296. pc_groups_reload();
  3297. clif_displaymessage(fd, msg_txt(sd,254)); // GM command configuration has been reloaded.
  3298. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3299. struct Battle_Config prev_config;
  3300. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3301. battle_config_read(BATTLE_CONF_FILENAME);
  3302. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3303. || prev_config.item_rate_common != battle_config.item_rate_common
  3304. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3305. || prev_config.item_rate_common_mvp != battle_config.item_rate_common_mvp
  3306. || prev_config.item_rate_card != battle_config.item_rate_card
  3307. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3308. || prev_config.item_rate_card_mvp != battle_config.item_rate_card_mvp
  3309. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3310. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3311. || prev_config.item_rate_equip_mvp != battle_config.item_rate_equip_mvp
  3312. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3313. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3314. || prev_config.item_rate_heal_mvp != battle_config.item_rate_heal_mvp
  3315. || prev_config.item_rate_use != battle_config.item_rate_use
  3316. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3317. || prev_config.item_rate_use_mvp != battle_config.item_rate_use_mvp
  3318. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3319. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3320. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3321. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3322. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3323. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3324. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3325. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3326. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3327. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3328. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3329. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3330. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3331. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3332. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3333. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3334. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3335. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3336. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3337. )
  3338. { // Exp or Drop rates changed.
  3339. mob_reload(); //Needed as well so rate changes take effect.
  3340. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3341. }
  3342. clif_displaymessage(fd, msg_txt(sd,255)); // Battle configuration has been reloaded.
  3343. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3344. status_readdb();
  3345. clif_displaymessage(fd, msg_txt(sd,256)); // Status database has been reloaded.
  3346. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3347. pc_readdb();
  3348. clif_displaymessage(fd, msg_txt(sd,257)); // Player database has been reloaded.
  3349. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3350. pc_read_motd();
  3351. clif_displaymessage(fd, msg_txt(sd,268)); // Reloaded the Message of the Day.
  3352. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3353. struct s_mapiterator* iter;
  3354. struct map_session_data* pl_sd;
  3355. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3356. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3357. iter = mapit_getallusers();
  3358. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3359. pc_close_npc(pl_sd,2);
  3360. mapit_free(iter);
  3361. flush_fifos();
  3362. map_reloadnpc(true); // reload config files seeking for npcs
  3363. script_reload();
  3364. npc_reload();
  3365. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3366. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3367. map_msg_reload();
  3368. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3369. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3370. do_reload_quest();
  3371. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3372. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3373. instance_reload();
  3374. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3375. } else if (strstr(command, "achievementdb") || strncmp(message, "achievementdb", 4) == 0) {
  3376. achievement_db_reload();
  3377. clif_displaymessage(fd, msg_txt(sd,771)); // Achievement database has been reloaded.
  3378. }
  3379. return 0;
  3380. }
  3381. /*==========================================
  3382. * @partysharelvl <share_range> [Akinari]
  3383. * Updates char server party share level range in runtime
  3384. * Temporary - Permanent update in inter_athena.conf
  3385. *------------------------------------------*/
  3386. ACMD_FUNC(partysharelvl) {
  3387. unsigned int share_lvl;
  3388. nullpo_retr(-1, sd);
  3389. if(!message || !*message) {
  3390. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3391. return -1;
  3392. } else {
  3393. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3394. }
  3395. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3396. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3397. else //Char server offline
  3398. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3399. return 0;
  3400. }
  3401. /*==========================================
  3402. * @mapinfo [0-3] <map name> by MC_Cameri
  3403. * => Shows information about the map [map name]
  3404. * 0 = no additional information
  3405. * 1 = Show users in that map and their location
  3406. * 2 = Shows NPCs in that map
  3407. * 3 = Shows the chats in that map
  3408. *------------------------------------------*/
  3409. ACMD_FUNC(mapinfo) {
  3410. struct map_session_data* pl_sd;
  3411. struct s_mapiterator* iter;
  3412. struct chat_data *cd = NULL;
  3413. char direction[12];
  3414. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3415. unsigned short m_index;
  3416. char mapname[24];
  3417. nullpo_retr(-1, sd);
  3418. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3419. memset(mapname, '\0', sizeof(mapname));
  3420. memset(direction, '\0', sizeof(direction));
  3421. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3422. if (list < 0 || list > 3) {
  3423. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3424. return -1;
  3425. }
  3426. if (mapname[0] == '\0') {
  3427. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3428. m_id = map_mapindex2mapid(sd->mapindex);
  3429. } else {
  3430. m_id = map_mapname2mapid(mapname);
  3431. }
  3432. if (m_id < 0) {
  3433. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3434. return -1;
  3435. }
  3436. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3437. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3438. // count chats (for initial message)
  3439. chat_num = 0;
  3440. iter = mapit_getallusers();
  3441. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3442. if( pl_sd->mapindex == m_index ) {
  3443. if( pl_sd->state.vending )
  3444. vend_num++;
  3445. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3446. chat_num++;
  3447. }
  3448. }
  3449. mapit_free(iter);
  3450. sprintf(atcmd_output, msg_txt(sd,1040), mapname, map[m_id].users, map[m_id].npc_num, chat_num, vend_num); // Map: %s | Players: %d | NPCs: %d | Chats: %d | Vendings: %d
  3451. clif_displaymessage(fd, atcmd_output);
  3452. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3453. if (map[m_id].flag.town)
  3454. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3455. if (map[m_id].flag.restricted){
  3456. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3457. clif_displaymessage(fd, atcmd_output);
  3458. }
  3459. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3460. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3461. else
  3462. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3463. if (map[m_id].flag.battleground){
  3464. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3465. clif_displaymessage(fd, atcmd_output);
  3466. }
  3467. /* Skill damage adjustment info [Cydh] */
  3468. #ifdef ADJUST_SKILL_DAMAGE
  3469. if (map[m_id].flag.skill_damage) {
  3470. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3471. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3472. ,map[m_id].adjust.damage.pc
  3473. ,map[m_id].adjust.damage.mob
  3474. ,map[m_id].adjust.damage.boss
  3475. ,map[m_id].adjust.damage.other
  3476. ,map[m_id].adjust.damage.caster);
  3477. clif_displaymessage(fd, atcmd_output);
  3478. if (map[m_id].skill_damage.count) {
  3479. uint8 j;
  3480. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3481. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3482. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3483. ,j+1
  3484. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3485. ,map[m_id].skill_damage.entries[j]->pc
  3486. ,map[m_id].skill_damage.entries[j]->mob
  3487. ,map[m_id].skill_damage.entries[j]->boss
  3488. ,map[m_id].skill_damage.entries[j]->other
  3489. ,map[m_id].skill_damage.entries[j]->caster);
  3490. clif_displaymessage(fd,atcmd_output);
  3491. }
  3492. }
  3493. }
  3494. #endif
  3495. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3496. if (map[m_id].flag.pvp)
  3497. strcat(atcmd_output, " Pvp ON |");
  3498. if (map[m_id].flag.pvp_noguild)
  3499. strcat(atcmd_output, " NoGuild |");
  3500. if (map[m_id].flag.pvp_noparty)
  3501. strcat(atcmd_output, " NoParty |");
  3502. if (map[m_id].flag.pvp_nightmaredrop)
  3503. strcat(atcmd_output, " NightmareDrop |");
  3504. if (map[m_id].flag.pvp_nocalcrank)
  3505. strcat(atcmd_output, " NoCalcRank |");
  3506. clif_displaymessage(fd, atcmd_output);
  3507. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3508. if (map[m_id].flag.gvg)
  3509. strcat(atcmd_output, " GvG ON |");
  3510. if (map[m_id].flag.gvg_dungeon)
  3511. strcat(atcmd_output, " GvG Dungeon |");
  3512. if (map[m_id].flag.gvg_castle)
  3513. strcat(atcmd_output, " GvG Castle |");
  3514. if (map[m_id].flag.gvg_te)
  3515. strcat(atcmd_output, " GvG TE |");
  3516. if (map[m_id].flag.gvg_te_castle)
  3517. strcat(atcmd_output, " GvG TE Castle |");
  3518. if (map[m_id].flag.gvg_noparty)
  3519. strcat(atcmd_output, " NoParty |");
  3520. clif_displaymessage(fd, atcmd_output);
  3521. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3522. if (map[m_id].flag.noteleport)
  3523. strcat(atcmd_output, " NoTeleport |");
  3524. if (map[m_id].flag.monster_noteleport)
  3525. strcat(atcmd_output, " Monster NoTeleport |");
  3526. if (map[m_id].flag.nowarp)
  3527. strcat(atcmd_output, " NoWarp |");
  3528. if (map[m_id].flag.nowarpto)
  3529. strcat(atcmd_output, " NoWarpTo |");
  3530. if (map[m_id].flag.noreturn)
  3531. strcat(atcmd_output, " NoReturn |");
  3532. if (map[m_id].flag.nogo)
  3533. strcat(atcmd_output, " NoGo |"); //
  3534. if (map[m_id].flag.nomemo)
  3535. strcat(atcmd_output, " NoMemo |");
  3536. clif_displaymessage(fd, atcmd_output);
  3537. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3538. (map[m_id].flag.noexppenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067), (map[m_id].flag.nozenypenalty) ? msg_txt(sd,1066) : msg_txt(sd,1067)); // On / Off
  3539. clif_displaymessage(fd, atcmd_output);
  3540. if (map[m_id].flag.nosave) {
  3541. if (!map[m_id].save.map)
  3542. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3543. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3544. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3545. clif_displaymessage(fd, atcmd_output);
  3546. }
  3547. else {
  3548. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3549. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3550. clif_displaymessage(fd, atcmd_output);
  3551. }
  3552. }
  3553. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3554. if (map[m_id].flag.snow)
  3555. strcat(atcmd_output, " Snow |");
  3556. if (map[m_id].flag.fog)
  3557. strcat(atcmd_output, " Fog |");
  3558. if (map[m_id].flag.sakura)
  3559. strcat(atcmd_output, " Sakura |");
  3560. if (map[m_id].flag.clouds)
  3561. strcat(atcmd_output, " Clouds |");
  3562. if (map[m_id].flag.clouds2)
  3563. strcat(atcmd_output, " Clouds2 |");
  3564. if (map[m_id].flag.fireworks)
  3565. strcat(atcmd_output, " Fireworks |");
  3566. if (map[m_id].flag.leaves)
  3567. strcat(atcmd_output, " Leaves |");
  3568. if (map[m_id].flag.nightenabled)
  3569. strcat(atcmd_output, " Displays Night |");
  3570. clif_displaymessage(fd, atcmd_output);
  3571. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3572. if (map[m_id].flag.nobranch)
  3573. strcat(atcmd_output, " NoBranch |");
  3574. if (map[m_id].flag.notrade)
  3575. strcat(atcmd_output, " NoTrade |");
  3576. if (map[m_id].flag.novending)
  3577. strcat(atcmd_output, " NoVending |");
  3578. if (map[m_id].flag.nodrop)
  3579. strcat(atcmd_output, " NoDrop |");
  3580. if (map[m_id].flag.noskill)
  3581. strcat(atcmd_output, " NoSkill |");
  3582. if (map[m_id].flag.noicewall)
  3583. strcat(atcmd_output, " NoIcewall |");
  3584. if (map[m_id].flag.allowks)
  3585. strcat(atcmd_output, " AllowKS |");
  3586. if (map[m_id].flag.reset)
  3587. strcat(atcmd_output, " Reset |");
  3588. if (map[m_id].flag.hidemobhpbar)
  3589. strcat(atcmd_output, " HideMobHPBar |");
  3590. clif_displaymessage(fd, atcmd_output);
  3591. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3592. if (map[m_id].nocommand)
  3593. strcat(atcmd_output, " NoCommand |");
  3594. if (map[m_id].flag.nobaseexp)
  3595. strcat(atcmd_output, " NoBaseEXP |");
  3596. if (map[m_id].flag.nojobexp)
  3597. strcat(atcmd_output, " NoJobEXP |");
  3598. if (map[m_id].flag.nomobloot)
  3599. strcat(atcmd_output, " NoMobLoot |");
  3600. if (map[m_id].flag.nomvploot)
  3601. strcat(atcmd_output, " NoMVPLoot |");
  3602. if (map[m_id].flag.partylock)
  3603. strcat(atcmd_output, " PartyLock |");
  3604. if (map[m_id].flag.guildlock)
  3605. strcat(atcmd_output, " GuildLock |");
  3606. if (map[m_id].flag.loadevent)
  3607. strcat(atcmd_output, " Loadevent |");
  3608. if (map[m_id].flag.chmautojoin)
  3609. strcat(atcmd_output, " Chmautojoin |");
  3610. if (map[m_id].flag.nousecart)
  3611. strcat(atcmd_output, " NoUsecart |");
  3612. if (map[m_id].flag.noitemconsumption)
  3613. strcat(atcmd_output, " NoItemConsumption |");
  3614. if (map[m_id].flag.nosumstarmiracle)
  3615. strcat(atcmd_output, " NoSumStarMiracle |");
  3616. if (map[m_id].flag.nomineeffect)
  3617. strcat(atcmd_output, " NoMineEffect |");
  3618. if (map[m_id].flag.nolockon)
  3619. strcat(atcmd_output, " NoLockOn |");
  3620. if (map[m_id].flag.notomb)
  3621. strcat(atcmd_output, " NoTomb |");
  3622. if (map[m_id].flag.nocostume)
  3623. strcat(atcmd_output, " NoCostume |");
  3624. clif_displaymessage(fd, atcmd_output);
  3625. switch (list) {
  3626. case 0:
  3627. // Do nothing. It's list 0, no additional display.
  3628. break;
  3629. case 1:
  3630. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3631. iter = mapit_getallusers();
  3632. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3633. {
  3634. if (pl_sd->mapindex == m_index) {
  3635. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3636. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3637. clif_displaymessage(fd, atcmd_output);
  3638. }
  3639. }
  3640. mapit_free(iter);
  3641. break;
  3642. case 2:
  3643. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3644. for (i = 0; i < map[m_id].npc_num;)
  3645. {
  3646. struct npc_data *nd = map[m_id].npc[i];
  3647. switch(nd->ud.dir) {
  3648. case DIR_NORTH: strcpy(direction, msg_txt(sd,491)); break; // North
  3649. case DIR_NORTHWEST: strcpy(direction, msg_txt(sd,492)); break; // North West
  3650. case DIR_WEST: strcpy(direction, msg_txt(sd,493)); break; // West
  3651. case DIR_SOUTHWEST: strcpy(direction, msg_txt(sd,494)); break; // South West
  3652. case DIR_SOUTH: strcpy(direction, msg_txt(sd,495)); break; // South
  3653. case DIR_SOUTHEAST: strcpy(direction, msg_txt(sd,496)); break; // South East
  3654. case DIR_EAST: strcpy(direction, msg_txt(sd,497)); break; // East
  3655. case DIR_NORTHEAST: strcpy(direction, msg_txt(sd,498)); break; // North East
  3656. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3657. }
  3658. if(strcmp(nd->name,nd->exname) == 0)
  3659. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3660. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3661. else
  3662. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3663. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3664. clif_displaymessage(fd, atcmd_output);
  3665. }
  3666. break;
  3667. case 3:
  3668. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3669. iter = mapit_getallusers();
  3670. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3671. {
  3672. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3673. pl_sd->mapindex == m_index &&
  3674. cd->usersd[0] == pl_sd)
  3675. {
  3676. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3677. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3678. clif_displaymessage(fd, atcmd_output);
  3679. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3680. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3681. clif_displaymessage(fd, atcmd_output);
  3682. }
  3683. }
  3684. mapit_free(iter);
  3685. break;
  3686. default: // normally impossible to arrive here
  3687. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3688. return -1;
  3689. break;
  3690. }
  3691. return 0;
  3692. }
  3693. /*==========================================
  3694. *
  3695. *------------------------------------------*/
  3696. ACMD_FUNC(mount_peco)
  3697. {
  3698. nullpo_retr(-1, sd);
  3699. if (sd->disguise) {
  3700. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3701. return -1;
  3702. }
  3703. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3704. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3705. unsigned int option = OPTION_DRAGON1;
  3706. if( message[0] ) {
  3707. int color = atoi(message);
  3708. option = ( color == 2 ? OPTION_DRAGON2 :
  3709. color == 3 ? OPTION_DRAGON3 :
  3710. color == 4 ? OPTION_DRAGON4 :
  3711. color == 5 ? OPTION_DRAGON5 :
  3712. OPTION_DRAGON1 );
  3713. }
  3714. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3715. pc_setoption(sd, sd->sc.option|option);
  3716. } else {
  3717. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3718. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3719. }
  3720. return 0;
  3721. }
  3722. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3723. if( !pc_isridingwug(sd) ) {
  3724. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3725. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3726. } else {
  3727. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3728. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3729. }
  3730. return 0;
  3731. }
  3732. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3733. if( !pc_ismadogear(sd) ) {
  3734. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3735. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3736. } else {
  3737. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3738. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3739. }
  3740. return 0;
  3741. }
  3742. if (!pc_isriding(sd)) { // if actually no peco
  3743. if (!pc_checkskill(sd, KN_RIDING)) {
  3744. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3745. return -1;
  3746. }
  3747. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3748. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3749. } else {//Dismount
  3750. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3751. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3752. }
  3753. return 0;
  3754. }
  3755. /*==========================================
  3756. *Spy Commands by Syrus22
  3757. *------------------------------------------*/
  3758. ACMD_FUNC(guildspy)
  3759. {
  3760. char guild_name[NAME_LENGTH];
  3761. struct guild *g;
  3762. nullpo_retr(-1, sd);
  3763. memset(guild_name, '\0', sizeof(guild_name));
  3764. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3765. if (!enable_spy)
  3766. {
  3767. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3768. return -1;
  3769. }
  3770. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3771. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3772. return -1;
  3773. }
  3774. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3775. (g = guild_search(atoi(message))) != NULL) {
  3776. if (sd->guildspy == g->guild_id) {
  3777. sd->guildspy = 0;
  3778. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3779. clif_displaymessage(fd, atcmd_output);
  3780. } else {
  3781. sd->guildspy = g->guild_id;
  3782. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3783. clif_displaymessage(fd, atcmd_output);
  3784. }
  3785. } else {
  3786. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3787. return -1;
  3788. }
  3789. return 0;
  3790. }
  3791. /*==========================================
  3792. *
  3793. *------------------------------------------*/
  3794. ACMD_FUNC(partyspy)
  3795. {
  3796. char party_name[NAME_LENGTH];
  3797. struct party_data *p;
  3798. nullpo_retr(-1, sd);
  3799. memset(party_name, '\0', sizeof(party_name));
  3800. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3801. if (!enable_spy)
  3802. {
  3803. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3804. return -1;
  3805. }
  3806. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3807. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3808. return -1;
  3809. }
  3810. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3811. (p = party_search(atoi(message))) != NULL) {
  3812. if (sd->partyspy == p->party.party_id) {
  3813. sd->partyspy = 0;
  3814. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3815. clif_displaymessage(fd, atcmd_output);
  3816. } else {
  3817. sd->partyspy = p->party.party_id;
  3818. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3819. clif_displaymessage(fd, atcmd_output);
  3820. }
  3821. } else {
  3822. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3823. return -1;
  3824. }
  3825. return 0;
  3826. }
  3827. ACMD_FUNC(clanspy){
  3828. char clan_name[NAME_LENGTH];
  3829. struct clan* c;
  3830. nullpo_retr(-1, sd);
  3831. memset(clan_name, '\0', sizeof(clan_name));
  3832. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3833. if( !enable_spy ){
  3834. clif_displaymessage(fd, msg_txt(sd, 1125)); // The mapserver has spy command support disabled.
  3835. return -1;
  3836. }
  3837. if( !message || !*message || sscanf( message, "%23[^\n]", clan_name ) < 1 ){
  3838. clif_displaymessage(fd, msg_txt(sd, 1499)); // Please enter a clan name/ID (usage: @clanspy <clan_name/ID>).
  3839. return -1;
  3840. }
  3841. if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
  3842. (c = clan_search(atoi(message))) != NULL) {
  3843. if (sd->clanspy == c->id) {
  3844. sd->clanspy = 0;
  3845. sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
  3846. clif_displaymessage(fd, atcmd_output);
  3847. }
  3848. else {
  3849. sd->clanspy = c->id;
  3850. sprintf(atcmd_output, msg_txt(sd, 1501), c->name); // Spying on the %s clan.
  3851. clif_displaymessage(fd, atcmd_output);
  3852. }
  3853. }
  3854. else {
  3855. clif_displaymessage(fd, msg_txt(sd, 1502)); // Incorrect clan name/ID.
  3856. return -1;
  3857. }
  3858. return 0;
  3859. }
  3860. /*==========================================
  3861. * @repairall [Valaris]
  3862. *------------------------------------------*/
  3863. ACMD_FUNC(repairall)
  3864. {
  3865. int count, i;
  3866. nullpo_retr(-1, sd);
  3867. count = 0;
  3868. for (i = 0; i < MAX_INVENTORY; i++) {
  3869. if (sd->inventory.u.items_inventory[i].nameid && sd->inventory.u.items_inventory[i].attribute == 1) {
  3870. sd->inventory.u.items_inventory[i].attribute = 0;
  3871. clif_produceeffect(sd, 0, sd->inventory.u.items_inventory[i].nameid);
  3872. count++;
  3873. }
  3874. }
  3875. if (count > 0) {
  3876. clif_misceffect(&sd->bl, 3);
  3877. clif_equiplist(sd);
  3878. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3879. } else {
  3880. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3881. return -1;
  3882. }
  3883. return 0;
  3884. }
  3885. /*==========================================
  3886. * @nuke [Valaris]
  3887. *------------------------------------------*/
  3888. ACMD_FUNC(nuke)
  3889. {
  3890. struct map_session_data *pl_sd;
  3891. nullpo_retr(-1, sd);
  3892. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3893. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3894. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3895. return -1;
  3896. }
  3897. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
  3898. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3899. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3900. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3901. } else {
  3902. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3903. return -1;
  3904. }
  3905. } else {
  3906. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3907. return -1;
  3908. }
  3909. return 0;
  3910. }
  3911. /*==========================================
  3912. * @tonpc
  3913. *------------------------------------------*/
  3914. ACMD_FUNC(tonpc)
  3915. {
  3916. char npcname[NPC_NAME_LENGTH];
  3917. struct npc_data *nd;
  3918. nullpo_retr(-1, sd);
  3919. memset(npcname, 0, sizeof(npcname));
  3920. if (!message || !*message || sscanf(message, "%49[^\n]", npcname) < 1) {
  3921. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3922. return -1;
  3923. }
  3924. if ((nd = npc_name2id(npcname)) != NULL) {
  3925. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
  3926. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3927. else
  3928. return -1;
  3929. } else {
  3930. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3931. return -1;
  3932. }
  3933. return 0;
  3934. }
  3935. /*==========================================
  3936. *
  3937. *------------------------------------------*/
  3938. ACMD_FUNC(shownpc)
  3939. {
  3940. char NPCname[NPC_NAME_LENGTH];
  3941. nullpo_retr(-1, sd);
  3942. memset(NPCname, '\0', sizeof(NPCname));
  3943. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3944. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3945. return -1;
  3946. }
  3947. if (npc_name2id(NPCname) != NULL) {
  3948. npc_enable(NPCname, 1);
  3949. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3950. } else {
  3951. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3952. return -1;
  3953. }
  3954. return 0;
  3955. }
  3956. /*==========================================
  3957. *
  3958. *------------------------------------------*/
  3959. ACMD_FUNC(hidenpc)
  3960. {
  3961. char NPCname[NPC_NAME_LENGTH];
  3962. nullpo_retr(-1, sd);
  3963. memset(NPCname, '\0', sizeof(NPCname));
  3964. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3965. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3966. return -1;
  3967. }
  3968. if (npc_name2id(NPCname) == NULL) {
  3969. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3970. return -1;
  3971. }
  3972. npc_enable(NPCname, 0);
  3973. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3974. return 0;
  3975. }
  3976. ACMD_FUNC(loadnpc)
  3977. {
  3978. if (!message || !*message) {
  3979. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3980. return -1;
  3981. }
  3982. if (!npc_addsrcfile(message, true)) {
  3983. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  3984. return -1;
  3985. }
  3986. npc_read_event_script();
  3987. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  3988. return 0;
  3989. }
  3990. ACMD_FUNC(unloadnpc)
  3991. {
  3992. struct npc_data *nd;
  3993. char NPCname[NPC_NAME_LENGTH];
  3994. nullpo_retr(-1, sd);
  3995. memset(NPCname, '\0', sizeof(NPCname));
  3996. if (!message || !*message || sscanf(message, "%49[^\n]", NPCname) < 1) {
  3997. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3998. return -1;
  3999. }
  4000. if ((nd = npc_name2id(NPCname)) == NULL) {
  4001. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4002. return -1;
  4003. }
  4004. npc_unload_duplicates(nd);
  4005. npc_unload(nd,true);
  4006. npc_read_event_script();
  4007. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  4008. return 0;
  4009. }
  4010. ACMD_FUNC(reloadnpcfile) {
  4011. if (!message || !*message) {
  4012. clif_displaymessage(fd, msg_txt(sd,733)); // Please enter a NPC file name (usage: @reloadnpcfile <file name>).
  4013. return -1;
  4014. }
  4015. if (npc_unloadfile(message))
  4016. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  4017. if (!npc_addsrcfile(message, true)) {
  4018. clif_displaymessage(fd, msg_txt(sd,261)); // Script could not be loaded.
  4019. return -1;
  4020. }
  4021. npc_read_event_script();
  4022. clif_displaymessage(fd, msg_txt(sd,262)); // Script loaded.
  4023. return 0;
  4024. }
  4025. /*==========================================
  4026. * time in txt for time command (by [Yor])
  4027. *------------------------------------------*/
  4028. char* txt_time(unsigned int duration)
  4029. {
  4030. int days, hours, minutes, seconds;
  4031. char temp[CHAT_SIZE_MAX];
  4032. static char temp1[CHAT_SIZE_MAX];
  4033. memset(temp, '\0', sizeof(temp));
  4034. memset(temp1, '\0', sizeof(temp1));
  4035. days = duration / (60 * 60 * 24);
  4036. duration = duration - (60 * 60 * 24 * days);
  4037. hours = duration / (60 * 60);
  4038. duration = duration - (60 * 60 * hours);
  4039. minutes = duration / 60;
  4040. seconds = duration - (60 * minutes);
  4041. if (days == 1)
  4042. sprintf(temp, msg_txt(NULL,219), days); // %d day
  4043. else if (days > 1)
  4044. sprintf(temp, msg_txt(NULL,220), days); // %d days
  4045. if (hours == 1)
  4046. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  4047. else if (hours > 1)
  4048. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  4049. if (minutes < 2)
  4050. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  4051. else
  4052. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  4053. if (seconds == 1)
  4054. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  4055. else if (seconds > 1)
  4056. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  4057. return temp1;
  4058. }
  4059. /*==========================================
  4060. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  4061. * Calculation management of GM modification (@day/@night GM commands) is done
  4062. *------------------------------------------*/
  4063. ACMD_FUNC(servertime)
  4064. {
  4065. const struct TimerData * timer_data;
  4066. time_t time_server; // variable for number of seconds (used with time() function)
  4067. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  4068. char temp[CHAT_SIZE_MAX];
  4069. nullpo_retr(-1, sd);
  4070. memset(temp, '\0', sizeof(temp));
  4071. time(&time_server); // get time in seconds since 1/1/1970
  4072. datetime = localtime(&time_server); // convert seconds in structure
  4073. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  4074. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  4075. clif_displaymessage(fd, temp);
  4076. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  4077. if (night_flag == 0)
  4078. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4079. else
  4080. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4081. } else if (battle_config.night_duration == 0)
  4082. if (night_flag == 1) { // we start with night
  4083. timer_data = get_timer(day_timer_tid);
  4084. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  4085. clif_displaymessage(fd, temp);
  4086. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  4087. } else
  4088. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  4089. else if (battle_config.day_duration == 0)
  4090. if (night_flag == 0) { // we start with day
  4091. timer_data = get_timer(night_timer_tid);
  4092. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4093. clif_displaymessage(fd, temp);
  4094. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  4095. } else
  4096. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  4097. else {
  4098. const struct TimerData * timer_data2;
  4099. if (night_flag == 0) {
  4100. timer_data = get_timer(night_timer_tid);
  4101. timer_data2 = get_timer(day_timer_tid);
  4102. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  4103. clif_displaymessage(fd, temp);
  4104. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  4105. 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.
  4106. else
  4107. 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.
  4108. clif_displaymessage(fd, temp);
  4109. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4110. clif_displaymessage(fd, temp);
  4111. } else {
  4112. timer_data = get_timer(day_timer_tid);
  4113. timer_data2 = get_timer(night_timer_tid);
  4114. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  4115. clif_displaymessage(fd, temp);
  4116. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  4117. 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.
  4118. else
  4119. 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.
  4120. clif_displaymessage(fd, temp);
  4121. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  4122. clif_displaymessage(fd, temp);
  4123. }
  4124. }
  4125. return 0;
  4126. }
  4127. /*==========================================
  4128. * @jail <char_name> by [Yor]
  4129. * Special warp! No check with nowarp and nowarpto flag
  4130. *------------------------------------------*/
  4131. ACMD_FUNC(jail)
  4132. {
  4133. struct map_session_data *pl_sd;
  4134. int x, y;
  4135. unsigned short m_index;
  4136. nullpo_retr(-1, sd);
  4137. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4138. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4139. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4140. return -1;
  4141. }
  4142. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4143. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4144. return -1;
  4145. }
  4146. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4147. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4148. return -1;
  4149. }
  4150. if (pl_sd->sc.data[SC_JAILED]) {
  4151. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4152. return -1;
  4153. }
  4154. switch(rnd() % 2) { //Jail Locations
  4155. case 0:
  4156. m_index = mapindex_name2id(MAP_JAIL);
  4157. x = 24;
  4158. y = 75;
  4159. break;
  4160. default:
  4161. m_index = mapindex_name2id(MAP_JAIL);
  4162. x = 49;
  4163. y = 75;
  4164. break;
  4165. }
  4166. //Duration of INT_MAX to specify infinity.
  4167. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4168. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4169. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4170. return 0;
  4171. }
  4172. /*==========================================
  4173. * @unjail/@discharge <char_name> by [Yor]
  4174. * Special warp! No check with nowarp and nowarpto flag
  4175. *------------------------------------------*/
  4176. ACMD_FUNC(unjail)
  4177. {
  4178. struct map_session_data *pl_sd;
  4179. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4180. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4181. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4182. return -1;
  4183. }
  4184. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4185. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4186. return -1;
  4187. }
  4188. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4189. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4190. return -1;
  4191. }
  4192. if (!pl_sd->sc.data[SC_JAILED]) {
  4193. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4194. return -1;
  4195. }
  4196. //Reset jail time to 1 sec.
  4197. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4198. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4199. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4200. return 0;
  4201. }
  4202. ACMD_FUNC(jailfor) {
  4203. struct map_session_data *pl_sd = NULL;
  4204. char * modif_p;
  4205. int jailtime = 0,x,y;
  4206. short m_index = 0;
  4207. nullpo_retr(-1, sd);
  4208. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4209. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4210. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4211. return -1;
  4212. }
  4213. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4214. modif_p = atcmd_output;
  4215. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4216. if (jailtime == 0) {
  4217. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4218. 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.
  4219. return -1;
  4220. }
  4221. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  4222. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4223. return -1;
  4224. }
  4225. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4226. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4227. return -1;
  4228. }
  4229. // Added by Coltaro
  4230. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4231. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4232. if (jailtime <= 0) {
  4233. jailtime = 0;
  4234. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4235. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4236. } else {
  4237. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4238. char timestr[21];
  4239. time_t now=time(NULL);
  4240. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4241. 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
  4242. clif_displaymessage(pl_sd->fd, atcmd_output);
  4243. 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
  4244. clif_displaymessage(fd, atcmd_output);
  4245. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4246. sprintf(atcmd_output,"Release date is: %s",timestr);
  4247. clif_displaymessage(pl_sd->fd, atcmd_output);
  4248. clif_displaymessage(fd, atcmd_output);
  4249. }
  4250. } else if (jailtime < 0) {
  4251. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4252. return -1;
  4253. }
  4254. // Jail locations, add more as you wish.
  4255. switch(rnd()%2) {
  4256. case 1: // Jail #1
  4257. m_index = mapindex_name2id(MAP_JAIL);
  4258. x = 49; y = 75;
  4259. break;
  4260. default: // Default Jail
  4261. m_index = mapindex_name2id(MAP_JAIL);
  4262. x = 24; y = 75;
  4263. break;
  4264. }
  4265. 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).
  4266. return 0;
  4267. }
  4268. //By Coltaro
  4269. ACMD_FUNC(jailtime){
  4270. int year, month, day, hour, minute, second;
  4271. char timestr[21];
  4272. time_t now = time(NULL);
  4273. nullpo_retr(-1, sd);
  4274. if (!sd->sc.data[SC_JAILED]) {
  4275. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4276. return -1;
  4277. }
  4278. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4279. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4280. return 0;
  4281. }
  4282. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4283. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4284. return -1;
  4285. }
  4286. // Get remaining jail time
  4287. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4288. 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
  4289. clif_displaymessage(fd, atcmd_output);
  4290. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4291. sprintf(atcmd_output,"Release date is: %s",timestr);
  4292. clif_displaymessage(fd, atcmd_output);
  4293. return 0;
  4294. }
  4295. /*==========================================
  4296. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4297. *------------------------------------------*/
  4298. ACMD_FUNC(disguise)
  4299. {
  4300. int id = 0;
  4301. nullpo_retr(-1, sd);
  4302. if (!message || !*message) {
  4303. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4304. return -1;
  4305. }
  4306. if ((id = atoi(message)) > 0)
  4307. { //Acquired an ID
  4308. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4309. id = 0; //Invalid id for either mobs or npcs.
  4310. } else { //Acquired a Name
  4311. if ((id = mobdb_searchname(message)) == 0)
  4312. {
  4313. struct npc_data* nd = npc_name2id(message);
  4314. if (nd != NULL)
  4315. id = nd->class_;
  4316. }
  4317. }
  4318. if (id == 0)
  4319. {
  4320. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4321. return -1;
  4322. }
  4323. if(pc_isriding(sd))
  4324. {
  4325. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4326. return -1;
  4327. }
  4328. if (sd->sc.data[SC_MONSTER_TRANSFORM] || sd->sc.data[SC_ACTIVE_MONSTER_TRANSFORM]) {
  4329. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4330. return -1;
  4331. }
  4332. pc_disguise(sd, id);
  4333. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4334. return 0;
  4335. }
  4336. /*==========================================
  4337. * DisguiseAll
  4338. *------------------------------------------*/
  4339. ACMD_FUNC(disguiseall)
  4340. {
  4341. int mob_id=0;
  4342. struct map_session_data *pl_sd;
  4343. struct s_mapiterator* iter;
  4344. nullpo_retr(-1, sd);
  4345. if (!message || !*message) {
  4346. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4347. return -1;
  4348. }
  4349. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4350. mob_id = atoi(message);
  4351. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4352. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4353. return -1;
  4354. }
  4355. iter = mapit_getallusers();
  4356. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4357. pc_disguise(pl_sd, mob_id);
  4358. mapit_free(iter);
  4359. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4360. return 0;
  4361. }
  4362. /*==========================================
  4363. * DisguiseGuild
  4364. *------------------------------------------*/
  4365. ACMD_FUNC(disguiseguild)
  4366. {
  4367. int id = 0, i;
  4368. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4369. struct guild *g;
  4370. memset(monster, '\0', sizeof(monster));
  4371. memset(guild, '\0', sizeof(guild));
  4372. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4373. 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>).
  4374. return -1;
  4375. }
  4376. if( (id = atoi(monster)) > 0 ) {
  4377. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4378. id = 0;
  4379. } else {
  4380. if( (id = mobdb_searchname(monster)) == 0 ) {
  4381. struct npc_data* nd = npc_name2id(monster);
  4382. if( nd != NULL )
  4383. id = nd->class_;
  4384. }
  4385. }
  4386. if( id == 0 ) {
  4387. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4388. return -1;
  4389. }
  4390. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4391. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4392. return -1;
  4393. }
  4394. for( i = 0; i < g->max_member; i++ ){
  4395. struct map_session_data *pl_sd;
  4396. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4397. pc_disguise(pl_sd, id);
  4398. }
  4399. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4400. return 0;
  4401. }
  4402. /*==========================================
  4403. * @undisguise by [Yor]
  4404. *------------------------------------------*/
  4405. ACMD_FUNC(undisguise)
  4406. {
  4407. nullpo_retr(-1, sd);
  4408. if (sd->disguise) {
  4409. pc_disguise(sd, 0);
  4410. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4411. } else {
  4412. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4413. return -1;
  4414. }
  4415. return 0;
  4416. }
  4417. /*==========================================
  4418. * UndisguiseAll
  4419. *------------------------------------------*/
  4420. ACMD_FUNC(undisguiseall)
  4421. {
  4422. struct map_session_data *pl_sd;
  4423. struct s_mapiterator* iter;
  4424. nullpo_retr(-1, sd);
  4425. iter = mapit_getallusers();
  4426. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4427. if( pl_sd->disguise )
  4428. pc_disguise(pl_sd, 0);
  4429. mapit_free(iter);
  4430. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4431. return 0;
  4432. }
  4433. /*==========================================
  4434. * UndisguiseGuild
  4435. *------------------------------------------*/
  4436. ACMD_FUNC(undisguiseguild)
  4437. {
  4438. char guild_name[NAME_LENGTH];
  4439. struct guild *g;
  4440. int i;
  4441. nullpo_retr(-1, sd);
  4442. memset(guild_name, '\0', sizeof(guild_name));
  4443. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4444. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4445. return -1;
  4446. }
  4447. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4448. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4449. return -1;
  4450. }
  4451. for(i = 0; i < g->max_member; i++){
  4452. struct map_session_data *pl_sd;
  4453. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4454. pc_disguise(pl_sd, 0);
  4455. }
  4456. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4457. return 0;
  4458. }
  4459. /*==========================================
  4460. * @exp by [Skotlex]
  4461. *------------------------------------------*/
  4462. ACMD_FUNC(exp)
  4463. {
  4464. char output[CHAT_SIZE_MAX];
  4465. double nextb, nextj;
  4466. nullpo_retr(-1, sd);
  4467. memset(output, '\0', sizeof(output));
  4468. nextb = pc_nextbaseexp(sd);
  4469. if (nextb)
  4470. nextb = sd->status.base_exp*100.0/nextb;
  4471. nextj = pc_nextjobexp(sd);
  4472. if (nextj)
  4473. nextj = sd->status.job_exp*100.0/nextj;
  4474. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4475. clif_displaymessage(fd, output);
  4476. return 0;
  4477. }
  4478. /*==========================================
  4479. * @broadcast by [Valaris]
  4480. *------------------------------------------*/
  4481. ACMD_FUNC(broadcast)
  4482. {
  4483. nullpo_retr(-1, sd);
  4484. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4485. if (!message || !*message) {
  4486. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4487. return -1;
  4488. }
  4489. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4490. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4491. return 0;
  4492. }
  4493. /*==========================================
  4494. * @localbroadcast by [Valaris]
  4495. *------------------------------------------*/
  4496. ACMD_FUNC(localbroadcast)
  4497. {
  4498. nullpo_retr(-1, sd);
  4499. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4500. if (!message || !*message) {
  4501. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4502. return -1;
  4503. }
  4504. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4505. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4506. return 0;
  4507. }
  4508. /*==========================================
  4509. * @email <actual@email> <new@email> by [Yor]
  4510. *------------------------------------------*/
  4511. ACMD_FUNC(email)
  4512. {
  4513. char actual_email[100];
  4514. char new_email[100];
  4515. nullpo_retr(-1, sd);
  4516. memset(actual_email, '\0', sizeof(actual_email));
  4517. memset(new_email, '\0', sizeof(new_email));
  4518. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4519. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4520. return -1;
  4521. }
  4522. if (e_mail_check(actual_email) == 0) {
  4523. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4524. return -1;
  4525. } else if (e_mail_check(new_email) == 0) {
  4526. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4527. return -1;
  4528. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4529. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4530. return -1;
  4531. } else if (strcmpi(actual_email, new_email) == 0) {
  4532. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4533. return -1;
  4534. }
  4535. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4536. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4537. return 0;
  4538. }
  4539. /*==========================================
  4540. *@effect
  4541. *------------------------------------------*/
  4542. ACMD_FUNC(effect)
  4543. {
  4544. int type = EF_NONE;
  4545. nullpo_retr(-1, sd);
  4546. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4547. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4548. return -1;
  4549. }
  4550. if( type <= EF_NONE || type >= EF_MAX ){
  4551. 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.
  4552. clif_displaymessage(fd, atcmd_output);
  4553. return -1;
  4554. }
  4555. clif_specialeffect(&sd->bl, type, ALL_CLIENT);
  4556. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4557. return 0;
  4558. }
  4559. /*==========================================
  4560. * @killer by MouseJstr
  4561. * enable killing players even when not in pvp
  4562. *------------------------------------------*/
  4563. ACMD_FUNC(killer)
  4564. {
  4565. nullpo_retr(-1, sd);
  4566. sd->state.killer = !sd->state.killer;
  4567. if(sd->state.killer)
  4568. clif_displaymessage(fd, msg_txt(sd,241)); // You can now attack and kill players freely.
  4569. else {
  4570. clif_displaymessage(fd, msg_txt(sd,292)); // Killer state reset.
  4571. pc_stop_attack(sd);
  4572. }
  4573. return 0;
  4574. }
  4575. /*==========================================
  4576. * @killable by MouseJstr
  4577. * enable other people killing you
  4578. *------------------------------------------*/
  4579. ACMD_FUNC(killable)
  4580. {
  4581. nullpo_retr(-1, sd);
  4582. sd->state.killable = !sd->state.killable;
  4583. if(sd->state.killable)
  4584. clif_displaymessage(fd, msg_txt(sd,242)); // You can now be attacked and killed by players.
  4585. else {
  4586. clif_displaymessage(fd, msg_txt(sd,288)); // You are no longer killable.
  4587. map_foreachinallrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4588. }
  4589. return 0;
  4590. }
  4591. /*==========================================
  4592. * @skillon by MouseJstr
  4593. * turn skills on for the map
  4594. *------------------------------------------*/
  4595. ACMD_FUNC(skillon)
  4596. {
  4597. nullpo_retr(-1, sd);
  4598. map[sd->bl.m].flag.noskill = 0;
  4599. clif_displaymessage(fd, msg_txt(sd,244)); // Skills have been enabled on this map.
  4600. return 0;
  4601. }
  4602. /*==========================================
  4603. * @skilloff by MouseJstr
  4604. * Turn skills off on the map
  4605. *------------------------------------------*/
  4606. ACMD_FUNC(skilloff)
  4607. {
  4608. nullpo_retr(-1, sd);
  4609. map[sd->bl.m].flag.noskill = 1;
  4610. clif_displaymessage(fd, msg_txt(sd,243)); // Skills have been disabled on this map.
  4611. return 0;
  4612. }
  4613. /*==========================================
  4614. * @npcmove by MouseJstr
  4615. * move a npc
  4616. *------------------------------------------*/
  4617. ACMD_FUNC(npcmove)
  4618. {
  4619. short x = 0, y = 0;
  4620. struct npc_data *nd = 0;
  4621. char npc_name[NPC_NAME_LENGTH];
  4622. nullpo_retr(-1, sd);
  4623. memset(npc_name, '\0', sizeof npc_name);
  4624. if (!message || !*message || sscanf(message, "%6hd %6hd %49[^\n]", &x, &y, npc_name) < 3) {
  4625. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4626. return -1;
  4627. }
  4628. if ((nd = npc_name2id(npc_name)) == NULL)
  4629. {
  4630. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4631. return -1;
  4632. }
  4633. if ( npc_movenpc( nd, x, y ) )
  4634. { //actually failed to move
  4635. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4636. return -1; //Not on a map.
  4637. } else
  4638. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved
  4639. return 0;
  4640. }
  4641. /*==========================================
  4642. * @addwarp by MouseJstr
  4643. * Create a new static warp point.
  4644. *------------------------------------------*/
  4645. ACMD_FUNC(addwarp)
  4646. {
  4647. char mapname[MAP_NAME_LENGTH_EXT], warpname[NPC_NAME_LENGTH];
  4648. short x,y;
  4649. unsigned short m;
  4650. struct npc_data* nd;
  4651. nullpo_retr(-1, sd);
  4652. memset(warpname, '\0', sizeof(warpname));
  4653. if (!message || !*message || sscanf(message, "%15s %6hd %6hd %49[^\n]", mapname, &x, &y, warpname) < 4) {
  4654. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4655. return -1;
  4656. }
  4657. m = mapindex_name2id(mapname);
  4658. if( m == 0 )
  4659. {
  4660. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4661. clif_displaymessage(fd, atcmd_output);
  4662. return -1;
  4663. }
  4664. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4665. if( nd == NULL )
  4666. return -1;
  4667. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4668. clif_displaymessage(fd, atcmd_output);
  4669. return 0;
  4670. }
  4671. /*==========================================
  4672. * @follow by [MouseJstr]
  4673. * Follow a player .. staying no more then 5 spaces away
  4674. *------------------------------------------*/
  4675. ACMD_FUNC(follow)
  4676. {
  4677. struct map_session_data *pl_sd = NULL;
  4678. nullpo_retr(-1, sd);
  4679. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4680. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4681. if (sd->followtarget == -1)
  4682. return -1;
  4683. pc_stop_following (sd);
  4684. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4685. return 0;
  4686. }
  4687. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4688. {
  4689. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4690. return -1;
  4691. }
  4692. if (sd->followtarget == pl_sd->bl.id) {
  4693. pc_stop_following (sd);
  4694. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4695. } else {
  4696. pc_follow(sd, pl_sd->bl.id);
  4697. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4698. }
  4699. return 0;
  4700. }
  4701. /*==========================================
  4702. * @dropall by [MouseJstr] and [Xantara]
  4703. * Drops all your possession on the ground based on item type
  4704. *------------------------------------------*/
  4705. ACMD_FUNC(dropall)
  4706. {
  4707. int8 type = -1;
  4708. uint16 i, count = 0, count2 = 0;
  4709. struct item_data *item_data = NULL;
  4710. nullpo_retr(-1, sd);
  4711. if( message[0] ) {
  4712. type = atoi(message);
  4713. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4714. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4715. {
  4716. clif_displaymessage(fd, msg_txt(sd,1492)); // Usage: @dropall {<type>}
  4717. 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
  4718. return -1;
  4719. }
  4720. }
  4721. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4722. if( sd->inventory.u.items_inventory[i].amount ) {
  4723. if( (item_data = itemdb_exists(sd->inventory.u.items_inventory[i].nameid)) == NULL ) {
  4724. 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);
  4725. continue;
  4726. }
  4727. if( !pc_candrop(sd,&sd->inventory.u.items_inventory[i]) )
  4728. continue;
  4729. if( type == -1 || type == (uint8)item_data->type ) {
  4730. if( sd->inventory.u.items_inventory[i].equip != 0 )
  4731. pc_unequipitem(sd, i, 3);
  4732. if(pc_dropitem(sd, i, sd->inventory.u.items_inventory[i].amount))
  4733. count += sd->inventory.u.items_inventory[i].amount;
  4734. else count2 += sd->inventory.u.items_inventory[i].amount;
  4735. }
  4736. }
  4737. }
  4738. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4739. clif_displaymessage(fd, atcmd_output);
  4740. return 0;
  4741. }
  4742. /*==========================================
  4743. * @storeall by [MouseJstr]
  4744. * Put everything into storage
  4745. *------------------------------------------*/
  4746. ACMD_FUNC(storeall)
  4747. {
  4748. int i;
  4749. nullpo_retr(-1, sd);
  4750. if (sd->state.storage_flag != 1)
  4751. { //Open storage.
  4752. if( storage_storageopen(sd) == 1 ) {
  4753. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4754. return -1;
  4755. }
  4756. }
  4757. for (i = 0; i < MAX_INVENTORY; i++) {
  4758. if (sd->inventory.u.items_inventory[i].amount) {
  4759. if(sd->inventory.u.items_inventory[i].equip != 0)
  4760. pc_unequipitem(sd, i, 3);
  4761. storage_storageadd(sd, &sd->storage, i, sd->inventory.u.items_inventory[i].amount);
  4762. }
  4763. }
  4764. storage_storageclose(sd);
  4765. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4766. return 0;
  4767. }
  4768. ACMD_FUNC(clearstorage)
  4769. {
  4770. int i, j;
  4771. nullpo_retr(-1, sd);
  4772. if (sd->state.storage_flag == 1) {
  4773. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4774. return -1;
  4775. }
  4776. if (sd->state.storage_flag == 3) {
  4777. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4778. return -1;
  4779. }
  4780. j = sd->storage.amount;
  4781. for (i = 0; i < j; ++i) {
  4782. storage_delitem(sd, &sd->storage, i, sd->storage.u.items_storage[i].amount);
  4783. }
  4784. sd->state.storage_flag = 1;
  4785. storage_storageclose(sd);
  4786. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4787. return 0;
  4788. }
  4789. ACMD_FUNC(cleargstorage)
  4790. {
  4791. int i, j;
  4792. struct guild *g;
  4793. struct s_storage *gstorage;
  4794. nullpo_retr(-1, sd);
  4795. g = sd->guild;
  4796. if (g == NULL) {
  4797. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  4798. return -1;
  4799. }
  4800. if (sd->state.storage_flag == 1) {
  4801. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4802. return -1;
  4803. }
  4804. if (sd->state.storage_flag == 2) {
  4805. clif_displaymessage(fd, msg_txt(sd,251)); // You have already opened your guild storage. Close it first.
  4806. return -1;
  4807. }
  4808. if (sd->state.storage_flag == 3) {
  4809. clif_displaymessage(fd, msg_txt(sd,250)); // You have already opened your storage. Close it first.
  4810. return -1;
  4811. }
  4812. gstorage = guild2storage2(sd->status.guild_id);
  4813. if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4814. return -1;
  4815. }
  4816. j = gstorage->amount;
  4817. gstorage->lock = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4818. for (i = 0; i < j; ++i) {
  4819. storage_guild_delitem(sd, gstorage, i, gstorage->u.items_guild[i].amount);
  4820. }
  4821. storage_guild_storageclose(sd);
  4822. gstorage->lock = false; // Cleaning done, release lock
  4823. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4824. return 0;
  4825. }
  4826. ACMD_FUNC(clearcart)
  4827. {
  4828. int i;
  4829. nullpo_retr(-1, sd);
  4830. if (pc_iscarton(sd) == 0) {
  4831. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4832. return -1;
  4833. }
  4834. if (sd->state.vending == 1) { //Somehow...
  4835. return -1;
  4836. }
  4837. for (i = 0; i < MAX_CART; i++) {
  4838. if (sd->cart.u.items_cart[i].nameid > 0)
  4839. pc_cart_delitem(sd, i, sd->cart.u.items_cart[i].amount, 1, LOG_TYPE_OTHER);
  4840. }
  4841. clif_clearcart(fd);
  4842. clif_updatestatus(sd,SP_CARTINFO);
  4843. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4844. return 0;
  4845. }
  4846. /*==========================================
  4847. * @skillid by [MouseJstr]
  4848. * lookup a skill by name
  4849. *------------------------------------------*/
  4850. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4851. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4852. ACMD_FUNC(skillid) {
  4853. int skillen, i, found = 0;
  4854. DBIterator* iter;
  4855. DBKey key;
  4856. DBData *data;
  4857. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4858. nullpo_retr(-1, sd);
  4859. if (!message || !*message) {
  4860. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4861. return -1;
  4862. }
  4863. skillen = strlen(message);
  4864. iter = db_iterator(skilldb_name2id);
  4865. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4866. int idx = skill_get_index(db_data2i(data));
  4867. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4868. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4869. clif_displaymessage(fd, atcmd_output);
  4870. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4871. 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)
  4872. }
  4873. }
  4874. dbi_destroy(iter);
  4875. if( found ) {
  4876. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4877. clif_displaymessage(fd, atcmd_output);
  4878. }
  4879. for(i = 0; i < found; i++) { /* partials */
  4880. clif_displaymessage(fd, partials[i]);
  4881. }
  4882. return 0;
  4883. }
  4884. /*==========================================
  4885. * @useskill by [MouseJstr]
  4886. * A way of using skills without having to find them in the skills menu
  4887. *------------------------------------------*/
  4888. ACMD_FUNC(useskill)
  4889. {
  4890. struct map_session_data *pl_sd = NULL;
  4891. struct block_list *bl;
  4892. uint16 skill_id;
  4893. uint16 skill_lv;
  4894. nullpo_retr(-1, sd);
  4895. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4896. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, atcmd_player_name) != 3) {
  4897. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <char name>
  4898. return -1;
  4899. }
  4900. if(!strcmp(atcmd_player_name,"self"))
  4901. pl_sd = sd; //quick keyword
  4902. else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
  4903. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4904. return -1;
  4905. }
  4906. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4907. {
  4908. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4909. return -1;
  4910. }
  4911. if (SKILL_CHK_HOMUN(skill_id) && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4912. bl = &sd->hd->bl;
  4913. else
  4914. bl = &sd->bl;
  4915. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4916. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4917. else
  4918. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4919. return 0;
  4920. }
  4921. /*==========================================
  4922. * @displayskill by [Skotlex]
  4923. * Debug command to locate new skill IDs. It sends the
  4924. * three possible skill-effect packets to the area.
  4925. *------------------------------------------*/
  4926. ACMD_FUNC(displayskill)
  4927. {
  4928. struct status_data * status;
  4929. unsigned int tick;
  4930. uint16 skill_id;
  4931. uint16 skill_lv = 1;
  4932. nullpo_retr(-1, sd);
  4933. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4934. {
  4935. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4936. return -1;
  4937. }
  4938. status = status_get_status_data(&sd->bl);
  4939. tick = gettick();
  4940. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, DMG_SPLASH);
  4941. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4942. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4943. return 0;
  4944. }
  4945. /*==========================================
  4946. * @skilltree by [MouseJstr]
  4947. * prints the skill tree for a player required to get to a skill
  4948. *------------------------------------------*/
  4949. ACMD_FUNC(skilltree)
  4950. {
  4951. struct map_session_data *pl_sd = NULL;
  4952. uint16 skill_id;
  4953. int meets, i, j, c=0;
  4954. struct skill_tree_entry *ent;
  4955. nullpo_retr(-1, sd);
  4956. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4957. if(!message || !*message || sscanf(message, "%6hu %23[^\n]", &skill_id, atcmd_player_name) != 2) {
  4958. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <char name>
  4959. return -1;
  4960. }
  4961. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  4962. {
  4963. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4964. return -1;
  4965. }
  4966. i = pc_calc_skilltree_normalize_job(pl_sd);
  4967. c = pc_mapid2jobid(i, pl_sd->status.sex);
  4968. 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).
  4969. clif_displaymessage(fd, atcmd_output);
  4970. c = pc_class2idx(c);
  4971. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].skill_id == 0 || skill_tree[c][j].skill_id == skill_id );
  4972. if( j == MAX_SKILL_TREE || skill_tree[c][j].skill_id == 0 )
  4973. {
  4974. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4975. return 0;
  4976. }
  4977. ent = &skill_tree[c][j];
  4978. meets = 1;
  4979. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4980. {
  4981. if( ent->need[j].skill_id && pc_checkskill(sd,ent->need[j].skill_id) < ent->need[j].skill_lv)
  4982. {
  4983. 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.
  4984. clif_displaymessage(fd, atcmd_output);
  4985. meets = 0;
  4986. }
  4987. }
  4988. if (meets == 1) {
  4989. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4990. }
  4991. return 0;
  4992. }
  4993. // Hand a ring with partners name on it to this char
  4994. void getring (struct map_session_data* sd)
  4995. {
  4996. char flag = 0;
  4997. unsigned short item_id;
  4998. struct item item_tmp;
  4999. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  5000. memset(&item_tmp, 0, sizeof(item_tmp));
  5001. item_tmp.nameid = item_id;
  5002. item_tmp.identify = 1;
  5003. item_tmp.card[0] = 255;
  5004. item_tmp.card[2] = sd->status.partner_id;
  5005. item_tmp.card[3] = sd->status.partner_id >> 16;
  5006. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  5007. clif_additem(sd,0,0,flag);
  5008. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  5009. }
  5010. }
  5011. /*==========================================
  5012. * @marry by [MouseJstr], fixed by Lupus
  5013. * Marry two players
  5014. *------------------------------------------*/
  5015. ACMD_FUNC(marry)
  5016. {
  5017. struct map_session_data *pl_sd = NULL;
  5018. nullpo_retr(-1, sd);
  5019. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5020. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5021. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  5022. return -1;
  5023. }
  5024. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  5025. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5026. return -1;
  5027. }
  5028. if (pc_marriage(sd, pl_sd)) {
  5029. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  5030. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  5031. if( pl_sd->bl.m != sd->bl.m )
  5032. clif_wedding_effect(&sd->bl);
  5033. getring(sd); // Auto-give named rings (Aru)
  5034. getring(pl_sd);
  5035. return 0;
  5036. }
  5037. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  5038. return -1;
  5039. }
  5040. /*==========================================
  5041. * @divorce by [MouseJstr], fixed by [Lupus]
  5042. * divorce two players
  5043. *------------------------------------------*/
  5044. ACMD_FUNC(divorce)
  5045. {
  5046. nullpo_retr(-1, sd);
  5047. if (!pc_divorce(sd)) {
  5048. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  5049. clif_displaymessage(fd, atcmd_output);
  5050. return -1;
  5051. }
  5052. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  5053. clif_displaymessage(fd, atcmd_output);
  5054. return 0;
  5055. }
  5056. /*==========================================
  5057. * @changelook by [Celest]
  5058. *------------------------------------------*/
  5059. ACMD_FUNC(changelook)
  5060. {
  5061. int i, j = 0, k = 0;
  5062. int pos[8] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE, LOOK_BODY2 };
  5063. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  5064. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  5065. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe 8-Body
  5066. return -1;
  5067. } else if ( i == 2 ) {
  5068. if (j < 1 || j > 8)
  5069. j = 1;
  5070. j = pos[j - 1];
  5071. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  5072. k = j; // swap
  5073. j = LOOK_HEAD_TOP;
  5074. }
  5075. clif_changelook(&sd->bl,j,k);
  5076. return 0;
  5077. }
  5078. /*==========================================
  5079. * @autotrade by durf [Lupus] [Paradox924X]
  5080. * Turns on/off Autotrade for a specific player
  5081. *------------------------------------------*/
  5082. ACMD_FUNC(autotrade) {
  5083. nullpo_retr(-1, sd);
  5084. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  5085. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  5086. return -1;
  5087. }
  5088. if( pc_isdead(sd) ) {
  5089. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  5090. return -1;
  5091. }
  5092. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  5093. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  5094. return -1;
  5095. }
  5096. sd->state.autotrade = 1;
  5097. if (battle_config.autotrade_monsterignore)
  5098. sd->state.monster_ignore = 1;
  5099. if( sd->state.vending ){
  5100. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
  5101. Sql_ShowDebug( mmysql_handle );
  5102. }
  5103. }else if( sd->state.buyingstore ){
  5104. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_table, sd->buyer_id ) != SQL_SUCCESS ){
  5105. Sql_ShowDebug( mmysql_handle );
  5106. }
  5107. }
  5108. if( battle_config.at_timeout ) {
  5109. int timeout = atoi(message);
  5110. 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);
  5111. }
  5112. channel_pcquit(sd,0xF); //leave all chan
  5113. clif_authfail_fd(sd->fd, 15);
  5114. chrif_save(sd, CSAVE_AUTOTRADE);
  5115. return 0;
  5116. }
  5117. /*==========================================
  5118. * @changegm by durf (changed by Lupus)
  5119. * Changes Master of your Guild to a specified guild member
  5120. *------------------------------------------*/
  5121. ACMD_FUNC(changegm)
  5122. {
  5123. struct guild *g;
  5124. struct map_session_data *pl_sd;
  5125. nullpo_retr(-1, sd);
  5126. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5127. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  5128. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  5129. return -1;
  5130. }
  5131. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  5132. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  5133. return -1;
  5134. }
  5135. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5136. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  5137. return -1;
  5138. }
  5139. if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  5140. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  5141. return -1;
  5142. }
  5143. guild_gm_change(sd->status.guild_id, pl_sd->status.char_id);
  5144. return 0;
  5145. }
  5146. /*==========================================
  5147. * @changeleader by Skotlex
  5148. * Changes the leader of a party.
  5149. *------------------------------------------*/
  5150. ACMD_FUNC(changeleader)
  5151. {
  5152. nullpo_retr(-1, sd);
  5153. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5154. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5155. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5156. return -1;
  5157. }
  5158. party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
  5159. return 0;
  5160. }
  5161. /*==========================================
  5162. * @partyoption by Skotlex
  5163. * Used to change the item share setting of a party.
  5164. *------------------------------------------*/
  5165. ACMD_FUNC(partyoption)
  5166. {
  5167. struct party_data *p;
  5168. int mi, option;
  5169. char w1[16], w2[16];
  5170. nullpo_retr(-1, sd);
  5171. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5172. {
  5173. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5174. return -1;
  5175. }
  5176. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5177. if (mi == MAX_PARTY)
  5178. return -1; //Shouldn't happen
  5179. if (!p->party.member[mi].leader)
  5180. {
  5181. clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
  5182. return -1;
  5183. }
  5184. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5185. {
  5186. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5187. return -1;
  5188. }
  5189. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5190. //Change item share type.
  5191. if (option != p->party.item)
  5192. party_changeoption(sd, p->party.exp, option);
  5193. else
  5194. clif_displaymessage(fd, msg_txt(sd,286)); // There's been no change in the setting.
  5195. return 0;
  5196. }
  5197. /*==========================================
  5198. * @autoloot by Upa-Kun
  5199. * Turns on/off AutoLoot for a specific player
  5200. *------------------------------------------*/
  5201. ACMD_FUNC(autoloot)
  5202. {
  5203. int rate;
  5204. nullpo_retr(-1, sd);
  5205. // autoloot command without value
  5206. if(!message || !*message)
  5207. {
  5208. if (sd->state.autoloot)
  5209. rate = 0;
  5210. else
  5211. rate = 10000;
  5212. } else {
  5213. double drate;
  5214. drate = atof(message);
  5215. rate = (int)(drate*100);
  5216. }
  5217. if (rate < 0) rate = 0;
  5218. if (rate > 10000) rate = 10000;
  5219. sd->state.autoloot = rate;
  5220. if (sd->state.autoloot) {
  5221. 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.
  5222. clif_displaymessage(fd, atcmd_output);
  5223. }else
  5224. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5225. return 0;
  5226. }
  5227. /*==========================================
  5228. * @alootid
  5229. *------------------------------------------*/
  5230. ACMD_FUNC(autolootitem)
  5231. {
  5232. struct item_data *item_data = NULL;
  5233. int i;
  5234. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5235. nullpo_retr(-1, sd);
  5236. if (message && *message) {
  5237. if (message[0] == '+') {
  5238. message++;
  5239. action = 1;
  5240. }
  5241. else if (message[0] == '-') {
  5242. message++;
  5243. action = 2;
  5244. }
  5245. else if (!strcmp(message,"reset"))
  5246. action = 4;
  5247. }
  5248. if (action < 3) // add or remove
  5249. {
  5250. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5251. item_data = itemdb_searchname(message);
  5252. if (!item_data) {
  5253. // No items founds in the DB with Id or Name
  5254. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5255. return -1;
  5256. }
  5257. }
  5258. switch(action) {
  5259. case 1:
  5260. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5261. if (i != AUTOLOOTITEM_SIZE) {
  5262. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5263. return -1;
  5264. }
  5265. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5266. if (i == AUTOLOOTITEM_SIZE) {
  5267. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5268. return -1;
  5269. }
  5270. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5271. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5272. clif_displaymessage(fd, atcmd_output);
  5273. sd->state.autolooting = 1;
  5274. break;
  5275. case 2:
  5276. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5277. if (i == AUTOLOOTITEM_SIZE) {
  5278. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5279. return -1;
  5280. }
  5281. sd->state.autolootid[i] = 0;
  5282. 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.
  5283. clif_displaymessage(fd, atcmd_output);
  5284. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5285. if (i == AUTOLOOTITEM_SIZE) {
  5286. sd->state.autolooting = 0;
  5287. }
  5288. break;
  5289. case 3:
  5290. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5291. clif_displaymessage(fd, atcmd_output);
  5292. 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>".
  5293. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5294. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5295. if (i == AUTOLOOTITEM_SIZE) {
  5296. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5297. } else {
  5298. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5299. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5300. {
  5301. if (sd->state.autolootid[i] == 0)
  5302. continue;
  5303. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5304. 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);
  5305. continue;
  5306. }
  5307. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5308. clif_displaymessage(fd, atcmd_output);
  5309. }
  5310. }
  5311. break;
  5312. case 4:
  5313. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5314. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5315. sd->state.autolooting = 0;
  5316. break;
  5317. }
  5318. return 0;
  5319. }
  5320. /*==========================================
  5321. * @autoloottype
  5322. * Flags:
  5323. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5324. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5325. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5326. * 262144: IT_CASH
  5327. *------------------------------------------
  5328. * Credits:
  5329. * chriser
  5330. * Aleos
  5331. *------------------------------------------*/
  5332. ACMD_FUNC(autoloottype)
  5333. {
  5334. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5335. enum item_types type= IT_UNKNOWN;
  5336. int ITEM_MAX = 1533;
  5337. nullpo_retr(-1, sd);
  5338. if (message && *message) {
  5339. if (message[0] == '+') {
  5340. message++;
  5341. action = 1;
  5342. }
  5343. else if (message[0] == '-') {
  5344. message++;
  5345. action = 2;
  5346. }
  5347. else if (!strcmp(message,"reset"))
  5348. action = 4;
  5349. }
  5350. if (action < 3) { // add or remove
  5351. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5352. type = IT_HEALING;
  5353. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5354. type = IT_USABLE;
  5355. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5356. type = IT_ETC;
  5357. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5358. type = IT_ARMOR;
  5359. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5360. type = IT_WEAPON;
  5361. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5362. type = IT_CARD;
  5363. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5364. type = IT_PETEGG;
  5365. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5366. type = IT_PETARMOR;
  5367. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5368. type = IT_AMMO;
  5369. else {
  5370. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5371. return -1;
  5372. }
  5373. }
  5374. switch (action) {
  5375. case 1:
  5376. if (sd->state.autoloottype&(1<<type)) {
  5377. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5378. return -1;
  5379. }
  5380. if (sd->state.autoloottype == ITEM_MAX) {
  5381. 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>.
  5382. return -1;
  5383. }
  5384. sd->state.autoloottype |= (1<<type); // Stores the type
  5385. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5386. clif_displaymessage(fd, atcmd_output);
  5387. break;
  5388. case 2:
  5389. if (!(sd->state.autoloottype&(1<<type))) {
  5390. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5391. return -1;
  5392. }
  5393. sd->state.autoloottype &= ~(1<<type);
  5394. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5395. clif_displaymessage(fd, atcmd_output);
  5396. break;
  5397. case 3:
  5398. 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>".
  5399. 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
  5400. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5401. if (sd->state.autoloottype == 0)
  5402. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5403. else {
  5404. uint8 i = 0;
  5405. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5406. while (i < IT_MAX) {
  5407. if (sd->state.autoloottype&(1<<i)) {
  5408. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(static_cast<item_types>(i)), i);
  5409. clif_displaymessage(fd, atcmd_output);
  5410. }
  5411. i++;
  5412. }
  5413. }
  5414. break;
  5415. case 4:
  5416. sd->state.autoloottype = 0;
  5417. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5418. break;
  5419. }
  5420. return 0;
  5421. }
  5422. /**
  5423. * No longer available, keeping here just in case it's back someday. [Ind]
  5424. **/
  5425. /*==========================================
  5426. * It is made to rain.
  5427. *------------------------------------------*/
  5428. //ACMD_FUNC(rain)
  5429. //{
  5430. // nullpo_retr(-1, sd);
  5431. // if (map[sd->bl.m].flag.rain) {
  5432. // map[sd->bl.m].flag.rain=0;
  5433. // clif_weather(sd->bl.m);
  5434. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5435. // } else {
  5436. // map[sd->bl.m].flag.rain=1;
  5437. // clif_weather(sd->bl.m);
  5438. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5439. // }
  5440. // return 0;
  5441. //}
  5442. /*==========================================
  5443. * It is made to snow.
  5444. *------------------------------------------*/
  5445. ACMD_FUNC(snow)
  5446. {
  5447. nullpo_retr(-1, sd);
  5448. if (map[sd->bl.m].flag.snow) {
  5449. map[sd->bl.m].flag.snow=0;
  5450. clif_weather(sd->bl.m);
  5451. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5452. } else {
  5453. map[sd->bl.m].flag.snow=1;
  5454. clif_weather(sd->bl.m);
  5455. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5456. }
  5457. return 0;
  5458. }
  5459. /*==========================================
  5460. * Cherry tree snowstorm is made to fall. (Sakura)
  5461. *------------------------------------------*/
  5462. ACMD_FUNC(sakura)
  5463. {
  5464. nullpo_retr(-1, sd);
  5465. if (map[sd->bl.m].flag.sakura) {
  5466. map[sd->bl.m].flag.sakura=0;
  5467. clif_weather(sd->bl.m);
  5468. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5469. } else {
  5470. map[sd->bl.m].flag.sakura=1;
  5471. clif_weather(sd->bl.m);
  5472. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5473. }
  5474. return 0;
  5475. }
  5476. /*==========================================
  5477. * Clouds appear.
  5478. *------------------------------------------*/
  5479. ACMD_FUNC(clouds)
  5480. {
  5481. nullpo_retr(-1, sd);
  5482. if (map[sd->bl.m].flag.clouds) {
  5483. map[sd->bl.m].flag.clouds=0;
  5484. clif_weather(sd->bl.m);
  5485. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5486. } else {
  5487. map[sd->bl.m].flag.clouds=1;
  5488. clif_weather(sd->bl.m);
  5489. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5490. }
  5491. return 0;
  5492. }
  5493. /*==========================================
  5494. * Different type of clouds using effect 516
  5495. *------------------------------------------*/
  5496. ACMD_FUNC(clouds2)
  5497. {
  5498. nullpo_retr(-1, sd);
  5499. if (map[sd->bl.m].flag.clouds2) {
  5500. map[sd->bl.m].flag.clouds2=0;
  5501. clif_weather(sd->bl.m);
  5502. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5503. } else {
  5504. map[sd->bl.m].flag.clouds2=1;
  5505. clif_weather(sd->bl.m);
  5506. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5507. }
  5508. return 0;
  5509. }
  5510. /*==========================================
  5511. * Fog hangs over.
  5512. *------------------------------------------*/
  5513. ACMD_FUNC(fog)
  5514. {
  5515. nullpo_retr(-1, sd);
  5516. if (map[sd->bl.m].flag.fog) {
  5517. map[sd->bl.m].flag.fog=0;
  5518. clif_weather(sd->bl.m);
  5519. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5520. } else {
  5521. map[sd->bl.m].flag.fog=1;
  5522. clif_weather(sd->bl.m);
  5523. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5524. }
  5525. return 0;
  5526. }
  5527. /*==========================================
  5528. * Fallen leaves fall.
  5529. *------------------------------------------*/
  5530. ACMD_FUNC(leaves)
  5531. {
  5532. nullpo_retr(-1, sd);
  5533. if (map[sd->bl.m].flag.leaves) {
  5534. map[sd->bl.m].flag.leaves=0;
  5535. clif_weather(sd->bl.m);
  5536. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5537. } else {
  5538. map[sd->bl.m].flag.leaves=1;
  5539. clif_weather(sd->bl.m);
  5540. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5541. }
  5542. return 0;
  5543. }
  5544. /*==========================================
  5545. * Fireworks appear.
  5546. *------------------------------------------*/
  5547. ACMD_FUNC(fireworks)
  5548. {
  5549. nullpo_retr(-1, sd);
  5550. if (map[sd->bl.m].flag.fireworks) {
  5551. map[sd->bl.m].flag.fireworks=0;
  5552. clif_weather(sd->bl.m);
  5553. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5554. } else {
  5555. map[sd->bl.m].flag.fireworks=1;
  5556. clif_weather(sd->bl.m);
  5557. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5558. }
  5559. return 0;
  5560. }
  5561. /*==========================================
  5562. * Clearing Weather Effects by Dexity
  5563. *------------------------------------------*/
  5564. ACMD_FUNC(clearweather)
  5565. {
  5566. nullpo_retr(-1, sd);
  5567. /**
  5568. * No longer available, keeping here just in case it's back someday. [Ind]
  5569. **/
  5570. //map[sd->bl.m].flag.rain=0;
  5571. map[sd->bl.m].flag.snow=0;
  5572. map[sd->bl.m].flag.sakura=0;
  5573. map[sd->bl.m].flag.clouds=0;
  5574. map[sd->bl.m].flag.clouds2=0;
  5575. map[sd->bl.m].flag.fog=0;
  5576. map[sd->bl.m].flag.fireworks=0;
  5577. map[sd->bl.m].flag.leaves=0;
  5578. clif_weather(sd->bl.m);
  5579. clif_displaymessage(fd, msg_txt(sd,291)); // Weather effects will dispell on warp/refresh
  5580. return 0;
  5581. }
  5582. /*===============================================================
  5583. * Sound Command - plays a sound for everyone around! [Codemaster]
  5584. *---------------------------------------------------------------*/
  5585. ACMD_FUNC(sound)
  5586. {
  5587. char sound_file[100];
  5588. memset(sound_file, '\0', sizeof(sound_file));
  5589. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5590. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5591. return -1;
  5592. }
  5593. if(strstr(sound_file, ".wav") == NULL)
  5594. strcat(sound_file, ".wav");
  5595. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5596. return 0;
  5597. }
  5598. /*==========================================
  5599. * MOB Search
  5600. *------------------------------------------*/
  5601. ACMD_FUNC(mobsearch)
  5602. {
  5603. char mob_name[100];
  5604. int mob_id;
  5605. int number = 0;
  5606. struct s_mapiterator* it;
  5607. nullpo_retr(-1, sd);
  5608. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5609. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5610. return -1;
  5611. }
  5612. if ((mob_id = atoi(mob_name)) == 0)
  5613. mob_id = mobdb_searchname(mob_name);
  5614. if( mobdb_checkid(mob_id) == 0){
  5615. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5616. clif_displaymessage(fd, atcmd_output);
  5617. return -1;
  5618. }
  5619. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5620. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5621. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5622. clif_displaymessage(fd, atcmd_output);
  5623. it = mapit_geteachmob();
  5624. for(;;)
  5625. {
  5626. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5627. if( md == NULL )
  5628. break;// no more mobs
  5629. if( md->bl.m != sd->bl.m )
  5630. continue;
  5631. if( md->mob_id != mob_id )
  5632. continue;
  5633. ++number;
  5634. if( md->spawn_timer == INVALID_TIMER )
  5635. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5636. else
  5637. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5638. clif_displaymessage(fd, atcmd_output);
  5639. }
  5640. mapit_free(it);
  5641. return 0;
  5642. }
  5643. /*==========================================
  5644. * @cleanmap - cleans items on the ground
  5645. * @cleanarea - cleans items on the ground within an specified area
  5646. *------------------------------------------*/
  5647. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5648. {
  5649. nullpo_ret(bl);
  5650. map_clearflooritem(bl);
  5651. return 0;
  5652. }
  5653. ACMD_FUNC(cleanmap)
  5654. {
  5655. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5656. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5657. return 0;
  5658. }
  5659. ACMD_FUNC(cleanarea)
  5660. {
  5661. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5662. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5663. 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);
  5664. }
  5665. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5666. 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);
  5667. }
  5668. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5669. map_foreachinallarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5670. }
  5671. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5672. return 0;
  5673. }
  5674. /*==========================================
  5675. * make a NPC/PET talk
  5676. * @npctalkc [SnakeDrak]
  5677. *------------------------------------------*/
  5678. ACMD_FUNC(npctalk)
  5679. {
  5680. char name[NPC_NAME_LENGTH],mes[100],temp[100];
  5681. struct npc_data *nd;
  5682. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5683. unsigned long color=0;
  5684. if (sd->sc.cant.chat)
  5685. return -1; //no "chatting" while muted.
  5686. if(!ifcolor) {
  5687. if (!message || !*message || sscanf(message, "%49[^,], %99[^\n]", name, mes) < 2) {
  5688. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5689. return -1;
  5690. }
  5691. }
  5692. else {
  5693. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5694. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5695. return -1;
  5696. }
  5697. }
  5698. if (!(nd = npc_name2id(name))) {
  5699. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5700. return -1;
  5701. }
  5702. strtok(name, "#"); // discard extra name identifier if present
  5703. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5704. if(ifcolor) clif_messagecolor(&nd->bl,color,temp,true,AREA_CHAT_WOC);
  5705. else clif_disp_overhead(&nd->bl, temp);
  5706. return 0;
  5707. }
  5708. ACMD_FUNC(pettalk)
  5709. {
  5710. char mes[100],temp[100];
  5711. struct pet_data *pd;
  5712. nullpo_retr(-1, sd);
  5713. if ( battle_config.min_chat_delay ) {
  5714. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5715. return 0;
  5716. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5717. }
  5718. if(!sd->status.pet_id || !(pd=sd->pd))
  5719. {
  5720. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  5721. return -1;
  5722. }
  5723. if (sd->sc.cant.chat)
  5724. return -1; //no "chatting" while muted.
  5725. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5726. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5727. return -1;
  5728. }
  5729. if (message[0] == '/')
  5730. {// pet emotion processing
  5731. const char* emo[] = {
  5732. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5733. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5734. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5735. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5736. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5737. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5738. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5739. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5740. "/whisp"
  5741. };
  5742. int i;
  5743. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5744. if( i == ET_DICE1 ) i = rnd()%6 + ET_DICE1; // randomize /dice
  5745. if( i < ARRAYLENGTH(emo) )
  5746. {
  5747. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5748. sd->emotionlasttime = time(NULL);
  5749. return 0;
  5750. }
  5751. sd->emotionlasttime = time(NULL);
  5752. clif_emotion(&pd->bl, i);
  5753. return 0;
  5754. }
  5755. }
  5756. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5757. clif_disp_overhead(&pd->bl, temp);
  5758. return 0;
  5759. }
  5760. /// @users - displays the number of players present on each map (and percentage)
  5761. /// #users displays on the target user instead of self
  5762. ACMD_FUNC(users)
  5763. {
  5764. char buf[CHAT_SIZE_MAX];
  5765. int i;
  5766. int users[MAX_MAPINDEX];
  5767. int users_all;
  5768. struct s_mapiterator* iter;
  5769. memset(users, 0, sizeof(users));
  5770. users_all = 0;
  5771. // count users on each map
  5772. iter = mapit_getallusers();
  5773. for(;;)
  5774. {
  5775. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5776. if( sd2 == NULL )
  5777. break;// no more users
  5778. if( sd2->mapindex >= MAX_MAPINDEX )
  5779. continue;// invalid mapindex
  5780. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5781. if( users_all < INT_MAX ) ++users_all;
  5782. }
  5783. mapit_free(iter);
  5784. // display results for each map
  5785. for( i = 0; i < MAX_MAPINDEX; ++i )
  5786. {
  5787. if( users[i] == 0 )
  5788. continue;// empty
  5789. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5790. clif_displaymessage(sd->fd, buf);
  5791. }
  5792. // display overall count
  5793. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5794. clif_displaymessage(sd->fd, buf);
  5795. return 0;
  5796. }
  5797. /*==========================================
  5798. *
  5799. *------------------------------------------*/
  5800. ACMD_FUNC(reset)
  5801. {
  5802. pc_resetstate(sd);
  5803. pc_resetskill(sd,1);
  5804. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5805. clif_displaymessage(fd, atcmd_output);
  5806. return 0;
  5807. }
  5808. /*==========================================
  5809. *
  5810. *------------------------------------------*/
  5811. ACMD_FUNC(summon)
  5812. {
  5813. char name[NAME_LENGTH];
  5814. int mob_id = 0;
  5815. int duration = 0;
  5816. struct mob_data *md;
  5817. unsigned int tick=gettick();
  5818. nullpo_retr(-1, sd);
  5819. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5820. {
  5821. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5822. return -1;
  5823. }
  5824. if (duration < 1)
  5825. duration =1;
  5826. else if (duration > 60)
  5827. duration =60;
  5828. if ((mob_id = atoi(name)) == 0)
  5829. mob_id = mobdb_searchname(name);
  5830. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5831. {
  5832. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5833. return -1;
  5834. }
  5835. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5836. if(!md)
  5837. return -1;
  5838. md->master_id=sd->bl.id;
  5839. md->special_state.ai=AI_ATTACK;
  5840. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5841. clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
  5842. mob_spawn(md);
  5843. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5844. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5845. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5846. return 0;
  5847. }
  5848. /*==========================================
  5849. * @adjgroup
  5850. * Temporarily move player to another group
  5851. * Useful during beta testing to allow players to use GM commands for short periods of time
  5852. *------------------------------------------*/
  5853. ACMD_FUNC(adjgroup)
  5854. {
  5855. int new_group = 0;
  5856. nullpo_retr(-1, sd);
  5857. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5858. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5859. return -1;
  5860. }
  5861. if (!pc_group_exists(new_group)) {
  5862. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5863. return -1;
  5864. }
  5865. sd->group_id = new_group;
  5866. pc_group_pc_load(sd);/* update cache */
  5867. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5868. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5869. return 0;
  5870. }
  5871. /*==========================================
  5872. * @trade by [MouseJstr]
  5873. * Open a trade window with a remote player
  5874. *------------------------------------------*/
  5875. ACMD_FUNC(trade)
  5876. {
  5877. struct map_session_data *pl_sd = NULL;
  5878. nullpo_retr(-1, sd);
  5879. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5880. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5881. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5882. return -1;
  5883. }
  5884. if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
  5885. {
  5886. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5887. return -1;
  5888. }
  5889. trade_traderequest(sd, pl_sd);
  5890. return 0;
  5891. }
  5892. /*==========================================
  5893. * @setbattleflag by [MouseJstr]
  5894. * set a battle_config flag without having to reboot
  5895. *------------------------------------------*/
  5896. ACMD_FUNC(setbattleflag)
  5897. {
  5898. char flag[128], value[128];
  5899. int reload = 0;
  5900. nullpo_retr(-1, sd);
  5901. if (!message || !*message || sscanf(message, "%127s %127s %11d", flag, value, &reload) != 2) {
  5902. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value> {<reload>}
  5903. return -1;
  5904. }
  5905. if (battle_set_value(flag, value) == 0)
  5906. {
  5907. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5908. return -1;
  5909. }
  5910. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5911. if (reload)
  5912. mob_reload();
  5913. return 0;
  5914. }
  5915. /*==========================================
  5916. * @unmute [Valaris]
  5917. *------------------------------------------*/
  5918. ACMD_FUNC(unmute)
  5919. {
  5920. struct map_session_data *pl_sd = NULL;
  5921. nullpo_retr(-1, sd);
  5922. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  5923. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  5924. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5925. return -1;
  5926. }
  5927. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  5928. {
  5929. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5930. return -1;
  5931. }
  5932. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5933. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5934. return -1;
  5935. }
  5936. pl_sd->status.manner = 0;
  5937. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5938. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5939. return 0;
  5940. }
  5941. /*==========================================
  5942. * @uptime by MC Cameri
  5943. *------------------------------------------*/
  5944. ACMD_FUNC(uptime)
  5945. {
  5946. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5947. minute = 60, days = 0, hours = 0, minutes = 0;
  5948. nullpo_retr(-1, sd);
  5949. seconds = get_uptime();
  5950. days = seconds/day;
  5951. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5952. hours = seconds/hour;
  5953. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5954. minutes = seconds/minute;
  5955. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5956. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds); // Server Uptime: %ld days, %ld hours, %ld minutes, %ld seconds.
  5957. clif_displaymessage(fd, atcmd_output);
  5958. return 0;
  5959. }
  5960. /*==========================================
  5961. * @changesex
  5962. * => Changes one's account sex. Switch from male to female or visversa
  5963. *------------------------------------------*/
  5964. ACMD_FUNC(changesex)
  5965. {
  5966. int i;
  5967. nullpo_retr(-1, sd);
  5968. pc_resetskill(sd,4);
  5969. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5970. for (i = 0; i < EQI_MAX; i++) {
  5971. if (sd->equip_index[i] >= 0)
  5972. pc_unequipitem(sd, sd->equip_index[i], 3);
  5973. }
  5974. chrif_changesex(sd, true);
  5975. return 0;
  5976. }
  5977. /*==========================================
  5978. * @changecharsex
  5979. * => Changes one's character sex. Switch from male to female or visversa.
  5980. *------------------------------------------*/
  5981. ACMD_FUNC(changecharsex)
  5982. {
  5983. int i;
  5984. nullpo_retr(-1, sd);
  5985. pc_resetskill(sd,4);
  5986. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5987. for (i = 0; i < EQI_MAX; i++) {
  5988. if (sd->equip_index[i] >= 0)
  5989. pc_unequipitem(sd, sd->equip_index[i], 3);
  5990. }
  5991. chrif_changesex(sd, false);
  5992. return 0;
  5993. }
  5994. /*================================================
  5995. * @mute - Mutes a player for a set amount of time
  5996. *------------------------------------------------*/
  5997. ACMD_FUNC(mute)
  5998. {
  5999. struct map_session_data *pl_sd = NULL;
  6000. int manner;
  6001. nullpo_retr(-1, sd);
  6002. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  6003. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  6004. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  6005. return -1;
  6006. }
  6007. if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
  6008. {
  6009. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6010. return -1;
  6011. }
  6012. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  6013. {
  6014. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  6015. return -1;
  6016. }
  6017. clif_manner_message(sd, 0);
  6018. clif_manner_message(pl_sd, 5);
  6019. if( pl_sd->status.manner < manner ) {
  6020. pl_sd->status.manner -= manner;
  6021. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6022. } else {
  6023. pl_sd->status.manner = 0;
  6024. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6025. }
  6026. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  6027. return 0;
  6028. }
  6029. /*==========================================
  6030. * @refresh (like @jumpto <<yourself>>)
  6031. *------------------------------------------*/
  6032. ACMD_FUNC(refresh)
  6033. {
  6034. nullpo_retr(-1, sd);
  6035. clif_refresh(sd);
  6036. return 0;
  6037. }
  6038. ACMD_FUNC(refreshall)
  6039. {
  6040. struct map_session_data* iter_sd;
  6041. struct s_mapiterator* iter;
  6042. nullpo_retr(-1, sd);
  6043. iter = mapit_getallusers();
  6044. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  6045. clif_refresh(iter_sd);
  6046. mapit_free(iter);
  6047. return 0;
  6048. }
  6049. /*==========================================
  6050. * @identify
  6051. * => GM's magnifier.
  6052. *------------------------------------------*/
  6053. ACMD_FUNC(identify)
  6054. {
  6055. int i,num;
  6056. nullpo_retr(-1, sd);
  6057. for(i=num=0;i<MAX_INVENTORY;i++){
  6058. if(sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6059. num++;
  6060. }
  6061. }
  6062. if (num > 0) {
  6063. clif_item_identify_list(sd);
  6064. } else {
  6065. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  6066. }
  6067. return 0;
  6068. }
  6069. /*===============================================
  6070. * @identifyall
  6071. * => Indentify all items in inventory - Akinari
  6072. *-----------------------------------------------*/
  6073. ACMD_FUNC(identifyall)
  6074. {
  6075. int i;
  6076. nullpo_retr(-1, sd);
  6077. for(i=0; i<MAX_INVENTORY; i++) {
  6078. if (sd->inventory.u.items_inventory[i].nameid > 0 && sd->inventory.u.items_inventory[i].identify != 1) {
  6079. sd->inventory.u.items_inventory[i].identify = 1;
  6080. clif_item_identified(sd,i,0);
  6081. }
  6082. }
  6083. return 0;
  6084. }
  6085. /*==========================================
  6086. * @gmotd (Global MOTD)
  6087. * by davidsiaw :P
  6088. *------------------------------------------*/
  6089. ACMD_FUNC(gmotd)
  6090. {
  6091. FILE* fp;
  6092. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  6093. {
  6094. char buf[CHAT_SIZE_MAX];
  6095. size_t len;
  6096. while( fgets(buf, sizeof(buf), fp) )
  6097. {
  6098. if( buf[0] == '/' && buf[1] == '/' )
  6099. {
  6100. continue;
  6101. }
  6102. len = strlen(buf);
  6103. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  6104. {// strip trailing EOL characters
  6105. len--;
  6106. }
  6107. if( len )
  6108. {
  6109. buf[len] = 0;
  6110. intif_broadcast(buf, len+1, 0);
  6111. }
  6112. }
  6113. fclose(fp);
  6114. }
  6115. return 0;
  6116. }
  6117. ACMD_FUNC(misceffect)
  6118. {
  6119. int effect = 0;
  6120. nullpo_retr(-1, sd);
  6121. if (!message || !*message)
  6122. return -1;
  6123. if (sscanf(message, "%11d", &effect) < 1)
  6124. return -1;
  6125. clif_misceffect(&sd->bl,effect);
  6126. return 0;
  6127. }
  6128. /*==========================================
  6129. * MAIL SYSTEM
  6130. *------------------------------------------*/
  6131. ACMD_FUNC(mail)
  6132. {
  6133. nullpo_ret(sd);
  6134. mail_openmail(sd);
  6135. return 0;
  6136. }
  6137. /*==========================================
  6138. * Show Monster DB Info v 1.0
  6139. * originally by [Lupus]
  6140. *------------------------------------------*/
  6141. ACMD_FUNC(mobinfo)
  6142. {
  6143. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  6144. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  6145. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  6146. char atcmd_output2[CHAT_SIZE_MAX];
  6147. struct item_data *item_data;
  6148. struct mob_db *mob;
  6149. uint16 mob_ids[MAX_SEARCH];
  6150. int count;
  6151. int i, k;
  6152. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6153. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6154. if (!message || !*message) {
  6155. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6156. return -1;
  6157. }
  6158. // If monster identifier/name argument is a name
  6159. if ((i = mobdb_checkid(atoi(message))))
  6160. {
  6161. mob_ids[0] = i;
  6162. count = 1;
  6163. } else
  6164. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6165. if (!count) {
  6166. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6167. return -1;
  6168. }
  6169. if (count >= MAX_SEARCH) {
  6170. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6171. clif_displaymessage(fd, atcmd_output);
  6172. count = MAX_SEARCH;
  6173. }
  6174. for (k = 0; k < count; k++) {
  6175. unsigned int j,base_exp,job_exp;
  6176. mob = mob_db(mob_ids[k]);
  6177. base_exp = mob->base_exp;
  6178. job_exp = mob->job_exp;
  6179. if (pc_isvip(sd)) { // Display EXP rate increase for VIP
  6180. base_exp = (base_exp * battle_config.vip_base_exp_increase) / 100;
  6181. job_exp = (job_exp * battle_config.vip_job_exp_increase) / 100;
  6182. }
  6183. #ifdef RENEWAL_EXP
  6184. if( battle_config.atcommand_mobinfo_type ) {
  6185. base_exp = base_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6186. job_exp = job_exp * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 1) / 100;
  6187. }
  6188. #endif
  6189. // stats
  6190. if (mob->mexp)
  6191. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6192. else
  6193. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6194. clif_displaymessage(fd, atcmd_output);
  6195. 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
  6196. clif_displaymessage(fd, atcmd_output);
  6197. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6198. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6199. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6200. clif_displaymessage(fd, atcmd_output);
  6201. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6202. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6203. mob->range2 , mob->range3, msize[mob->status.size],
  6204. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6205. clif_displaymessage(fd, atcmd_output);
  6206. // drops
  6207. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6208. strcpy(atcmd_output, " ");
  6209. j = 0;
  6210. for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
  6211. int droprate;
  6212. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6213. continue;
  6214. droprate = mob->dropitem[i].p;
  6215. #ifdef RENEWAL_DROP
  6216. if( battle_config.atcommand_mobinfo_type ) {
  6217. droprate = droprate * pc_level_penalty_mod(mob->lv - sd->status.base_level, mob->status.class_, mob->status.mode, 2) / 100;
  6218. if (droprate <= 0 && !battle_config.drop_rate0item)
  6219. droprate = 1;
  6220. }
  6221. #endif
  6222. if (pc_isvip(sd)) // Display drop rate increase for VIP
  6223. droprate += (droprate * battle_config.vip_drop_increase) / 100;
  6224. if (item_data->slot)
  6225. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6226. else
  6227. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6228. strcat(atcmd_output, atcmd_output2);
  6229. if (++j % 3 == 0) {
  6230. clif_displaymessage(fd, atcmd_output);
  6231. strcpy(atcmd_output, " ");
  6232. }
  6233. }
  6234. if (j == 0)
  6235. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6236. else if (j % 3 != 0)
  6237. clif_displaymessage(fd, atcmd_output);
  6238. // mvp
  6239. if (mob->mexp) {
  6240. float mvppercent, mvpremain;
  6241. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6242. clif_displaymessage(fd, atcmd_output);
  6243. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6244. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6245. j = 0;
  6246. for (i = 0; i < MAX_MVP_DROP_TOTAL; i++) {
  6247. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6248. continue;
  6249. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6250. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6251. if(battle_config.item_drop_mvp_mode == 0) {
  6252. mvpremain -= mvppercent;
  6253. }
  6254. if (mvppercent > 0) {
  6255. j++;
  6256. if (j == 1) {
  6257. if (item_data->slot)
  6258. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6259. else
  6260. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6261. } else {
  6262. if (item_data->slot)
  6263. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6264. else
  6265. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6266. }
  6267. strcat(atcmd_output, atcmd_output2);
  6268. }
  6269. }
  6270. if (j == 0)
  6271. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6272. else
  6273. clif_displaymessage(fd, atcmd_output);
  6274. }
  6275. }
  6276. return 0;
  6277. }
  6278. /*=========================================
  6279. * @showmobs by KarLaeda
  6280. * => For 15 sec displays the mobs on minimap
  6281. *------------------------------------------*/
  6282. ACMD_FUNC(showmobs)
  6283. {
  6284. char mob_name[100];
  6285. int mob_id;
  6286. int number = 0;
  6287. struct s_mapiterator* it;
  6288. nullpo_retr(-1, sd);
  6289. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6290. return -1;
  6291. if((mob_id = atoi(mob_name)) == 0)
  6292. mob_id = mobdb_searchname(mob_name);
  6293. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6294. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6295. clif_displaymessage(fd, atcmd_output);
  6296. return 0;
  6297. }
  6298. 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.
  6299. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6300. return 0;
  6301. }
  6302. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6303. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6304. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6305. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6306. mob_name, mapindex_id2name(sd->mapindex));
  6307. clif_displaymessage(fd, atcmd_output);
  6308. it = mapit_geteachmob();
  6309. for(;;)
  6310. {
  6311. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6312. if( md == NULL )
  6313. break;// no more mobs
  6314. if( md->bl.m != sd->bl.m )
  6315. continue;
  6316. if( mob_id != -1 && md->mob_id != mob_id )
  6317. continue;
  6318. if( md->special_state.ai || md->master_id )
  6319. continue; // hide slaves and player summoned mobs
  6320. if( md->spawn_timer != INVALID_TIMER )
  6321. continue; // hide mobs waiting for respawn
  6322. ++number;
  6323. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6324. }
  6325. mapit_free(it);
  6326. return 0;
  6327. }
  6328. /*==========================================
  6329. * homunculus level up [orn]
  6330. *------------------------------------------*/
  6331. ACMD_FUNC(homlevel)
  6332. {
  6333. TBL_HOM * hd;
  6334. int level = 0, i = 0;
  6335. nullpo_retr(-1, sd);
  6336. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6337. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6338. return -1;
  6339. }
  6340. if ( !hom_is_active(sd->hd) ) {
  6341. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6342. return -1;
  6343. }
  6344. hd = sd->hd;
  6345. for (i = 1; i <= level && hd->exp_next; i++){
  6346. hd->homunculus.exp += hd->exp_next;
  6347. if( !hom_levelup(hd) )
  6348. break;
  6349. }
  6350. status_calc_homunculus(hd, SCO_NONE);
  6351. status_percent_heal(&hd->bl, 100, 100);
  6352. clif_specialeffect(&hd->bl,EF_HO_UP,AREA);
  6353. return 0;
  6354. }
  6355. /*==========================================
  6356. * homunculus evolution H [orn]
  6357. *------------------------------------------*/
  6358. ACMD_FUNC(homevolution)
  6359. {
  6360. nullpo_retr(-1, sd);
  6361. if ( !hom_is_active(sd->hd) ) {
  6362. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6363. return -1;
  6364. }
  6365. if ( !hom_evolution(sd->hd) ) {
  6366. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6367. return -1;
  6368. }
  6369. clif_homskillinfoblock(sd);
  6370. return 0;
  6371. }
  6372. ACMD_FUNC(hommutate)
  6373. {
  6374. int homun_id, m_class = 0, m_id;
  6375. nullpo_retr(-1, sd);
  6376. if (!hom_is_active(sd->hd)) {
  6377. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6378. return -1;
  6379. }
  6380. if (!message || !*message) {
  6381. homun_id = 6048 + (rnd() % 4);
  6382. } else {
  6383. homun_id = atoi(message);
  6384. }
  6385. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6386. m_id = hom_class2mapid(homun_id);
  6387. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6388. hom_mutate(sd->hd, homun_id);
  6389. } else {
  6390. clif_emotion(&sd->hd->bl, ET_SWEAT);
  6391. }
  6392. return 0;
  6393. }
  6394. /*==========================================
  6395. * call choosen homunculus [orn]
  6396. *------------------------------------------*/
  6397. ACMD_FUNC(makehomun)
  6398. {
  6399. int homunid;
  6400. nullpo_retr(-1, sd);
  6401. if ( sd->status.hom_id ) {
  6402. clif_displaymessage(fd, msg_txt(sd,450)); // You already have a homunculus
  6403. return -1;
  6404. }
  6405. if (!message || !*message) {
  6406. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6407. return -1;
  6408. }
  6409. homunid = atoi(message);
  6410. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6411. {
  6412. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6413. return -1;
  6414. }
  6415. hom_create_request(sd,homunid);
  6416. return 0;
  6417. }
  6418. /*==========================================
  6419. * modify homunculus intimacy [orn]
  6420. *------------------------------------------*/
  6421. ACMD_FUNC(homfriendly)
  6422. {
  6423. int friendly = 0;
  6424. nullpo_retr(-1, sd);
  6425. if ( !hom_is_active(sd->hd) ) {
  6426. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6427. return -1;
  6428. }
  6429. if (!message || !*message) {
  6430. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6431. return -1;
  6432. }
  6433. friendly = atoi(message);
  6434. friendly = cap_value(friendly, 0, 1000);
  6435. sd->hd->homunculus.intimacy = friendly * 100 ;
  6436. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6437. return 0;
  6438. }
  6439. /*==========================================
  6440. * modify homunculus hunger [orn]
  6441. *------------------------------------------*/
  6442. ACMD_FUNC(homhungry)
  6443. {
  6444. int hungry = 0;
  6445. nullpo_retr(-1, sd);
  6446. if ( !hom_is_active(sd->hd) ) {
  6447. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6448. return -1;
  6449. }
  6450. if (!message || !*message) {
  6451. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6452. return -1;
  6453. }
  6454. hungry = atoi(message);
  6455. hungry = cap_value(hungry, 0, 100);
  6456. sd->hd->homunculus.hunger = hungry;
  6457. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6458. return 0;
  6459. }
  6460. /*==========================================
  6461. * make the homunculus speak [orn]
  6462. *------------------------------------------*/
  6463. ACMD_FUNC(homtalk)
  6464. {
  6465. char mes[100],temp[100];
  6466. nullpo_retr(-1, sd);
  6467. if ( battle_config.min_chat_delay ) {
  6468. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6469. return 0;
  6470. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6471. }
  6472. if (sd->sc.cant.chat)
  6473. return -1; //no "chatting" while muted.
  6474. if ( !hom_is_active(sd->hd) ) {
  6475. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6476. return -1;
  6477. }
  6478. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6479. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6480. return -1;
  6481. }
  6482. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6483. clif_disp_overhead(&sd->hd->bl, temp);
  6484. return 0;
  6485. }
  6486. /*==========================================
  6487. * Show homunculus stats
  6488. *------------------------------------------*/
  6489. ACMD_FUNC(hominfo)
  6490. {
  6491. struct homun_data *hd;
  6492. struct status_data *status;
  6493. nullpo_retr(-1, sd);
  6494. if ( !hom_is_active(sd->hd) ) {
  6495. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6496. return -1;
  6497. }
  6498. hd = sd->hd;
  6499. status = status_get_status_data(&hd->bl);
  6500. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6501. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6502. status->hp, status->max_hp, status->sp, status->max_sp);
  6503. clif_displaymessage(fd, atcmd_output);
  6504. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6505. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6506. clif_displaymessage(fd, atcmd_output);
  6507. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6508. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6509. clif_displaymessage(fd, atcmd_output);
  6510. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6511. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6512. status->str, status->agi, status->vit,
  6513. status->int_, status->dex, status->luk);
  6514. clif_displaymessage(fd, atcmd_output);
  6515. return 0;
  6516. }
  6517. ACMD_FUNC(homstats)
  6518. {
  6519. struct homun_data *hd;
  6520. struct s_homunculus_db *db;
  6521. struct s_homunculus *hom;
  6522. int lv, min, max, evo;
  6523. nullpo_retr(-1, sd);
  6524. if ( !hom_is_active(sd->hd) ) {
  6525. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6526. return -1;
  6527. }
  6528. hd = sd->hd;
  6529. hom = &hd->homunculus;
  6530. db = hd->homunculusDB;
  6531. lv = hom->level;
  6532. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6533. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6534. clif_displaymessage(fd, atcmd_output);
  6535. lv--; //Since the first increase is at level 2.
  6536. evo = (hom->class_ == db->evo_class);
  6537. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6538. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6539. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6540. clif_displaymessage(fd, atcmd_output);
  6541. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6542. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6543. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6544. clif_displaymessage(fd, atcmd_output);
  6545. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6546. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6547. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6548. clif_displaymessage(fd, atcmd_output);
  6549. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6550. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6551. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6552. clif_displaymessage(fd, atcmd_output);
  6553. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6554. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6555. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6556. clif_displaymessage(fd, atcmd_output);
  6557. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6558. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6559. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6560. clif_displaymessage(fd, atcmd_output);
  6561. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6562. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6563. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6564. clif_displaymessage(fd, atcmd_output);
  6565. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6566. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6567. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6568. clif_displaymessage(fd, atcmd_output);
  6569. return 0;
  6570. }
  6571. ACMD_FUNC(homshuffle)
  6572. {
  6573. nullpo_retr(-1, sd);
  6574. if(!sd->hd)
  6575. return -1; // nothing to do
  6576. if(!hom_shuffle(sd->hd))
  6577. return -1;
  6578. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6579. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6580. return 0;
  6581. }
  6582. /*==========================================
  6583. * Show Items DB Info v 1.0
  6584. * originally by [Lupus]
  6585. *------------------------------------------*/
  6586. ACMD_FUNC(iteminfo)
  6587. {
  6588. struct item_data *item_array[MAX_SEARCH];
  6589. int i, count = 1;
  6590. if (!message || !*message) {
  6591. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6592. return -1;
  6593. }
  6594. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6595. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6596. if (!count) {
  6597. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6598. return -1;
  6599. }
  6600. if (count == MAX_SEARCH) {
  6601. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6602. clif_displaymessage(fd, atcmd_output);
  6603. }
  6604. for (i = 0; i < count; i++) {
  6605. struct item_data * item_data = item_array[i];
  6606. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6607. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6608. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6609. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6610. );
  6611. clif_displaymessage(fd, atcmd_output);
  6612. 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
  6613. clif_displaymessage(fd, atcmd_output);
  6614. if (item_data->maxchance == -1) {
  6615. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6616. clif_displaymessage(fd, atcmd_output);
  6617. }
  6618. else if (!battle_config.atcommand_mobinfo_type) {
  6619. if (item_data->maxchance)
  6620. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6621. else
  6622. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6623. clif_displaymessage(fd, atcmd_output);
  6624. }
  6625. }
  6626. return 0;
  6627. }
  6628. /*==========================================
  6629. * Show who drops the item.
  6630. *------------------------------------------*/
  6631. ACMD_FUNC(whodrops)
  6632. {
  6633. struct item_data *item_data, *item_array[MAX_SEARCH];
  6634. int i,j, count = 1;
  6635. if (!message || !*message) {
  6636. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6637. return -1;
  6638. }
  6639. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6640. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6641. if (!count) {
  6642. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6643. return -1;
  6644. }
  6645. if (count == MAX_SEARCH) {
  6646. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6647. clif_displaymessage(fd, atcmd_output);
  6648. }
  6649. for (i = 0; i < count; i++) {
  6650. item_data = item_array[i];
  6651. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6652. clif_displaymessage(fd, atcmd_output);
  6653. if (item_data->mob[0].chance == 0) {
  6654. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6655. clif_displaymessage(fd, atcmd_output);
  6656. } else {
  6657. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6658. clif_displaymessage(fd, atcmd_output);
  6659. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6660. {
  6661. int dropchance = item_data->mob[j].chance;
  6662. #ifdef RENEWAL_DROP
  6663. if( battle_config.atcommand_mobinfo_type )
  6664. 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;
  6665. #endif
  6666. if (pc_isvip(sd)) // Display item rate increase for VIP
  6667. dropchance += (dropchance * battle_config.vip_drop_increase) / 100;
  6668. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6669. clif_displaymessage(fd, atcmd_output);
  6670. }
  6671. }
  6672. }
  6673. return 0;
  6674. }
  6675. ACMD_FUNC(whereis)
  6676. {
  6677. uint16 mob_ids[MAX_SEARCH] = {0};
  6678. int count = 0;
  6679. if (!message || !*message) {
  6680. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6681. return -1;
  6682. }
  6683. int i_message = atoi(message);
  6684. if (mobdb_checkid(i_message)) {
  6685. // ID given
  6686. mob_ids[0] = i_message;
  6687. count = 1;
  6688. } else {
  6689. // Name given, get all monster associated whith this name
  6690. count = mobdb_searchname_array(message, mob_ids, MAX_SEARCH);
  6691. }
  6692. if (count <= 0) {
  6693. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6694. return -1;
  6695. }
  6696. if (count >= MAX_SEARCH) {
  6697. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH); // Displaying first %d matches
  6698. clif_displaymessage(fd, atcmd_output);
  6699. count = MAX_SEARCH;
  6700. }
  6701. for (int i = 0; i < count; i++) {
  6702. uint16 mob_id = mob_ids[i];
  6703. struct mob_db * mob = mob_db(mob_id);
  6704. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6705. clif_displaymessage(fd, atcmd_output);
  6706. const std::vector<spawn_info> spawns = mob_get_spawns(mob_id);
  6707. if (spawns.size() <= 0) {
  6708. // This monster does not spawn normally.
  6709. clif_displaymessage(fd, msg_txt(sd,1290));
  6710. } else {
  6711. for(auto& spawn : spawns)
  6712. {
  6713. int16 mapid = map_mapindex2mapid(spawn.mapindex);
  6714. if (mapid < 0)
  6715. continue;
  6716. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[mapid].name, spawn.qty);
  6717. clif_displaymessage(fd, atcmd_output);
  6718. }
  6719. }
  6720. }
  6721. return 0;
  6722. }
  6723. ACMD_FUNC(version)
  6724. {
  6725. pc_show_version(sd);
  6726. return 0;
  6727. }
  6728. /*==========================================
  6729. * @mutearea by MouseJstr
  6730. *------------------------------------------*/
  6731. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6732. {
  6733. int time, id;
  6734. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6735. if (pl_sd == NULL)
  6736. return 0;
  6737. id = va_arg(ap, int);
  6738. time = va_arg(ap, int);
  6739. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6740. pl_sd->status.manner -= time;
  6741. if (pl_sd->status.manner < 0)
  6742. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6743. else
  6744. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6745. }
  6746. return 0;
  6747. }
  6748. ACMD_FUNC(mutearea)
  6749. {
  6750. int time;
  6751. nullpo_ret(sd);
  6752. if (!message || !*message) {
  6753. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6754. return -1;
  6755. }
  6756. time = atoi(message);
  6757. map_foreachinallarea(atcommand_mutearea_sub,sd->bl.m,
  6758. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6759. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6760. return 0;
  6761. }
  6762. ACMD_FUNC(rates)
  6763. {
  6764. char buf[CHAT_SIZE_MAX];
  6765. nullpo_ret(sd);
  6766. memset(buf, '\0', sizeof(buf));
  6767. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6768. (battle_config.base_exp_rate + (pc_isvip(sd) ? (battle_config.vip_base_exp_increase * battle_config.base_exp_rate) / 100 : 0)) / 100.,
  6769. (battle_config.job_exp_rate + (pc_isvip(sd) ? (battle_config.vip_job_exp_increase * battle_config.job_exp_rate) / 100 : 0)) / 100.);
  6770. clif_displaymessage(fd, buf);
  6771. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6772. (battle_config.item_rate_common + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common) / 100 : 0)) / 100.,
  6773. (battle_config.item_rate_heal + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal) / 100 : 0)) / 100.,
  6774. (battle_config.item_rate_use + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use) / 100 : 0)) / 100.,
  6775. (battle_config.item_rate_equip + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip) / 100 : 0)) / 100.,
  6776. (battle_config.item_rate_card + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card) / 100 : 0)) / 100.);
  6777. clif_displaymessage(fd, buf);
  6778. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6779. (battle_config.item_rate_common_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_boss) / 100 : 0)) / 100.,
  6780. (battle_config.item_rate_heal_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_boss) / 100 : 0)) / 100.,
  6781. (battle_config.item_rate_use_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_boss) / 100 : 0)) / 100.,
  6782. (battle_config.item_rate_equip_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_boss) / 100 : 0)) / 100.,
  6783. (battle_config.item_rate_card_boss + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_boss) / 100 : 0)) / 100.);
  6784. clif_displaymessage(fd, buf);
  6785. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1024), // MVP Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6786. (battle_config.item_rate_common_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_common_mvp) / 100 : 0)) / 100.,
  6787. (battle_config.item_rate_heal_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_heal_mvp) / 100 : 0)) / 100.,
  6788. (battle_config.item_rate_use_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_use_mvp) / 100 : 0)) / 100.,
  6789. (battle_config.item_rate_equip_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_equip_mvp) / 100 : 0)) / 100.,
  6790. (battle_config.item_rate_card_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_card_mvp) / 100 : 0)) / 100.);
  6791. clif_displaymessage(fd, buf);
  6792. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6793. (battle_config.item_rate_mvp + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_mvp) / 100 : 0)) / 100.,
  6794. (battle_config.item_rate_adddrop + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_adddrop) / 100 : 0)) / 100.,
  6795. (battle_config.item_rate_treasure + (pc_isvip(sd) ? (battle_config.vip_drop_increase * battle_config.item_rate_treasure) / 100 : 0)) / 100.);
  6796. clif_displaymessage(fd, buf);
  6797. return 0;
  6798. }
  6799. /*==========================================
  6800. * @me by lordalfa
  6801. * => Displays the OUTPUT string on top of the Visible players Heads.
  6802. *------------------------------------------*/
  6803. ACMD_FUNC(me)
  6804. {
  6805. char tempmes[CHAT_SIZE_MAX];
  6806. nullpo_retr(-1, sd);
  6807. memset(tempmes, '\0', sizeof(tempmes));
  6808. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6809. if (sd->sc.cant.chat)
  6810. return -1; //no "chatting" while muted.
  6811. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6812. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6813. return -1;
  6814. }
  6815. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6816. clif_disp_overhead(&sd->bl, atcmd_output);
  6817. return 0;
  6818. }
  6819. /*==========================================
  6820. * @size
  6821. * => Resize your character sprite. [Valaris]
  6822. *------------------------------------------*/
  6823. ACMD_FUNC(size)
  6824. {
  6825. int size = SZ_SMALL;
  6826. nullpo_retr(-1, sd);
  6827. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6828. if(sd->state.size) {
  6829. sd->state.size = SZ_SMALL;
  6830. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6831. }
  6832. sd->state.size = size;
  6833. if( size == SZ_MEDIUM )
  6834. clif_specialeffect(&sd->bl,EF_BABYBODY,AREA);
  6835. else if( size == SZ_BIG )
  6836. clif_specialeffect(&sd->bl,EF_GIANTBODY,AREA);
  6837. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6838. return 0;
  6839. }
  6840. ACMD_FUNC(sizeall)
  6841. {
  6842. int size;
  6843. struct map_session_data *pl_sd;
  6844. struct s_mapiterator* iter;
  6845. size = atoi(message);
  6846. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6847. iter = mapit_getallusers();
  6848. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6849. if( pl_sd->state.size != size ) {
  6850. if( pl_sd->state.size ) {
  6851. pl_sd->state.size = SZ_SMALL;
  6852. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6853. }
  6854. pl_sd->state.size = size;
  6855. if( size == SZ_MEDIUM )
  6856. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6857. else if( size == SZ_BIG )
  6858. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6859. }
  6860. }
  6861. mapit_free(iter);
  6862. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6863. return 0;
  6864. }
  6865. ACMD_FUNC(sizeguild)
  6866. {
  6867. int size = SZ_SMALL, i;
  6868. char guild[NAME_LENGTH];
  6869. struct map_session_data *pl_sd;
  6870. struct guild *g;
  6871. nullpo_retr(-1, sd);
  6872. memset(guild, '\0', sizeof(guild));
  6873. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6874. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6875. return -1;
  6876. }
  6877. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6878. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6879. return -1;
  6880. }
  6881. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6882. for( i = 0; i < g->max_member; i++ ) {
  6883. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6884. if( pl_sd->state.size ) {
  6885. pl_sd->state.size = SZ_SMALL;
  6886. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6887. }
  6888. pl_sd->state.size = size;
  6889. if( size == SZ_MEDIUM )
  6890. clif_specialeffect(&pl_sd->bl,EF_BABYBODY,AREA);
  6891. else if( size == SZ_BIG )
  6892. clif_specialeffect(&pl_sd->bl,EF_GIANTBODY,AREA);
  6893. }
  6894. }
  6895. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6896. return 0;
  6897. }
  6898. /*==========================================
  6899. * @monsterignore
  6900. * => Makes monsters ignore you. [Valaris]
  6901. *------------------------------------------*/
  6902. ACMD_FUNC(monsterignore)
  6903. {
  6904. nullpo_retr(-1, sd);
  6905. if (!sd->state.monster_ignore) {
  6906. sd->state.monster_ignore = 1;
  6907. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6908. } else {
  6909. sd->state.monster_ignore = 0;
  6910. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6911. }
  6912. return 0;
  6913. }
  6914. /*==========================================
  6915. * @fakename
  6916. * => Gives your character a fake name. [Valaris]
  6917. *------------------------------------------*/
  6918. ACMD_FUNC(fakename)
  6919. {
  6920. nullpo_retr(-1, sd);
  6921. if( !message || !*message )
  6922. {
  6923. if( sd->fakename[0] )
  6924. {
  6925. sd->fakename[0] = '\0';
  6926. clif_name_area(&sd->bl);
  6927. if (sd->disguise)
  6928. clif_name_self(&sd->bl);
  6929. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6930. return 0;
  6931. }
  6932. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6933. return -1;
  6934. }
  6935. if( strlen(message) < 2 )
  6936. {
  6937. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6938. return -1;
  6939. }
  6940. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6941. clif_name_area(&sd->bl);
  6942. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6943. clif_name_self(&sd->bl);
  6944. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6945. return 0;
  6946. }
  6947. /*==========================================
  6948. * Ragnarok Resources
  6949. *------------------------------------------*/
  6950. ACMD_FUNC(mapflag) {
  6951. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6952. #define setflag( cmd ) \
  6953. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6954. map[ sd->bl.m ].flag.cmd = flag;\
  6955. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6956. clif_displaymessage(sd->fd,atcmd_output);\
  6957. return 0;\
  6958. }
  6959. char flag_name[100];
  6960. short flag=0,i;
  6961. nullpo_retr(-1, sd);
  6962. memset(flag_name, '\0', sizeof(flag_name));
  6963. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6964. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6965. clif_displaymessage(sd->fd,"----------------------------------");
  6966. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6967. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6968. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6969. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6970. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6971. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6972. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6973. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6974. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6975. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6976. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6977. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6978. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6979. checkflag(nolockon); checkflag(notomb); checkflag(nocostume); checkflag(gvg_te);
  6980. checkflag(gvg_te_castle); checkflag(hidemobhpbar);
  6981. #ifdef ADJUST_SKILL_DAMAGE
  6982. checkflag(skill_damage);
  6983. #endif
  6984. clif_displaymessage(sd->fd," ");
  6985. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6986. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6987. return 1;
  6988. }
  6989. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6990. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6991. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6992. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6993. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6994. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6995. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6996. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6997. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6998. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6999. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  7000. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  7001. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  7002. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  7003. setflag(nolockon); setflag(notomb); setflag(nocostume); setflag(gvg_te);
  7004. setflag(gvg_te_castle); setflag(hidemobhpbar);
  7005. #ifdef ADJUST_SKILL_DAMAGE
  7006. setflag(skill_damage);
  7007. #endif
  7008. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  7009. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  7010. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  7011. clif_displaymessage(sd->fd,"----------------------------------");
  7012. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  7013. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  7014. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  7015. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  7016. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  7017. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  7018. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb,");
  7019. clif_displaymessage(sd->fd,"nocostume, gvg_te, gvg_te_castle, hidemobhpbar");
  7020. #ifdef ADJUST_SKILL_DAMAGE
  7021. clif_displaymessage(sd->fd,"skill_damage");
  7022. #endif
  7023. #undef checkflag
  7024. #undef setflag
  7025. return 0;
  7026. }
  7027. /*===================================
  7028. * Remove some messages
  7029. *-----------------------------------*/
  7030. ACMD_FUNC(showexp)
  7031. {
  7032. if (sd->state.showexp) {
  7033. sd->state.showexp = 0;
  7034. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  7035. return 0;
  7036. }
  7037. sd->state.showexp = 1;
  7038. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  7039. return 0;
  7040. }
  7041. ACMD_FUNC(showzeny)
  7042. {
  7043. if (sd->state.showzeny) {
  7044. sd->state.showzeny = 0;
  7045. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  7046. return 0;
  7047. }
  7048. sd->state.showzeny = 1;
  7049. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  7050. return 0;
  7051. }
  7052. ACMD_FUNC(showdelay)
  7053. {
  7054. if (sd->state.showdelay) {
  7055. sd->state.showdelay = 0;
  7056. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  7057. return 0;
  7058. }
  7059. sd->state.showdelay = 1;
  7060. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  7061. return 0;
  7062. }
  7063. /*==========================================
  7064. * Duel organizing functions [LuzZza]
  7065. *
  7066. * @duel [limit|nick] - create a duel
  7067. * @invite <nick> - invite player
  7068. * @accept - accept invitation
  7069. * @reject - reject invitation
  7070. * @leave - leave duel
  7071. *------------------------------------------*/
  7072. ACMD_FUNC(invite)
  7073. {
  7074. unsigned int did = sd->duel_group;
  7075. struct map_session_data *target_sd = NULL;
  7076. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7077. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7078. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7079. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7080. clif_displaymessage(fd, atcmd_output);
  7081. return -1;
  7082. }
  7083. if(did == 0 || !duel_exist(did) ) {
  7084. clif_displaymessage(fd, msg_txt(sd,350)); // "Duel: @invite without @duel."
  7085. return 0;
  7086. }
  7087. if( !duel_check_player_limit( duel_get_duelid(did) ) ){
  7088. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7089. return 0;
  7090. }
  7091. if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
  7092. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7093. return 0;
  7094. }
  7095. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7096. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7097. return 0;
  7098. }
  7099. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  7100. {
  7101. 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.
  7102. clif_displaymessage(fd, atcmd_output);
  7103. return 0;
  7104. }
  7105. duel_invite(did, sd, target_sd);
  7106. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7107. return 0;
  7108. }
  7109. ACMD_FUNC(duel)
  7110. {
  7111. unsigned int maxpl = 0;
  7112. if(sd->duel_group > 0) {
  7113. duel_showinfo(sd->duel_group, sd);
  7114. return 0;
  7115. }
  7116. if(sd->duel_invite > 0) {
  7117. clif_displaymessage(fd, msg_txt(sd,355)); // "Duel: @duel without @reject."
  7118. return 0;
  7119. }
  7120. if(!duel_checktime(sd)) {
  7121. char output[CHAT_SIZE_MAX];
  7122. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7123. clif_displaymessage(fd, output);
  7124. return 0;
  7125. }
  7126. if( message[0] ) {
  7127. if(sscanf(message, "%11u", &maxpl) >= 1) {
  7128. if(maxpl < 2 || maxpl > 65535) {
  7129. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  7130. return 0;
  7131. }
  7132. duel_create(sd, maxpl);
  7133. } else {
  7134. struct map_session_data *target_sd = NULL;
  7135. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7136. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7137. if (sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7138. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  7139. clif_displaymessage(fd, atcmd_output);
  7140. return -1;
  7141. }
  7142. target_sd = map_nick2sd(atcmd_player_name,true);
  7143. if(target_sd != NULL) {
  7144. unsigned int newduel;
  7145. if((newduel = duel_create(sd, 2)) != -1) {
  7146. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  7147. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  7148. return 0;
  7149. }
  7150. duel_invite(newduel, sd, target_sd);
  7151. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  7152. }
  7153. } else {
  7154. clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
  7155. return 0;
  7156. }
  7157. }
  7158. } else
  7159. duel_create(sd, 0);
  7160. return 0;
  7161. }
  7162. ACMD_FUNC(leave)
  7163. {
  7164. if(sd->duel_group <= 0) {
  7165. clif_displaymessage(fd, msg_txt(sd,358)); // "Duel: @leave without @duel."
  7166. return 0;
  7167. }
  7168. duel_leave(sd->duel_group, sd);
  7169. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7170. return 0;
  7171. }
  7172. ACMD_FUNC(accept)
  7173. {
  7174. if(!duel_checktime(sd)) {
  7175. char output[CHAT_SIZE_MAX];
  7176. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval); // "Duel: You can take part in duel only one time per %d minutes."
  7177. clif_displaymessage(fd, output);
  7178. return 0;
  7179. }
  7180. if(sd->duel_invite <= 0 || !duel_exist(sd->duel_invite) ) {
  7181. clif_displaymessage(fd, msg_txt(sd,360)); // "Duel: @accept without invititation."
  7182. return 0;
  7183. }
  7184. if( duel_check_player_limit( duel_get_duelid( sd->duel_invite ) ) )
  7185. {
  7186. clif_displaymessage(fd, msg_txt(sd,351)); // "Duel: Limit of players is reached."
  7187. return 0;
  7188. }
  7189. duel_accept(sd->duel_invite, sd);
  7190. clif_displaymessage(fd, msg_txt(sd,361)); // "Duel: Invitation has been accepted."
  7191. return 0;
  7192. }
  7193. ACMD_FUNC(reject)
  7194. {
  7195. if(sd->duel_invite <= 0) {
  7196. clif_displaymessage(fd, msg_txt(sd,362)); // "Duel: @reject without invititation."
  7197. return 0;
  7198. }
  7199. duel_reject(sd->duel_invite, sd);
  7200. clif_displaymessage(fd, msg_txt(sd,363)); // "Duel: Invitation has been rejected."
  7201. return 0;
  7202. }
  7203. /*===================================
  7204. * Cash Points
  7205. *-----------------------------------*/
  7206. ACMD_FUNC(cash)
  7207. {
  7208. char output[128];
  7209. int value;
  7210. int ret=0;
  7211. nullpo_retr(-1, sd);
  7212. // Since there is no cashpoint update packet we need to force updating like this
  7213. if( sd->state.cashshop_open ){
  7214. clif_displaymessage(fd, msg_txt(sd, 1376)); // Please close the cashshop before using this command.
  7215. return -1;
  7216. }
  7217. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7218. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7219. return -1;
  7220. }
  7221. parent_cmd = atcommand_checkalias(command+1);
  7222. if( !strcmpi(parent_cmd,"cash") )
  7223. {
  7224. if( value > 0 ) {
  7225. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7226. // If this option is set, the message is already sent by pc function
  7227. if( !battle_config.cashshop_show_points ){
  7228. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints); // Gained %d cash points. Total %d points.
  7229. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7230. }
  7231. }
  7232. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7233. } else {
  7234. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7235. value = -sd->cashPoints;
  7236. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7237. // If this option is set, the message is already sent by pc function
  7238. if( !battle_config.cashshop_show_points ){
  7239. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints); // Removed %d cash points. Total %d points.
  7240. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7241. }
  7242. }
  7243. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7244. }
  7245. }
  7246. else
  7247. { // @points
  7248. if( value > 0 ) {
  7249. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7250. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints); // Gained %d kafra points. Total %d points.
  7251. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7252. }
  7253. else clif_displaymessage(fd, msg_txt(sd,149)); // Impossible to increase the number/value.
  7254. } else {
  7255. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7256. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints); // Removed %d kafra points. Total %d points.
  7257. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], output, false, SELF);
  7258. }
  7259. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7260. }
  7261. }
  7262. return 0;
  7263. }
  7264. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7265. ACMD_FUNC(clone)
  7266. {
  7267. int x=0,y=0,flag=0,master=0,i=0;
  7268. struct map_session_data *pl_sd=NULL;
  7269. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  7270. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  7271. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7272. return 0;
  7273. }
  7274. if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
  7275. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7276. return 0;
  7277. }
  7278. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7279. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7280. return 0;
  7281. }
  7282. parent_cmd = atcommand_checkalias(command+1);
  7283. if (strcmpi(parent_cmd, "clone") == 0)
  7284. flag = 1;
  7285. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7286. flag = 2;
  7287. if(pc_isdead(sd)){
  7288. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7289. return 0;
  7290. }
  7291. master = sd->bl.id;
  7292. if (battle_config.atc_slave_clone_limit
  7293. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7294. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7295. return 0;
  7296. }
  7297. }
  7298. do {
  7299. x = sd->bl.x + (rnd() % 10 - 5);
  7300. y = sd->bl.y + (rnd() % 10 - 5);
  7301. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7302. if (i >= 10) {
  7303. x = sd->bl.x;
  7304. y = sd->bl.y;
  7305. }
  7306. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, MD_NONE, flag?1:0, 0)) > 0) {
  7307. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7308. return 0;
  7309. }
  7310. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7311. return 0;
  7312. }
  7313. /*=====================================
  7314. * Autorejecting Invites/Deals [LuzZza]
  7315. * Usage: @noask
  7316. *-------------------------------------*/
  7317. ACMD_FUNC(noask)
  7318. {
  7319. if(sd->state.noask) {
  7320. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7321. sd->state.noask = 0;
  7322. } else {
  7323. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7324. sd->state.noask = 1;
  7325. }
  7326. return 0;
  7327. }
  7328. /*=====================================
  7329. * Send a @request message to all GMs of lowest_gm_level.
  7330. * Usage: @request <petition>
  7331. *-------------------------------------*/
  7332. ACMD_FUNC(request)
  7333. {
  7334. if (!message || !*message) {
  7335. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7336. return -1;
  7337. }
  7338. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7339. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7340. clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], atcmd_output, false, SELF);
  7341. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7342. return 0;
  7343. }
  7344. /*==========================================
  7345. * Feel (SG save map) Reset [HiddenDragon]
  7346. *------------------------------------------*/
  7347. ACMD_FUNC(feelreset)
  7348. {
  7349. pc_resetfeel(sd);
  7350. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7351. return 0;
  7352. }
  7353. /*==========================================
  7354. * AUCTION SYSTEM
  7355. *------------------------------------------*/
  7356. ACMD_FUNC(auction)
  7357. {
  7358. nullpo_ret(sd);
  7359. if (!battle_config.feature_auction) {
  7360. clif_messagecolor(&sd->bl, color_table[COLOR_RED], msg_txt(sd, 517), false, SELF);
  7361. return 0;
  7362. }
  7363. clif_Auction_openwindow(sd);
  7364. return 0;
  7365. }
  7366. /*==========================================
  7367. * Kill Steal Protection
  7368. *------------------------------------------*/
  7369. ACMD_FUNC(ksprotection)
  7370. {
  7371. nullpo_retr(-1,sd);
  7372. if( sd->state.noks ) {
  7373. sd->state.noks = 0;
  7374. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7375. }
  7376. else
  7377. {
  7378. if( !message || !*message || !strcmpi(message, "party") )
  7379. { // Default is Party
  7380. sd->state.noks = 2;
  7381. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7382. }
  7383. else if( !strcmpi(message, "self") )
  7384. {
  7385. sd->state.noks = 1;
  7386. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7387. }
  7388. else if( !strcmpi(message, "guild") )
  7389. {
  7390. sd->state.noks = 3;
  7391. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7392. }
  7393. else
  7394. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7395. }
  7396. return 0;
  7397. }
  7398. /*==========================================
  7399. * Map Kill Steal Protection Setting
  7400. *------------------------------------------*/
  7401. ACMD_FUNC(allowks)
  7402. {
  7403. nullpo_retr(-1,sd);
  7404. if( map[sd->bl.m].flag.allowks ) {
  7405. map[sd->bl.m].flag.allowks = 0;
  7406. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7407. } else {
  7408. map[sd->bl.m].flag.allowks = 1;
  7409. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7410. }
  7411. return 0;
  7412. }
  7413. ACMD_FUNC(resetstat)
  7414. {
  7415. nullpo_retr(-1, sd);
  7416. pc_resetstate(sd);
  7417. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name); // '%s' stats points reset.
  7418. clif_displaymessage(fd, atcmd_output);
  7419. return 0;
  7420. }
  7421. ACMD_FUNC(resetskill)
  7422. {
  7423. nullpo_retr(-1,sd);
  7424. pc_resetskill(sd,1);
  7425. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name); // '%s' skill points reset.
  7426. clif_displaymessage(fd, atcmd_output);
  7427. return 0;
  7428. }
  7429. /*==========================================
  7430. * #storagelist: Displays the items list of a player's storage.
  7431. * #cartlist: Displays contents of target's cart.
  7432. * #itemlist: Displays contents of target's inventory.
  7433. *------------------------------------------*/
  7434. ACMD_FUNC(itemlist)
  7435. {
  7436. int i, j, count, counter;
  7437. const char* location;
  7438. const struct item* items;
  7439. int size;
  7440. StringBuf buf;
  7441. nullpo_retr(-1, sd);
  7442. parent_cmd = atcommand_checkalias(command+1);
  7443. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7444. location = "storage";
  7445. items = sd->storage.u.items_storage;
  7446. size = sd->storage.max_amount;
  7447. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7448. location = "cart";
  7449. items = sd->cart.u.items_cart;
  7450. size = MAX_CART;
  7451. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7452. location = "inventory";
  7453. items = sd->inventory.u.items_inventory;
  7454. size = MAX_INVENTORY;
  7455. } else
  7456. return 1;
  7457. StringBuf_Init(&buf);
  7458. count = 0; // total slots occupied
  7459. counter = 0; // total items found
  7460. for( i = 0; i < size; ++i ) {
  7461. const struct item* it = &items[i];
  7462. struct item_data* itd;
  7463. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7464. continue;
  7465. counter += it->amount;
  7466. count++;
  7467. if( count == 1 ) {
  7468. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7469. clif_displaymessage(fd, StringBuf_Value(&buf));
  7470. StringBuf_Clear(&buf);
  7471. }
  7472. if( it->refine )
  7473. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7474. else
  7475. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7476. if( it->equip ) {
  7477. char equipstr[CHAT_SIZE_MAX];
  7478. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7479. if( it->equip&EQP_GARMENT )
  7480. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7481. if( it->equip&EQP_ACC_L )
  7482. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7483. if( it->equip&EQP_ARMOR )
  7484. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7485. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7486. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7487. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7488. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7489. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7490. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7491. if( it->equip&EQP_SHOES )
  7492. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7493. if( it->equip&EQP_ACC_R )
  7494. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7495. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7496. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7497. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7498. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7499. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7500. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7501. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7502. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7503. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7504. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7505. if( (it->equip&EQP_HELM) == EQP_HELM )
  7506. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7507. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7508. strcat(equipstr, msg_txt(sd,518)); // Lower Costume Head,
  7509. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7510. strcat(equipstr, msg_txt(sd,519)); // Top Costume Head,
  7511. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7512. strcat(equipstr, msg_txt(sd,520)); // Top/Lower Costume Head,
  7513. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7514. strcat(equipstr, msg_txt(sd,521)); // Mid Costume Head,
  7515. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7516. strcat(equipstr, msg_txt(sd,522)); // Mid/Lower Costume Head,
  7517. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7518. strcat(equipstr, msg_txt(sd,523)); // Top/Mid/Lower Costume Head,
  7519. if( it->equip&EQP_COSTUME_GARMENT )
  7520. strcat(equipstr, msg_txt(sd,524)); // Costume Robe,
  7521. //if( it->equip&EQP_COSTUME_FLOOR )
  7522. //strcat(equipstr, msg_txt(sd,525)); // Costume Floor,
  7523. if( it->equip&EQP_AMMO )
  7524. strcat(equipstr, msg_txt(sd,526)); // Ammo,
  7525. if( it->equip&EQP_SHADOW_ARMOR )
  7526. strcat(equipstr, msg_txt(sd,527)); // Shadow Body,
  7527. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7528. strcat(equipstr, msg_txt(sd,528)); // Shadow Right Hand,
  7529. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7530. strcat(equipstr, msg_txt(sd,529)); // Shadow Left Hand,
  7531. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7532. strcat(equipstr, msg_txt(sd,530)); // Shadow Both Hands,
  7533. if( it->equip&EQP_SHADOW_SHOES )
  7534. strcat(equipstr, msg_txt(sd,531)); // Shadow Shoes,
  7535. if( it->equip&EQP_SHADOW_ACC_R )
  7536. strcat(equipstr, msg_txt(sd,532)); // Shadow Right Accessory,
  7537. if( it->equip&EQP_SHADOW_ACC_L )
  7538. strcat(equipstr, msg_txt(sd,533)); // Shadow Left Accessory,
  7539. // remove final ', '
  7540. equipstr[strlen(equipstr) - 2] = '\0';
  7541. StringBuf_AppendStr(&buf, equipstr);
  7542. }
  7543. clif_displaymessage(fd, StringBuf_Value(&buf));
  7544. StringBuf_Clear(&buf);
  7545. if( it->card[0] == CARD0_PET ) { // pet egg
  7546. if (it->card[3])
  7547. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7548. else
  7549. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7550. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7551. 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)
  7552. } else if(it->card[0] == CARD0_CREATE) { // created item
  7553. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7554. } else { // normal item
  7555. int counter2 = 0;
  7556. for( j = 0; j < itd->slot; ++j ) {
  7557. struct item_data* card;
  7558. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7559. continue;
  7560. counter2++;
  7561. if( counter2 == 1 )
  7562. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7563. if( counter2 != 1 )
  7564. StringBuf_AppendStr(&buf, ", ");
  7565. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7566. }
  7567. if( counter2 > 0 )
  7568. StringBuf_AppendStr(&buf, ")");
  7569. }
  7570. if( StringBuf_Length(&buf) > 0 )
  7571. clif_displaymessage(fd, StringBuf_Value(&buf));
  7572. StringBuf_Clear(&buf);
  7573. }
  7574. if( count == 0 )
  7575. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7576. else
  7577. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7578. clif_displaymessage(fd, StringBuf_Value(&buf));
  7579. StringBuf_Destroy(&buf);
  7580. return 0;
  7581. }
  7582. ACMD_FUNC(stats)
  7583. {
  7584. char job_jobname[100];
  7585. char output[CHAT_SIZE_MAX];
  7586. int i;
  7587. struct {
  7588. const char* format;
  7589. int value;
  7590. } output_table[] = {
  7591. { "Base Level - %d", 0 },
  7592. { NULL, 0 },
  7593. { "Hp - %d", 0 },
  7594. { "MaxHp - %d", 0 },
  7595. { "Sp - %d", 0 },
  7596. { "MaxSp - %d", 0 },
  7597. { "Str - %3d", 0 },
  7598. { "Agi - %3d", 0 },
  7599. { "Vit - %3d", 0 },
  7600. { "Int - %3d", 0 },
  7601. { "Dex - %3d", 0 },
  7602. { "Luk - %3d", 0 },
  7603. { "Zeny - %d", 0 },
  7604. { "Free SK Points - %d", 0 },
  7605. { "JobChangeLvl (2nd) - %d", 0 },
  7606. { "JobChangeLvl (3rd) - %d", 0 },
  7607. { NULL, 0 }
  7608. };
  7609. memset(job_jobname, '\0', sizeof(job_jobname));
  7610. memset(output, '\0', sizeof(output));
  7611. //direct array initialization with variables is not standard C compliant.
  7612. output_table[0].value = sd->status.base_level;
  7613. output_table[1].format = job_jobname;
  7614. output_table[1].value = sd->status.job_level;
  7615. output_table[2].value = sd->status.hp;
  7616. output_table[3].value = sd->status.max_hp;
  7617. output_table[4].value = sd->status.sp;
  7618. output_table[5].value = sd->status.max_sp;
  7619. output_table[6].value = sd->status.str;
  7620. output_table[7].value = sd->status.agi;
  7621. output_table[8].value = sd->status.vit;
  7622. output_table[9].value = sd->status.int_;
  7623. output_table[10].value = sd->status.dex;
  7624. output_table[11].value = sd->status.luk;
  7625. output_table[12].value = sd->status.zeny;
  7626. output_table[13].value = sd->status.skill_point;
  7627. output_table[14].value = sd->change_level_2nd;
  7628. output_table[15].value = sd->change_level_3rd;
  7629. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7630. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7631. clif_displaymessage(fd, output);
  7632. for (i = 0; output_table[i].format != NULL; i++) {
  7633. sprintf(output, output_table[i].format, output_table[i].value);
  7634. clif_displaymessage(fd, output);
  7635. }
  7636. return 0;
  7637. }
  7638. ACMD_FUNC(delitem)
  7639. {
  7640. char item_name[100];
  7641. unsigned short nameid;
  7642. int amount = 0, total, idx;
  7643. struct item_data* id;
  7644. nullpo_retr(-1, sd);
  7645. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7646. {
  7647. 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>).
  7648. return -1;
  7649. }
  7650. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7651. {
  7652. nameid = id->nameid;
  7653. }
  7654. else
  7655. {
  7656. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7657. return -1;
  7658. }
  7659. total = amount;
  7660. // delete items
  7661. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7662. {
  7663. int delamount = ( amount < sd->inventory.u.items_inventory[idx].amount ) ? amount : sd->inventory.u.items_inventory[idx].amount;
  7664. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->inventory.u.items_inventory[idx].card[0] == CARD0_PET )
  7665. {// delete pet
  7666. intif_delete_petdata(MakeDWord(sd->inventory.u.items_inventory[idx].card[1], sd->inventory.u.items_inventory[idx].card[2]));
  7667. }
  7668. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7669. amount-= delamount;
  7670. }
  7671. // notify target
  7672. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7673. clif_displaymessage(sd->fd, atcmd_output);
  7674. // notify source
  7675. if( amount == total )
  7676. {
  7677. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7678. }
  7679. else if( amount )
  7680. {
  7681. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7682. clif_displaymessage(fd, atcmd_output);
  7683. }
  7684. else
  7685. {
  7686. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7687. clif_displaymessage(fd, atcmd_output);
  7688. }
  7689. return 0;
  7690. }
  7691. /*==========================================
  7692. * Custom Fonts
  7693. *------------------------------------------*/
  7694. ACMD_FUNC(font)
  7695. {
  7696. int font_id;
  7697. nullpo_retr(-1,sd);
  7698. font_id = atoi(message);
  7699. if( font_id == 0 ) {
  7700. if( sd->status.font ) {
  7701. sd->status.font = 0;
  7702. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7703. clif_font(sd);
  7704. } else {
  7705. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7706. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7707. }
  7708. } else if( font_id < 0 || font_id > 9 )
  7709. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7710. else if( font_id != sd->status.font ) {
  7711. sd->status.font = font_id;
  7712. clif_font(sd);
  7713. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7714. } else
  7715. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7716. return 0;
  7717. }
  7718. /*==========================================
  7719. * type: 1 = commands (@), 2 = charcommands (#)
  7720. *------------------------------------------*/
  7721. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7722. {
  7723. char line_buff[CHATBOX_SIZE];
  7724. char* cur = line_buff;
  7725. AtCommandInfo* cmd;
  7726. DBIterator *iter = db_iterator(atcommand_db);
  7727. int count = 0;
  7728. memset(line_buff,' ',CHATBOX_SIZE);
  7729. line_buff[CHATBOX_SIZE-1] = 0;
  7730. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7731. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7732. unsigned int slen = 0;
  7733. switch( type ) {
  7734. case COMMAND_CHARCOMMAND:
  7735. if( cmd->char_groups[sd->group_pos] == 0 )
  7736. continue;
  7737. break;
  7738. case COMMAND_ATCOMMAND:
  7739. if( cmd->at_groups[sd->group_pos] == 0 )
  7740. continue;
  7741. break;
  7742. default:
  7743. continue;
  7744. }
  7745. slen = strlen(cmd->command);
  7746. // flush the text buffer if this command won't fit into it
  7747. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7748. clif_displaymessage(fd,line_buff);
  7749. cur = line_buff;
  7750. memset(line_buff,' ',CHATBOX_SIZE);
  7751. line_buff[CHATBOX_SIZE-1] = 0;
  7752. }
  7753. memcpy(cur,cmd->command,slen);
  7754. cur += slen+(10-slen%10);
  7755. count++;
  7756. }
  7757. dbi_destroy(iter);
  7758. clif_displaymessage(fd,line_buff);
  7759. if ( atcmd_binding_count ) {
  7760. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7761. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7762. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7763. unsigned int slen = strlen(atcmd_binding[i]->command);
  7764. if ( count_bind == 0 ) {
  7765. cur = line_buff;
  7766. memset(line_buff,' ',CHATBOX_SIZE);
  7767. line_buff[CHATBOX_SIZE-1] = 0;
  7768. clif_displaymessage(fd, "-----------------");
  7769. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7770. }
  7771. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7772. clif_displaymessage(fd,line_buff);
  7773. cur = line_buff;
  7774. memset(line_buff,' ',CHATBOX_SIZE);
  7775. line_buff[CHATBOX_SIZE-1] = 0;
  7776. }
  7777. memcpy(cur,atcmd_binding[i]->command,slen);
  7778. cur += slen+(10-slen%10);
  7779. count_bind++;
  7780. }
  7781. }
  7782. if ( count_bind )
  7783. clif_displaymessage(fd,line_buff);// last one
  7784. count += count_bind;
  7785. }
  7786. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7787. clif_displaymessage(fd, atcmd_output);
  7788. return;
  7789. }
  7790. /*==========================================
  7791. * @commands Lists available @ commands to you
  7792. *------------------------------------------*/
  7793. ACMD_FUNC(commands)
  7794. {
  7795. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7796. return 0;
  7797. }
  7798. /*==========================================
  7799. * @charcommands Lists available # commands to you
  7800. *------------------------------------------*/
  7801. ACMD_FUNC(charcommands) {
  7802. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7803. return 0;
  7804. }
  7805. /* for new mounts */
  7806. ACMD_FUNC(mount2) {
  7807. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7808. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7809. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7810. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7811. } else {
  7812. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7813. if (&sd->sc)
  7814. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7815. }
  7816. return 0;
  7817. }
  7818. ACMD_FUNC(accinfo) {
  7819. char query[NAME_LENGTH];
  7820. char type = 0; // type = 1, get only account name
  7821. if (!message || !*message || strlen(message) > NAME_LENGTH
  7822. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7823. {
  7824. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7825. 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".
  7826. return -1;
  7827. } else if (type != 0) {
  7828. type = type-'0'; //make it int
  7829. if (type != 1) {
  7830. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7831. return -1;
  7832. }
  7833. }
  7834. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7835. return 0;
  7836. }
  7837. /**
  7838. * @set <variable name{[index]}>{ <value>}
  7839. *
  7840. * Gets or sets a value of a non server variable.
  7841. * If a value is specified it is used to set the variable's value,
  7842. * if not the variable's value is read.
  7843. * In any case it reads and displays the variable's value.
  7844. *
  7845. * Original implementation by Ind
  7846. */
  7847. ACMD_FUNC(set) {
  7848. char reg[46], val[128], name[32];
  7849. int toset = 0, len, index;
  7850. bool is_str = false;
  7851. int64 uid;
  7852. if( !message || !*message || (toset = sscanf(message, "%45s %127[^\n]s", reg, val)) < 1 ) {
  7853. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7854. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7855. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7856. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7857. return -1;
  7858. }
  7859. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7860. if( reg[0] == '.' ) {
  7861. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7862. return -1;
  7863. } else if( reg[0] == '\'' ) {
  7864. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7865. return -1;
  7866. }
  7867. // Check if the user wanted to set an array
  7868. if( sscanf( reg, "%31[^[][%11d]", name, &index ) < 2 ){
  7869. // The user did not specify array brackets, so we set the index to zero
  7870. index = 0;
  7871. }
  7872. is_str = is_string_variable(name);
  7873. if( ( len = strlen(val) ) > 1 ) {
  7874. if( val[0] == '"' && val[len-1] == '"') {
  7875. val[len-1] = '\0'; //Strip quotes.
  7876. memmove(val, val+1, len-1);
  7877. }
  7878. }
  7879. // Only set the variable if there is a value for it
  7880. if( toset >= 2 ){
  7881. setd_sub( NULL, sd, name, index, is_str ? (void*)val : (void*)__64BPRTSIZE((atoi(val))), NULL );
  7882. }
  7883. uid = reference_uid( add_str( name ), index );
  7884. if( is_str ) {// string variable
  7885. char* value;
  7886. switch( reg[0] ) {
  7887. case '@':
  7888. value = pc_readregstr(sd, uid);
  7889. break;
  7890. case '$':
  7891. value = mapreg_readregstr(uid);
  7892. break;
  7893. case '#':
  7894. if( reg[1] == '#' )
  7895. value = pc_readaccountreg2str(sd, uid);// global
  7896. else
  7897. value = pc_readaccountregstr(sd, uid);// local
  7898. break;
  7899. default:
  7900. value = pc_readglobalreg_str(sd, uid);
  7901. break;
  7902. }
  7903. if( value == NULL || *value == '\0' ){// empty string
  7904. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7905. }else{
  7906. sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now :%s
  7907. }
  7908. } else {// integer variable
  7909. int value;
  7910. switch( reg[0] ) {
  7911. case '@':
  7912. value = pc_readreg(sd, uid);
  7913. break;
  7914. case '$':
  7915. value = mapreg_readreg(uid);
  7916. break;
  7917. case '#':
  7918. if( reg[1] == '#' )
  7919. value = pc_readaccountreg2(sd, uid);// global
  7920. else
  7921. value = pc_readaccountreg(sd, uid);// local
  7922. break;
  7923. default:
  7924. value = pc_readglobalreg(sd, uid);
  7925. break;
  7926. }
  7927. sprintf(atcmd_output,msg_txt(sd,1373),reg,value); // %s value is now :%d
  7928. }
  7929. clif_displaymessage(fd, atcmd_output);
  7930. return 0;
  7931. }
  7932. ACMD_FUNC(addperm) {
  7933. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7934. bool add;
  7935. int i;
  7936. parent_cmd = atcommand_checkalias(command+1);
  7937. add = (strcmpi(parent_cmd, "addperm") == 0);
  7938. if( !message || !*message ) {
  7939. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7940. clif_displaymessage(fd, atcmd_output);
  7941. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7942. for( i = 0; i < perm_size; i++ ) {
  7943. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7944. clif_displaymessage(fd, atcmd_output);
  7945. }
  7946. return -1;
  7947. }
  7948. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7949. if( i == perm_size ) {
  7950. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7951. clif_displaymessage(fd, atcmd_output);
  7952. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7953. for( i = 0; i < perm_size; i++ ) {
  7954. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7955. clif_displaymessage(fd, atcmd_output);
  7956. }
  7957. return -1;
  7958. }
  7959. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7960. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7961. clif_displaymessage(fd, atcmd_output);
  7962. return -1;
  7963. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7964. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7965. clif_displaymessage(fd, atcmd_output);
  7966. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7967. clif_displaymessage(fd, atcmd_output);
  7968. for( i = 0; i < perm_size; i++ ) {
  7969. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7970. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7971. clif_displaymessage(fd, atcmd_output);
  7972. }
  7973. }
  7974. return -1;
  7975. }
  7976. if( add )
  7977. sd->permissions |= pc_g_permission_name[i].permission;
  7978. else
  7979. sd->permissions &=~ pc_g_permission_name[i].permission;
  7980. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7981. clif_displaymessage(fd, atcmd_output);
  7982. return 0;
  7983. }
  7984. ACMD_FUNC(unloadnpcfile) {
  7985. if( !message || !*message ) {
  7986. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7987. return -1;
  7988. }
  7989. if( npc_unloadfile(message) )
  7990. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7991. else {
  7992. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7993. return -1;
  7994. }
  7995. return 0;
  7996. }
  7997. ACMD_FUNC(cart) {
  7998. #define MC_CART_MDFY(idx, x) \
  7999. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  8000. sd->status.skill[(idx)].lv = (x)?1:0; \
  8001. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  8002. int val = atoi(message);
  8003. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  8004. uint16 sk_idx = 0;
  8005. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  8006. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  8007. clif_displaymessage(fd, atcmd_output);
  8008. return -1;
  8009. }
  8010. if( val == 0 && !pc_iscarton(sd) ) {
  8011. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  8012. return -1;
  8013. }
  8014. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  8015. return -1;
  8016. if( need_skill ) {
  8017. MC_CART_MDFY(sk_idx,1);
  8018. }
  8019. if( !pc_setcart(sd, val) ) {
  8020. if( need_skill ) {
  8021. MC_CART_MDFY(sk_idx,0);
  8022. }
  8023. return -1;/* @cart failed */
  8024. }
  8025. if( need_skill ) {
  8026. MC_CART_MDFY(sk_idx,0);
  8027. }
  8028. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  8029. return 0;
  8030. #undef MC_CART_MDFY
  8031. }
  8032. /* Channel System [Ind] */
  8033. ACMD_FUNC(join){
  8034. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  8035. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  8036. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  8037. clif_displaymessage(fd, atcmd_output);
  8038. return -1;
  8039. }
  8040. return channel_pcjoin(sd, chname, pass);
  8041. }
  8042. /*
  8043. * Display available option for @channel command
  8044. * @command : the name of used command (for alias case)
  8045. */
  8046. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  8047. {
  8048. int fd = sd->fd;
  8049. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  8050. bool can_create = (can_delete || channel_config.private_channel.allow);
  8051. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  8052. //option create
  8053. if( can_create ) {
  8054. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  8055. clif_displaymessage(fd, atcmd_output);
  8056. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  8057. }
  8058. //option delete
  8059. if(can_delete){
  8060. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  8061. clif_displaymessage(fd, atcmd_output);
  8062. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  8063. }
  8064. //option list
  8065. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  8066. clif_displaymessage(fd, atcmd_output);
  8067. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  8068. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  8069. clif_displaymessage(fd, atcmd_output);
  8070. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  8071. if( can_create ) {
  8072. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  8073. clif_displaymessage(fd, atcmd_output);
  8074. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  8075. }
  8076. //option setcolor
  8077. if(can_create){
  8078. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  8079. clif_displaymessage(fd, atcmd_output);
  8080. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  8081. }
  8082. //option join
  8083. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  8084. clif_displaymessage(fd, atcmd_output);
  8085. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  8086. //option leave
  8087. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  8088. clif_displaymessage(fd, atcmd_output);
  8089. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  8090. //option bindto
  8091. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  8092. clif_displaymessage(fd, atcmd_output);
  8093. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  8094. //option unbind
  8095. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  8096. clif_displaymessage(fd, atcmd_output);
  8097. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  8098. //option ban/unban/banlist
  8099. if( can_create ) {
  8100. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  8101. clif_displaymessage(fd, atcmd_output);
  8102. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  8103. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  8104. clif_displaymessage(fd, atcmd_output);
  8105. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  8106. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  8107. clif_displaymessage(fd, atcmd_output);
  8108. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  8109. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  8110. clif_displaymessage(fd, atcmd_output);
  8111. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  8112. }
  8113. //option setopt
  8114. if(can_create){
  8115. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  8116. clif_displaymessage(fd, atcmd_output);
  8117. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  8118. }
  8119. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  8120. clif_displaymessage(fd, atcmd_output);
  8121. }
  8122. ACMD_FUNC(channel) {
  8123. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  8124. sub1[0] = sub2[0] = '\0';
  8125. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  8126. atcmd_channel_help(sd,command);
  8127. return 0;
  8128. }
  8129. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  8130. return channel_pcdelete(sd,sub1);
  8131. } else if ( strcmpi(key,"list") == 0 ) {
  8132. return channel_display_list(sd,sub1);
  8133. } else if ( strcmpi(key,"setcolor") == 0 ) {
  8134. return channel_pccolor(sd, sub1, sub2);
  8135. } else if ( strcmpi(key,"join") == 0 ) {
  8136. return channel_pcjoin(sd, sub1, sub2);
  8137. }else if ( strcmpi(key,"leave") == 0 ) {
  8138. return channel_pcleave(sd, sub1);
  8139. } else if ( strcmpi(key,"bindto") == 0 ) {
  8140. return channel_pcbind(sd, sub1);
  8141. } else if ( strcmpi(key,"unbind") == 0 ) {
  8142. return channel_pcunbind(sd);
  8143. } else if ( strcmpi(key,"ban") == 0 ) {
  8144. return channel_pcban(sd,sub1,sub2,0);
  8145. } else if ( strcmpi(key,"kick") == 0 ) {
  8146. return channel_pckick(sd,sub1,sub2);
  8147. } else if ( strcmpi(key,"banlist") == 0 ) {
  8148. return channel_pcban(sd,sub1,NULL,3);
  8149. } else if ( strcmpi(key,"unban") == 0 ) {
  8150. return channel_pcban(sd,sub1,sub2,1);
  8151. } else if ( strcmpi(key,"unbanall") == 0 ) {
  8152. return channel_pcban(sd,sub1,NULL,2);
  8153. } else {
  8154. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  8155. sub3[0] = sub4[0] = '\0';
  8156. sscanf(sub2, "%19s %19s", sub3, sub4);
  8157. if( strcmpi(key,"create") == 0 && ( channel_config.private_channel.allow || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  8158. if (sub4[0] != '\0') {
  8159. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  8160. return -1;
  8161. }
  8162. return channel_pccreate(sd,sub1,sub3);
  8163. } else if ( strcmpi(key,"setopt") == 0 ) {
  8164. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8165. }
  8166. atcmd_channel_help(sd,command);
  8167. }
  8168. return 0;
  8169. }
  8170. ACMD_FUNC(fontcolor)
  8171. {
  8172. if( !message || !*message ) {
  8173. channel_display_list(sd,"colors");
  8174. return -1;
  8175. }
  8176. if( strcmpi(message,"Normal") == 0 ) {
  8177. sd->fontcolor = 0;
  8178. } else {
  8179. unsigned char k;
  8180. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8181. if( k == channel_config.colors_count ) {
  8182. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8183. clif_displaymessage(fd, atcmd_output);
  8184. return -1;
  8185. }
  8186. sd->fontcolor = k;
  8187. }
  8188. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8189. clif_displaymessage(fd, atcmd_output);
  8190. return 0;
  8191. }
  8192. ACMD_FUNC(langtype)
  8193. {
  8194. char langstr[8];
  8195. int i=0, fail=0;
  8196. memset(langstr, '\0', sizeof(langstr));
  8197. if(sscanf(message, "%3s", langstr) >= 1){
  8198. int lang=0;
  8199. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8200. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8201. char output[100];
  8202. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8203. sd->langtype = lang;
  8204. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8205. clif_displaymessage(fd,output);
  8206. return 0;
  8207. } else if (lang != -1) { //defined langage but failed check
  8208. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8209. return -1;
  8210. }
  8211. }
  8212. //wrong or no entry
  8213. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8214. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8215. while(fail != -1){ //out of range
  8216. fail = msg_checklangtype(i,false);
  8217. if(fail == 1)
  8218. clif_displaymessage(fd,msg_langtype2langstr(i));
  8219. i++;
  8220. }
  8221. return -1;
  8222. }
  8223. #ifdef VIP_ENABLE
  8224. ACMD_FUNC(vip) {
  8225. struct map_session_data *pl_sd = NULL;
  8226. char * modif_p;
  8227. int32 vipdifftime = 0;
  8228. time_t now=time(NULL);
  8229. nullpo_retr(-1, sd);
  8230. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8231. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8232. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8233. return -1;
  8234. }
  8235. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8236. modif_p = atcmd_output;
  8237. vipdifftime = (int32)solve_time(modif_p);
  8238. if (vipdifftime == 0) {
  8239. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8240. 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.
  8241. return -1;
  8242. }
  8243. if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8244. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8245. return -1;
  8246. }
  8247. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8248. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8249. return -1;
  8250. }
  8251. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8252. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8253. if (pl_sd->vip.time <= now) {
  8254. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8255. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8256. } else {
  8257. int year,month,day,hour,minute,second;
  8258. char timestr[21];
  8259. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8260. 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.
  8261. clif_displaymessage(pl_sd->fd,atcmd_output);
  8262. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8263. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8264. clif_displaymessage(pl_sd->fd,atcmd_output);
  8265. if (pl_sd != sd) {
  8266. 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.
  8267. clif_displaymessage(fd,atcmd_output);
  8268. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8269. clif_displaymessage(fd,atcmd_output);
  8270. }
  8271. }
  8272. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8273. return 0;
  8274. }
  8275. /** Enable/disable rate info */
  8276. ACMD_FUNC(showrate) {
  8277. nullpo_retr(-1,sd);
  8278. if (!sd->vip.disableshowrate) {
  8279. safestrncpy(atcmd_output,msg_txt(sd,718),CHAT_SIZE_MAX); //Personal rate information is not displayed now.
  8280. sd->vip.disableshowrate = 1;
  8281. } else {
  8282. safestrncpy(atcmd_output,msg_txt(sd,719),CHAT_SIZE_MAX); //Personal rate information will be shown.
  8283. sd->vip.disableshowrate = 0;
  8284. }
  8285. clif_displaymessage(fd,atcmd_output);
  8286. return 0;
  8287. }
  8288. #endif
  8289. ACMD_FUNC(fullstrip) {
  8290. int i;
  8291. TBL_PC *tsd;
  8292. nullpo_retr(-1,sd);
  8293. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8294. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8295. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8296. return -1;
  8297. }
  8298. if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
  8299. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8300. return -1;
  8301. }
  8302. for( i = 0; i < EQI_MAX; i++ ) {
  8303. if( tsd->equip_index[ i ] >= 0 )
  8304. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8305. }
  8306. return 0;
  8307. }
  8308. ACMD_FUNC(costume) {
  8309. const char* names[] = {
  8310. "Wedding",
  8311. "Xmas",
  8312. "Summer",
  8313. "Hanbok",
  8314. "Oktoberfest",
  8315. };
  8316. const int name2id[] = {
  8317. SC_WEDDING,
  8318. SC_XMAS,
  8319. SC_SUMMER,
  8320. SC_HANBOK,
  8321. SC_OKTOBERFEST
  8322. };
  8323. unsigned short k = 0, len = ARRAYLENGTH(names);
  8324. if( !message || !*message ) {
  8325. for( k = 0; k < len; k++ ) {
  8326. if( sd->sc.data[name2id[k]] ) {
  8327. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8328. clif_displaymessage(sd->fd, atcmd_output);
  8329. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8330. return 0;
  8331. }
  8332. }
  8333. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8334. for( k = 0; k < len; k++ ) {
  8335. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8336. clif_displaymessage(sd->fd, atcmd_output);
  8337. }
  8338. return -1;
  8339. }
  8340. for( k = 0; k < len; k++ ) {
  8341. if( sd->sc.data[name2id[k]] ) {
  8342. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8343. clif_displaymessage(sd->fd, atcmd_output);
  8344. return -1;
  8345. }
  8346. }
  8347. for( k = 0; k < len; k++ )
  8348. if( strcmpi(message, names[k]) == 0 )
  8349. break;
  8350. if( k == len ) {
  8351. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8352. clif_displaymessage(sd->fd, atcmd_output);
  8353. return -1;
  8354. }
  8355. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8356. return 0;
  8357. }
  8358. /**
  8359. * Clone other player's equipments
  8360. * Usage: @cloneequip <char name/ID>
  8361. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8362. * @author [Cydh], [Antares]
  8363. */
  8364. ACMD_FUNC(cloneequip) {
  8365. struct map_session_data *pl_sd;
  8366. nullpo_retr(-1, sd);
  8367. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8368. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8369. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8370. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8371. clif_displaymessage(fd, atcmd_output);
  8372. return -1;
  8373. }
  8374. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8375. clif_displaymessage(fd, msg_txt(sd, 3));
  8376. return -1;
  8377. }
  8378. if (sd == pl_sd) {
  8379. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8380. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8381. clif_displaymessage(fd, atcmd_output);
  8382. return -1;
  8383. }
  8384. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8385. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8386. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8387. clif_displaymessage(fd, atcmd_output);
  8388. return -1;
  8389. }
  8390. else {
  8391. int8 i;
  8392. for (i = 0; i < EQI_MAX; i++) {
  8393. short idx;
  8394. char flag = 0;
  8395. struct item tmp_item;
  8396. if ((idx = pl_sd->equip_index[i]) < 0)
  8397. continue;
  8398. if (i == EQI_AMMO)
  8399. continue;
  8400. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8401. continue;
  8402. tmp_item = pl_sd->inventory.u.items_inventory[idx];
  8403. if (itemdb_isspecial(tmp_item.card[0]))
  8404. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8405. tmp_item.bound = 0;
  8406. tmp_item.expire_time = 0;
  8407. tmp_item.unique_id = 0;
  8408. tmp_item.favorite = 0;
  8409. tmp_item.amount = 1;
  8410. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8411. clif_additem(sd, 0, 0, flag);
  8412. else
  8413. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8414. }
  8415. }
  8416. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8417. sprintf(atcmd_output, msg_txt(sd, 738), "equip"); // Clone '%s' is done.
  8418. clif_displaymessage(fd, atcmd_output);
  8419. return 0;
  8420. }
  8421. /**
  8422. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8423. * Usage: @clonestat <char name/ID>
  8424. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8425. * @author [Cydh], [Antares]
  8426. */
  8427. ACMD_FUNC(clonestat) {
  8428. struct map_session_data *pl_sd;
  8429. nullpo_retr(-1, sd);
  8430. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8431. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8432. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8433. sprintf(atcmd_output, msg_txt(sd, 735), command); // Usage: %s <char name/ID>
  8434. clif_displaymessage(fd, atcmd_output);
  8435. return -1;
  8436. }
  8437. if (!(pl_sd = map_nick2sd(atcmd_player_name, true)) && !(pl_sd = map_charid2sd(atoi(atcmd_player_name)))) {
  8438. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8439. return -1;
  8440. }
  8441. if (sd == pl_sd) {
  8442. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8443. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8444. clif_displaymessage(fd, atcmd_output);
  8445. return -1;
  8446. }
  8447. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8448. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8449. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8450. clif_displaymessage(fd, atcmd_output);
  8451. return -1;
  8452. }
  8453. else {
  8454. uint8 i;
  8455. short max_status[6];
  8456. pc_resetstate(sd);
  8457. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8458. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8459. else {
  8460. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8461. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8462. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8463. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8464. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8465. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8466. }
  8467. #define clonestat_check(cmd,stat)\
  8468. {\
  8469. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8470. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8471. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8472. clif_displaymessage(fd, atcmd_output);\
  8473. sd->status.cmd = max_status[(stat)];\
  8474. }\
  8475. else\
  8476. sd->status.cmd = pl_sd->status.cmd;\
  8477. }
  8478. clonestat_check(str, PARAM_STR);
  8479. clonestat_check(agi, PARAM_AGI);
  8480. clonestat_check(vit, PARAM_VIT);
  8481. clonestat_check(int_, PARAM_INT);
  8482. clonestat_check(dex, PARAM_DEX);
  8483. clonestat_check(luk, PARAM_LUK);
  8484. for (i = 0; i < PARAM_MAX; i++) {
  8485. clif_updatestatus(sd, SP_STR + i);
  8486. clif_updatestatus(sd, SP_USTR + i);
  8487. }
  8488. status_calc_pc(sd, SCO_FORCE);
  8489. }
  8490. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8491. sprintf(atcmd_output, msg_txt(sd, 738), "status"); // Clone '%s' is done.
  8492. clif_displaymessage(fd, atcmd_output);
  8493. #undef clonestat_check
  8494. return 0;
  8495. }
  8496. /**
  8497. * Adopt a character.
  8498. * Usage: @adopt <char name>
  8499. * https://rathena.org/board/topic/104014-suggestion-add-adopt-or-etc/
  8500. */
  8501. ACMD_FUNC(adopt)
  8502. {
  8503. TBL_PC *b_sd;
  8504. enum adopt_responses response;
  8505. nullpo_retr(-1, sd);
  8506. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8507. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  8508. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  8509. sprintf(atcmd_output, msg_txt(sd, 435), command); // Please enter a player name (usage: %s <char name>).
  8510. clif_displaymessage(fd, atcmd_output);
  8511. return -1;
  8512. }
  8513. if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
  8514. clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
  8515. return -1;
  8516. }
  8517. response = pc_try_adopt(sd, map_charid2sd(sd->status.partner_id), b_sd);
  8518. if (response == ADOPT_ALLOWED) {
  8519. TBL_PC *p_sd = map_charid2sd(sd->status.partner_id);
  8520. b_sd->adopt_invite = sd->status.account_id;
  8521. clif_Adopt_request(b_sd, sd, p_sd->status.account_id);
  8522. return 0;
  8523. }
  8524. if (response < ADOPT_MORE_CHILDREN) // No displaymessage for client-type responses
  8525. clif_displaymessage(fd, msg_txt(sd, 744 + response - 1));
  8526. return -1;
  8527. }
  8528. #include "../custom/atcommand.inc"
  8529. /**
  8530. * Fills the reference of available commands in atcommand DBMap
  8531. **/
  8532. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8533. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8534. // Define with restriction
  8535. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8536. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8537. void atcommand_basecommands(void) {
  8538. /**
  8539. * Command reference list, place the base of your commands here
  8540. * TODO: List all commands that causing crash
  8541. **/
  8542. AtCommandInfo atcommand_base[] = {
  8543. #include "../custom/atcommand_def.inc"
  8544. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8545. ACMD_DEF(where),
  8546. ACMD_DEF(jumpto),
  8547. ACMD_DEF(jump),
  8548. ACMD_DEF(who),
  8549. ACMD_DEF2("who2", who),
  8550. ACMD_DEF2("who3", who),
  8551. ACMD_DEF2("whomap", who),
  8552. ACMD_DEF2("whomap2", who),
  8553. ACMD_DEF2("whomap3", who),
  8554. ACMD_DEF(whogm),
  8555. ACMD_DEF(save),
  8556. ACMD_DEF(load),
  8557. ACMD_DEF(speed),
  8558. ACMD_DEF(storage),
  8559. ACMD_DEF(guildstorage),
  8560. ACMD_DEF(option),
  8561. ACMD_DEF(hide), // + /hide
  8562. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8563. ACMD_DEF(kill),
  8564. ACMD_DEF(alive),
  8565. ACMD_DEF(kami),
  8566. ACMD_DEF2("kamib", kami),
  8567. ACMD_DEF2("kamic", kami),
  8568. ACMD_DEF2("lkami", kami),
  8569. ACMD_DEF(heal),
  8570. ACMD_DEF(item),
  8571. ACMD_DEF(item2),
  8572. ACMD_DEF2("itembound",item),
  8573. ACMD_DEF2("itembound2",item2),
  8574. ACMD_DEF(itemreset),
  8575. ACMD_DEF(clearstorage),
  8576. ACMD_DEF(cleargstorage),
  8577. ACMD_DEF(clearcart),
  8578. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8579. ACMD_DEF2("jlvl", joblevelup),
  8580. ACMD_DEF(help),
  8581. ACMD_DEF(pvpoff),
  8582. ACMD_DEF(pvpon),
  8583. ACMD_DEF(gvgoff),
  8584. ACMD_DEF(gvgon),
  8585. ACMD_DEF(model),
  8586. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8587. ACMD_DEF(monster),
  8588. ACMD_DEF2("monstersmall", monster),
  8589. ACMD_DEF2("monsterbig", monster),
  8590. ACMD_DEF(killmonster),
  8591. ACMD_DEF2("killmonster2", killmonster),
  8592. ACMD_DEF(refine),
  8593. ACMD_DEF(produce),
  8594. ACMD_DEF(memo),
  8595. ACMD_DEF(gat),
  8596. ACMD_DEF(displaystatus),
  8597. ACMD_DEF2("stpoint", statuspoint),
  8598. ACMD_DEF2("skpoint", skillpoint),
  8599. ACMD_DEF(zeny),
  8600. ACMD_DEF2("str", param),
  8601. ACMD_DEF2("agi", param),
  8602. ACMD_DEF2("vit", param),
  8603. ACMD_DEF2("int", param),
  8604. ACMD_DEF2("dex", param),
  8605. ACMD_DEF2("luk", param),
  8606. ACMD_DEF2("glvl", guildlevelup),
  8607. ACMD_DEF(makeegg),
  8608. ACMD_DEF(hatch),
  8609. ACMD_DEF(petfriendly),
  8610. ACMD_DEF(pethungry),
  8611. ACMD_DEF(petrename),
  8612. ACMD_DEF(recall), // + /recall
  8613. ACMD_DEF(night),
  8614. ACMD_DEF(day),
  8615. ACMD_DEF(doom),
  8616. ACMD_DEF(doommap),
  8617. ACMD_DEF(raise),
  8618. ACMD_DEF(raisemap),
  8619. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8620. ACMD_DEF(kickall),
  8621. ACMD_DEF(allskill),
  8622. ACMD_DEF(questskill),
  8623. ACMD_DEF(lostskill),
  8624. ACMD_DEF(spiritball),
  8625. ACMD_DEF(party),
  8626. ACMD_DEF(guild),
  8627. ACMD_DEF(breakguild),
  8628. ACMD_DEF(agitstart),
  8629. ACMD_DEF(agitend),
  8630. ACMD_DEF(mapexit),
  8631. ACMD_DEF(idsearch),
  8632. ACMD_DEF(broadcast), // + /b and /nb
  8633. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8634. ACMD_DEF(recallall),
  8635. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8636. ACMD_DEF2("reloaditemdb", reload),
  8637. ACMD_DEF2("reloadmobdb", reload),
  8638. ACMD_DEF2("reloadskilldb", reload),
  8639. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8640. ACMD_DEF2("reloadatcommand", reload),
  8641. ACMD_DEF2("reloadbattleconf", reload),
  8642. ACMD_DEF2("reloadstatusdb", reload),
  8643. ACMD_DEF2("reloadpcdb", reload),
  8644. ACMD_DEF2("reloadmotd", reload),
  8645. ACMD_DEF2("reloadquestdb", reload),
  8646. ACMD_DEF2("reloadmsgconf", reload),
  8647. ACMD_DEF2("reloadinstancedb", reload),
  8648. ACMD_DEF2("reloadachievementdb",reload),
  8649. ACMD_DEF(partysharelvl),
  8650. ACMD_DEF(mapinfo),
  8651. ACMD_DEF(dye),
  8652. ACMD_DEF2("hairstyle", hair_style),
  8653. ACMD_DEF2("haircolor", hair_color),
  8654. ACMD_DEF2("allstats", stat_all),
  8655. ACMD_DEF2("block", char_block),
  8656. ACMD_DEF2("ban", char_ban),
  8657. ACMD_DEF2("unblock", char_unblock),
  8658. ACMD_DEF2("unban", char_unban),
  8659. ACMD_DEF2("charban", char_ban),
  8660. ACMD_DEF2("charunban", char_unban),
  8661. ACMD_DEF2("mount", mount_peco),
  8662. ACMD_DEF(guildspy),
  8663. ACMD_DEF(partyspy),
  8664. ACMD_DEF(clanspy),
  8665. ACMD_DEF(repairall),
  8666. ACMD_DEF(guildrecall),
  8667. ACMD_DEF(partyrecall),
  8668. ACMD_DEF(nuke),
  8669. ACMD_DEF(shownpc),
  8670. ACMD_DEF(hidenpc),
  8671. ACMD_DEF(loadnpc),
  8672. ACMD_DEF(unloadnpc),
  8673. ACMD_DEF(reloadnpcfile),
  8674. ACMD_DEF2("time", servertime),
  8675. ACMD_DEF(jail),
  8676. ACMD_DEF(unjail),
  8677. ACMD_DEF(jailfor),
  8678. ACMD_DEF(jailtime),
  8679. ACMD_DEF(disguise),
  8680. ACMD_DEF(undisguise),
  8681. ACMD_DEF(email),
  8682. ACMD_DEF(effect),
  8683. ACMD_DEF(follow),
  8684. ACMD_DEF(addwarp),
  8685. ACMD_DEF(skillon),
  8686. ACMD_DEF(skilloff),
  8687. ACMD_DEF(killer),
  8688. ACMD_DEF(npcmove),
  8689. ACMD_DEF(killable),
  8690. ACMD_DEF(dropall),
  8691. ACMD_DEF(storeall),
  8692. ACMD_DEF(skillid),
  8693. ACMD_DEF(useskill),
  8694. ACMD_DEF(displayskill),
  8695. ACMD_DEF(snow),
  8696. ACMD_DEF(sakura),
  8697. ACMD_DEF(clouds),
  8698. ACMD_DEF(clouds2),
  8699. ACMD_DEF(fog),
  8700. ACMD_DEF(fireworks),
  8701. ACMD_DEF(leaves),
  8702. ACMD_DEF(summon),
  8703. ACMD_DEF(adjgroup),
  8704. ACMD_DEF(trade),
  8705. ACMD_DEF(send),
  8706. ACMD_DEF(setbattleflag),
  8707. ACMD_DEF(unmute),
  8708. ACMD_DEF(clearweather),
  8709. ACMD_DEF(uptime),
  8710. ACMD_DEF(changesex),
  8711. ACMD_DEF(changecharsex),
  8712. ACMD_DEF(mute),
  8713. ACMD_DEF(refresh),
  8714. ACMD_DEF(refreshall),
  8715. ACMD_DEF(identify),
  8716. ACMD_DEF(identifyall),
  8717. ACMD_DEF(gmotd),
  8718. ACMD_DEF(misceffect),
  8719. ACMD_DEF(mobsearch),
  8720. ACMD_DEF(cleanmap),
  8721. ACMD_DEF(cleanarea),
  8722. ACMD_DEF(npctalk),
  8723. ACMD_DEF(pettalk),
  8724. ACMD_DEF(users),
  8725. ACMD_DEF(reset),
  8726. ACMD_DEF(skilltree),
  8727. ACMD_DEF(marry),
  8728. ACMD_DEF(divorce),
  8729. ACMD_DEF(sound),
  8730. ACMD_DEF(undisguiseall),
  8731. ACMD_DEF(disguiseall),
  8732. ACMD_DEF(changelook),
  8733. ACMD_DEF(autoloot),
  8734. ACMD_DEF2("alootid", autolootitem),
  8735. ACMD_DEF(autoloottype),
  8736. ACMD_DEF(mobinfo),
  8737. ACMD_DEF(exp),
  8738. ACMD_DEF(version),
  8739. ACMD_DEF(mutearea),
  8740. ACMD_DEF(rates),
  8741. ACMD_DEF(iteminfo),
  8742. ACMD_DEF(whodrops),
  8743. ACMD_DEF(whereis),
  8744. ACMD_DEF(mapflag),
  8745. ACMD_DEF(me),
  8746. ACMD_DEF(monsterignore),
  8747. ACMD_DEF(fakename),
  8748. ACMD_DEF(size),
  8749. ACMD_DEF(showexp),
  8750. ACMD_DEF(showzeny),
  8751. ACMD_DEF(showdelay),
  8752. ACMD_DEF(autotrade),
  8753. ACMD_DEF(changegm),
  8754. ACMD_DEF(changeleader),
  8755. ACMD_DEF(partyoption),
  8756. ACMD_DEF(invite),
  8757. ACMD_DEF(duel),
  8758. ACMD_DEF(leave),
  8759. ACMD_DEF(accept),
  8760. ACMD_DEF(reject),
  8761. ACMD_DEF(clone),
  8762. ACMD_DEF2("slaveclone", clone),
  8763. ACMD_DEF2("evilclone", clone),
  8764. ACMD_DEF(tonpc),
  8765. ACMD_DEF(commands),
  8766. ACMD_DEF(noask),
  8767. ACMD_DEF(request),
  8768. ACMD_DEF(homlevel),
  8769. ACMD_DEF(homevolution),
  8770. ACMD_DEF(hommutate),
  8771. ACMD_DEF(makehomun),
  8772. ACMD_DEF(homfriendly),
  8773. ACMD_DEF(homhungry),
  8774. ACMD_DEF(homtalk),
  8775. ACMD_DEF(hominfo),
  8776. ACMD_DEF(homstats),
  8777. ACMD_DEF(homshuffle),
  8778. ACMD_DEF(showmobs),
  8779. ACMD_DEF(feelreset),
  8780. ACMD_DEF(auction),
  8781. ACMD_DEF(mail),
  8782. ACMD_DEF2("noks", ksprotection),
  8783. ACMD_DEF(allowks),
  8784. ACMD_DEF(cash),
  8785. ACMD_DEF2("points", cash),
  8786. ACMD_DEF(agitstart2),
  8787. ACMD_DEF(agitend2),
  8788. ACMD_DEF(resetskill),
  8789. ACMD_DEF(resetstat),
  8790. ACMD_DEF2("storagelist", itemlist),
  8791. ACMD_DEF2("cartlist", itemlist),
  8792. ACMD_DEF2("itemlist", itemlist),
  8793. ACMD_DEF(stats),
  8794. ACMD_DEF(delitem),
  8795. ACMD_DEF(charcommands),
  8796. ACMD_DEF(font),
  8797. ACMD_DEF(accinfo),
  8798. ACMD_DEF(set),
  8799. ACMD_DEF(undisguiseguild),
  8800. ACMD_DEF(disguiseguild),
  8801. ACMD_DEF(sizeall),
  8802. ACMD_DEF(sizeguild),
  8803. ACMD_DEF(addperm),
  8804. ACMD_DEF2("rmvperm", addperm),
  8805. ACMD_DEF(unloadnpcfile),
  8806. ACMD_DEF(cart),
  8807. ACMD_DEF(mount2),
  8808. ACMD_DEF(join),
  8809. ACMD_DEFR(channel,ATCMD_NOSCRIPT),
  8810. ACMD_DEF(fontcolor),
  8811. ACMD_DEF(langtype),
  8812. #ifdef VIP_ENABLE
  8813. ACMD_DEF(vip),
  8814. ACMD_DEF(showrate),
  8815. #endif
  8816. ACMD_DEF(fullstrip),
  8817. ACMD_DEF(costume),
  8818. ACMD_DEF(cloneequip),
  8819. ACMD_DEF(clonestat),
  8820. ACMD_DEF(bodystyle),
  8821. ACMD_DEF(adopt),
  8822. ACMD_DEF(agitstart3),
  8823. ACMD_DEF(agitend3),
  8824. };
  8825. AtCommandInfo* atcommand;
  8826. int i;
  8827. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8828. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8829. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8830. continue;
  8831. }
  8832. CREATE(atcommand, AtCommandInfo, 1);
  8833. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8834. atcommand->func = atcommand_base[i].func;
  8835. atcommand->restriction = atcommand_base[i].restriction;
  8836. strdb_put(atcommand_db, atcommand->command, atcommand);
  8837. }
  8838. return;
  8839. }
  8840. /*==========================================
  8841. * Command lookup functions
  8842. *------------------------------------------*/
  8843. bool atcommand_exists(const char* name)
  8844. {
  8845. return strdb_exists(atcommand_db, name);
  8846. }
  8847. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8848. {
  8849. if (strdb_exists(atcommand_db, name))
  8850. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8851. return NULL;
  8852. }
  8853. static const char* atcommand_checkalias(const char *aliasname)
  8854. {
  8855. AliasInfo *alias_info = NULL;
  8856. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8857. return alias_info->command->command;
  8858. return aliasname;
  8859. }
  8860. /// AtCommand suggestion
  8861. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8862. DBIterator* atcommand_iter;
  8863. DBIterator* alias_iter;
  8864. AtCommandInfo* command_info = NULL;
  8865. AliasInfo* alias_info = NULL;
  8866. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8867. char* full_match[MAX_SUGGESTIONS];
  8868. char* suggestions[MAX_SUGGESTIONS];
  8869. char* match;
  8870. int prefix_count = 0, full_count = 0;
  8871. bool can_use;
  8872. if (!battle_config.atcommand_suggestions_enabled)
  8873. return;
  8874. atcommand_iter = db_iterator(atcommand_db);
  8875. alias_iter = db_iterator(atcommand_alias_db);
  8876. // Build the matches
  8877. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8878. match = strstr(command_info->command, name);
  8879. can_use = pc_can_use_command(sd, command_info->command, type);
  8880. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8881. suggestions[prefix_count] = command_info->command;
  8882. ++prefix_count;
  8883. }
  8884. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8885. full_match[full_count] = command_info->command;
  8886. ++full_count;
  8887. }
  8888. }
  8889. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8890. match = strstr(alias_info->alias, name);
  8891. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8892. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8893. suggestions[prefix_count] = alias_info->alias;
  8894. ++prefix_count;
  8895. }
  8896. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8897. full_match[full_count] = alias_info->alias;
  8898. ++full_count;
  8899. }
  8900. }
  8901. if ((full_count+prefix_count) > 0) {
  8902. char buffer[512];
  8903. int i;
  8904. // Merge full match and prefix match results
  8905. if (prefix_count < MAX_SUGGESTIONS) {
  8906. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8907. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8908. }
  8909. // Build the suggestion string
  8910. strcpy(buffer, msg_txt(sd,205)); // Maybe you meant:
  8911. strcat(buffer,"\n");
  8912. for(i=0; i < prefix_count; ++i) {
  8913. strcat(buffer,suggestions[i]);
  8914. strcat(buffer," ");
  8915. }
  8916. clif_displaymessage(sd->fd, buffer);
  8917. }
  8918. dbi_destroy(atcommand_iter);
  8919. dbi_destroy(alias_iter);
  8920. }
  8921. /**
  8922. * Executes an at-command
  8923. * @param fd
  8924. * @param sd
  8925. * @param message
  8926. * @param type
  8927. * 0 : script call (atcommand)
  8928. * 1 : normal player @atcommand
  8929. * 2 : console (admin:@atcommand)
  8930. * 3 : script call (useatcmd)
  8931. */
  8932. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8933. {
  8934. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8935. char output[CHAT_SIZE_MAX];
  8936. //Reconstructed message
  8937. char atcmd_msg[CHAT_SIZE_MAX];
  8938. TBL_PC * ssd = NULL; //sd for target
  8939. AtCommandInfo * info;
  8940. bool is_atcommand = true; // false if it's a charcommand
  8941. nullpo_retr(false, sd);
  8942. //Shouldn't happen
  8943. if ( !message || !*message )
  8944. return false;
  8945. //If cannot use atcomamnd while talking with NPC [Kichi]
  8946. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8947. return false;
  8948. //Block NOCHAT but do not display it as a normal message
  8949. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8950. return true;
  8951. // skip 10/11-langtype's codepage indicator, if detected
  8952. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8953. message += 3;
  8954. //Should display as a normal message
  8955. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8956. return false;
  8957. // type value 0|2 = script|console invoked: bypass restrictions
  8958. if ( type == 1 || type == 3) {
  8959. //Commands are disabled on maps flagged as 'nocommand'
  8960. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8961. clif_displaymessage(fd, msg_txt(sd,143)); // Commands are disabled on this map.
  8962. return false;
  8963. }
  8964. }
  8965. if (*message == charcommand_symbol)
  8966. is_atcommand = false;
  8967. if (is_atcommand) { // @command
  8968. sprintf(atcmd_msg, "%s", message);
  8969. ssd = sd;
  8970. } else { // #command
  8971. char charname[NAME_LENGTH];
  8972. int n;
  8973. //Checks to see if #command has a name or a name + parameters.
  8974. if ((n = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params)) < 2
  8975. && (n = sscanf(message, "%255s %23s %255[^\n]", command, charname, params)) < 2
  8976. ) {
  8977. if (pc_get_group_level(sd) == 0) {
  8978. if (n < 1)
  8979. return false; // No command found. Display as normal message.
  8980. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8981. 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
  8982. return false;
  8983. }
  8984. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8985. clif_displaymessage(fd, output);
  8986. return true;
  8987. }
  8988. ssd = map_nick2sd(charname,true);
  8989. if (ssd == NULL) {
  8990. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8991. clif_displaymessage(fd, output);
  8992. return true;
  8993. }
  8994. if (n > 2)
  8995. sprintf(atcmd_msg, "%s %s", command, params);
  8996. else
  8997. sprintf(atcmd_msg, "%s", command);
  8998. }
  8999. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  9000. sd->idletime = last_tick;
  9001. //Clearing these to be used once more.
  9002. memset(command, '\0', sizeof(command));
  9003. memset(params, '\0', sizeof(params));
  9004. //check to see if any params exist within this command
  9005. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  9006. params[0] = '\0';
  9007. // @commands (script based)
  9008. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  9009. struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
  9010. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  9011. if( binding != NULL && binding->npc_event[0] &&
  9012. ((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
  9013. (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
  9014. {
  9015. // Check if self or character invoking; if self == character invoked, then self invoke.
  9016. npc_do_atcmd_event(ssd, command, params, binding->npc_event);
  9017. return true;
  9018. }
  9019. }
  9020. //Grab the command information and check for the proper GM level required to use it or if the command exists
  9021. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  9022. if (info == NULL) {
  9023. if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
  9024. return false;
  9025. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  9026. clif_displaymessage(fd, output);
  9027. atcommand_get_suggestions(sd, command + 1, is_atcommand);
  9028. return true;
  9029. }
  9030. //check restriction
  9031. if (info->restriction) {
  9032. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  9033. return true;
  9034. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  9035. return true;
  9036. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  9037. && ((is_atcommand && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  9038. return true;
  9039. }
  9040. // type == 1 : player invoked
  9041. if (type == 1) {
  9042. if ((is_atcommand && info->at_groups[sd->group_pos] == 0) ||
  9043. (!is_atcommand && info->char_groups[sd->group_pos] == 0) )
  9044. return false;
  9045. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  9046. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  9047. return true;
  9048. }
  9049. }
  9050. //Attempt to use the command
  9051. if ( (info->func(fd, ssd, command, params) != 0) )
  9052. {
  9053. sprintf(output,msg_txt(sd,154), command); // %s failed.
  9054. clif_displaymessage(fd, output);
  9055. return true;
  9056. }
  9057. //Log only if successful.
  9058. log_atcommand(sd, is_atcommand ? atcmd_msg : message);
  9059. return true;
  9060. }
  9061. /*==========================================
  9062. *
  9063. *------------------------------------------*/
  9064. static void atcommand_config_read(const char* config_filename)
  9065. {
  9066. config_setting_t *aliases = NULL, *help = NULL;
  9067. const char *symbol = NULL;
  9068. int num_aliases = 0;
  9069. if (conf_read_file(&atcommand_config, config_filename))
  9070. return;
  9071. // Command symbols
  9072. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  9073. if (ISPRINT(*symbol) && // no control characters
  9074. *symbol != '/' && // symbol of client commands
  9075. *symbol != '%' && // symbol of party chat
  9076. *symbol != '$' && // symbol of guild chat
  9077. *symbol != charcommand_symbol)
  9078. atcommand_symbol = *symbol;
  9079. }
  9080. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  9081. if (ISPRINT(*symbol) && // no control characters
  9082. *symbol != '/' && // symbol of client commands
  9083. *symbol != '%' && // symbol of party chat
  9084. *symbol != '$' && // symbol of guild chat
  9085. *symbol != atcommand_symbol)
  9086. charcommand_symbol = *symbol;
  9087. }
  9088. // Command aliases
  9089. aliases = config_lookup(&atcommand_config, "aliases");
  9090. if (aliases != NULL) {
  9091. int i = 0;
  9092. int count = config_setting_length(aliases);
  9093. for (i = 0; i < count; ++i) {
  9094. config_setting_t *command;
  9095. const char *commandname = NULL;
  9096. int j = 0, alias_count = 0;
  9097. AtCommandInfo *commandinfo = NULL;
  9098. command = config_setting_get_elem(aliases, i);
  9099. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  9100. continue;
  9101. commandname = config_setting_name(command);
  9102. if (!atcommand_exists(commandname)) {
  9103. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  9104. continue;
  9105. }
  9106. commandinfo = get_atcommandinfo_byname(commandname);
  9107. alias_count = config_setting_length(command);
  9108. for (j = 0; j < alias_count; ++j) {
  9109. const char *alias = config_setting_get_string_elem(command, j);
  9110. if (alias != NULL) {
  9111. AliasInfo *alias_info;
  9112. if (strdb_exists(atcommand_alias_db, alias)) {
  9113. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  9114. continue;
  9115. }
  9116. CREATE(alias_info, AliasInfo, 1);
  9117. alias_info->command = commandinfo;
  9118. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  9119. strdb_put(atcommand_alias_db, alias, alias_info);
  9120. ++num_aliases;
  9121. }
  9122. }
  9123. }
  9124. }
  9125. // Commands help
  9126. // We only check if all commands exist
  9127. help = config_lookup(&atcommand_config, "help");
  9128. if (help != NULL) {
  9129. int count = config_setting_length(help);
  9130. int i;
  9131. for (i = 0; i < count; ++i) {
  9132. config_setting_t *command;
  9133. const char *commandname;
  9134. command = config_setting_get_elem(help, i);
  9135. commandname = config_setting_name(command);
  9136. if (!atcommand_exists(commandname))
  9137. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  9138. }
  9139. }
  9140. ShowStatus("Done reading '" CL_WHITE "%d" CL_RESET "' command aliases in '" CL_WHITE "%s" CL_RESET "'.\n", num_aliases, config_filename);
  9141. return;
  9142. }
  9143. void atcommand_db_load_groups(int* group_ids) {
  9144. DBIterator *iter = db_iterator(atcommand_db);
  9145. AtCommandInfo* cmd;
  9146. int i;
  9147. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9148. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9149. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  9150. for(i = 0; i < pc_group_max; i++) {
  9151. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  9152. cmd->at_groups[i] = 1;
  9153. else
  9154. cmd->at_groups[i] = 0;
  9155. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  9156. cmd->char_groups[i] = 1;
  9157. else
  9158. cmd->char_groups[i] = 0;
  9159. }
  9160. }
  9161. dbi_destroy(iter);
  9162. return;
  9163. }
  9164. void atcommand_db_clear(void) {
  9165. if (atcommand_db != NULL) {
  9166. DBIterator *iter = db_iterator(atcommand_db);
  9167. AtCommandInfo* cmd;
  9168. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9169. aFree(cmd->at_groups);
  9170. aFree(cmd->char_groups);
  9171. }
  9172. dbi_destroy(iter);
  9173. db_destroy(atcommand_db);
  9174. }
  9175. if (atcommand_alias_db != NULL)
  9176. db_destroy(atcommand_alias_db);
  9177. config_destroy(&atcommand_config);
  9178. }
  9179. void atcommand_doload(void) {
  9180. atcommand_db_clear();
  9181. atcommand_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9182. atcommand_alias_db = stridb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA), ATCOMMAND_LENGTH);
  9183. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9184. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9185. }
  9186. void do_init_atcommand(void) {
  9187. atcommand_doload();
  9188. }
  9189. void do_final_atcommand(void) {
  9190. atcommand_db_clear();
  9191. }