atcommand.c 312 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #include "../common/cbasetypes.h"
  4. #include "../common/mmo.h"
  5. #include "../common/timer.h"
  6. #include "../common/nullpo.h"
  7. #include "../common/showmsg.h"
  8. #include "../common/malloc.h"
  9. #include "../common/random.h"
  10. #include "../common/socket.h"
  11. #include "../common/strlib.h"
  12. #include "../common/utils.h"
  13. #include "../common/conf.h"
  14. #include "map.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "channel.h"
  19. #include "chrif.h"
  20. #include "duel.h"
  21. #include "instance.h"
  22. #include "intif.h"
  23. #include "pet.h"
  24. #include "homunculus.h"
  25. #include "mail.h"
  26. #include "mercenary.h"
  27. #include "elemental.h"
  28. #include "party.h"
  29. #include "storage.h"
  30. #include "trade.h"
  31. #include "mapreg.h"
  32. #include "quest.h"
  33. #include <stdlib.h>
  34. #include <math.h>
  35. #define ATCOMMAND_LENGTH 50
  36. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  37. typedef struct AtCommandInfo AtCommandInfo;
  38. typedef struct AliasInfo AliasInfo;
  39. int atcmd_binding_count = 0;
  40. /// Atcommand restriction usage
  41. enum e_atcmd_restict {
  42. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  43. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  44. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  45. };
  46. struct AtCommandInfo {
  47. char command[ATCOMMAND_LENGTH];
  48. AtCommandFunc func;
  49. char* at_groups; /// Quick @commands "can-use" lookup
  50. char* char_groups; /// Quick @charcommands "can-use" lookup
  51. uint8 restriction; /// Restrictions see enum e_restict
  52. };
  53. struct AliasInfo {
  54. AtCommandInfo *command;
  55. char alias[ATCOMMAND_LENGTH];
  56. };
  57. char atcommand_symbol = '@'; // first char of the commands
  58. char charcommand_symbol = '#';
  59. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  60. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  61. static config_t atcommand_config;
  62. static char atcmd_output[CHAT_SIZE_MAX];
  63. static char atcmd_player_name[NAME_LENGTH];
  64. const char *parent_cmd;
  65. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  66. static const char* atcommand_checkalias(const char *aliasname); // @help
  67. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  68. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  69. // @commands (script-based)
  70. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  71. int i = 0;
  72. if( *name == atcommand_symbol || *name == charcommand_symbol )
  73. name++; // for backwards compatibility
  74. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  75. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  76. }
  77. /**
  78. * retrieves the help string associated with a given command.
  79. *
  80. * @param name the name of the command to retrieve help information for
  81. * @return the string associated with the command, or NULL
  82. */
  83. static const char* atcommand_help_string(const char* command)
  84. {
  85. const char* str = NULL;
  86. config_setting_t* info;
  87. if( *command == atcommand_symbol || *command == charcommand_symbol )
  88. {// remove the prefix symbol for the raw name of the command
  89. command ++;
  90. }
  91. // convert alias to the real command name
  92. command = atcommand_checkalias(command);
  93. // attempt to find the first default help command
  94. info = config_lookup(&atcommand_config, "help");
  95. if( info == NULL )
  96. {// failed to find the help property in the configuration file
  97. return NULL;
  98. }
  99. if( !config_setting_lookup_string( info, command, &str ) )
  100. {// failed to find the matching help string
  101. return NULL;
  102. }
  103. // push the result from the method
  104. return str;
  105. }
  106. /*==========================================
  107. * @send (used for testing packet sends from the client)
  108. *------------------------------------------*/
  109. ACMD_FUNC(send)
  110. {
  111. int len=0,type;
  112. // read message type as hex number (without the 0x)
  113. if(!message || !*message ||
  114. !((sscanf(message, "len %x", &type)==1 && (len=1))
  115. || sscanf(message, "%x", &type)==1) )
  116. {
  117. int i;
  118. for (i = 900; i <= 903; ++i)
  119. clif_displaymessage(fd, msg_txt(sd,i));
  120. return -1;
  121. }
  122. #define PARSE_ERROR(error,p) \
  123. {\
  124. clif_displaymessage(fd, (error));\
  125. sprintf(atcmd_output, ">%s", (p));\
  126. clif_displaymessage(fd, atcmd_output);\
  127. }
  128. //define PARSE_ERROR
  129. #define CHECK_EOS(p) \
  130. if(*(p) == 0){\
  131. clif_displaymessage(fd, "Unexpected end of string");\
  132. return -1;\
  133. }
  134. //define CHECK_EOS
  135. #define SKIP_VALUE(p) \
  136. {\
  137. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  138. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  139. }
  140. //define SKIP_VALUE
  141. #define GET_VALUE(p,num) \
  142. {\
  143. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  144. PARSE_ERROR("Invalid number in:",(p));\
  145. return -1;\
  146. }\
  147. }
  148. //define GET_VALUE
  149. if (type > 0 && type < MAX_PACKET_DB) {
  150. int off,end;
  151. long num;
  152. if(len)
  153. {// show packet length
  154. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  155. clif_displaymessage(fd, atcmd_output);
  156. return 0;
  157. }
  158. len=packet_db[sd->packet_ver][type].len;
  159. off=2;
  160. if(len == 0)
  161. {// unknown packet - ERROR
  162. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  163. clif_displaymessage(fd, atcmd_output);
  164. return -1;
  165. } else if(len == -1)
  166. {// dynamic packet
  167. len=SHRT_MAX-4; // maximum length
  168. off=4;
  169. }
  170. WFIFOHEAD(fd, len);
  171. WFIFOW(fd,0)=TOW(type);
  172. // parse packet contents
  173. SKIP_VALUE(message);
  174. while(*message != 0 && off < len){
  175. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  176. {// default (byte)
  177. GET_VALUE(message,num);
  178. WFIFOB(fd,off)=TOB(num);
  179. ++off;
  180. } else if(TOUPPER(*message) == 'B')
  181. {// byte
  182. ++message;
  183. GET_VALUE(message,num);
  184. WFIFOB(fd,off)=TOB(num);
  185. ++off;
  186. } else if(TOUPPER(*message) == 'W')
  187. {// word (2 bytes)
  188. ++message;
  189. GET_VALUE(message,num);
  190. WFIFOW(fd,off)=TOW(num);
  191. off+=2;
  192. } else if(TOUPPER(*message) == 'L')
  193. {// long word (4 bytes)
  194. ++message;
  195. GET_VALUE(message,num);
  196. WFIFOL(fd,off)=TOL(num);
  197. off+=4;
  198. } else if(TOUPPER(*message) == 'S')
  199. {// string - escapes are valid
  200. // get string length - num <= 0 means not fixed length (default)
  201. ++message;
  202. if(*message == '"'){
  203. num=0;
  204. } else {
  205. GET_VALUE(message,num);
  206. while(*message != '"')
  207. {// find start of string
  208. if(*message == 0 || ISSPACE(*message)){
  209. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  210. return -1;
  211. }
  212. ++message;
  213. }
  214. }
  215. // parse string
  216. ++message;
  217. CHECK_EOS(message);
  218. end=(num<=0? 0: min(off+((int)num),len));
  219. for(; *message != '"' && (off < end || end == 0); ++off){
  220. if(*message == '\\'){
  221. ++message;
  222. CHECK_EOS(message);
  223. switch(*message){
  224. case 'a': num=0x07; break; // Bell
  225. case 'b': num=0x08; break; // Backspace
  226. case 't': num=0x09; break; // Horizontal tab
  227. case 'n': num=0x0A; break; // Line feed
  228. case 'v': num=0x0B; break; // Vertical tab
  229. case 'f': num=0x0C; break; // Form feed
  230. case 'r': num=0x0D; break; // Carriage return
  231. case 'e': num=0x1B; break; // Escape
  232. default: num=*message; break;
  233. case 'x': // Hexadecimal
  234. {
  235. ++message;
  236. CHECK_EOS(message);
  237. if(!ISXDIGIT(*message)){
  238. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  239. return -1;
  240. }
  241. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  242. if(ISXDIGIT(*message)){
  243. ++message;
  244. CHECK_EOS(message);
  245. num<<=8;
  246. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  247. }
  248. WFIFOB(fd,off)=TOB(num);
  249. ++message;
  250. CHECK_EOS(message);
  251. continue;
  252. }
  253. case '0':
  254. case '1':
  255. case '2':
  256. case '3':
  257. case '4':
  258. case '5':
  259. case '6':
  260. case '7': // Octal
  261. {
  262. num=*message-'0'; // 1st octal digit
  263. ++message;
  264. CHECK_EOS(message);
  265. if(ISDIGIT(*message) && *message < '8'){
  266. num<<=3;
  267. num+=*message-'0'; // 2nd octal digit
  268. ++message;
  269. CHECK_EOS(message);
  270. if(ISDIGIT(*message) && *message < '8'){
  271. num<<=3;
  272. num+=*message-'0'; // 3rd octal digit
  273. ++message;
  274. CHECK_EOS(message);
  275. }
  276. }
  277. WFIFOB(fd,off)=TOB(num);
  278. continue;
  279. }
  280. }
  281. } else
  282. num=*message;
  283. WFIFOB(fd,off)=TOB(num);
  284. ++message;
  285. CHECK_EOS(message);
  286. }//for
  287. while(*message != '"')
  288. {// ignore extra characters
  289. ++message;
  290. CHECK_EOS(message);
  291. }
  292. // terminate the string
  293. if(off < end)
  294. {// fill the rest with 0's
  295. memset(WFIFOP(fd,off),0,end-off);
  296. off=end;
  297. }
  298. } else
  299. {// unknown
  300. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  301. return -1;
  302. }
  303. SKIP_VALUE(message);
  304. }
  305. if(packet_db[sd->packet_ver][type].len == -1)
  306. {// send dynamic packet
  307. WFIFOW(fd,2)=TOW(off);
  308. WFIFOSET(fd,off);
  309. } else
  310. {// send static packet
  311. if(off < len)
  312. memset(WFIFOP(fd,off),0,len-off);
  313. WFIFOSET(fd,len);
  314. }
  315. } else {
  316. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  317. return -1;
  318. }
  319. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  320. clif_displaymessage(fd, atcmd_output);
  321. return 0;
  322. #undef PARSE_ERROR
  323. #undef CHECK_EOS
  324. #undef SKIP_VALUE
  325. #undef GET_VALUE
  326. }
  327. /**
  328. * Retrieves map name suggestions for a given string.
  329. * This will first check if any map names contain the given string, and will
  330. * print out MAX_SUGGESTIONS results if any maps are found.
  331. * Otherwise, suggestions will be calculated through Levenshtein distance,
  332. * and up to 5 of the closest matches will be printed.
  333. *
  334. * @author Euphy
  335. */
  336. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  337. char buffer[512];
  338. int i, count = 0;
  339. if (strlen(name) < 2)
  340. return;
  341. // build the suggestion string
  342. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  343. strcat(buffer, "\n");
  344. // check for maps that contain string
  345. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  346. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  347. strcat(buffer, map[i].name);
  348. strcat(buffer, " ");
  349. if (++count >= MAX_SUGGESTIONS)
  350. break;
  351. }
  352. }
  353. // if no maps found, search by edit distance
  354. if (!count) {
  355. unsigned int distance[MAX_MAP_PER_SERVER][2];
  356. int j;
  357. // calculate Levenshtein distance for all maps
  358. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  359. if (strlen(map[i].name) < 4) // invalid map name?
  360. distance[i][0] = INT_MAX;
  361. else {
  362. distance[i][0] = levenshtein(map[i].name, name);
  363. distance[i][1] = i;
  364. }
  365. }
  366. // selection sort elements as needed
  367. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  368. for (i = 0; i < count; i++) {
  369. int min = i;
  370. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  371. if (distance[j][0] < distance[min][0])
  372. min = j;
  373. }
  374. // print map name
  375. if (distance[min][0] > 4) { // awful results, don't bother
  376. if (!i) return;
  377. break;
  378. }
  379. strcat(buffer, map[distance[min][1]].name);
  380. strcat(buffer, " ");
  381. // swap elements
  382. swap(distance[i][0], distance[min][0]);
  383. swap(distance[i][1], distance[min][1]);
  384. }
  385. }
  386. clif_displaymessage(sd->fd, buffer);
  387. }
  388. /*==========================================
  389. * @rura, @warp, @mapmove
  390. *------------------------------------------*/
  391. ACMD_FUNC(mapmove)
  392. {
  393. char map_name[MAP_NAME_LENGTH_EXT];
  394. unsigned short mapindex;
  395. short x = 0, y = 0;
  396. int16 m = -1;
  397. nullpo_retr(-1, sd);
  398. memset(map_name, '\0', sizeof(map_name));
  399. if (!message || !*message ||
  400. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  401. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  402. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  403. return -1;
  404. }
  405. mapindex = mapindex_name2id(map_name);
  406. if (mapindex)
  407. m = map_mapindex2mapid(mapindex);
  408. if (!mapindex) { // m < 0 means on different server! [Kevin]
  409. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  410. if (battle_config.warp_suggestions_enabled)
  411. warp_get_suggestions(sd, map_name);
  412. return -1;
  413. }
  414. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  415. { //This is to prevent the pc_setpos call from printing an error.
  416. clif_displaymessage(fd, msg_txt(sd,2));
  417. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  418. x = y = 0; //Invalid cell, use random spot.
  419. }
  420. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  421. clif_displaymessage(fd, msg_txt(sd,247));
  422. return -1;
  423. }
  424. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  425. clif_displaymessage(fd, msg_txt(sd,248));
  426. return -1;
  427. }
  428. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  429. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  430. return -1;
  431. }
  432. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  433. return 0;
  434. }
  435. /*==========================================
  436. * Displays where a character is. Corrected version by Silent. [Skotlex]
  437. *------------------------------------------*/
  438. ACMD_FUNC(where)
  439. {
  440. struct map_session_data* pl_sd;
  441. nullpo_retr(-1, sd);
  442. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  443. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  444. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  445. return -1;
  446. }
  447. pl_sd = map_nick2sd(atcmd_player_name);
  448. if (pl_sd == NULL ||
  449. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  450. (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))
  451. ) {
  452. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  453. return -1;
  454. }
  455. 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);
  456. clif_displaymessage(fd, atcmd_output);
  457. return 0;
  458. }
  459. /*==========================================
  460. *
  461. *------------------------------------------*/
  462. ACMD_FUNC(jumpto)
  463. {
  464. struct map_session_data *pl_sd = NULL;
  465. nullpo_retr(-1, sd);
  466. if (!message || !*message) {
  467. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  468. return -1;
  469. }
  470. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  471. {
  472. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  473. return -1;
  474. }
  475. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  476. {
  477. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  478. return -1;
  479. }
  480. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  481. {
  482. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  483. return -1;
  484. }
  485. if( pc_isdead(sd) )
  486. {
  487. clif_displaymessage(fd, msg_txt(sd,664));
  488. return -1;
  489. }
  490. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  491. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  492. clif_displaymessage(fd, atcmd_output);
  493. return 0;
  494. }
  495. /*==========================================
  496. *
  497. *------------------------------------------*/
  498. ACMD_FUNC(jump)
  499. {
  500. short x = 0, y = 0;
  501. nullpo_retr(-1, sd);
  502. memset(atcmd_output, '\0', sizeof(atcmd_output));
  503. sscanf(message, "%hd %hd", &x, &y);
  504. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  505. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  506. return -1;
  507. }
  508. if( pc_isdead(sd) )
  509. {
  510. clif_displaymessage(fd, msg_txt(sd,664));
  511. return -1;
  512. }
  513. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  514. { //This is to prevent the pc_setpos call from printing an error.
  515. clif_displaymessage(fd, msg_txt(sd,2));
  516. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  517. x = y = 0; //Invalid cell, use random spot.
  518. }
  519. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  520. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  521. clif_displaymessage(fd, atcmd_output);
  522. return 0;
  523. }
  524. /*==========================================
  525. * Display list of online characters with
  526. * various info.
  527. *------------------------------------------*/
  528. ACMD_FUNC(who) {
  529. struct map_session_data *pl_sd = NULL;
  530. struct s_mapiterator *iter = NULL;
  531. char player_name[NAME_LENGTH] = "";
  532. int count = 0;
  533. int level = 0;
  534. StringBuf buf;
  535. /**
  536. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  537. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  538. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  539. */
  540. int display_type = 1;
  541. int map_id = -1;
  542. nullpo_retr(-1, sd);
  543. if (strstr(command, "map") != NULL) {
  544. char map_name[MAP_NAME_LENGTH_EXT] = "";
  545. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  546. map_id = sd->bl.m;
  547. } else {
  548. sscanf(message, "%23s", player_name);
  549. }
  550. if (strstr(command, "2") != NULL)
  551. display_type = 2;
  552. else if (strstr(command, "3") != NULL)
  553. display_type = 3;
  554. level = pc_get_group_level(sd);
  555. StringBuf_Init(&buf);
  556. iter = mapit_getallusers();
  557. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  558. if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
  559. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  560. || (map_id >= 0 && pl_sd->bl.m != map_id))
  561. continue;
  562. switch (display_type) {
  563. case 2: {
  564. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  565. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  566. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  567. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  568. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  569. break;
  570. }
  571. case 3: {
  572. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  573. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  574. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  575. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  576. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  577. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  578. break;
  579. }
  580. default: {
  581. struct party_data *p = party_search(pl_sd->status.party_id);
  582. struct guild *g = pl_sd->guild;
  583. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  584. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  585. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  586. if (p != NULL)
  587. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  588. if (g != NULL)
  589. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  590. break;
  591. }
  592. }
  593. clif_displaymessage(fd, StringBuf_Value(&buf));
  594. StringBuf_Clear(&buf);
  595. count++;
  596. }
  597. }
  598. mapit_free(iter);
  599. if (map_id < 0) {
  600. if (count == 0)
  601. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  602. else if (count == 1)
  603. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  604. else
  605. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  606. } else {
  607. if (count == 0)
  608. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  609. else if (count == 1)
  610. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  611. else
  612. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  613. }
  614. clif_displaymessage(fd, StringBuf_Value(&buf));
  615. StringBuf_Destroy(&buf);
  616. return 0;
  617. }
  618. /*==========================================
  619. *
  620. *------------------------------------------*/
  621. ACMD_FUNC(whogm)
  622. {
  623. struct map_session_data* pl_sd;
  624. struct s_mapiterator* iter;
  625. int j, count;
  626. int level;
  627. char match_text[CHAT_SIZE_MAX];
  628. char player_name[NAME_LENGTH];
  629. struct guild *g;
  630. struct party_data *p;
  631. nullpo_retr(-1, sd);
  632. memset(atcmd_output, '\0', sizeof(atcmd_output));
  633. memset(match_text, '\0', sizeof(match_text));
  634. memset(player_name, '\0', sizeof(player_name));
  635. if (sscanf(message, "%199[^\n]", match_text) < 1)
  636. strcpy(match_text, "");
  637. for (j = 0; match_text[j]; j++)
  638. match_text[j] = TOLOWER(match_text[j]);
  639. count = 0;
  640. level = pc_get_group_level(sd);
  641. iter = mapit_getallusers();
  642. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  643. {
  644. int pl_level = pc_get_group_level(pl_sd);
  645. if (!pl_level)
  646. continue;
  647. if (match_text[0])
  648. {
  649. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  650. for (j = 0; player_name[j]; j++)
  651. player_name[j] = TOLOWER(player_name[j]);
  652. // search with no case sensitive
  653. if (strstr(player_name, match_text) == NULL)
  654. continue;
  655. }
  656. if (pl_level > level) {
  657. if (pl_sd->sc.option & OPTION_INVISIBLE)
  658. continue;
  659. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  660. clif_displaymessage(fd, atcmd_output);
  661. count++;
  662. continue;
  663. }
  664. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  665. pl_sd->status.name, pl_level,
  666. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  667. clif_displaymessage(fd, atcmd_output);
  668. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  669. pl_sd->status.base_level,
  670. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  671. clif_displaymessage(fd, atcmd_output);
  672. p = party_search(pl_sd->status.party_id);
  673. g = pl_sd->guild;
  674. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  675. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  676. clif_displaymessage(fd, atcmd_output);
  677. count++;
  678. }
  679. mapit_free(iter);
  680. if (count == 0)
  681. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  682. else if (count == 1)
  683. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  684. else {
  685. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  686. clif_displaymessage(fd, atcmd_output);
  687. }
  688. return 0;
  689. }
  690. /*==========================================
  691. *
  692. *------------------------------------------*/
  693. ACMD_FUNC(save)
  694. {
  695. nullpo_retr(-1, sd);
  696. if( map[sd->bl.m].instance_id ) {
  697. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  698. return 1;
  699. }
  700. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  701. if (sd->status.pet_id > 0 && sd->pd)
  702. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  703. chrif_save(sd,0);
  704. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  705. return 0;
  706. }
  707. /*==========================================
  708. *
  709. *------------------------------------------*/
  710. ACMD_FUNC(load)
  711. {
  712. int16 m;
  713. nullpo_retr(-1, sd);
  714. m = map_mapindex2mapid(sd->status.save_point.map);
  715. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  716. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  717. return -1;
  718. }
  719. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  720. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  721. return -1;
  722. }
  723. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  724. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  725. return 0;
  726. }
  727. /*==========================================
  728. *
  729. *------------------------------------------*/
  730. ACMD_FUNC(speed)
  731. {
  732. int speed;
  733. nullpo_retr(-1, sd);
  734. memset(atcmd_output, '\0', sizeof(atcmd_output));
  735. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  736. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  737. clif_displaymessage(fd, atcmd_output);
  738. return -1;
  739. }
  740. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  741. if (speed < 0)
  742. sd->base_status.speed = DEFAULT_WALK_SPEED;
  743. else
  744. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  745. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  746. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  747. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  748. } else
  749. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  750. status_calc_bl(&sd->bl, SCB_SPEED);
  751. return 0;
  752. }
  753. /*==========================================
  754. *
  755. *------------------------------------------*/
  756. ACMD_FUNC(storage)
  757. {
  758. nullpo_retr(-1, sd);
  759. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  760. return -1;
  761. if (storage_storageopen(sd) == 1)
  762. { //Already open.
  763. clif_displaymessage(fd, msg_txt(sd,250));
  764. return -1;
  765. }
  766. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  767. return 0;
  768. }
  769. /*==========================================
  770. *
  771. *------------------------------------------*/
  772. ACMD_FUNC(guildstorage)
  773. {
  774. nullpo_retr(-1, sd);
  775. if (!sd->status.guild_id) {
  776. clif_displaymessage(fd, msg_txt(sd,252));
  777. return -1;
  778. }
  779. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  780. return -1;
  781. if (sd->state.storage_flag == 1) {
  782. clif_displaymessage(fd, msg_txt(sd,250));
  783. return -1;
  784. }
  785. if (sd->state.storage_flag == 2) {
  786. clif_displaymessage(fd, msg_txt(sd,251));
  787. return -1;
  788. }
  789. storage_guild_storageopen(sd);
  790. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  791. return 0;
  792. }
  793. /*==========================================
  794. *
  795. *------------------------------------------*/
  796. ACMD_FUNC(option)
  797. {
  798. int param1 = 0, param2 = 0, param3 = 0;
  799. nullpo_retr(-1, sd);
  800. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  801. {// failed to match the parameters so inform the user of the options
  802. const char* text;
  803. // attempt to find the setting information for this command
  804. text = atcommand_help_string( command );
  805. // notify the user of the requirement to enter an option
  806. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  807. if( text )
  808. {// send the help text associated with this command
  809. clif_displaymessage( fd, text );
  810. }
  811. return -1;
  812. }
  813. sd->sc.opt1 = param1;
  814. sd->sc.opt2 = param2;
  815. pc_setoption(sd, param3);
  816. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  817. return 0;
  818. }
  819. /*==========================================
  820. *
  821. *------------------------------------------*/
  822. ACMD_FUNC(hide)
  823. {
  824. nullpo_retr(-1, sd);
  825. if (sd->sc.option & OPTION_INVISIBLE) {
  826. sd->sc.option &= ~OPTION_INVISIBLE;
  827. if (sd->disguise)
  828. status_set_viewdata(&sd->bl, sd->disguise);
  829. else
  830. status_set_viewdata(&sd->bl, sd->status.class_);
  831. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  832. // increment the number of pvp players on the map
  833. map[sd->bl.m].users_pvp++;
  834. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  835. {// register the player for ranking calculations
  836. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  837. }
  838. //bugreport:2266
  839. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  840. } else {
  841. sd->sc.option |= OPTION_INVISIBLE;
  842. sd->vd.class_ = INVISIBLE_CLASS;
  843. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  844. // decrement the number of pvp players on the map
  845. map[sd->bl.m].users_pvp--;
  846. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  847. {// unregister the player for ranking
  848. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  849. sd->pvp_timer = INVALID_TIMER;
  850. }
  851. }
  852. clif_changeoption(&sd->bl);
  853. return 0;
  854. }
  855. /*==========================================
  856. * Changes a character's class
  857. *------------------------------------------*/
  858. ACMD_FUNC(jobchange)
  859. {
  860. int job = 0, upper = 0;
  861. const char* text;
  862. nullpo_retr(-1, sd);
  863. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  864. int i;
  865. bool found = false;
  866. upper = 0;
  867. // Normal Jobs
  868. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  869. if (strncmpi(message, job_name(i), 16) == 0) {
  870. job = i;
  871. found = true;
  872. }
  873. }
  874. // High Jobs, Babys and Third
  875. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  876. if (strncmpi(message, job_name(i), 16) == 0) {
  877. job = i;
  878. found = true;
  879. }
  880. }
  881. if (!found) {
  882. text = atcommand_help_string(command);
  883. if (text)
  884. clif_displaymessage(fd, text);
  885. return -1;
  886. }
  887. }
  888. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  889. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  890. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  891. { // Deny direct transformation into dummy jobs
  892. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  893. return 0;
  894. }
  895. if (pcdb_checkid(job))
  896. {
  897. if (pc_jobchange(sd, job, upper))
  898. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  899. else {
  900. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  901. return -1;
  902. }
  903. } else {
  904. text = atcommand_help_string(command);
  905. if (text)
  906. clif_displaymessage(fd, text);
  907. return -1;
  908. }
  909. return 0;
  910. }
  911. /*==========================================
  912. *
  913. *------------------------------------------*/
  914. ACMD_FUNC(kill)
  915. {
  916. nullpo_retr(-1, sd);
  917. status_kill(&sd->bl);
  918. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  919. if (fd != sd->fd)
  920. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  921. return 0;
  922. }
  923. /*==========================================
  924. *
  925. *------------------------------------------*/
  926. ACMD_FUNC(alive)
  927. {
  928. nullpo_retr(-1, sd);
  929. if (!status_revive(&sd->bl, 100, 100))
  930. {
  931. clif_displaymessage(fd, msg_txt(sd,667));
  932. return -1;
  933. }
  934. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  935. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  936. return 0;
  937. }
  938. /*==========================================
  939. * +kamic [LuzZza]
  940. *------------------------------------------*/
  941. ACMD_FUNC(kami)
  942. {
  943. unsigned long color=0;
  944. nullpo_retr(-1, sd);
  945. memset(atcmd_output, '\0', sizeof(atcmd_output));
  946. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  947. if (!message || !*message) {
  948. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  949. return -1;
  950. }
  951. sscanf(message, "%199[^\n]", atcmd_output);
  952. if (strstr(command, "l") != NULL)
  953. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  954. else
  955. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  956. } else {
  957. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  958. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  959. return -1;
  960. }
  961. if(color > 0xFFFFFF) {
  962. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  963. return -1;
  964. }
  965. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  966. }
  967. return 0;
  968. }
  969. /*==========================================
  970. *
  971. *------------------------------------------*/
  972. ACMD_FUNC(heal)
  973. {
  974. int hp = 0, sp = 0; // [Valaris] thanks to fov
  975. nullpo_retr(-1, sd);
  976. sscanf(message, "%d %d", &hp, &sp);
  977. // some overflow checks
  978. if( hp == INT_MIN ) hp++;
  979. if( sp == INT_MIN ) sp++;
  980. if ( hp == 0 && sp == 0 ) {
  981. if (!status_percent_heal(&sd->bl, 100, 100))
  982. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  983. else
  984. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  985. return 0;
  986. }
  987. if ( hp > 0 && sp >= 0 ) {
  988. if(!status_heal(&sd->bl, hp, sp, 0))
  989. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  990. else
  991. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  992. return 0;
  993. }
  994. if ( hp < 0 && sp <= 0 ) {
  995. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  996. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  997. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  998. return 0;
  999. }
  1000. //Opposing signs.
  1001. if ( hp ) {
  1002. if (hp > 0)
  1003. status_heal(&sd->bl, hp, 0, 0);
  1004. else {
  1005. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1006. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1007. }
  1008. }
  1009. if ( sp ) {
  1010. if (sp > 0)
  1011. status_heal(&sd->bl, 0, sp, 0);
  1012. else
  1013. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1014. }
  1015. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1016. return 0;
  1017. }
  1018. /*==========================================
  1019. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1020. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1021. *------------------------------------------*/
  1022. ACMD_FUNC(item)
  1023. {
  1024. char item_name[100];
  1025. int number = 0, bound = BOUND_NONE;
  1026. char flag = 0;
  1027. struct item item_tmp;
  1028. struct item_data *item_data[10];
  1029. int get_count, i, j=0;
  1030. char *itemlist;
  1031. nullpo_retr(-1, sd);
  1032. memset(item_name, '\0', sizeof(item_name));
  1033. parent_cmd = atcommand_checkalias(command+1);
  1034. if (!strcmpi(parent_cmd,"itembound")) {
  1035. if (!message || !*message || (
  1036. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 3 &&
  1037. sscanf(message, "%99s %d %d", item_name, &number, &bound) < 3))
  1038. {
  1039. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1040. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1041. return -1;
  1042. }
  1043. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1044. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1045. return -1;
  1046. }
  1047. } else if (!message || !*message || (
  1048. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  1049. sscanf(message, "%99s %d", item_name, &number) < 1
  1050. )) {
  1051. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1052. return -1;
  1053. }
  1054. itemlist = strtok(item_name, ":");
  1055. while (itemlist != NULL && j<10) {
  1056. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1057. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1058. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1059. return -1;
  1060. }
  1061. itemlist = strtok(NULL, ":"); //next itemline
  1062. j++;
  1063. }
  1064. if (number <= 0)
  1065. number = 1;
  1066. get_count = number;
  1067. for(j--; j>=0; j--){ //produce items in list
  1068. unsigned short item_id = item_data[j]->nameid;
  1069. //Check if it's stackable.
  1070. if (!itemdb_isstackable2(item_data[j]))
  1071. get_count = 1;
  1072. for (i = 0; i < number; i += get_count) {
  1073. // if not pet egg
  1074. if (!pet_create_egg(sd, item_id)) {
  1075. memset(&item_tmp, 0, sizeof(item_tmp));
  1076. item_tmp.nameid = item_id;
  1077. item_tmp.identify = 1;
  1078. item_tmp.bound = bound;
  1079. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1080. clif_additem(sd, 0, 0, flag);
  1081. }
  1082. }
  1083. }
  1084. if (flag == 0)
  1085. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1086. return 0;
  1087. }
  1088. /*==========================================
  1089. *
  1090. *------------------------------------------*/
  1091. ACMD_FUNC(item2)
  1092. {
  1093. struct item item_tmp;
  1094. struct item_data *item_data;
  1095. char item_name[100];
  1096. unsigned short item_id;
  1097. int number = 0, bound = BOUND_NONE;
  1098. int identify = 0, refine = 0, attr = 0;
  1099. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1100. nullpo_retr(-1, sd);
  1101. memset(item_name, '\0', sizeof(item_name));
  1102. parent_cmd = atcommand_checkalias(command+1);
  1103. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1104. if (!message || !*message || (
  1105. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1106. sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1107. {
  1108. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1109. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1110. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1111. return -1;
  1112. }
  1113. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1114. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1115. return -1;
  1116. }
  1117. } else if ( !message || !*message || (
  1118. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1119. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1120. )) {
  1121. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1122. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1123. return -1;
  1124. }
  1125. if (number <= 0)
  1126. number = 1;
  1127. item_id = 0;
  1128. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1129. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1130. item_id = item_data->nameid;
  1131. if (item_id > 500) {
  1132. int loop, get_count, i;
  1133. char flag = 0;
  1134. loop = 1;
  1135. get_count = number;
  1136. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1137. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1138. loop = number;
  1139. get_count = 1;
  1140. if (item_data->type == IT_PETEGG) {
  1141. identify = 1;
  1142. refine = 0;
  1143. }
  1144. if (item_data->type == IT_PETARMOR)
  1145. refine = 0;
  1146. if (refine > MAX_REFINE)
  1147. refine = MAX_REFINE;
  1148. } else {
  1149. identify = 1;
  1150. refine = attr = 0;
  1151. }
  1152. for (i = 0; i < loop; i++) {
  1153. memset(&item_tmp, 0, sizeof(item_tmp));
  1154. item_tmp.nameid = item_id;
  1155. item_tmp.identify = identify;
  1156. item_tmp.refine = refine;
  1157. item_tmp.attribute = attr;
  1158. item_tmp.card[0] = c1;
  1159. item_tmp.card[1] = c2;
  1160. item_tmp.card[2] = c3;
  1161. item_tmp.card[3] = c4;
  1162. item_tmp.bound = bound;
  1163. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1164. clif_additem(sd, 0, 0, flag);
  1165. }
  1166. if (flag == 0)
  1167. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1168. } else {
  1169. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1170. return -1;
  1171. }
  1172. return 0;
  1173. }
  1174. /*==========================================
  1175. *
  1176. *------------------------------------------*/
  1177. ACMD_FUNC(itemreset)
  1178. {
  1179. int i;
  1180. nullpo_retr(-1, sd);
  1181. for (i = 0; i < MAX_INVENTORY; i++) {
  1182. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1183. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1184. }
  1185. }
  1186. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1187. return 0;
  1188. }
  1189. /*==========================================
  1190. * Atcommand @lvlup
  1191. *------------------------------------------*/
  1192. ACMD_FUNC(baselevelup)
  1193. {
  1194. int level=0, i=0, status_point=0;
  1195. nullpo_retr(-1, sd);
  1196. level = atoi(message);
  1197. if (!message || !*message || !level) {
  1198. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1199. return -1;
  1200. }
  1201. if (level > 0) {
  1202. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1203. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1204. return -1;
  1205. } // End Addition
  1206. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1207. level = pc_maxbaselv(sd) - sd->status.base_level;
  1208. for (i = 0; i < level; i++)
  1209. status_point += pc_gets_status_point(sd->status.base_level + i);
  1210. sd->status.status_point += status_point;
  1211. sd->status.base_level += (unsigned int)level;
  1212. status_calc_pc(sd, SCO_FORCE);
  1213. status_percent_heal(&sd->bl, 100, 100);
  1214. clif_misceffect(&sd->bl, 0);
  1215. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1216. } else {
  1217. if (sd->status.base_level == 1) {
  1218. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1219. return -1;
  1220. }
  1221. level*=-1;
  1222. if ((unsigned int)level >= sd->status.base_level)
  1223. level = sd->status.base_level-1;
  1224. for (i = 0; i > -level; i--)
  1225. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1226. if (sd->status.status_point < status_point)
  1227. pc_resetstate(sd);
  1228. if (sd->status.status_point < status_point)
  1229. sd->status.status_point = 0;
  1230. else
  1231. sd->status.status_point -= status_point;
  1232. sd->status.base_level -= (unsigned int)level;
  1233. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1234. status_calc_pc(sd, SCO_FORCE);
  1235. }
  1236. sd->status.base_exp = 0;
  1237. clif_updatestatus(sd, SP_STATUSPOINT);
  1238. clif_updatestatus(sd, SP_BASELEVEL);
  1239. clif_updatestatus(sd, SP_BASEEXP);
  1240. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1241. pc_baselevelchanged(sd);
  1242. if(sd->status.party_id)
  1243. party_send_levelup(sd);
  1244. return 0;
  1245. }
  1246. /*==========================================
  1247. *
  1248. *------------------------------------------*/
  1249. ACMD_FUNC(joblevelup)
  1250. {
  1251. int level=0;
  1252. nullpo_retr(-1, sd);
  1253. level = atoi(message);
  1254. if (!message || !*message || !level) {
  1255. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1256. return -1;
  1257. }
  1258. if (level > 0) {
  1259. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1260. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1261. return -1;
  1262. }
  1263. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1264. level = pc_maxjoblv(sd) - sd->status.job_level;
  1265. sd->status.job_level += (unsigned int)level;
  1266. sd->status.skill_point += level;
  1267. clif_misceffect(&sd->bl, 1);
  1268. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1269. } else {
  1270. if (sd->status.job_level == 1) {
  1271. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1272. return -1;
  1273. }
  1274. level *=-1;
  1275. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1276. level = sd->status.job_level-1;
  1277. sd->status.job_level -= (unsigned int)level;
  1278. if (sd->status.skill_point < level)
  1279. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1280. if (sd->status.skill_point < level)
  1281. sd->status.skill_point = 0;
  1282. else
  1283. sd->status.skill_point -= level;
  1284. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1285. }
  1286. sd->status.job_exp = 0;
  1287. clif_updatestatus(sd, SP_JOBLEVEL);
  1288. clif_updatestatus(sd, SP_JOBEXP);
  1289. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1290. clif_updatestatus(sd, SP_SKILLPOINT);
  1291. status_calc_pc(sd, SCO_FORCE);
  1292. return 0;
  1293. }
  1294. /*==========================================
  1295. * @help
  1296. *------------------------------------------*/
  1297. ACMD_FUNC(help)
  1298. {
  1299. config_setting_t *help;
  1300. const char *text = NULL;
  1301. const char *command_name = NULL;
  1302. char *default_command = "help";
  1303. nullpo_retr(-1, sd);
  1304. help = config_lookup(&atcommand_config, "help");
  1305. if (help == NULL) {
  1306. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1307. return -1;
  1308. }
  1309. if (!message || !*message) {
  1310. command_name = default_command; // If no command_name specified, display help for @help.
  1311. } else {
  1312. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1313. ++message;
  1314. command_name = atcommand_checkalias(message);
  1315. }
  1316. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1317. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1318. clif_displaymessage(fd, atcmd_output);
  1319. atcommand_get_suggestions(sd, command_name, true);
  1320. return -1;
  1321. }
  1322. if (!config_setting_lookup_string(help, command_name, &text)) {
  1323. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1324. clif_displaymessage(fd, atcmd_output);
  1325. atcommand_get_suggestions(sd, command_name, true);
  1326. return -1;
  1327. }
  1328. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1329. clif_displaymessage(fd, atcmd_output);
  1330. { // Display aliases
  1331. DBIterator* iter;
  1332. AtCommandInfo *command_info;
  1333. AliasInfo *alias_info = NULL;
  1334. StringBuf buf;
  1335. bool has_aliases = false;
  1336. StringBuf_Init(&buf);
  1337. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1338. command_info = get_atcommandinfo_byname(command_name);
  1339. iter = db_iterator(atcommand_alias_db);
  1340. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1341. if (alias_info->command == command_info) {
  1342. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1343. has_aliases = true;
  1344. }
  1345. }
  1346. dbi_destroy(iter);
  1347. if (has_aliases)
  1348. clif_displaymessage(fd, StringBuf_Value(&buf));
  1349. StringBuf_Destroy(&buf);
  1350. }
  1351. // Display help contents
  1352. clif_displaymessage(fd, text);
  1353. return 0;
  1354. }
  1355. // helper function, used in foreach calls to stop auto-attack timers
  1356. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1357. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1358. {
  1359. struct unit_data *ud = unit_bl2ud(bl);
  1360. int id = va_arg(ap, int);
  1361. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1362. {
  1363. unit_stop_attack(bl);
  1364. return 1;
  1365. }
  1366. return 0;
  1367. }
  1368. /*==========================================
  1369. *
  1370. *------------------------------------------*/
  1371. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1372. {
  1373. TBL_PC* sd = (TBL_PC*)bl;
  1374. clif_pvpset(sd, 0, 0, 2);
  1375. if (sd->pvp_timer != INVALID_TIMER) {
  1376. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1377. sd->pvp_timer = INVALID_TIMER;
  1378. }
  1379. return 0;
  1380. }
  1381. ACMD_FUNC(pvpoff)
  1382. {
  1383. nullpo_retr(-1, sd);
  1384. if (!map[sd->bl.m].flag.pvp) {
  1385. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1386. return -1;
  1387. }
  1388. map[sd->bl.m].flag.pvp = 0;
  1389. if (!battle_config.pk_mode){
  1390. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1391. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1392. }
  1393. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1394. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1395. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1396. return 0;
  1397. }
  1398. /*==========================================
  1399. *
  1400. *------------------------------------------*/
  1401. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1402. {
  1403. TBL_PC* sd = (TBL_PC*)bl;
  1404. if (sd->pvp_timer == INVALID_TIMER) {
  1405. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1406. sd->pvp_rank = 0;
  1407. sd->pvp_lastusers = 0;
  1408. sd->pvp_point = 5;
  1409. sd->pvp_won = 0;
  1410. sd->pvp_lost = 0;
  1411. }
  1412. return 0;
  1413. }
  1414. ACMD_FUNC(pvpon)
  1415. {
  1416. nullpo_retr(-1, sd);
  1417. if (map[sd->bl.m].flag.pvp) {
  1418. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1419. return -1;
  1420. }
  1421. map[sd->bl.m].flag.pvp = 1;
  1422. if (!battle_config.pk_mode) {// display pvp circle and rank
  1423. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1424. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1425. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1426. }
  1427. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1428. return 0;
  1429. }
  1430. /*==========================================
  1431. *
  1432. *------------------------------------------*/
  1433. ACMD_FUNC(gvgoff)
  1434. {
  1435. nullpo_retr(-1, sd);
  1436. if (!map[sd->bl.m].flag.gvg) {
  1437. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1438. return -1;
  1439. }
  1440. map[sd->bl.m].flag.gvg = 0;
  1441. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1442. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1443. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1444. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1445. return 0;
  1446. }
  1447. /*==========================================
  1448. *
  1449. *------------------------------------------*/
  1450. ACMD_FUNC(gvgon)
  1451. {
  1452. nullpo_retr(-1, sd);
  1453. if (map[sd->bl.m].flag.gvg) {
  1454. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1455. return -1;
  1456. }
  1457. map[sd->bl.m].flag.gvg = 1;
  1458. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1459. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1460. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1461. return 0;
  1462. }
  1463. /*==========================================
  1464. *
  1465. *------------------------------------------*/
  1466. ACMD_FUNC(model)
  1467. {
  1468. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1469. nullpo_retr(-1, sd);
  1470. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1471. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1472. sprintf(atcmd_output, msg_txt(sd,991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>).
  1473. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1474. clif_displaymessage(fd, atcmd_output);
  1475. return -1;
  1476. }
  1477. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1478. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1479. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1480. pc_changelook(sd, LOOK_HAIR, hair_style);
  1481. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1482. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1483. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1484. } else {
  1485. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1486. return -1;
  1487. }
  1488. return 0;
  1489. }
  1490. /*==========================================
  1491. * @dye && @ccolor
  1492. *------------------------------------------*/
  1493. ACMD_FUNC(dye)
  1494. {
  1495. int cloth_color = 0;
  1496. nullpo_retr(-1, sd);
  1497. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1498. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1499. 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>).
  1500. clif_displaymessage(fd, atcmd_output);
  1501. return -1;
  1502. }
  1503. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1504. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1505. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1506. } else {
  1507. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1508. return -1;
  1509. }
  1510. return 0;
  1511. }
  1512. /*==========================================
  1513. * @hairstyle && @hstyle
  1514. *------------------------------------------*/
  1515. ACMD_FUNC(hair_style)
  1516. {
  1517. int hair_style = 0;
  1518. nullpo_retr(-1, sd);
  1519. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1520. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1521. 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>).
  1522. clif_displaymessage(fd, atcmd_output);
  1523. return -1;
  1524. }
  1525. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1526. pc_changelook(sd, LOOK_HAIR, hair_style);
  1527. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1528. } else {
  1529. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1530. return -1;
  1531. }
  1532. return 0;
  1533. }
  1534. /*==========================================
  1535. * @haircolor && @hcolor
  1536. *------------------------------------------*/
  1537. ACMD_FUNC(hair_color)
  1538. {
  1539. int hair_color = 0;
  1540. nullpo_retr(-1, sd);
  1541. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1542. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1543. 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>).
  1544. clif_displaymessage(fd, atcmd_output);
  1545. return -1;
  1546. }
  1547. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1548. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1549. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1550. } else {
  1551. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1552. return -1;
  1553. }
  1554. return 0;
  1555. }
  1556. /*==========================================
  1557. * @go [city_number or city_name] - Updated by Harbin
  1558. *------------------------------------------*/
  1559. ACMD_FUNC(go)
  1560. {
  1561. int i;
  1562. int town;
  1563. char map_name[MAP_NAME_LENGTH];
  1564. int16 m;
  1565. const struct {
  1566. char map[MAP_NAME_LENGTH];
  1567. int x, y;
  1568. } data[] = {
  1569. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1570. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1571. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1572. { MAP_PAYON, 162, 233 }, // 3=Payon
  1573. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1574. #ifdef RENEWAL
  1575. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1576. #else
  1577. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1578. #endif
  1579. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1580. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1581. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1582. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1583. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1584. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1585. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1586. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1587. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1588. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1589. { MAP_JAIL, 23, 61 }, // 16=Prison
  1590. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1591. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1592. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1593. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1594. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1595. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1596. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1597. { MAP_VEINS, 216, 123 }, // 24=Veins
  1598. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1599. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1600. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1601. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1602. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1603. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1604. { MAP_MORA, 44, 151 }, // 31=Mora
  1605. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1606. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1607. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1608. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1609. };
  1610. nullpo_retr(-1, sd);
  1611. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1612. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1613. return 0;
  1614. }
  1615. memset(map_name, '\0', sizeof(map_name));
  1616. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1617. // get the number
  1618. town = atoi(message);
  1619. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1620. {// no value matched so send the list of locations
  1621. const char* text;
  1622. // attempt to find the text help string
  1623. text = atcommand_help_string( command );
  1624. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1625. if( text )
  1626. {// send the text to the client
  1627. clif_displaymessage( fd, text );
  1628. }
  1629. return -1;
  1630. }
  1631. // get possible name of the city
  1632. map_name[MAP_NAME_LENGTH-1] = '\0';
  1633. for (i = 0; map_name[i]; i++)
  1634. map_name[i] = TOLOWER(map_name[i]);
  1635. // try to identify the map name
  1636. if (strncmp(map_name, "prontera", 3) == 0) {
  1637. town = 0;
  1638. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1639. strncmp(map_name, "morroc", 4) == 0) {
  1640. town = 1;
  1641. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1642. town = 2;
  1643. } else if (strncmp(map_name, "payon", 3) == 0) {
  1644. town = 3;
  1645. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1646. town = 4;
  1647. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1648. town = 5;
  1649. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1650. town = 6;
  1651. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1652. strcmp(map_name, "christmas") == 0 ||
  1653. strncmp(map_name, "xmas", 3) == 0 ||
  1654. strncmp(map_name, "x-mas", 3) == 0) {
  1655. town = 7;
  1656. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1657. town = 8;
  1658. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1659. strncmp(map_name, "yuno", 3) == 0) {
  1660. town = 9;
  1661. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1662. town = 10;
  1663. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1664. strncmp(map_name, "gonryun", 3) == 0) {
  1665. town = 11;
  1666. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1667. town = 12;
  1668. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1669. town = 13;
  1670. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1671. town = 14;
  1672. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1673. strncmp(map_name, "startpoint", 3) == 0 ||
  1674. strncmp(map_name, "beginning", 3) == 0) {
  1675. town = 15;
  1676. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1677. strncmp(map_name, "prison", 3) == 0 ||
  1678. strncmp(map_name, "jail", 3) == 0) {
  1679. town = 16;
  1680. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1681. town = 17;
  1682. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1683. town = 18;
  1684. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1685. town = 19;
  1686. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1687. town = 20;
  1688. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1689. town = 21;
  1690. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1691. town = 22;
  1692. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1693. town = 23;
  1694. } else if (strncmp(map_name, "veins", 3) == 0) {
  1695. town = 24;
  1696. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1697. town = 25;
  1698. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1699. town = 26;
  1700. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1701. town = 27;
  1702. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1703. town = 28;
  1704. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1705. town = 29;
  1706. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1707. town = 30;
  1708. } else if (strcmp(map_name, "mora") == 0) {
  1709. town = 31;
  1710. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1711. town = 32;
  1712. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1713. town = 33;
  1714. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1715. town = 34;
  1716. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1717. town = 35;
  1718. }
  1719. if (town >= 0 && town < ARRAYLENGTH(data))
  1720. {
  1721. m = map_mapname2mapid(data[town].map);
  1722. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1723. clif_displaymessage(fd, msg_txt(sd,247));
  1724. return -1;
  1725. }
  1726. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1727. clif_displaymessage(fd, msg_txt(sd,248));
  1728. return -1;
  1729. }
  1730. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1731. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1732. } else {
  1733. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1734. return -1;
  1735. }
  1736. } else { // if you arrive here, you have an error in town variable when reading of names
  1737. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1738. return -1;
  1739. }
  1740. return 0;
  1741. }
  1742. /*==========================================
  1743. *
  1744. *------------------------------------------*/
  1745. ACMD_FUNC(monster)
  1746. {
  1747. char name[NAME_LENGTH];
  1748. char monster[NAME_LENGTH];
  1749. char eventname[EVENT_NAME_LENGTH] = "";
  1750. int mob_id;
  1751. int number = 0;
  1752. int count;
  1753. int i, range;
  1754. short mx, my;
  1755. unsigned int size;
  1756. nullpo_retr(-1, sd);
  1757. memset(name, '\0', sizeof(name));
  1758. memset(monster, '\0', sizeof(monster));
  1759. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1760. if (!message || !*message) {
  1761. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1762. return -1;
  1763. }
  1764. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1765. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1766. //All data can be left as it is.
  1767. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1768. //Here, it is possible name was not given and we are using monster for it.
  1769. if (count < 3) //Blank mob's name.
  1770. name[0] = '\0';
  1771. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1772. //All data can be left as it is.
  1773. } else if (sscanf(message, "%23s", monster) > 0) {
  1774. //As before, name may be already filled.
  1775. name[0] = '\0';
  1776. } else {
  1777. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1778. return -1;
  1779. }
  1780. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1781. mob_id = mobdb_checkid(atoi(monster));
  1782. if (mob_id == 0) {
  1783. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1784. return -1;
  1785. }
  1786. if (mob_id == MOBID_EMPERIUM) {
  1787. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1788. return -1;
  1789. }
  1790. if (number <= 0)
  1791. number = 1;
  1792. if( !name[0] )
  1793. strcpy(name, "--ja--");
  1794. // 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
  1795. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1796. number = battle_config.atc_spawn_quantity_limit;
  1797. parent_cmd = atcommand_checkalias(command+1);
  1798. if (strcmp(parent_cmd, "monstersmall") == 0)
  1799. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1800. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1801. size = SZ_BIG;
  1802. else
  1803. size = SZ_SMALL;
  1804. if (battle_config.etc_log)
  1805. 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);
  1806. count = 0;
  1807. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1808. for (i = 0; i < number; i++) {
  1809. int k;
  1810. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1811. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1812. if(k) {
  1813. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1814. count ++;
  1815. }
  1816. }
  1817. if (count != 0)
  1818. if (number == count)
  1819. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1820. else {
  1821. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1822. clif_displaymessage(fd, atcmd_output);
  1823. }
  1824. else {
  1825. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1826. return -1;
  1827. }
  1828. return 0;
  1829. }
  1830. /*==========================================
  1831. *
  1832. *------------------------------------------*/
  1833. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1834. {
  1835. struct mob_data *md;
  1836. int flag;
  1837. nullpo_ret(md=(struct mob_data *)bl);
  1838. flag = va_arg(ap, int);
  1839. if (md->guardian_data)
  1840. return 0; //Do not touch WoE mobs!
  1841. if (flag)
  1842. status_zap(bl,md->status.hp, 0);
  1843. else
  1844. status_kill(bl);
  1845. return 1;
  1846. }
  1847. ACMD_FUNC(killmonster)
  1848. {
  1849. int map_id, drop_flag;
  1850. char map_name[MAP_NAME_LENGTH_EXT];
  1851. nullpo_retr(-1, sd);
  1852. memset(map_name, '\0', sizeof(map_name));
  1853. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1854. map_id = sd->bl.m;
  1855. else {
  1856. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1857. map_id = sd->bl.m;
  1858. }
  1859. parent_cmd = atcommand_checkalias(command+1);
  1860. drop_flag = strcmp(parent_cmd, "killmonster2");
  1861. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1862. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1863. return 0;
  1864. }
  1865. /*==========================================
  1866. *
  1867. *------------------------------------------*/
  1868. ACMD_FUNC(refine)
  1869. {
  1870. int j, position = 0, refine = 0, current_position, final_refine;
  1871. int count;
  1872. nullpo_retr(-1, sd);
  1873. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1874. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1875. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1876. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1877. clif_displaymessage(fd, atcmd_output);
  1878. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1879. clif_displaymessage(fd, atcmd_output);
  1880. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1881. clif_displaymessage(fd, atcmd_output);
  1882. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1883. clif_displaymessage(fd, atcmd_output);
  1884. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1885. clif_displaymessage(fd, atcmd_output);
  1886. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1887. clif_displaymessage(fd, atcmd_output);
  1888. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1889. clif_displaymessage(fd, atcmd_output);
  1890. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1891. clif_displaymessage(fd, atcmd_output);
  1892. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1893. clif_displaymessage(fd, atcmd_output);
  1894. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1895. clif_displaymessage(fd, atcmd_output);
  1896. return -1;
  1897. }
  1898. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1899. count = 0;
  1900. for (j = 0; j < EQI_MAX; j++) {
  1901. int i;
  1902. if ((i = sd->equip_index[j]) < 0)
  1903. continue;
  1904. if(j == EQI_AMMO)
  1905. continue;
  1906. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1907. continue;
  1908. if(position && !(sd->status.inventory[i].equip & position))
  1909. continue;
  1910. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1911. if (sd->status.inventory[i].refine != final_refine) {
  1912. sd->status.inventory[i].refine = final_refine;
  1913. current_position = sd->status.inventory[i].equip;
  1914. pc_unequipitem(sd, i, 3);
  1915. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1916. clif_delitem(sd, i, 1, 3);
  1917. clif_additem(sd, i, 1, 0);
  1918. pc_equipitem(sd, i, current_position);
  1919. clif_misceffect(&sd->bl, 3);
  1920. count++;
  1921. }
  1922. }
  1923. if (count == 0)
  1924. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1925. else if (count == 1)
  1926. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1927. else {
  1928. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1929. clif_displaymessage(fd, atcmd_output);
  1930. }
  1931. return 0;
  1932. }
  1933. /*==========================================
  1934. *
  1935. *------------------------------------------*/
  1936. ACMD_FUNC(produce)
  1937. {
  1938. char item_name[100];
  1939. unsigned short item_id;
  1940. int attribute = 0, star = 0;
  1941. struct item_data *item_data;
  1942. struct item tmp_item;
  1943. nullpo_retr(-1, sd);
  1944. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1945. memset(item_name, '\0', sizeof(item_name));
  1946. if (!message || !*message || (
  1947. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1948. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1949. )) {
  1950. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1951. return -1;
  1952. }
  1953. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1954. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1955. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1956. return -1;
  1957. }
  1958. item_id = item_data->nameid;
  1959. if (itemdb_isequip2(item_data)) {
  1960. char flag = 0;
  1961. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1962. attribute = ATTRIBUTE_NORMAL;
  1963. if (star < MIN_STAR || star > MAX_STAR)
  1964. star = 0;
  1965. memset(&tmp_item, 0, sizeof tmp_item);
  1966. tmp_item.nameid = item_id;
  1967. tmp_item.amount = 1;
  1968. tmp_item.identify = 1;
  1969. tmp_item.card[0] = CARD0_FORGE;
  1970. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1971. ((star*5) << 8) + attribute:0;
  1972. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1973. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1974. clif_produceeffect(sd, 0, item_id);
  1975. clif_misceffect(&sd->bl, 3);
  1976. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1977. clif_additem(sd, 0, 0, flag);
  1978. } else {
  1979. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  1980. clif_displaymessage(fd, atcmd_output);
  1981. return -1;
  1982. }
  1983. return 0;
  1984. }
  1985. /*==========================================
  1986. *
  1987. *------------------------------------------*/
  1988. ACMD_FUNC(memo)
  1989. {
  1990. int position = 0;
  1991. nullpo_retr(-1, sd);
  1992. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1993. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1994. {
  1995. int i;
  1996. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1997. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1998. {
  1999. if( sd->status.memo_point[i].map )
  2000. 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);
  2001. else
  2002. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2003. clif_displaymessage(sd->fd, atcmd_output);
  2004. }
  2005. return 0;
  2006. }
  2007. if( position < 0 || position >= MAX_MEMOPOINTS )
  2008. {
  2009. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2010. clif_displaymessage(fd, atcmd_output);
  2011. return -1;
  2012. }
  2013. return !pc_memo( sd, position );
  2014. }
  2015. /*==========================================
  2016. *
  2017. *------------------------------------------*/
  2018. ACMD_FUNC(gat)
  2019. {
  2020. int y;
  2021. nullpo_retr(-1, sd);
  2022. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2023. for (y = 2; y >= -2; y--) {
  2024. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2025. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2026. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2027. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2028. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2029. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2030. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2031. clif_displaymessage(fd, atcmd_output);
  2032. }
  2033. return 0;
  2034. }
  2035. /*==========================================
  2036. *
  2037. *------------------------------------------*/
  2038. ACMD_FUNC(displaystatus)
  2039. {
  2040. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2041. nullpo_retr(-1, sd);
  2042. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2043. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2044. return -1;
  2045. }
  2046. if (i < 2) flag = 1;
  2047. if (i < 3) tick = 0;
  2048. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2049. return 0;
  2050. }
  2051. /*==========================================
  2052. * @stpoint (Rewritten by [Yor])
  2053. *------------------------------------------*/
  2054. ACMD_FUNC(statuspoint)
  2055. {
  2056. int point;
  2057. unsigned int new_status_point;
  2058. if (!message || !*message || (point = atoi(message)) == 0) {
  2059. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2060. return -1;
  2061. }
  2062. if(point < 0)
  2063. {
  2064. if(sd->status.status_point < (unsigned int)(-point))
  2065. {
  2066. new_status_point = 0;
  2067. }
  2068. else
  2069. {
  2070. new_status_point = sd->status.status_point + point;
  2071. }
  2072. }
  2073. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2074. {
  2075. new_status_point = UINT_MAX;
  2076. }
  2077. else
  2078. {
  2079. new_status_point = sd->status.status_point + point;
  2080. }
  2081. if (new_status_point != sd->status.status_point) {
  2082. sd->status.status_point = new_status_point;
  2083. clif_updatestatus(sd, SP_STATUSPOINT);
  2084. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2085. } else {
  2086. if (point < 0)
  2087. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2088. else
  2089. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2090. return -1;
  2091. }
  2092. return 0;
  2093. }
  2094. /*==========================================
  2095. * @skpoint (Rewritten by [Yor])
  2096. *------------------------------------------*/
  2097. ACMD_FUNC(skillpoint)
  2098. {
  2099. int point;
  2100. unsigned int new_skill_point;
  2101. nullpo_retr(-1, sd);
  2102. if (!message || !*message || (point = atoi(message)) == 0) {
  2103. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2104. return -1;
  2105. }
  2106. if(point < 0)
  2107. {
  2108. if(sd->status.skill_point < (unsigned int)(-point))
  2109. {
  2110. new_skill_point = 0;
  2111. }
  2112. else
  2113. {
  2114. new_skill_point = sd->status.skill_point + point;
  2115. }
  2116. }
  2117. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2118. {
  2119. new_skill_point = UINT_MAX;
  2120. }
  2121. else
  2122. {
  2123. new_skill_point = sd->status.skill_point + point;
  2124. }
  2125. if (new_skill_point != sd->status.skill_point) {
  2126. sd->status.skill_point = new_skill_point;
  2127. clif_updatestatus(sd, SP_SKILLPOINT);
  2128. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2129. } else {
  2130. if (point < 0)
  2131. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2132. else
  2133. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2134. return -1;
  2135. }
  2136. return 0;
  2137. }
  2138. /*==========================================
  2139. * @zeny
  2140. *------------------------------------------*/
  2141. ACMD_FUNC(zeny)
  2142. {
  2143. int zeny=0, ret=-1;
  2144. nullpo_retr(-1, sd);
  2145. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2146. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2147. return -1;
  2148. }
  2149. if(zeny > 0){
  2150. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2151. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2152. }
  2153. else {
  2154. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2155. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2156. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2157. }
  2158. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2159. return 0;
  2160. }
  2161. /*==========================================
  2162. *
  2163. *------------------------------------------*/
  2164. ACMD_FUNC(param)
  2165. {
  2166. uint8 i;
  2167. int value = 0;
  2168. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2169. short new_value, *status[6], max_status[6];
  2170. //we don't use direct initialization because it isn't part of the c standard.
  2171. nullpo_retr(-1, sd);
  2172. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2173. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2174. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2175. return -1;
  2176. }
  2177. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2178. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2179. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2180. return -1;
  2181. }
  2182. status[0] = &sd->status.str;
  2183. status[1] = &sd->status.agi;
  2184. status[2] = &sd->status.vit;
  2185. status[3] = &sd->status.int_;
  2186. status[4] = &sd->status.dex;
  2187. status[5] = &sd->status.luk;
  2188. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2189. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2190. else {
  2191. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2192. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2193. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2194. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2195. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2196. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2197. }
  2198. if(value > 0 && *status[i] + value >= max_status[i])
  2199. new_value = max_status[i];
  2200. else if(value < 0 && *status[i] <= -value)
  2201. new_value = 1;
  2202. else
  2203. new_value = *status[i] + value;
  2204. if (new_value != *status[i]) {
  2205. *status[i] = new_value;
  2206. clif_updatestatus(sd, SP_STR + i);
  2207. clif_updatestatus(sd, SP_USTR + i);
  2208. status_calc_pc(sd, SCO_FORCE);
  2209. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2210. } else {
  2211. if (value < 0)
  2212. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2213. else
  2214. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2215. return -1;
  2216. }
  2217. return 0;
  2218. }
  2219. /*==========================================
  2220. * Stat all by fritz (rewritten by [Yor])
  2221. *------------------------------------------*/
  2222. ACMD_FUNC(stat_all)
  2223. {
  2224. int value = 0;
  2225. uint8 count, i;
  2226. short *status[PARAM_MAX], max_status[PARAM_MAX];
  2227. //we don't use direct initialization because it isn't part of the c standard.
  2228. nullpo_retr(-1, sd);
  2229. status[0] = &sd->status.str;
  2230. status[1] = &sd->status.agi;
  2231. status[2] = &sd->status.vit;
  2232. status[3] = &sd->status.int_;
  2233. status[4] = &sd->status.dex;
  2234. status[5] = &sd->status.luk;
  2235. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2236. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2237. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2238. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2239. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2240. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2241. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2242. value = SHRT_MAX;
  2243. } else {
  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. }
  2255. count = 0;
  2256. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2257. short new_value;
  2258. if (value > 0 && *status[i] + value >= max_status[i])
  2259. new_value = max_status[i];
  2260. else if (value < 0 && *status[i] <= -value)
  2261. new_value = 1;
  2262. else
  2263. new_value = *status[i] + value;
  2264. if (new_value != *status[i]) {
  2265. *status[i] = new_value;
  2266. clif_updatestatus(sd, SP_STR + i);
  2267. clif_updatestatus(sd, SP_USTR + i);
  2268. count++;
  2269. }
  2270. }
  2271. if (count > 0) { // if at least 1 stat modified
  2272. status_calc_pc(sd, SCO_FORCE);
  2273. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2274. } else {
  2275. if (value < 0)
  2276. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2277. else
  2278. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2279. return -1;
  2280. }
  2281. return 0;
  2282. }
  2283. /*==========================================
  2284. *
  2285. *------------------------------------------*/
  2286. ACMD_FUNC(guildlevelup) {
  2287. int level = 0;
  2288. short added_level;
  2289. struct guild *guild_info;
  2290. nullpo_retr(-1, sd);
  2291. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2292. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2293. return -1;
  2294. }
  2295. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2296. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2297. return -1;
  2298. }
  2299. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2300. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2301. // return -1;
  2302. //}
  2303. added_level = (short)level;
  2304. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2305. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2306. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2307. added_level = 1 - guild_info->guild_lv;
  2308. if (added_level != 0) {
  2309. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2310. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2311. } else {
  2312. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2313. return -1;
  2314. }
  2315. return 0;
  2316. }
  2317. /*==========================================
  2318. *
  2319. *------------------------------------------*/
  2320. ACMD_FUNC(makeegg) {
  2321. struct item_data *item_data;
  2322. int id, pet_id;
  2323. nullpo_retr(-1, sd);
  2324. if (!message || !*message) {
  2325. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2326. return -1;
  2327. }
  2328. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2329. id = item_data->nameid;
  2330. else
  2331. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2332. ;
  2333. else
  2334. id = atoi(message);
  2335. pet_id = search_petDB_index(id, PET_CLASS);
  2336. if (pet_id < 0)
  2337. pet_id = search_petDB_index(id, PET_EGG);
  2338. if (pet_id >= 0) {
  2339. sd->catch_target_class = pet_db[pet_id].class_;
  2340. intif_create_pet(
  2341. sd->status.account_id, sd->status.char_id,
  2342. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2343. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2344. 100, 0, 1, pet_db[pet_id].jname);
  2345. } else {
  2346. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2347. return -1;
  2348. }
  2349. return 0;
  2350. }
  2351. /*==========================================
  2352. *
  2353. *------------------------------------------*/
  2354. ACMD_FUNC(hatch) {
  2355. nullpo_retr(-1, sd);
  2356. if (sd->status.pet_id <= 0)
  2357. clif_sendegg(sd);
  2358. else {
  2359. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2360. return -1;
  2361. }
  2362. return 0;
  2363. }
  2364. /*==========================================
  2365. *
  2366. *------------------------------------------*/
  2367. ACMD_FUNC(petfriendly) {
  2368. int friendly;
  2369. struct pet_data *pd;
  2370. nullpo_retr(-1, sd);
  2371. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2372. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2373. return -1;
  2374. }
  2375. pd = sd->pd;
  2376. if (!pd) {
  2377. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2378. return -1;
  2379. }
  2380. if (friendly < 0 || friendly > 1000)
  2381. {
  2382. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2383. return -1;
  2384. }
  2385. if (friendly == pd->pet.intimate) {
  2386. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2387. return -1;
  2388. }
  2389. pet_set_intimate(pd, friendly);
  2390. clif_send_petstatus(sd);
  2391. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2392. return 0;
  2393. }
  2394. /*==========================================
  2395. *
  2396. *------------------------------------------*/
  2397. ACMD_FUNC(pethungry)
  2398. {
  2399. int hungry;
  2400. struct pet_data *pd;
  2401. nullpo_retr(-1, sd);
  2402. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2403. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2404. return -1;
  2405. }
  2406. pd = sd->pd;
  2407. if (!sd->status.pet_id || !pd) {
  2408. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2409. return -1;
  2410. }
  2411. if (hungry < 0 || hungry > 100) {
  2412. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2413. return -1;
  2414. }
  2415. if (hungry == pd->pet.hungry) {
  2416. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2417. return -1;
  2418. }
  2419. pd->pet.hungry = hungry;
  2420. clif_send_petstatus(sd);
  2421. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2422. return 0;
  2423. }
  2424. /*==========================================
  2425. *
  2426. *------------------------------------------*/
  2427. ACMD_FUNC(petrename)
  2428. {
  2429. struct pet_data *pd;
  2430. nullpo_retr(-1, sd);
  2431. if (!sd->status.pet_id || !sd->pd) {
  2432. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2433. return -1;
  2434. }
  2435. pd = sd->pd;
  2436. if (!pd->pet.rename_flag) {
  2437. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2438. return -1;
  2439. }
  2440. pd->pet.rename_flag = 0;
  2441. intif_save_petdata(sd->status.account_id, &pd->pet);
  2442. clif_send_petstatus(sd);
  2443. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2444. return 0;
  2445. }
  2446. /*==========================================
  2447. *
  2448. *------------------------------------------*/
  2449. ACMD_FUNC(recall) {
  2450. struct map_session_data *pl_sd = NULL;
  2451. nullpo_retr(-1, sd);
  2452. if (!message || !*message) {
  2453. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2454. return -1;
  2455. }
  2456. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2457. {
  2458. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2459. return -1;
  2460. }
  2461. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2462. {
  2463. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2464. return -1;
  2465. }
  2466. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2467. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2468. return -1;
  2469. }
  2470. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2471. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2472. return -1;
  2473. }
  2474. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2475. return -1;
  2476. }
  2477. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2478. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2479. clif_displaymessage(fd, atcmd_output);
  2480. return 0;
  2481. }
  2482. /*==========================================
  2483. * charblock command (usage: charblock <player_name>)
  2484. * This command do a definitiv ban on a player
  2485. *------------------------------------------*/
  2486. ACMD_FUNC(char_block)
  2487. {
  2488. nullpo_retr(-1, sd);
  2489. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2490. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2491. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2492. clif_displaymessage(fd, atcmd_output);
  2493. return -1;
  2494. }
  2495. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2496. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2497. clif_displaymessage(fd, atcmd_output);
  2498. return 0;
  2499. }
  2500. /*==========================================
  2501. * accountban command (usage: ban <%time> <player_name>)
  2502. * charban command (usage: charban <%time> <player_name>)
  2503. * %time see common/timer.c::solve_time()
  2504. *------------------------------------------*/
  2505. ACMD_FUNC(char_ban)
  2506. {
  2507. char *modif_p, output[CHAT_SIZE_MAX];
  2508. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2509. int bantype = 0;
  2510. nullpo_retr(-1, sd);
  2511. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2512. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2513. parent_cmd = atcommand_checkalias(command+1);
  2514. if (strcmpi(parent_cmd,"charban") == 0)
  2515. bantype = CHRIF_OP_BAN;
  2516. else if (strcmpi(parent_cmd,"ban") == 0)
  2517. bantype = CHRIF_OP_LOGIN_BAN;
  2518. else
  2519. return -1;
  2520. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2521. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2522. clif_displaymessage(fd, output);
  2523. return -1;
  2524. }
  2525. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2526. modif_p = atcmd_output;
  2527. timediff = (int32)solve_time(modif_p); //discard seconds
  2528. if (timediff == 0) { //allow negative ?
  2529. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2530. clif_displaymessage(fd, output);
  2531. 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.
  2532. return -1;
  2533. }
  2534. if( timediff < 0 && (
  2535. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2536. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2537. ))
  2538. {
  2539. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2540. return -1;
  2541. }
  2542. if (bantype == CHRIF_OP_BAN)
  2543. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2544. else
  2545. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2546. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2547. clif_displaymessage(fd, output);
  2548. return 0;
  2549. }
  2550. /*==========================================
  2551. * charunblock command (usage: charunblock <player_name>)
  2552. *------------------------------------------*/
  2553. ACMD_FUNC(char_unblock)
  2554. {
  2555. nullpo_retr(-1, sd);
  2556. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2557. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2558. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2559. clif_displaymessage(fd, atcmd_output);
  2560. return -1;
  2561. }
  2562. // send answer to login server via char-server
  2563. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2564. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2565. clif_displaymessage(fd, atcmd_output);
  2566. return 0;
  2567. }
  2568. /*==========================================
  2569. * acc unban command (usage: unban <player_name>)
  2570. * char unban command (usage: charunban <player_name>)
  2571. *------------------------------------------*/
  2572. ACMD_FUNC(char_unban){
  2573. int unbantype = 0;
  2574. nullpo_retr(-1, sd);
  2575. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2576. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2577. parent_cmd = atcommand_checkalias(command+1);
  2578. if (strcmpi(parent_cmd,"charunban") == 0)
  2579. unbantype = CHRIF_OP_UNBAN;
  2580. else if (strcmpi(parent_cmd,"unban") == 0)
  2581. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2582. else
  2583. return -1;
  2584. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2585. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2586. clif_displaymessage(fd, atcmd_output);
  2587. return -1;
  2588. }
  2589. if (unbantype == CHRIF_OP_UNBAN)
  2590. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2591. else
  2592. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2593. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2594. clif_displaymessage(fd, atcmd_output);
  2595. return 0;
  2596. }
  2597. /*==========================================
  2598. *
  2599. *------------------------------------------*/
  2600. ACMD_FUNC(night)
  2601. {
  2602. nullpo_retr(-1, sd);
  2603. if (night_flag != 1) {
  2604. map_night_timer(night_timer_tid, 0, 0, 1);
  2605. } else {
  2606. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2607. return -1;
  2608. }
  2609. return 0;
  2610. }
  2611. /*==========================================
  2612. *
  2613. *------------------------------------------*/
  2614. ACMD_FUNC(day)
  2615. {
  2616. nullpo_retr(-1, sd);
  2617. if (night_flag != 0) {
  2618. map_day_timer(day_timer_tid, 0, 0, 1);
  2619. } else {
  2620. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2621. return -1;
  2622. }
  2623. return 0;
  2624. }
  2625. /*==========================================
  2626. *
  2627. *------------------------------------------*/
  2628. ACMD_FUNC(doom)
  2629. {
  2630. struct map_session_data* pl_sd;
  2631. struct s_mapiterator* iter;
  2632. nullpo_retr(-1, sd);
  2633. iter = mapit_getallusers();
  2634. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2635. {
  2636. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2637. {
  2638. status_kill(&pl_sd->bl);
  2639. clif_specialeffect(&pl_sd->bl,450,AREA);
  2640. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2641. }
  2642. }
  2643. mapit_free(iter);
  2644. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2645. return 0;
  2646. }
  2647. /*==========================================
  2648. *
  2649. *------------------------------------------*/
  2650. ACMD_FUNC(doommap)
  2651. {
  2652. struct map_session_data* pl_sd;
  2653. struct s_mapiterator* iter;
  2654. nullpo_retr(-1, sd);
  2655. iter = mapit_getallusers();
  2656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2657. {
  2658. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2659. {
  2660. status_kill(&pl_sd->bl);
  2661. clif_specialeffect(&pl_sd->bl,450,AREA);
  2662. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2663. }
  2664. }
  2665. mapit_free(iter);
  2666. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2667. return 0;
  2668. }
  2669. /*==========================================
  2670. *
  2671. *------------------------------------------*/
  2672. static void atcommand_raise_sub(struct map_session_data* sd) {
  2673. status_revive(&sd->bl, 100, 100);
  2674. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2675. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2676. }
  2677. /*==========================================
  2678. *
  2679. *------------------------------------------*/
  2680. ACMD_FUNC(raise)
  2681. {
  2682. struct map_session_data* pl_sd;
  2683. struct s_mapiterator* iter;
  2684. nullpo_retr(-1, sd);
  2685. iter = mapit_getallusers();
  2686. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2687. if( pc_isdead(pl_sd) )
  2688. atcommand_raise_sub(pl_sd);
  2689. mapit_free(iter);
  2690. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2691. return 0;
  2692. }
  2693. /*==========================================
  2694. *
  2695. *------------------------------------------*/
  2696. ACMD_FUNC(raisemap)
  2697. {
  2698. struct map_session_data* pl_sd;
  2699. struct s_mapiterator* iter;
  2700. nullpo_retr(-1, sd);
  2701. iter = mapit_getallusers();
  2702. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2703. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2704. atcommand_raise_sub(pl_sd);
  2705. mapit_free(iter);
  2706. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2707. return 0;
  2708. }
  2709. /*==========================================
  2710. *
  2711. *------------------------------------------*/
  2712. ACMD_FUNC(kick)
  2713. {
  2714. struct map_session_data *pl_sd;
  2715. nullpo_retr(-1, sd);
  2716. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2717. if (!message || !*message) {
  2718. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2719. return -1;
  2720. }
  2721. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2722. {
  2723. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2724. return -1;
  2725. }
  2726. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2727. {
  2728. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2729. return -1;
  2730. }
  2731. clif_GM_kick(sd, pl_sd);
  2732. return 0;
  2733. }
  2734. /*==========================================
  2735. *
  2736. *------------------------------------------*/
  2737. ACMD_FUNC(kickall)
  2738. {
  2739. struct map_session_data* pl_sd;
  2740. struct s_mapiterator* iter;
  2741. nullpo_retr(-1, sd);
  2742. iter = mapit_getallusers();
  2743. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2744. {
  2745. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2746. if (sd->status.account_id != pl_sd->status.account_id)
  2747. clif_GM_kick(NULL, pl_sd);
  2748. }
  2749. }
  2750. mapit_free(iter);
  2751. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2752. return 0;
  2753. }
  2754. /*==========================================
  2755. *
  2756. *------------------------------------------*/
  2757. ACMD_FUNC(allskill)
  2758. {
  2759. nullpo_retr(-1, sd);
  2760. pc_allskillup(sd); // all skills
  2761. sd->status.skill_point = 0; // 0 skill points
  2762. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2763. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2764. return 0;
  2765. }
  2766. /*==========================================
  2767. *
  2768. *------------------------------------------*/
  2769. ACMD_FUNC(questskill)
  2770. {
  2771. uint16 skill_id;
  2772. nullpo_retr(-1, sd);
  2773. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2774. {// also send a list of skills applicable to this command
  2775. const char* text;
  2776. // attempt to find the text corresponding to this command
  2777. text = atcommand_help_string( command );
  2778. // send the error message as always
  2779. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2780. if( text )
  2781. {// send the skill ID list associated with this command
  2782. clif_displaymessage( fd, text );
  2783. }
  2784. return -1;
  2785. }
  2786. if (skill_id >= MAX_SKILL_DB) {
  2787. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2788. return -1;
  2789. }
  2790. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2791. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2792. return -1;
  2793. }
  2794. if (pc_checkskill(sd, skill_id) > 0) {
  2795. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2796. return -1;
  2797. }
  2798. pc_skill(sd, skill_id, 1, 0);
  2799. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2800. return 0;
  2801. }
  2802. /*==========================================
  2803. *
  2804. *------------------------------------------*/
  2805. ACMD_FUNC(lostskill)
  2806. {
  2807. uint16 skill_id;
  2808. nullpo_retr(-1, sd);
  2809. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2810. {// also send a list of skills applicable to this command
  2811. const char* text;
  2812. // attempt to find the text corresponding to this command
  2813. text = atcommand_help_string( command );
  2814. // send the error message as always
  2815. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2816. if( text )
  2817. {// send the skill ID list associated with this command
  2818. clif_displaymessage( fd, text );
  2819. }
  2820. return -1;
  2821. }
  2822. if (skill_id >= MAX_SKILL) {
  2823. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2824. return -1;
  2825. }
  2826. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2827. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2828. return -1;
  2829. }
  2830. if (pc_checkskill(sd, skill_id) == 0) {
  2831. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2832. return -1;
  2833. }
  2834. sd->status.skill[skill_id].lv = 0;
  2835. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2836. clif_deleteskill(sd,skill_id);
  2837. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2838. return 0;
  2839. }
  2840. /*==========================================
  2841. *
  2842. *------------------------------------------*/
  2843. ACMD_FUNC(spiritball)
  2844. {
  2845. int max_spiritballs;
  2846. int number;
  2847. nullpo_retr(-1, sd);
  2848. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2849. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2850. {
  2851. char msg[CHAT_SIZE_MAX];
  2852. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2853. clif_displaymessage(fd, msg);
  2854. return -1;
  2855. }
  2856. if( sd->spiritball > 0 )
  2857. pc_delspiritball(sd, sd->spiritball, 1);
  2858. sd->spiritball = number;
  2859. clif_spiritball(&sd->bl);
  2860. // no message, player can look the difference
  2861. return 0;
  2862. }
  2863. /*==========================================
  2864. *
  2865. *------------------------------------------*/
  2866. ACMD_FUNC(party)
  2867. {
  2868. char party[NAME_LENGTH];
  2869. nullpo_retr(-1, sd);
  2870. memset(party, '\0', sizeof(party));
  2871. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2872. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2873. return -1;
  2874. }
  2875. party_create(sd, party, 0, 0);
  2876. return 0;
  2877. }
  2878. /*==========================================
  2879. *
  2880. *------------------------------------------*/
  2881. ACMD_FUNC(guild)
  2882. {
  2883. char guild[NAME_LENGTH];
  2884. int prev;
  2885. nullpo_retr(-1, sd);
  2886. memset(guild, '\0', sizeof(guild));
  2887. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2888. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2889. return -1;
  2890. }
  2891. prev = battle_config.guild_emperium_check;
  2892. battle_config.guild_emperium_check = 0;
  2893. guild_create(sd, guild);
  2894. battle_config.guild_emperium_check = prev;
  2895. return 0;
  2896. }
  2897. ACMD_FUNC(breakguild)
  2898. {
  2899. nullpo_retr(-1, sd);
  2900. if (sd->status.guild_id) { // Check if the player has a guild
  2901. struct guild *g;
  2902. g = sd->guild; // Search the guild
  2903. if (g) { // Check if guild was found
  2904. if (sd->state.gmaster_flag) { // Check if player is guild master
  2905. int ret = 0;
  2906. ret = guild_break(sd, g->name); // Break guild
  2907. if (ret) { // Check if anything went wrong
  2908. return 0; // Guild was broken
  2909. } else {
  2910. return -1; // Something went wrong
  2911. }
  2912. } else { // Not guild master
  2913. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2914. return -1;
  2915. }
  2916. } else { // Guild was not found. HOW?
  2917. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2918. return -1;
  2919. }
  2920. } else { // Player does not have a guild
  2921. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2922. return -1;
  2923. }
  2924. return 0;
  2925. }
  2926. /*==========================================
  2927. *
  2928. *------------------------------------------*/
  2929. ACMD_FUNC(agitstart)
  2930. {
  2931. nullpo_retr(-1, sd);
  2932. if (agit_flag == 1) {
  2933. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2934. return -1;
  2935. }
  2936. agit_flag = 1;
  2937. guild_agit_start();
  2938. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2939. return 0;
  2940. }
  2941. /*==========================================
  2942. *
  2943. *------------------------------------------*/
  2944. ACMD_FUNC(agitstart2)
  2945. {
  2946. nullpo_retr(-1, sd);
  2947. if (agit2_flag == 1) {
  2948. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2949. return -1;
  2950. }
  2951. agit2_flag = 1;
  2952. guild_agit2_start();
  2953. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2954. return 0;
  2955. }
  2956. /*==========================================
  2957. *
  2958. *------------------------------------------*/
  2959. ACMD_FUNC(agitend)
  2960. {
  2961. nullpo_retr(-1, sd);
  2962. if (agit_flag == 0) {
  2963. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2964. return -1;
  2965. }
  2966. agit_flag = 0;
  2967. guild_agit_end();
  2968. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2969. return 0;
  2970. }
  2971. /*==========================================
  2972. *
  2973. *------------------------------------------*/
  2974. ACMD_FUNC(agitend2)
  2975. {
  2976. nullpo_retr(-1, sd);
  2977. if (agit2_flag == 0) {
  2978. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2979. return -1;
  2980. }
  2981. agit2_flag = 0;
  2982. guild_agit2_end();
  2983. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2984. return 0;
  2985. }
  2986. /*==========================================
  2987. * @mapexit - shuts down the map server
  2988. *------------------------------------------*/
  2989. ACMD_FUNC(mapexit)
  2990. {
  2991. nullpo_retr(-1, sd);
  2992. do_shutdown();
  2993. return 0;
  2994. }
  2995. /*==========================================
  2996. * idsearch <part_of_name>: revrited by [Yor]
  2997. *------------------------------------------*/
  2998. ACMD_FUNC(idsearch)
  2999. {
  3000. char item_name[100];
  3001. unsigned int i, match;
  3002. struct item_data *item_array[MAX_SEARCH];
  3003. nullpo_retr(-1, sd);
  3004. memset(item_name, '\0', sizeof(item_name));
  3005. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3006. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3007. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3008. return -1;
  3009. }
  3010. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3011. clif_displaymessage(fd, atcmd_output);
  3012. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3013. if (match > MAX_SEARCH) {
  3014. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3015. clif_displaymessage(fd, atcmd_output);
  3016. match = MAX_SEARCH;
  3017. }
  3018. for(i = 0; i < match; i++) {
  3019. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3020. clif_displaymessage(fd, atcmd_output);
  3021. }
  3022. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3023. clif_displaymessage(fd, atcmd_output);
  3024. return 0;
  3025. }
  3026. /*==========================================
  3027. * Recall All Characters Online To Your Location
  3028. *------------------------------------------*/
  3029. ACMD_FUNC(recallall)
  3030. {
  3031. struct map_session_data* pl_sd;
  3032. struct s_mapiterator* iter;
  3033. int count;
  3034. nullpo_retr(-1, sd);
  3035. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3036. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3037. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3038. return -1;
  3039. }
  3040. count = 0;
  3041. iter = mapit_getallusers();
  3042. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3043. {
  3044. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3045. {
  3046. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3047. continue; // Don't waste time warping the character to the same place.
  3048. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3049. count++;
  3050. else {
  3051. if (pc_isdead(pl_sd)) { //Wake them up
  3052. pc_setstand(pl_sd, true);
  3053. pc_setrestartvalue(pl_sd,1);
  3054. }
  3055. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3056. }
  3057. }
  3058. }
  3059. mapit_free(iter);
  3060. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3061. if (count) {
  3062. 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.
  3063. clif_displaymessage(fd, atcmd_output);
  3064. }
  3065. return 0;
  3066. }
  3067. /*==========================================
  3068. * Recall online characters of a guild to your location
  3069. *------------------------------------------*/
  3070. ACMD_FUNC(guildrecall)
  3071. {
  3072. struct map_session_data* pl_sd;
  3073. struct s_mapiterator* iter;
  3074. int count;
  3075. char guild_name[NAME_LENGTH];
  3076. struct guild *g;
  3077. nullpo_retr(-1, sd);
  3078. memset(guild_name, '\0', sizeof(guild_name));
  3079. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3080. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3081. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3082. return -1;
  3083. }
  3084. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3085. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3086. return -1;
  3087. }
  3088. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3089. (g = guild_search(atoi(message))) == NULL)
  3090. {
  3091. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3092. return -1;
  3093. }
  3094. count = 0;
  3095. iter = mapit_getallusers();
  3096. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3097. {
  3098. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3099. {
  3100. 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))
  3101. continue; // Skip GMs greater than you... or chars already on the cell
  3102. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3103. count++;
  3104. else
  3105. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3106. }
  3107. }
  3108. mapit_free(iter);
  3109. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3110. clif_displaymessage(fd, atcmd_output);
  3111. if (count) {
  3112. 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.
  3113. clif_displaymessage(fd, atcmd_output);
  3114. }
  3115. return 0;
  3116. }
  3117. /*==========================================
  3118. * Recall online characters of a party to your location
  3119. *------------------------------------------*/
  3120. ACMD_FUNC(partyrecall)
  3121. {
  3122. struct map_session_data* pl_sd;
  3123. struct s_mapiterator* iter;
  3124. char party_name[NAME_LENGTH];
  3125. struct party_data *p;
  3126. int count;
  3127. nullpo_retr(-1, sd);
  3128. memset(party_name, '\0', sizeof(party_name));
  3129. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3130. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3131. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3132. return -1;
  3133. }
  3134. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3135. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3136. return -1;
  3137. }
  3138. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3139. (p = party_search(atoi(message))) == NULL)
  3140. {
  3141. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3142. return -1;
  3143. }
  3144. count = 0;
  3145. iter = mapit_getallusers();
  3146. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3147. {
  3148. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3149. {
  3150. 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))
  3151. continue; // Skip GMs greater than you... or chars already on the cell
  3152. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3153. count++;
  3154. else
  3155. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3156. }
  3157. }
  3158. mapit_free(iter);
  3159. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3160. clif_displaymessage(fd, atcmd_output);
  3161. if (count) {
  3162. 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.
  3163. clif_displaymessage(fd, atcmd_output);
  3164. }
  3165. return 0;
  3166. }
  3167. /*==========================================
  3168. *
  3169. *------------------------------------------*/
  3170. void atcommand_doload();
  3171. ACMD_FUNC(reload) {
  3172. nullpo_retr(-1, sd);
  3173. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3174. const char* text;
  3175. text = atcommand_help_string( command );
  3176. if(text)
  3177. clif_displaymessage( fd, text );
  3178. return -1;
  3179. }
  3180. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3181. itemdb_reload();
  3182. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3183. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3184. mob_reload();
  3185. read_petdb();
  3186. hom_reload();
  3187. mercenary_readdb();
  3188. mercenary_read_skilldb();
  3189. reload_elementaldb();
  3190. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3191. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3192. skill_reload();
  3193. hom_reload_skill();
  3194. reload_elemental_skilldb();
  3195. mercenary_read_skilldb();
  3196. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3197. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3198. config_t run_test;
  3199. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3200. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3201. return -1;
  3202. }
  3203. config_destroy(&run_test);
  3204. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3205. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3206. return -1;
  3207. }
  3208. config_destroy(&run_test);
  3209. atcommand_doload();
  3210. pc_groups_reload();
  3211. clif_displaymessage(fd, msg_txt(sd,254));
  3212. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3213. struct Battle_Config prev_config;
  3214. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3215. battle_config_read(BATTLE_CONF_FILENAME);
  3216. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3217. || prev_config.item_rate_common != battle_config.item_rate_common
  3218. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3219. || prev_config.item_rate_card != battle_config.item_rate_card
  3220. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3221. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3222. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3223. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3224. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3225. || prev_config.item_rate_use != battle_config.item_rate_use
  3226. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3227. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3228. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3229. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3230. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3231. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3232. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3233. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3234. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3235. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3236. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3237. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3238. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3239. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3240. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3241. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3242. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3243. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3244. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3245. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3246. )
  3247. { // Exp or Drop rates changed.
  3248. mob_reload(); //Needed as well so rate changes take effect.
  3249. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3250. }
  3251. clif_displaymessage(fd, msg_txt(sd,255));
  3252. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3253. status_readdb();
  3254. clif_displaymessage(fd, msg_txt(sd,256));
  3255. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3256. pc_readdb();
  3257. clif_displaymessage(fd, msg_txt(sd,257));
  3258. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3259. pc_read_motd();
  3260. clif_displaymessage(fd, msg_txt(sd,268));
  3261. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3262. struct s_mapiterator* iter;
  3263. struct map_session_data* pl_sd;
  3264. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3265. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3266. iter = mapit_getallusers();
  3267. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3268. pc_close_npc(pl_sd,2);
  3269. mapit_free(iter);
  3270. flush_fifos();
  3271. map_reloadnpc(true); // reload config files seeking for npcs
  3272. script_reload();
  3273. npc_reload();
  3274. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3275. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3276. map_msg_reload();
  3277. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3278. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3279. do_reload_quest();
  3280. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3281. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3282. packetdb_readdb();
  3283. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3284. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3285. instance_readdb();
  3286. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3287. }
  3288. return 0;
  3289. }
  3290. /*==========================================
  3291. * @partysharelvl <share_range> [Akinari]
  3292. * Updates char server party share level range in runtime
  3293. * Temporary - Permanent update in inter_athena.conf
  3294. *------------------------------------------*/
  3295. ACMD_FUNC(partysharelvl) {
  3296. unsigned int share_lvl;
  3297. nullpo_retr(-1, sd);
  3298. if(!message || !*message) {
  3299. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3300. return -1;
  3301. } else
  3302. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3303. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3304. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3305. else //Char server offline
  3306. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3307. return 0;
  3308. }
  3309. /*==========================================
  3310. * @mapinfo [0-3] <map name> by MC_Cameri
  3311. * => Shows information about the map [map name]
  3312. * 0 = no additional information
  3313. * 1 = Show users in that map and their location
  3314. * 2 = Shows NPCs in that map
  3315. * 3 = Shows the chats in that map
  3316. *------------------------------------------*/
  3317. ACMD_FUNC(mapinfo) {
  3318. struct map_session_data* pl_sd;
  3319. struct s_mapiterator* iter;
  3320. struct chat_data *cd = NULL;
  3321. char direction[12];
  3322. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3323. unsigned short m_index;
  3324. char mapname[24];
  3325. nullpo_retr(-1, sd);
  3326. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3327. memset(mapname, '\0', sizeof(mapname));
  3328. memset(direction, '\0', sizeof(direction));
  3329. sscanf(message, "%d %23[^\n]", &list, mapname);
  3330. if (list < 0 || list > 3) {
  3331. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3332. return -1;
  3333. }
  3334. if (mapname[0] == '\0') {
  3335. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3336. m_id = map_mapindex2mapid(sd->mapindex);
  3337. } else {
  3338. m_id = map_mapname2mapid(mapname);
  3339. }
  3340. if (m_id < 0) {
  3341. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3342. return -1;
  3343. }
  3344. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3345. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3346. // count chats (for initial message)
  3347. chat_num = 0;
  3348. iter = mapit_getallusers();
  3349. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3350. if( pl_sd->mapindex == m_index ) {
  3351. if( pl_sd->state.vending )
  3352. vend_num++;
  3353. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3354. chat_num++;
  3355. }
  3356. }
  3357. mapit_free(iter);
  3358. 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
  3359. clif_displaymessage(fd, atcmd_output);
  3360. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3361. if (map[m_id].flag.town)
  3362. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3363. if (map[m_id].flag.restricted){
  3364. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3365. clif_displaymessage(fd, atcmd_output);
  3366. }
  3367. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3368. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3369. else
  3370. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3371. if (map[m_id].flag.battleground){
  3372. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3373. clif_displaymessage(fd, atcmd_output);
  3374. }
  3375. /* Skill damage adjustment info [Cydh] */
  3376. #ifdef ADJUST_SKILL_DAMAGE
  3377. if (map[m_id].flag.skill_damage) {
  3378. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3379. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3380. ,map[m_id].adjust.damage.pc
  3381. ,map[m_id].adjust.damage.mob
  3382. ,map[m_id].adjust.damage.boss
  3383. ,map[m_id].adjust.damage.other
  3384. ,map[m_id].adjust.damage.caster);
  3385. clif_displaymessage(fd, atcmd_output);
  3386. if (map[m_id].skill_damage[0].skill_id) {
  3387. int j;
  3388. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3389. for (j = 0; j < MAX_MAP_SKILL_MODIFIER; j++) {
  3390. if (map[m_id].skill_damage[j].skill_id) {
  3391. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3392. ,j+1
  3393. ,skill_get_name(map[m_id].skill_damage[j].skill_id)
  3394. ,map[m_id].skill_damage[j].pc
  3395. ,map[m_id].skill_damage[j].mob
  3396. ,map[m_id].skill_damage[j].boss
  3397. ,map[m_id].skill_damage[j].other
  3398. ,map[m_id].skill_damage[j].caster);
  3399. clif_displaymessage(fd,atcmd_output);
  3400. }
  3401. }
  3402. }
  3403. }
  3404. #endif
  3405. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3406. if (map[m_id].flag.pvp)
  3407. strcat(atcmd_output, " Pvp ON |");
  3408. if (map[m_id].flag.pvp_noguild)
  3409. strcat(atcmd_output, " NoGuild |");
  3410. if (map[m_id].flag.pvp_noparty)
  3411. strcat(atcmd_output, " NoParty |");
  3412. if (map[m_id].flag.pvp_nightmaredrop)
  3413. strcat(atcmd_output, " NightmareDrop |");
  3414. if (map[m_id].flag.pvp_nocalcrank)
  3415. strcat(atcmd_output, " NoCalcRank |");
  3416. clif_displaymessage(fd, atcmd_output);
  3417. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3418. if (map[m_id].flag.gvg)
  3419. strcat(atcmd_output, " GvG ON |");
  3420. if (map[m_id].flag.gvg_dungeon)
  3421. strcat(atcmd_output, " GvG Dungeon |");
  3422. if (map[m_id].flag.gvg_castle)
  3423. strcat(atcmd_output, " GvG Castle |");
  3424. if (map[m_id].flag.gvg_noparty)
  3425. strcat(atcmd_output, " NoParty |");
  3426. clif_displaymessage(fd, atcmd_output);
  3427. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3428. if (map[m_id].flag.noteleport)
  3429. strcat(atcmd_output, " NoTeleport |");
  3430. if (map[m_id].flag.monster_noteleport)
  3431. strcat(atcmd_output, " Monster NoTeleport |");
  3432. if (map[m_id].flag.nowarp)
  3433. strcat(atcmd_output, " NoWarp |");
  3434. if (map[m_id].flag.nowarpto)
  3435. strcat(atcmd_output, " NoWarpTo |");
  3436. if (map[m_id].flag.noreturn)
  3437. strcat(atcmd_output, " NoReturn |");
  3438. if (map[m_id].flag.nogo)
  3439. strcat(atcmd_output, " NoGo |"); //
  3440. if (map[m_id].flag.nomemo)
  3441. strcat(atcmd_output, " NoMemo |");
  3442. clif_displaymessage(fd, atcmd_output);
  3443. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3444. (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
  3445. clif_displaymessage(fd, atcmd_output);
  3446. if (map[m_id].flag.nosave) {
  3447. if (!map[m_id].save.map)
  3448. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3449. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3450. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3451. clif_displaymessage(fd, atcmd_output);
  3452. }
  3453. else {
  3454. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3455. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3456. clif_displaymessage(fd, atcmd_output);
  3457. }
  3458. }
  3459. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3460. if (map[m_id].flag.snow)
  3461. strcat(atcmd_output, " Snow |");
  3462. if (map[m_id].flag.fog)
  3463. strcat(atcmd_output, " Fog |");
  3464. if (map[m_id].flag.sakura)
  3465. strcat(atcmd_output, " Sakura |");
  3466. if (map[m_id].flag.clouds)
  3467. strcat(atcmd_output, " Clouds |");
  3468. if (map[m_id].flag.clouds2)
  3469. strcat(atcmd_output, " Clouds2 |");
  3470. if (map[m_id].flag.fireworks)
  3471. strcat(atcmd_output, " Fireworks |");
  3472. if (map[m_id].flag.leaves)
  3473. strcat(atcmd_output, " Leaves |");
  3474. if (map[m_id].flag.nightenabled)
  3475. strcat(atcmd_output, " Displays Night |");
  3476. clif_displaymessage(fd, atcmd_output);
  3477. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3478. if (map[m_id].flag.nobranch)
  3479. strcat(atcmd_output, " NoBranch |");
  3480. if (map[m_id].flag.notrade)
  3481. strcat(atcmd_output, " NoTrade |");
  3482. if (map[m_id].flag.novending)
  3483. strcat(atcmd_output, " NoVending |");
  3484. if (map[m_id].flag.nodrop)
  3485. strcat(atcmd_output, " NoDrop |");
  3486. if (map[m_id].flag.noskill)
  3487. strcat(atcmd_output, " NoSkill |");
  3488. if (map[m_id].flag.noicewall)
  3489. strcat(atcmd_output, " NoIcewall |");
  3490. if (map[m_id].flag.allowks)
  3491. strcat(atcmd_output, " AllowKS |");
  3492. if (map[m_id].flag.reset)
  3493. strcat(atcmd_output, " Reset |");
  3494. clif_displaymessage(fd, atcmd_output);
  3495. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3496. if (map[m_id].nocommand)
  3497. strcat(atcmd_output, " NoCommand |");
  3498. if (map[m_id].flag.nobaseexp)
  3499. strcat(atcmd_output, " NoBaseEXP |");
  3500. if (map[m_id].flag.nojobexp)
  3501. strcat(atcmd_output, " NoJobEXP |");
  3502. if (map[m_id].flag.nomobloot)
  3503. strcat(atcmd_output, " NoMobLoot |");
  3504. if (map[m_id].flag.nomvploot)
  3505. strcat(atcmd_output, " NoMVPLoot |");
  3506. if (map[m_id].flag.partylock)
  3507. strcat(atcmd_output, " PartyLock |");
  3508. if (map[m_id].flag.guildlock)
  3509. strcat(atcmd_output, " GuildLock |");
  3510. if (map[m_id].flag.loadevent)
  3511. strcat(atcmd_output, " Loadevent |");
  3512. if (map[m_id].flag.chmautojoin)
  3513. strcat(atcmd_output, " Chmautojoin |");
  3514. if (map[m_id].flag.nousecart)
  3515. strcat(atcmd_output, " NoUsecart |");
  3516. if (map[m_id].flag.noitemconsumption)
  3517. strcat(atcmd_output, " NoItemConsumption |");
  3518. if (map[m_id].flag.nosumstarmiracle)
  3519. strcat(atcmd_output, " NoSumStarMiracle |");
  3520. if (map[m_id].flag.nomineeffect)
  3521. strcat(atcmd_output, " NoMineEffect |");
  3522. if (map[m_id].flag.nolockon)
  3523. strcat(atcmd_output, " NoLockOn |");
  3524. if (map[m_id].flag.notomb)
  3525. strcat(atcmd_output, " NoTomb |");
  3526. clif_displaymessage(fd, atcmd_output);
  3527. switch (list) {
  3528. case 0:
  3529. // Do nothing. It's list 0, no additional display.
  3530. break;
  3531. case 1:
  3532. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3533. iter = mapit_getallusers();
  3534. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3535. {
  3536. if (pl_sd->mapindex == m_index) {
  3537. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3538. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3539. clif_displaymessage(fd, atcmd_output);
  3540. }
  3541. }
  3542. mapit_free(iter);
  3543. break;
  3544. case 2:
  3545. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3546. for (i = 0; i < map[m_id].npc_num;)
  3547. {
  3548. struct npc_data *nd = map[m_id].npc[i];
  3549. switch(nd->ud.dir) {
  3550. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3551. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3552. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3553. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3554. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3555. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3556. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3557. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3558. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3559. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3560. }
  3561. if(strcmp(nd->name,nd->exname) == 0)
  3562. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3563. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3564. else
  3565. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3566. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3567. clif_displaymessage(fd, atcmd_output);
  3568. }
  3569. break;
  3570. case 3:
  3571. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3572. iter = mapit_getallusers();
  3573. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3574. {
  3575. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3576. pl_sd->mapindex == m_index &&
  3577. cd->usersd[0] == pl_sd)
  3578. {
  3579. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3580. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3581. clif_displaymessage(fd, atcmd_output);
  3582. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3583. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3584. clif_displaymessage(fd, atcmd_output);
  3585. }
  3586. }
  3587. mapit_free(iter);
  3588. break;
  3589. default: // normally impossible to arrive here
  3590. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3591. return -1;
  3592. break;
  3593. }
  3594. return 0;
  3595. }
  3596. /*==========================================
  3597. *
  3598. *------------------------------------------*/
  3599. ACMD_FUNC(mount_peco)
  3600. {
  3601. nullpo_retr(-1, sd);
  3602. if (sd->disguise) {
  3603. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3604. return -1;
  3605. }
  3606. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3607. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3608. unsigned int option = OPTION_DRAGON1;
  3609. if( message[0] ) {
  3610. int color = atoi(message);
  3611. option = ( color == 2 ? OPTION_DRAGON2 :
  3612. color == 3 ? OPTION_DRAGON3 :
  3613. color == 4 ? OPTION_DRAGON4 :
  3614. color == 5 ? OPTION_DRAGON5 :
  3615. OPTION_DRAGON1 );
  3616. }
  3617. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3618. pc_setoption(sd, sd->sc.option|option);
  3619. } else {
  3620. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3621. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3622. }
  3623. return 0;
  3624. }
  3625. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3626. if( !pc_isridingwug(sd) ) {
  3627. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3628. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3629. } else {
  3630. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3631. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3632. }
  3633. return 0;
  3634. }
  3635. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3636. if( !pc_ismadogear(sd) ) {
  3637. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3638. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3639. } else {
  3640. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3641. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3642. }
  3643. return 0;
  3644. }
  3645. if (!pc_isriding(sd)) { // if actually no peco
  3646. if (!pc_checkskill(sd, KN_RIDING)) {
  3647. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3648. return -1;
  3649. }
  3650. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3651. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3652. } else {//Dismount
  3653. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3654. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3655. }
  3656. return 0;
  3657. }
  3658. /*==========================================
  3659. *Spy Commands by Syrus22
  3660. *------------------------------------------*/
  3661. ACMD_FUNC(guildspy)
  3662. {
  3663. char guild_name[NAME_LENGTH];
  3664. struct guild *g;
  3665. nullpo_retr(-1, sd);
  3666. memset(guild_name, '\0', sizeof(guild_name));
  3667. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3668. if (!enable_spy)
  3669. {
  3670. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3671. return -1;
  3672. }
  3673. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3674. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3675. return -1;
  3676. }
  3677. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3678. (g = guild_search(atoi(message))) != NULL) {
  3679. if (sd->guildspy == g->guild_id) {
  3680. sd->guildspy = 0;
  3681. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3682. clif_displaymessage(fd, atcmd_output);
  3683. } else {
  3684. sd->guildspy = g->guild_id;
  3685. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3686. clif_displaymessage(fd, atcmd_output);
  3687. }
  3688. } else {
  3689. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3690. return -1;
  3691. }
  3692. return 0;
  3693. }
  3694. /*==========================================
  3695. *
  3696. *------------------------------------------*/
  3697. ACMD_FUNC(partyspy)
  3698. {
  3699. char party_name[NAME_LENGTH];
  3700. struct party_data *p;
  3701. nullpo_retr(-1, sd);
  3702. memset(party_name, '\0', sizeof(party_name));
  3703. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3704. if (!enable_spy)
  3705. {
  3706. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3707. return -1;
  3708. }
  3709. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3710. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3711. return -1;
  3712. }
  3713. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3714. (p = party_search(atoi(message))) != NULL) {
  3715. if (sd->partyspy == p->party.party_id) {
  3716. sd->partyspy = 0;
  3717. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3718. clif_displaymessage(fd, atcmd_output);
  3719. } else {
  3720. sd->partyspy = p->party.party_id;
  3721. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3722. clif_displaymessage(fd, atcmd_output);
  3723. }
  3724. } else {
  3725. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3726. return -1;
  3727. }
  3728. return 0;
  3729. }
  3730. /*==========================================
  3731. * @repairall [Valaris]
  3732. *------------------------------------------*/
  3733. ACMD_FUNC(repairall)
  3734. {
  3735. int count, i;
  3736. nullpo_retr(-1, sd);
  3737. count = 0;
  3738. for (i = 0; i < MAX_INVENTORY; i++) {
  3739. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3740. sd->status.inventory[i].attribute = 0;
  3741. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3742. count++;
  3743. }
  3744. }
  3745. if (count > 0) {
  3746. clif_misceffect(&sd->bl, 3);
  3747. clif_equiplist(sd);
  3748. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3749. } else {
  3750. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3751. return -1;
  3752. }
  3753. return 0;
  3754. }
  3755. /*==========================================
  3756. * @nuke [Valaris]
  3757. *------------------------------------------*/
  3758. ACMD_FUNC(nuke)
  3759. {
  3760. struct map_session_data *pl_sd;
  3761. nullpo_retr(-1, sd);
  3762. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3763. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3764. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3765. return -1;
  3766. }
  3767. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3768. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3769. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3770. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3771. } else {
  3772. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3773. return -1;
  3774. }
  3775. } else {
  3776. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3777. return -1;
  3778. }
  3779. return 0;
  3780. }
  3781. /*==========================================
  3782. * @tonpc
  3783. *------------------------------------------*/
  3784. ACMD_FUNC(tonpc)
  3785. {
  3786. char npcname[NAME_LENGTH+1];
  3787. struct npc_data *nd;
  3788. nullpo_retr(-1, sd);
  3789. memset(npcname, 0, sizeof(npcname));
  3790. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3791. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3792. return -1;
  3793. }
  3794. if ((nd = npc_name2id(npcname)) != NULL) {
  3795. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3796. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3797. else
  3798. return -1;
  3799. } else {
  3800. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3801. return -1;
  3802. }
  3803. return 0;
  3804. }
  3805. /*==========================================
  3806. *
  3807. *------------------------------------------*/
  3808. ACMD_FUNC(shownpc)
  3809. {
  3810. char NPCname[NAME_LENGTH+1];
  3811. nullpo_retr(-1, sd);
  3812. memset(NPCname, '\0', sizeof(NPCname));
  3813. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3814. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3815. return -1;
  3816. }
  3817. if (npc_name2id(NPCname) != NULL) {
  3818. npc_enable(NPCname, 1);
  3819. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3820. } else {
  3821. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3822. return -1;
  3823. }
  3824. return 0;
  3825. }
  3826. /*==========================================
  3827. *
  3828. *------------------------------------------*/
  3829. ACMD_FUNC(hidenpc)
  3830. {
  3831. char NPCname[NAME_LENGTH+1];
  3832. nullpo_retr(-1, sd);
  3833. memset(NPCname, '\0', sizeof(NPCname));
  3834. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3835. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3836. return -1;
  3837. }
  3838. if (npc_name2id(NPCname) == NULL) {
  3839. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3840. return -1;
  3841. }
  3842. npc_enable(NPCname, 0);
  3843. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3844. return 0;
  3845. }
  3846. ACMD_FUNC(loadnpc)
  3847. {
  3848. if (!message || !*message) {
  3849. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3850. return -1;
  3851. }
  3852. // add to list of script sources and run it
  3853. if( !npc_addsrcfile(message) //try to read file
  3854. || !npc_parsesrcfile(message,true)
  3855. ){
  3856. clif_displaymessage(fd, msg_txt(sd,261));
  3857. return -1;
  3858. }
  3859. npc_read_event_script();
  3860. clif_displaymessage(fd, msg_txt(sd,262));
  3861. return 0;
  3862. }
  3863. ACMD_FUNC(unloadnpc)
  3864. {
  3865. struct npc_data *nd;
  3866. char NPCname[NAME_LENGTH];
  3867. nullpo_retr(-1, sd);
  3868. memset(NPCname, '\0', sizeof(NPCname));
  3869. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3870. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3871. return -1;
  3872. }
  3873. if ((nd = npc_name2id(NPCname)) == NULL) {
  3874. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3875. return -1;
  3876. }
  3877. npc_unload_duplicates(nd);
  3878. npc_unload(nd,true);
  3879. npc_read_event_script();
  3880. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3881. return 0;
  3882. }
  3883. /*==========================================
  3884. * time in txt for time command (by [Yor])
  3885. *------------------------------------------*/
  3886. char* txt_time(unsigned int duration)
  3887. {
  3888. int days, hours, minutes, seconds;
  3889. char temp[CHAT_SIZE_MAX];
  3890. static char temp1[CHAT_SIZE_MAX];
  3891. memset(temp, '\0', sizeof(temp));
  3892. memset(temp1, '\0', sizeof(temp1));
  3893. days = duration / (60 * 60 * 24);
  3894. duration = duration - (60 * 60 * 24 * days);
  3895. hours = duration / (60 * 60);
  3896. duration = duration - (60 * 60 * hours);
  3897. minutes = duration / 60;
  3898. seconds = duration - (60 * minutes);
  3899. if (days == 1)
  3900. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3901. else if (days > 1)
  3902. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3903. if (hours == 1)
  3904. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3905. else if (hours > 1)
  3906. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3907. if (minutes < 2)
  3908. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3909. else
  3910. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3911. if (seconds == 1)
  3912. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3913. else if (seconds > 1)
  3914. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3915. return temp1;
  3916. }
  3917. /*==========================================
  3918. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3919. * Calculation management of GM modification (@day/@night GM commands) is done
  3920. *------------------------------------------*/
  3921. ACMD_FUNC(servertime)
  3922. {
  3923. const struct TimerData * timer_data;
  3924. time_t time_server; // variable for number of seconds (used with time() function)
  3925. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3926. char temp[CHAT_SIZE_MAX];
  3927. nullpo_retr(-1, sd);
  3928. memset(temp, '\0', sizeof(temp));
  3929. time(&time_server); // get time in seconds since 1/1/1970
  3930. datetime = localtime(&time_server); // convert seconds in structure
  3931. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3932. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3933. clif_displaymessage(fd, temp);
  3934. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3935. if (night_flag == 0)
  3936. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3937. else
  3938. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3939. } else if (battle_config.night_duration == 0)
  3940. if (night_flag == 1) { // we start with night
  3941. timer_data = get_timer(day_timer_tid);
  3942. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  3943. clif_displaymessage(fd, temp);
  3944. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3945. } else
  3946. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3947. else if (battle_config.day_duration == 0)
  3948. if (night_flag == 0) { // we start with day
  3949. timer_data = get_timer(night_timer_tid);
  3950. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3951. clif_displaymessage(fd, temp);
  3952. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3953. } else
  3954. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3955. else {
  3956. const struct TimerData * timer_data2;
  3957. if (night_flag == 0) {
  3958. timer_data = get_timer(night_timer_tid);
  3959. timer_data2 = get_timer(day_timer_tid);
  3960. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3961. clif_displaymessage(fd, temp);
  3962. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3963. 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.
  3964. else
  3965. 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.
  3966. clif_displaymessage(fd, temp);
  3967. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3968. clif_displaymessage(fd, temp);
  3969. } else {
  3970. timer_data = get_timer(day_timer_tid);
  3971. timer_data2 = get_timer(night_timer_tid);
  3972. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  3973. clif_displaymessage(fd, temp);
  3974. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3975. 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.
  3976. else
  3977. 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.
  3978. clif_displaymessage(fd, temp);
  3979. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3980. clif_displaymessage(fd, temp);
  3981. }
  3982. }
  3983. return 0;
  3984. }
  3985. /*==========================================
  3986. * @jail <char_name> by [Yor]
  3987. * Special warp! No check with nowarp and nowarpto flag
  3988. *------------------------------------------*/
  3989. ACMD_FUNC(jail)
  3990. {
  3991. struct map_session_data *pl_sd;
  3992. int x, y;
  3993. unsigned short m_index;
  3994. nullpo_retr(-1, sd);
  3995. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3996. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3997. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3998. return -1;
  3999. }
  4000. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4001. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4002. return -1;
  4003. }
  4004. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4005. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4006. return -1;
  4007. }
  4008. if (pl_sd->sc.data[SC_JAILED]) {
  4009. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4010. return -1;
  4011. }
  4012. switch(rnd() % 2) { //Jail Locations
  4013. case 0:
  4014. m_index = mapindex_name2id(MAP_JAIL);
  4015. x = 24;
  4016. y = 75;
  4017. break;
  4018. default:
  4019. m_index = mapindex_name2id(MAP_JAIL);
  4020. x = 49;
  4021. y = 75;
  4022. break;
  4023. }
  4024. //Duration of INT_MAX to specify infinity.
  4025. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4026. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4027. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4028. return 0;
  4029. }
  4030. /*==========================================
  4031. * @unjail/@discharge <char_name> by [Yor]
  4032. * Special warp! No check with nowarp and nowarpto flag
  4033. *------------------------------------------*/
  4034. ACMD_FUNC(unjail)
  4035. {
  4036. struct map_session_data *pl_sd;
  4037. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4038. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4039. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4040. return -1;
  4041. }
  4042. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4043. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4044. return -1;
  4045. }
  4046. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4047. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4048. return -1;
  4049. }
  4050. if (!pl_sd->sc.data[SC_JAILED]) {
  4051. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4052. return -1;
  4053. }
  4054. //Reset jail time to 1 sec.
  4055. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4056. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4057. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4058. return 0;
  4059. }
  4060. ACMD_FUNC(jailfor) {
  4061. struct map_session_data *pl_sd = NULL;
  4062. char * modif_p;
  4063. int jailtime = 0,x,y;
  4064. short m_index = 0;
  4065. nullpo_retr(-1, sd);
  4066. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4067. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4068. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4069. return -1;
  4070. }
  4071. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4072. modif_p = atcmd_output;
  4073. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4074. if (jailtime == 0) {
  4075. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4076. 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.
  4077. return -1;
  4078. }
  4079. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4080. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4081. return -1;
  4082. }
  4083. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4084. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4085. return -1;
  4086. }
  4087. // Added by Coltaro
  4088. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4089. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4090. if (jailtime <= 0) {
  4091. jailtime = 0;
  4092. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4093. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4094. } else {
  4095. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4096. char timestr[21];
  4097. time_t now=time(NULL);
  4098. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4099. 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
  4100. clif_displaymessage(pl_sd->fd, atcmd_output);
  4101. 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
  4102. clif_displaymessage(fd, atcmd_output);
  4103. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4104. sprintf(atcmd_output,"Release date is: %s",timestr);
  4105. clif_displaymessage(pl_sd->fd, atcmd_output);
  4106. clif_displaymessage(fd, atcmd_output);
  4107. }
  4108. } else if (jailtime < 0) {
  4109. clif_displaymessage(fd, msg_txt(sd,1136));
  4110. return -1;
  4111. }
  4112. // Jail locations, add more as you wish.
  4113. switch(rnd()%2) {
  4114. case 1: // Jail #1
  4115. m_index = mapindex_name2id(MAP_JAIL);
  4116. x = 49; y = 75;
  4117. break;
  4118. default: // Default Jail
  4119. m_index = mapindex_name2id(MAP_JAIL);
  4120. x = 24; y = 75;
  4121. break;
  4122. }
  4123. 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).
  4124. return 0;
  4125. }
  4126. //By Coltaro
  4127. ACMD_FUNC(jailtime){
  4128. int year, month, day, hour, minute, second;
  4129. char timestr[21];
  4130. time_t now = time(NULL);
  4131. nullpo_retr(-1, sd);
  4132. if (!sd->sc.data[SC_JAILED]) {
  4133. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4134. return -1;
  4135. }
  4136. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4137. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4138. return 0;
  4139. }
  4140. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4141. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4142. return -1;
  4143. }
  4144. // Get remaining jail time
  4145. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4146. 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
  4147. clif_displaymessage(fd, atcmd_output);
  4148. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4149. sprintf(atcmd_output,"Release date is: %s",timestr);
  4150. clif_displaymessage(fd, atcmd_output);
  4151. return 0;
  4152. }
  4153. /*==========================================
  4154. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4155. *------------------------------------------*/
  4156. ACMD_FUNC(disguise)
  4157. {
  4158. int id = 0;
  4159. nullpo_retr(-1, sd);
  4160. if (!message || !*message) {
  4161. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4162. return -1;
  4163. }
  4164. if ((id = atoi(message)) > 0)
  4165. { //Acquired an ID
  4166. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4167. id = 0; //Invalid id for either mobs or npcs.
  4168. } else { //Acquired a Name
  4169. if ((id = mobdb_searchname(message)) == 0)
  4170. {
  4171. struct npc_data* nd = npc_name2id(message);
  4172. if (nd != NULL)
  4173. id = nd->class_;
  4174. }
  4175. }
  4176. if (id == 0)
  4177. {
  4178. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4179. return -1;
  4180. }
  4181. if(pc_isriding(sd))
  4182. {
  4183. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4184. return -1;
  4185. }
  4186. if (sd->sc.data[SC_MONSTER_TRANSFORM]) {
  4187. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4188. return -1;
  4189. }
  4190. pc_disguise(sd, id);
  4191. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4192. return 0;
  4193. }
  4194. /*==========================================
  4195. * DisguiseAll
  4196. *------------------------------------------*/
  4197. ACMD_FUNC(disguiseall)
  4198. {
  4199. int mob_id=0;
  4200. struct map_session_data *pl_sd;
  4201. struct s_mapiterator* iter;
  4202. nullpo_retr(-1, sd);
  4203. if (!message || !*message) {
  4204. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4205. return -1;
  4206. }
  4207. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4208. mob_id = atoi(message);
  4209. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4210. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4211. return -1;
  4212. }
  4213. iter = mapit_getallusers();
  4214. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4215. pc_disguise(pl_sd, mob_id);
  4216. mapit_free(iter);
  4217. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4218. return 0;
  4219. }
  4220. /*==========================================
  4221. * DisguiseGuild
  4222. *------------------------------------------*/
  4223. ACMD_FUNC(disguiseguild)
  4224. {
  4225. int id = 0, i;
  4226. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4227. struct guild *g;
  4228. memset(monster, '\0', sizeof(monster));
  4229. memset(guild, '\0', sizeof(guild));
  4230. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4231. 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>).
  4232. return -1;
  4233. }
  4234. if( (id = atoi(monster)) > 0 ) {
  4235. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4236. id = 0;
  4237. } else {
  4238. if( (id = mobdb_searchname(monster)) == 0 ) {
  4239. struct npc_data* nd = npc_name2id(monster);
  4240. if( nd != NULL )
  4241. id = nd->class_;
  4242. }
  4243. }
  4244. if( id == 0 ) {
  4245. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4246. return -1;
  4247. }
  4248. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4249. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4250. return -1;
  4251. }
  4252. for( i = 0; i < g->max_member; i++ ){
  4253. struct map_session_data *pl_sd;
  4254. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4255. pc_disguise(pl_sd, id);
  4256. }
  4257. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4258. return 0;
  4259. }
  4260. /*==========================================
  4261. * @undisguise by [Yor]
  4262. *------------------------------------------*/
  4263. ACMD_FUNC(undisguise)
  4264. {
  4265. nullpo_retr(-1, sd);
  4266. if (sd->disguise) {
  4267. pc_disguise(sd, 0);
  4268. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4269. } else {
  4270. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4271. return -1;
  4272. }
  4273. return 0;
  4274. }
  4275. /*==========================================
  4276. * UndisguiseAll
  4277. *------------------------------------------*/
  4278. ACMD_FUNC(undisguiseall)
  4279. {
  4280. struct map_session_data *pl_sd;
  4281. struct s_mapiterator* iter;
  4282. nullpo_retr(-1, sd);
  4283. iter = mapit_getallusers();
  4284. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4285. if( pl_sd->disguise )
  4286. pc_disguise(pl_sd, 0);
  4287. mapit_free(iter);
  4288. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4289. return 0;
  4290. }
  4291. /*==========================================
  4292. * UndisguiseGuild
  4293. *------------------------------------------*/
  4294. ACMD_FUNC(undisguiseguild)
  4295. {
  4296. char guild_name[NAME_LENGTH];
  4297. struct guild *g;
  4298. int i;
  4299. nullpo_retr(-1, sd);
  4300. memset(guild_name, '\0', sizeof(guild_name));
  4301. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4302. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4303. return -1;
  4304. }
  4305. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4306. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4307. return -1;
  4308. }
  4309. for(i = 0; i < g->max_member; i++){
  4310. struct map_session_data *pl_sd;
  4311. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4312. pc_disguise(pl_sd, 0);
  4313. }
  4314. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4315. return 0;
  4316. }
  4317. /*==========================================
  4318. * @exp by [Skotlex]
  4319. *------------------------------------------*/
  4320. ACMD_FUNC(exp)
  4321. {
  4322. char output[CHAT_SIZE_MAX];
  4323. double nextb, nextj;
  4324. nullpo_retr(-1, sd);
  4325. memset(output, '\0', sizeof(output));
  4326. nextb = pc_nextbaseexp(sd);
  4327. if (nextb)
  4328. nextb = sd->status.base_exp*100.0/nextb;
  4329. nextj = pc_nextjobexp(sd);
  4330. if (nextj)
  4331. nextj = sd->status.job_exp*100.0/nextj;
  4332. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4333. clif_displaymessage(fd, output);
  4334. return 0;
  4335. }
  4336. /*==========================================
  4337. * @broadcast by [Valaris]
  4338. *------------------------------------------*/
  4339. ACMD_FUNC(broadcast)
  4340. {
  4341. nullpo_retr(-1, sd);
  4342. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4343. if (!message || !*message) {
  4344. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4345. return -1;
  4346. }
  4347. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4348. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4349. return 0;
  4350. }
  4351. /*==========================================
  4352. * @localbroadcast by [Valaris]
  4353. *------------------------------------------*/
  4354. ACMD_FUNC(localbroadcast)
  4355. {
  4356. nullpo_retr(-1, sd);
  4357. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4358. if (!message || !*message) {
  4359. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4360. return -1;
  4361. }
  4362. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4363. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4364. return 0;
  4365. }
  4366. /*==========================================
  4367. * @email <actual@email> <new@email> by [Yor]
  4368. *------------------------------------------*/
  4369. ACMD_FUNC(email)
  4370. {
  4371. char actual_email[100];
  4372. char new_email[100];
  4373. nullpo_retr(-1, sd);
  4374. memset(actual_email, '\0', sizeof(actual_email));
  4375. memset(new_email, '\0', sizeof(new_email));
  4376. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4377. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4378. return -1;
  4379. }
  4380. if (e_mail_check(actual_email) == 0) {
  4381. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4382. return -1;
  4383. } else if (e_mail_check(new_email) == 0) {
  4384. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4385. return -1;
  4386. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4387. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4388. return -1;
  4389. } else if (strcmpi(actual_email, new_email) == 0) {
  4390. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4391. return -1;
  4392. }
  4393. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4394. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4395. return 0;
  4396. }
  4397. /*==========================================
  4398. *@effect
  4399. *------------------------------------------*/
  4400. ACMD_FUNC(effect)
  4401. {
  4402. int type = 0, flag = 0;
  4403. nullpo_retr(-1, sd);
  4404. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4405. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4406. return -1;
  4407. }
  4408. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4409. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4410. return 0;
  4411. }
  4412. /*==========================================
  4413. * @killer by MouseJstr
  4414. * enable killing players even when not in pvp
  4415. *------------------------------------------*/
  4416. ACMD_FUNC(killer)
  4417. {
  4418. nullpo_retr(-1, sd);
  4419. sd->state.killer = !sd->state.killer;
  4420. if(sd->state.killer)
  4421. clif_displaymessage(fd, msg_txt(sd,241));
  4422. else {
  4423. clif_displaymessage(fd, msg_txt(sd,292));
  4424. pc_stop_attack(sd);
  4425. }
  4426. return 0;
  4427. }
  4428. /*==========================================
  4429. * @killable by MouseJstr
  4430. * enable other people killing you
  4431. *------------------------------------------*/
  4432. ACMD_FUNC(killable)
  4433. {
  4434. nullpo_retr(-1, sd);
  4435. sd->state.killable = !sd->state.killable;
  4436. if(sd->state.killable)
  4437. clif_displaymessage(fd, msg_txt(sd,242));
  4438. else {
  4439. clif_displaymessage(fd, msg_txt(sd,288));
  4440. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4441. }
  4442. return 0;
  4443. }
  4444. /*==========================================
  4445. * @skillon by MouseJstr
  4446. * turn skills on for the map
  4447. *------------------------------------------*/
  4448. ACMD_FUNC(skillon)
  4449. {
  4450. nullpo_retr(-1, sd);
  4451. map[sd->bl.m].flag.noskill = 0;
  4452. clif_displaymessage(fd, msg_txt(sd,244));
  4453. return 0;
  4454. }
  4455. /*==========================================
  4456. * @skilloff by MouseJstr
  4457. * Turn skills off on the map
  4458. *------------------------------------------*/
  4459. ACMD_FUNC(skilloff)
  4460. {
  4461. nullpo_retr(-1, sd);
  4462. map[sd->bl.m].flag.noskill = 1;
  4463. clif_displaymessage(fd, msg_txt(sd,243));
  4464. return 0;
  4465. }
  4466. /*==========================================
  4467. * @npcmove by MouseJstr
  4468. * move a npc
  4469. *------------------------------------------*/
  4470. ACMD_FUNC(npcmove)
  4471. {
  4472. int x = 0, y = 0, m;
  4473. struct npc_data *nd = 0;
  4474. nullpo_retr(-1, sd);
  4475. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4476. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4477. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4478. return -1;
  4479. }
  4480. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4481. {
  4482. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4483. return -1;
  4484. }
  4485. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4486. {
  4487. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4488. return -1; //Not on a map.
  4489. }
  4490. x = cap_value(x, 0, map[m].xs-1);
  4491. y = cap_value(y, 0, map[m].ys-1);
  4492. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4493. map_moveblock(&nd->bl, x, y, gettick());
  4494. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4495. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4496. return 0;
  4497. }
  4498. /*==========================================
  4499. * @addwarp by MouseJstr
  4500. * Create a new static warp point.
  4501. *------------------------------------------*/
  4502. ACMD_FUNC(addwarp)
  4503. {
  4504. char mapname[32], warpname[NAME_LENGTH+1];
  4505. int x,y;
  4506. unsigned short m;
  4507. struct npc_data* nd;
  4508. nullpo_retr(-1, sd);
  4509. memset(warpname, '\0', sizeof(warpname));
  4510. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4511. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4512. return -1;
  4513. }
  4514. m = mapindex_name2id(mapname);
  4515. if( m == 0 )
  4516. {
  4517. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4518. clif_displaymessage(fd, atcmd_output);
  4519. return -1;
  4520. }
  4521. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4522. if( nd == NULL )
  4523. return -1;
  4524. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4525. clif_displaymessage(fd, atcmd_output);
  4526. return 0;
  4527. }
  4528. /*==========================================
  4529. * @follow by [MouseJstr]
  4530. * Follow a player .. staying no more then 5 spaces away
  4531. *------------------------------------------*/
  4532. ACMD_FUNC(follow)
  4533. {
  4534. struct map_session_data *pl_sd = NULL;
  4535. nullpo_retr(-1, sd);
  4536. if (!message || !*message) {
  4537. if (sd->followtarget == -1)
  4538. return -1;
  4539. pc_stop_following (sd);
  4540. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4541. return 0;
  4542. }
  4543. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4544. {
  4545. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4546. return -1;
  4547. }
  4548. if (sd->followtarget == pl_sd->bl.id) {
  4549. pc_stop_following (sd);
  4550. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4551. } else {
  4552. pc_follow(sd, pl_sd->bl.id);
  4553. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4554. }
  4555. return 0;
  4556. }
  4557. /*==========================================
  4558. * @dropall by [MouseJstr] and [Xantara]
  4559. * Drops all your possession on the ground based on item type
  4560. *------------------------------------------*/
  4561. ACMD_FUNC(dropall)
  4562. {
  4563. int8 type = -1;
  4564. uint16 i, count = 0, count2 = 0;
  4565. struct item_data *item_data = NULL;
  4566. nullpo_retr(-1, sd);
  4567. if( message[0] ) {
  4568. type = atoi(message);
  4569. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4570. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4571. {
  4572. clif_displaymessage(fd, msg_txt(sd,1492));
  4573. clif_displaymessage(fd, msg_txt(sd,1493));
  4574. return -1;
  4575. }
  4576. }
  4577. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4578. if( sd->status.inventory[i].amount ) {
  4579. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4580. ShowDebug("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->status.inventory[i].nameid, sd->status.account_id, sd->status.char_id);
  4581. continue;
  4582. }
  4583. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4584. continue;
  4585. if( type == -1 || type == (uint8)item_data->type ) {
  4586. if( sd->status.inventory[i].equip != 0 )
  4587. pc_unequipitem(sd, i, 3);
  4588. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4589. count += sd->status.inventory[i].amount;
  4590. else count2 += sd->status.inventory[i].amount;
  4591. }
  4592. }
  4593. }
  4594. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4595. clif_displaymessage(fd, atcmd_output);
  4596. return 0;
  4597. }
  4598. /*==========================================
  4599. * @storeall by [MouseJstr]
  4600. * Put everything into storage
  4601. *------------------------------------------*/
  4602. ACMD_FUNC(storeall)
  4603. {
  4604. int i;
  4605. nullpo_retr(-1, sd);
  4606. if (sd->state.storage_flag != 1)
  4607. { //Open storage.
  4608. if( storage_storageopen(sd) == 1 ) {
  4609. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4610. return -1;
  4611. }
  4612. }
  4613. for (i = 0; i < MAX_INVENTORY; i++) {
  4614. if (sd->status.inventory[i].amount) {
  4615. if(sd->status.inventory[i].equip != 0)
  4616. pc_unequipitem(sd, i, 3);
  4617. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4618. }
  4619. }
  4620. storage_storageclose(sd);
  4621. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4622. return 0;
  4623. }
  4624. ACMD_FUNC(clearstorage)
  4625. {
  4626. int i, j;
  4627. nullpo_retr(-1, sd);
  4628. if (sd->state.storage_flag == 1) {
  4629. clif_displaymessage(fd, msg_txt(sd,250));
  4630. return -1;
  4631. }
  4632. j = sd->status.storage.storage_amount;
  4633. for (i = 0; i < j; ++i) {
  4634. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4635. }
  4636. storage_storageclose(sd);
  4637. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4638. return 0;
  4639. }
  4640. ACMD_FUNC(cleargstorage)
  4641. {
  4642. int i, j;
  4643. struct guild *g;
  4644. struct guild_storage *gstorage;
  4645. nullpo_retr(-1, sd);
  4646. g = sd->guild;
  4647. if (g == NULL) {
  4648. clif_displaymessage(fd, msg_txt(sd,43));
  4649. return -1;
  4650. }
  4651. if (sd->state.storage_flag == 1) {
  4652. clif_displaymessage(fd, msg_txt(sd,250));
  4653. return -1;
  4654. }
  4655. if (sd->state.storage_flag == 2) {
  4656. clif_displaymessage(fd, msg_txt(sd,251));
  4657. return -1;
  4658. }
  4659. gstorage = guild2storage2(sd->status.guild_id);
  4660. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4661. return -1;
  4662. }
  4663. j = gstorage->storage_amount;
  4664. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4665. for (i = 0; i < j; ++i) {
  4666. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4667. }
  4668. storage_guild_storageclose(sd);
  4669. gstorage->lock = 0; // Cleaning done, release lock
  4670. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4671. return 0;
  4672. }
  4673. ACMD_FUNC(clearcart)
  4674. {
  4675. int i;
  4676. nullpo_retr(-1, sd);
  4677. if (pc_iscarton(sd) == 0) {
  4678. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4679. return -1;
  4680. }
  4681. if (sd->state.vending == 1) { //Somehow...
  4682. return -1;
  4683. }
  4684. for( i = 0; i < MAX_CART; i++ )
  4685. if(sd->status.cart[i].nameid > 0)
  4686. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4687. clif_clearcart(fd);
  4688. clif_updatestatus(sd,SP_CARTINFO);
  4689. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4690. return 0;
  4691. }
  4692. /*==========================================
  4693. * @skillid by [MouseJstr]
  4694. * lookup a skill by name
  4695. *------------------------------------------*/
  4696. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4697. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4698. ACMD_FUNC(skillid) {
  4699. int skillen, i, found = 0;
  4700. DBIterator* iter;
  4701. DBKey key;
  4702. DBData *data;
  4703. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4704. nullpo_retr(-1, sd);
  4705. if (!message || !*message) {
  4706. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4707. return -1;
  4708. }
  4709. skillen = strlen(message);
  4710. iter = db_iterator(skilldb_name2id);
  4711. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4712. int idx = skill_get_index(db_data2i(data));
  4713. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4714. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4715. clif_displaymessage(fd, atcmd_output);
  4716. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4717. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4718. }
  4719. }
  4720. dbi_destroy(iter);
  4721. if( found ) {
  4722. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4723. clif_displaymessage(fd, atcmd_output);
  4724. }
  4725. for(i = 0; i < found; i++) { /* partials */
  4726. clif_displaymessage(fd, partials[i]);
  4727. }
  4728. return 0;
  4729. }
  4730. /*==========================================
  4731. * @useskill by [MouseJstr]
  4732. * A way of using skills without having to find them in the skills menu
  4733. *------------------------------------------*/
  4734. ACMD_FUNC(useskill)
  4735. {
  4736. struct map_session_data *pl_sd = NULL;
  4737. struct block_list *bl;
  4738. uint16 skill_id;
  4739. uint16 skill_lv;
  4740. char target[100];
  4741. nullpo_retr(-1, sd);
  4742. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4743. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4744. return -1;
  4745. }
  4746. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4747. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4748. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4749. return -1;
  4750. }
  4751. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4752. {
  4753. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4754. return -1;
  4755. }
  4756. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4757. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4758. bl = &sd->hd->bl;
  4759. else
  4760. bl = &sd->bl;
  4761. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4762. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4763. else
  4764. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4765. return 0;
  4766. }
  4767. /*==========================================
  4768. * @displayskill by [Skotlex]
  4769. * Debug command to locate new skill IDs. It sends the
  4770. * three possible skill-effect packets to the area.
  4771. *------------------------------------------*/
  4772. ACMD_FUNC(displayskill)
  4773. {
  4774. struct status_data * status;
  4775. unsigned int tick;
  4776. uint16 skill_id;
  4777. uint16 skill_lv = 1;
  4778. nullpo_retr(-1, sd);
  4779. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4780. {
  4781. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4782. return -1;
  4783. }
  4784. status = status_get_status_data(&sd->bl);
  4785. tick = gettick();
  4786. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4787. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4788. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4789. return 0;
  4790. }
  4791. /*==========================================
  4792. * @skilltree by [MouseJstr]
  4793. * prints the skill tree for a player required to get to a skill
  4794. *------------------------------------------*/
  4795. ACMD_FUNC(skilltree)
  4796. {
  4797. struct map_session_data *pl_sd = NULL;
  4798. uint16 skill_id;
  4799. int meets, j, c=0;
  4800. char target[NAME_LENGTH];
  4801. struct skill_tree_entry *ent;
  4802. nullpo_retr(-1, sd);
  4803. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4804. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4805. return -1;
  4806. }
  4807. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4808. {
  4809. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4810. return -1;
  4811. }
  4812. c = pc_calc_skilltree_normalize_job(pl_sd);
  4813. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4814. 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).
  4815. clif_displaymessage(fd, atcmd_output);
  4816. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4817. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4818. {
  4819. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4820. return 0;
  4821. }
  4822. ent = &skill_tree[c][j];
  4823. meets = 1;
  4824. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4825. {
  4826. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4827. {
  4828. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4829. clif_displaymessage(fd, atcmd_output);
  4830. meets = 0;
  4831. }
  4832. }
  4833. if (meets == 1) {
  4834. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4835. }
  4836. return 0;
  4837. }
  4838. // Hand a ring with partners name on it to this char
  4839. void getring (struct map_session_data* sd)
  4840. {
  4841. char flag = 0;
  4842. unsigned short item_id;
  4843. struct item item_tmp;
  4844. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4845. memset(&item_tmp, 0, sizeof(item_tmp));
  4846. item_tmp.nameid = item_id;
  4847. item_tmp.identify = 1;
  4848. item_tmp.card[0] = 255;
  4849. item_tmp.card[2] = sd->status.partner_id;
  4850. item_tmp.card[3] = sd->status.partner_id >> 16;
  4851. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4852. clif_additem(sd,0,0,flag);
  4853. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4854. }
  4855. }
  4856. /*==========================================
  4857. * @marry by [MouseJstr], fixed by Lupus
  4858. * Marry two players
  4859. *------------------------------------------*/
  4860. ACMD_FUNC(marry)
  4861. {
  4862. struct map_session_data *pl_sd = NULL;
  4863. char player_name[NAME_LENGTH] = "";
  4864. nullpo_retr(-1, sd);
  4865. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4866. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4867. return -1;
  4868. }
  4869. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4870. clif_displaymessage(fd, msg_txt(sd,3));
  4871. return -1;
  4872. }
  4873. if (pc_marriage(sd, pl_sd)) {
  4874. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4875. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4876. getring(sd); // Auto-give named rings (Aru)
  4877. getring(pl_sd);
  4878. return 0;
  4879. }
  4880. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4881. return -1;
  4882. }
  4883. /*==========================================
  4884. * @divorce by [MouseJstr], fixed by [Lupus]
  4885. * divorce two players
  4886. *------------------------------------------*/
  4887. ACMD_FUNC(divorce)
  4888. {
  4889. nullpo_retr(-1, sd);
  4890. if (!pc_divorce(sd)) {
  4891. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4892. clif_displaymessage(fd, atcmd_output);
  4893. return -1;
  4894. }
  4895. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4896. clif_displaymessage(fd, atcmd_output);
  4897. return 0;
  4898. }
  4899. /*==========================================
  4900. * @changelook by [Celest]
  4901. *------------------------------------------*/
  4902. ACMD_FUNC(changelook)
  4903. {
  4904. int i, j = 0, k = 0;
  4905. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4906. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4907. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4908. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4909. return -1;
  4910. } else if ( i == 2 ) {
  4911. if (j < 1 || j > 7)
  4912. j = 1;
  4913. j = pos[j - 1];
  4914. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4915. k = j; // swap
  4916. j = LOOK_HEAD_TOP;
  4917. }
  4918. clif_changelook(&sd->bl,j,k);
  4919. return 0;
  4920. }
  4921. /*==========================================
  4922. * @autotrade by durf [Lupus] [Paradox924X]
  4923. * Turns on/off Autotrade for a specific player
  4924. *------------------------------------------*/
  4925. ACMD_FUNC(autotrade) {
  4926. nullpo_retr(-1, sd);
  4927. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4928. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4929. return -1;
  4930. }
  4931. if( pc_isdead(sd) ) {
  4932. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4933. return -1;
  4934. }
  4935. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4936. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4937. return -1;
  4938. }
  4939. sd->state.autotrade = 1;
  4940. if (battle_config.autotrade_monsterignore)
  4941. sd->state.monster_ignore = 1;
  4942. if( sd->state.vending ){
  4943. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4944. Sql_ShowDebug( mmysql_handle );
  4945. }
  4946. }else if( sd->state.buyingstore ){
  4947. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
  4948. Sql_ShowDebug( mmysql_handle );
  4949. }
  4950. }
  4951. if( battle_config.at_timeout ) {
  4952. int timeout = atoi(message);
  4953. 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);
  4954. }
  4955. channel_pcquit(sd,0xF); //leave all chan
  4956. clif_authfail_fd(sd->fd, 15);
  4957. chrif_save(sd,3);
  4958. return 0;
  4959. }
  4960. /*==========================================
  4961. * @changegm by durf (changed by Lupus)
  4962. * Changes Master of your Guild to a specified guild member
  4963. *------------------------------------------*/
  4964. ACMD_FUNC(changegm)
  4965. {
  4966. struct guild *g;
  4967. struct map_session_data *pl_sd;
  4968. nullpo_retr(-1, sd);
  4969. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4970. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4971. return -1;
  4972. }
  4973. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4974. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4975. return -1;
  4976. }
  4977. if( !message[0] ) {
  4978. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4979. return -1;
  4980. }
  4981. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4982. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4983. return -1;
  4984. }
  4985. guild_gm_change(sd->status.guild_id, pl_sd);
  4986. return 0;
  4987. }
  4988. /*==========================================
  4989. * @changeleader by Skotlex
  4990. * Changes the leader of a party.
  4991. *------------------------------------------*/
  4992. ACMD_FUNC(changeleader)
  4993. {
  4994. nullpo_retr(-1, sd);
  4995. if( !message[0] )
  4996. {
  4997. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4998. return -1;
  4999. }
  5000. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  5001. return 0;
  5002. return -1;
  5003. }
  5004. /*==========================================
  5005. * @partyoption by Skotlex
  5006. * Used to change the item share setting of a party.
  5007. *------------------------------------------*/
  5008. ACMD_FUNC(partyoption)
  5009. {
  5010. struct party_data *p;
  5011. int mi, option;
  5012. char w1[16], w2[16];
  5013. nullpo_retr(-1, sd);
  5014. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5015. {
  5016. clif_displaymessage(fd, msg_txt(sd,282));
  5017. return -1;
  5018. }
  5019. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5020. if (mi == MAX_PARTY)
  5021. return -1; //Shouldn't happen
  5022. if (!p->party.member[mi].leader)
  5023. {
  5024. clif_displaymessage(fd, msg_txt(sd,282));
  5025. return -1;
  5026. }
  5027. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5028. {
  5029. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5030. return -1;
  5031. }
  5032. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5033. //Change item share type.
  5034. if (option != p->party.item)
  5035. party_changeoption(sd, p->party.exp, option);
  5036. else
  5037. clif_displaymessage(fd, msg_txt(sd,286));
  5038. return 0;
  5039. }
  5040. /*==========================================
  5041. * @autoloot by Upa-Kun
  5042. * Turns on/off AutoLoot for a specific player
  5043. *------------------------------------------*/
  5044. ACMD_FUNC(autoloot)
  5045. {
  5046. int rate;
  5047. nullpo_retr(-1, sd);
  5048. // autoloot command without value
  5049. if(!message || !*message)
  5050. {
  5051. if (sd->state.autoloot)
  5052. rate = 0;
  5053. else
  5054. rate = 10000;
  5055. } else {
  5056. double drate;
  5057. drate = atof(message);
  5058. rate = (int)(drate*100);
  5059. }
  5060. if (rate < 0) rate = 0;
  5061. if (rate > 10000) rate = 10000;
  5062. sd->state.autoloot = rate;
  5063. if (sd->state.autoloot) {
  5064. 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.
  5065. clif_displaymessage(fd, atcmd_output);
  5066. }else
  5067. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5068. return 0;
  5069. }
  5070. /*==========================================
  5071. * @alootid
  5072. *------------------------------------------*/
  5073. ACMD_FUNC(autolootitem)
  5074. {
  5075. struct item_data *item_data = NULL;
  5076. int i;
  5077. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5078. nullpo_retr(-1, sd);
  5079. if (message && *message) {
  5080. if (message[0] == '+') {
  5081. message++;
  5082. action = 1;
  5083. }
  5084. else if (message[0] == '-') {
  5085. message++;
  5086. action = 2;
  5087. }
  5088. else if (!strcmp(message,"reset"))
  5089. action = 4;
  5090. }
  5091. if (action < 3) // add or remove
  5092. {
  5093. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5094. item_data = itemdb_searchname(message);
  5095. if (!item_data) {
  5096. // No items founds in the DB with Id or Name
  5097. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5098. return -1;
  5099. }
  5100. }
  5101. switch(action) {
  5102. case 1:
  5103. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5104. if (i != AUTOLOOTITEM_SIZE) {
  5105. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5106. return -1;
  5107. }
  5108. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5109. if (i == AUTOLOOTITEM_SIZE) {
  5110. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5111. return -1;
  5112. }
  5113. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5114. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5115. clif_displaymessage(fd, atcmd_output);
  5116. sd->state.autolooting = 1;
  5117. break;
  5118. case 2:
  5119. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5120. if (i == AUTOLOOTITEM_SIZE) {
  5121. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5122. return -1;
  5123. }
  5124. sd->state.autolootid[i] = 0;
  5125. 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.
  5126. clif_displaymessage(fd, atcmd_output);
  5127. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5128. if (i == AUTOLOOTITEM_SIZE) {
  5129. sd->state.autolooting = 0;
  5130. }
  5131. break;
  5132. case 3:
  5133. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5134. clif_displaymessage(fd, atcmd_output);
  5135. 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>".
  5136. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5137. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5138. if (i == AUTOLOOTITEM_SIZE) {
  5139. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5140. } else {
  5141. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5142. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5143. {
  5144. if (sd->state.autolootid[i] == 0)
  5145. continue;
  5146. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5147. 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);
  5148. continue;
  5149. }
  5150. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5151. clif_displaymessage(fd, atcmd_output);
  5152. }
  5153. }
  5154. break;
  5155. case 4:
  5156. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5157. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5158. sd->state.autolooting = 0;
  5159. break;
  5160. }
  5161. return 0;
  5162. }
  5163. /*==========================================
  5164. * @autoloottype
  5165. * Flags:
  5166. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5167. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5168. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5169. * 262144: IT_CASH
  5170. *------------------------------------------
  5171. * Credits:
  5172. * chriser
  5173. * Aleos
  5174. *------------------------------------------*/
  5175. ACMD_FUNC(autoloottype)
  5176. {
  5177. uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5178. enum item_types type = -1;
  5179. int ITEM_MAX = 1533;
  5180. nullpo_retr(-1, sd);
  5181. if (message && *message) {
  5182. if (message[0] == '+') {
  5183. message++;
  5184. action = 1;
  5185. }
  5186. else if (message[0] == '-') {
  5187. message++;
  5188. action = 2;
  5189. }
  5190. else if (!strcmp(message,"reset"))
  5191. action = 4;
  5192. }
  5193. if (action < 3) { // add or remove
  5194. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5195. type = IT_HEALING;
  5196. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5197. type = IT_USABLE;
  5198. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5199. type = IT_ETC;
  5200. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5201. type = IT_ARMOR;
  5202. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5203. type = IT_WEAPON;
  5204. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5205. type = IT_CARD;
  5206. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5207. type = IT_PETEGG;
  5208. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5209. type = IT_PETARMOR;
  5210. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5211. type = IT_AMMO;
  5212. else {
  5213. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5214. return -1;
  5215. }
  5216. }
  5217. switch (action) {
  5218. case 1:
  5219. if (sd->state.autoloottype&(1<<type)) {
  5220. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5221. return -1;
  5222. }
  5223. if (sd->state.autoloottype == ITEM_MAX) {
  5224. 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>.
  5225. return -1;
  5226. }
  5227. sd->state.autoloottype |= (1<<type); // Stores the type
  5228. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5229. clif_displaymessage(fd, atcmd_output);
  5230. break;
  5231. case 2:
  5232. if (!(sd->state.autoloottype&(1<<type))) {
  5233. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5234. return -1;
  5235. }
  5236. sd->state.autoloottype &= ~(1<<type);
  5237. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5238. clif_displaymessage(fd, atcmd_output);
  5239. break;
  5240. case 3:
  5241. 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>".
  5242. 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
  5243. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5244. if (sd->state.autoloottype == 0)
  5245. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5246. else {
  5247. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5248. while (i < IT_MAX) {
  5249. if (sd->state.autoloottype&(1<<i)) {
  5250. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5251. clif_displaymessage(fd, atcmd_output);
  5252. }
  5253. i++;
  5254. }
  5255. }
  5256. break;
  5257. case 4:
  5258. sd->state.autoloottype = 0;
  5259. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5260. break;
  5261. }
  5262. return 0;
  5263. }
  5264. /**
  5265. * No longer available, keeping here just in case it's back someday. [Ind]
  5266. **/
  5267. /*==========================================
  5268. * It is made to rain.
  5269. *------------------------------------------*/
  5270. //ACMD_FUNC(rain)
  5271. //{
  5272. // nullpo_retr(-1, sd);
  5273. // if (map[sd->bl.m].flag.rain) {
  5274. // map[sd->bl.m].flag.rain=0;
  5275. // clif_weather(sd->bl.m);
  5276. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5277. // } else {
  5278. // map[sd->bl.m].flag.rain=1;
  5279. // clif_weather(sd->bl.m);
  5280. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5281. // }
  5282. // return 0;
  5283. //}
  5284. /*==========================================
  5285. * It is made to snow.
  5286. *------------------------------------------*/
  5287. ACMD_FUNC(snow)
  5288. {
  5289. nullpo_retr(-1, sd);
  5290. if (map[sd->bl.m].flag.snow) {
  5291. map[sd->bl.m].flag.snow=0;
  5292. clif_weather(sd->bl.m);
  5293. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5294. } else {
  5295. map[sd->bl.m].flag.snow=1;
  5296. clif_weather(sd->bl.m);
  5297. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5298. }
  5299. return 0;
  5300. }
  5301. /*==========================================
  5302. * Cherry tree snowstorm is made to fall. (Sakura)
  5303. *------------------------------------------*/
  5304. ACMD_FUNC(sakura)
  5305. {
  5306. nullpo_retr(-1, sd);
  5307. if (map[sd->bl.m].flag.sakura) {
  5308. map[sd->bl.m].flag.sakura=0;
  5309. clif_weather(sd->bl.m);
  5310. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5311. } else {
  5312. map[sd->bl.m].flag.sakura=1;
  5313. clif_weather(sd->bl.m);
  5314. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5315. }
  5316. return 0;
  5317. }
  5318. /*==========================================
  5319. * Clouds appear.
  5320. *------------------------------------------*/
  5321. ACMD_FUNC(clouds)
  5322. {
  5323. nullpo_retr(-1, sd);
  5324. if (map[sd->bl.m].flag.clouds) {
  5325. map[sd->bl.m].flag.clouds=0;
  5326. clif_weather(sd->bl.m);
  5327. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5328. } else {
  5329. map[sd->bl.m].flag.clouds=1;
  5330. clif_weather(sd->bl.m);
  5331. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5332. }
  5333. return 0;
  5334. }
  5335. /*==========================================
  5336. * Different type of clouds using effect 516
  5337. *------------------------------------------*/
  5338. ACMD_FUNC(clouds2)
  5339. {
  5340. nullpo_retr(-1, sd);
  5341. if (map[sd->bl.m].flag.clouds2) {
  5342. map[sd->bl.m].flag.clouds2=0;
  5343. clif_weather(sd->bl.m);
  5344. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5345. } else {
  5346. map[sd->bl.m].flag.clouds2=1;
  5347. clif_weather(sd->bl.m);
  5348. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5349. }
  5350. return 0;
  5351. }
  5352. /*==========================================
  5353. * Fog hangs over.
  5354. *------------------------------------------*/
  5355. ACMD_FUNC(fog)
  5356. {
  5357. nullpo_retr(-1, sd);
  5358. if (map[sd->bl.m].flag.fog) {
  5359. map[sd->bl.m].flag.fog=0;
  5360. clif_weather(sd->bl.m);
  5361. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5362. } else {
  5363. map[sd->bl.m].flag.fog=1;
  5364. clif_weather(sd->bl.m);
  5365. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5366. }
  5367. return 0;
  5368. }
  5369. /*==========================================
  5370. * Fallen leaves fall.
  5371. *------------------------------------------*/
  5372. ACMD_FUNC(leaves)
  5373. {
  5374. nullpo_retr(-1, sd);
  5375. if (map[sd->bl.m].flag.leaves) {
  5376. map[sd->bl.m].flag.leaves=0;
  5377. clif_weather(sd->bl.m);
  5378. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5379. } else {
  5380. map[sd->bl.m].flag.leaves=1;
  5381. clif_weather(sd->bl.m);
  5382. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5383. }
  5384. return 0;
  5385. }
  5386. /*==========================================
  5387. * Fireworks appear.
  5388. *------------------------------------------*/
  5389. ACMD_FUNC(fireworks)
  5390. {
  5391. nullpo_retr(-1, sd);
  5392. if (map[sd->bl.m].flag.fireworks) {
  5393. map[sd->bl.m].flag.fireworks=0;
  5394. clif_weather(sd->bl.m);
  5395. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5396. } else {
  5397. map[sd->bl.m].flag.fireworks=1;
  5398. clif_weather(sd->bl.m);
  5399. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5400. }
  5401. return 0;
  5402. }
  5403. /*==========================================
  5404. * Clearing Weather Effects by Dexity
  5405. *------------------------------------------*/
  5406. ACMD_FUNC(clearweather)
  5407. {
  5408. nullpo_retr(-1, sd);
  5409. /**
  5410. * No longer available, keeping here just in case it's back someday. [Ind]
  5411. **/
  5412. //map[sd->bl.m].flag.rain=0;
  5413. map[sd->bl.m].flag.snow=0;
  5414. map[sd->bl.m].flag.sakura=0;
  5415. map[sd->bl.m].flag.clouds=0;
  5416. map[sd->bl.m].flag.clouds2=0;
  5417. map[sd->bl.m].flag.fog=0;
  5418. map[sd->bl.m].flag.fireworks=0;
  5419. map[sd->bl.m].flag.leaves=0;
  5420. clif_weather(sd->bl.m);
  5421. clif_displaymessage(fd, msg_txt(sd,291));
  5422. return 0;
  5423. }
  5424. /*===============================================================
  5425. * Sound Command - plays a sound for everyone around! [Codemaster]
  5426. *---------------------------------------------------------------*/
  5427. ACMD_FUNC(sound)
  5428. {
  5429. char sound_file[100];
  5430. memset(sound_file, '\0', sizeof(sound_file));
  5431. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5432. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5433. return -1;
  5434. }
  5435. if(strstr(sound_file, ".wav") == NULL)
  5436. strcat(sound_file, ".wav");
  5437. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5438. return 0;
  5439. }
  5440. /*==========================================
  5441. * MOB Search
  5442. *------------------------------------------*/
  5443. ACMD_FUNC(mobsearch)
  5444. {
  5445. char mob_name[100];
  5446. int mob_id;
  5447. int number = 0;
  5448. struct s_mapiterator* it;
  5449. nullpo_retr(-1, sd);
  5450. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5451. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5452. return -1;
  5453. }
  5454. if ((mob_id = atoi(mob_name)) == 0)
  5455. mob_id = mobdb_searchname(mob_name);
  5456. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5457. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5458. clif_displaymessage(fd, atcmd_output);
  5459. return -1;
  5460. }
  5461. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5462. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5463. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5464. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5465. clif_displaymessage(fd, atcmd_output);
  5466. it = mapit_geteachmob();
  5467. for(;;)
  5468. {
  5469. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5470. if( md == NULL )
  5471. break;// no more mobs
  5472. if( md->bl.m != sd->bl.m )
  5473. continue;
  5474. if( mob_id != -1 && md->mob_id != mob_id )
  5475. continue;
  5476. ++number;
  5477. if( md->spawn_timer == INVALID_TIMER )
  5478. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5479. else
  5480. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5481. clif_displaymessage(fd, atcmd_output);
  5482. }
  5483. mapit_free(it);
  5484. return 0;
  5485. }
  5486. /*==========================================
  5487. * @cleanmap - cleans items on the ground
  5488. * @cleanarea - cleans items on the ground within an specified area
  5489. *------------------------------------------*/
  5490. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5491. {
  5492. nullpo_ret(bl);
  5493. map_clearflooritem(bl);
  5494. return 0;
  5495. }
  5496. ACMD_FUNC(cleanmap)
  5497. {
  5498. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5499. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5500. return 0;
  5501. }
  5502. ACMD_FUNC(cleanarea)
  5503. {
  5504. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5505. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5506. map_foreachinarea(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);
  5507. }
  5508. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5509. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, sd->bl.x - x0, sd->bl.y - x0, sd->bl.x + x0, sd->bl.y + x0, BL_ITEM);
  5510. }
  5511. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5512. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5513. }
  5514. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5515. return 0;
  5516. }
  5517. /*==========================================
  5518. * make a NPC/PET talk
  5519. * @npctalkc [SnakeDrak]
  5520. *------------------------------------------*/
  5521. ACMD_FUNC(npctalk)
  5522. {
  5523. char name[NAME_LENGTH],mes[100],temp[100];
  5524. struct npc_data *nd;
  5525. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5526. unsigned long color=0;
  5527. if (sd->sc.cant.chat)
  5528. return -1; //no "chatting" while muted.
  5529. if(!ifcolor) {
  5530. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5531. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5532. return -1;
  5533. }
  5534. }
  5535. else {
  5536. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5537. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5538. return -1;
  5539. }
  5540. }
  5541. if (!(nd = npc_name2id(name))) {
  5542. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5543. return -1;
  5544. }
  5545. strtok(name, "#"); // discard extra name identifier if present
  5546. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5547. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5548. else clif_disp_overhead(&nd->bl, temp);
  5549. return 0;
  5550. }
  5551. ACMD_FUNC(pettalk)
  5552. {
  5553. char mes[100],temp[100];
  5554. struct pet_data *pd;
  5555. nullpo_retr(-1, sd);
  5556. if ( battle_config.min_chat_delay ) {
  5557. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5558. return 0;
  5559. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5560. }
  5561. if(!sd->status.pet_id || !(pd=sd->pd))
  5562. {
  5563. clif_displaymessage(fd, msg_txt(sd,184));
  5564. return -1;
  5565. }
  5566. if (sd->sc.cant.chat)
  5567. return -1; //no "chatting" while muted.
  5568. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5569. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5570. return -1;
  5571. }
  5572. if (message[0] == '/')
  5573. {// pet emotion processing
  5574. const char* emo[] = {
  5575. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5576. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5577. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5578. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5579. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5580. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5581. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5582. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5583. "/whisp"
  5584. };
  5585. int i;
  5586. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5587. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5588. if( i < ARRAYLENGTH(emo) )
  5589. {
  5590. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5591. sd->emotionlasttime = time(NULL);
  5592. return 0;
  5593. }
  5594. sd->emotionlasttime = time(NULL);
  5595. clif_emotion(&pd->bl, i);
  5596. return 0;
  5597. }
  5598. }
  5599. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5600. clif_disp_overhead(&pd->bl, temp);
  5601. return 0;
  5602. }
  5603. /// @users - displays the number of players present on each map (and percentage)
  5604. /// #users displays on the target user instead of self
  5605. ACMD_FUNC(users)
  5606. {
  5607. char buf[CHAT_SIZE_MAX];
  5608. int i;
  5609. int users[MAX_MAPINDEX];
  5610. int users_all;
  5611. struct s_mapiterator* iter;
  5612. memset(users, 0, sizeof(users));
  5613. users_all = 0;
  5614. // count users on each map
  5615. iter = mapit_getallusers();
  5616. for(;;)
  5617. {
  5618. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5619. if( sd2 == NULL )
  5620. break;// no more users
  5621. if( sd2->mapindex >= MAX_MAPINDEX )
  5622. continue;// invalid mapindex
  5623. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5624. if( users_all < INT_MAX ) ++users_all;
  5625. }
  5626. mapit_free(iter);
  5627. // display results for each map
  5628. for( i = 0; i < MAX_MAPINDEX; ++i )
  5629. {
  5630. if( users[i] == 0 )
  5631. continue;// empty
  5632. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5633. clif_displaymessage(sd->fd, buf);
  5634. }
  5635. // display overall count
  5636. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5637. clif_displaymessage(sd->fd, buf);
  5638. return 0;
  5639. }
  5640. /*==========================================
  5641. *
  5642. *------------------------------------------*/
  5643. ACMD_FUNC(reset)
  5644. {
  5645. pc_resetstate(sd);
  5646. pc_resetskill(sd,1);
  5647. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5648. clif_displaymessage(fd, atcmd_output);
  5649. return 0;
  5650. }
  5651. /*==========================================
  5652. *
  5653. *------------------------------------------*/
  5654. ACMD_FUNC(summon)
  5655. {
  5656. char name[NAME_LENGTH];
  5657. int mob_id = 0;
  5658. int duration = 0;
  5659. struct mob_data *md;
  5660. unsigned int tick=gettick();
  5661. nullpo_retr(-1, sd);
  5662. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5663. {
  5664. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5665. return -1;
  5666. }
  5667. if (duration < 1)
  5668. duration =1;
  5669. else if (duration > 60)
  5670. duration =60;
  5671. if ((mob_id = atoi(name)) == 0)
  5672. mob_id = mobdb_searchname(name);
  5673. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5674. {
  5675. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5676. return -1;
  5677. }
  5678. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5679. if(!md)
  5680. return -1;
  5681. md->master_id=sd->bl.id;
  5682. md->special_state.ai=AI_ATTACK;
  5683. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5684. clif_specialeffect(&md->bl,344,AREA);
  5685. mob_spawn(md);
  5686. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5687. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5688. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5689. return 0;
  5690. }
  5691. /*==========================================
  5692. * @adjgroup
  5693. * Temporarily move player to another group
  5694. * Useful during beta testing to allow players to use GM commands for short periods of time
  5695. *------------------------------------------*/
  5696. ACMD_FUNC(adjgroup)
  5697. {
  5698. int new_group = 0;
  5699. nullpo_retr(-1, sd);
  5700. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5701. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5702. return -1;
  5703. }
  5704. if (!pc_group_exists(new_group)) {
  5705. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5706. return -1;
  5707. }
  5708. sd->group_id = new_group;
  5709. pc_group_pc_load(sd);/* update cache */
  5710. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5711. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5712. return 0;
  5713. }
  5714. /*==========================================
  5715. * @trade by [MouseJstr]
  5716. * Open a trade window with a remote player
  5717. *------------------------------------------*/
  5718. ACMD_FUNC(trade)
  5719. {
  5720. struct map_session_data *pl_sd = NULL;
  5721. nullpo_retr(-1, sd);
  5722. if (!message || !*message) {
  5723. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5724. return -1;
  5725. }
  5726. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5727. {
  5728. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5729. return -1;
  5730. }
  5731. trade_traderequest(sd, pl_sd);
  5732. return 0;
  5733. }
  5734. /*==========================================
  5735. * @setbattleflag by [MouseJstr]
  5736. * set a battle_config flag without having to reboot
  5737. *------------------------------------------*/
  5738. ACMD_FUNC(setbattleflag)
  5739. {
  5740. char flag[128], value[128];
  5741. nullpo_retr(-1, sd);
  5742. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5743. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5744. return -1;
  5745. }
  5746. if (battle_set_value(flag, value) == 0)
  5747. {
  5748. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5749. return -1;
  5750. }
  5751. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5752. return 0;
  5753. }
  5754. /*==========================================
  5755. * @unmute [Valaris]
  5756. *------------------------------------------*/
  5757. ACMD_FUNC(unmute)
  5758. {
  5759. struct map_session_data *pl_sd = NULL;
  5760. nullpo_retr(-1, sd);
  5761. if (!message || !*message) {
  5762. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5763. return -1;
  5764. }
  5765. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5766. {
  5767. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5768. return -1;
  5769. }
  5770. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5771. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5772. return -1;
  5773. }
  5774. pl_sd->status.manner = 0;
  5775. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5776. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5777. return 0;
  5778. }
  5779. /*==========================================
  5780. * @uptime by MC Cameri
  5781. *------------------------------------------*/
  5782. ACMD_FUNC(uptime)
  5783. {
  5784. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5785. minute = 60, days = 0, hours = 0, minutes = 0;
  5786. nullpo_retr(-1, sd);
  5787. seconds = get_uptime();
  5788. days = seconds/day;
  5789. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5790. hours = seconds/hour;
  5791. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5792. minutes = seconds/minute;
  5793. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5794. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5795. clif_displaymessage(fd, atcmd_output);
  5796. return 0;
  5797. }
  5798. /*==========================================
  5799. * @changesex <sex>
  5800. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5801. *------------------------------------------*/
  5802. ACMD_FUNC(changesex)
  5803. {
  5804. int i;
  5805. nullpo_retr(-1, sd);
  5806. pc_resetskill(sd,4);
  5807. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5808. for( i=0; i<EQI_MAX; i++ )
  5809. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5810. chrif_changesex(sd);
  5811. return 0;
  5812. }
  5813. /*================================================
  5814. * @mute - Mutes a player for a set amount of time
  5815. *------------------------------------------------*/
  5816. ACMD_FUNC(mute)
  5817. {
  5818. struct map_session_data *pl_sd = NULL;
  5819. int manner;
  5820. nullpo_retr(-1, sd);
  5821. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5822. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5823. return -1;
  5824. }
  5825. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5826. {
  5827. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5828. return -1;
  5829. }
  5830. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5831. {
  5832. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5833. return -1;
  5834. }
  5835. clif_manner_message(sd, 0);
  5836. clif_manner_message(pl_sd, 5);
  5837. if( pl_sd->status.manner < manner ) {
  5838. pl_sd->status.manner -= manner;
  5839. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5840. } else {
  5841. pl_sd->status.manner = 0;
  5842. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5843. }
  5844. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5845. return 0;
  5846. }
  5847. /*==========================================
  5848. * @refresh (like @jumpto <<yourself>>)
  5849. *------------------------------------------*/
  5850. ACMD_FUNC(refresh)
  5851. {
  5852. nullpo_retr(-1, sd);
  5853. clif_refresh(sd);
  5854. return 0;
  5855. }
  5856. ACMD_FUNC(refreshall)
  5857. {
  5858. struct map_session_data* iter_sd;
  5859. struct s_mapiterator* iter;
  5860. nullpo_retr(-1, sd);
  5861. iter = mapit_getallusers();
  5862. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5863. clif_refresh(iter_sd);
  5864. mapit_free(iter);
  5865. return 0;
  5866. }
  5867. /*==========================================
  5868. * @identify
  5869. * => GM's magnifier.
  5870. *------------------------------------------*/
  5871. ACMD_FUNC(identify)
  5872. {
  5873. int i,num;
  5874. nullpo_retr(-1, sd);
  5875. for(i=num=0;i<MAX_INVENTORY;i++){
  5876. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5877. num++;
  5878. }
  5879. }
  5880. if (num > 0) {
  5881. clif_item_identify_list(sd);
  5882. } else {
  5883. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5884. }
  5885. return 0;
  5886. }
  5887. /*===============================================
  5888. * @identifyall
  5889. * => Indentify all items in inventory - Akinari
  5890. *-----------------------------------------------*/
  5891. ACMD_FUNC(identifyall)
  5892. {
  5893. int i;
  5894. nullpo_retr(-1, sd);
  5895. for(i=0; i<MAX_INVENTORY; i++) {
  5896. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5897. sd->status.inventory[i].identify=1;
  5898. clif_item_identified(sd,i,0);
  5899. }
  5900. }
  5901. return 0;
  5902. }
  5903. /*==========================================
  5904. * @gmotd (Global MOTD)
  5905. * by davidsiaw :P
  5906. *------------------------------------------*/
  5907. ACMD_FUNC(gmotd)
  5908. {
  5909. FILE* fp;
  5910. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5911. {
  5912. char buf[CHAT_SIZE_MAX];
  5913. size_t len;
  5914. while( fgets(buf, sizeof(buf), fp) )
  5915. {
  5916. if( buf[0] == '/' && buf[1] == '/' )
  5917. {
  5918. continue;
  5919. }
  5920. len = strlen(buf);
  5921. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5922. {// strip trailing EOL characters
  5923. len--;
  5924. }
  5925. if( len )
  5926. {
  5927. buf[len] = 0;
  5928. intif_broadcast(buf, len+1, 0);
  5929. }
  5930. }
  5931. fclose(fp);
  5932. }
  5933. return 0;
  5934. }
  5935. ACMD_FUNC(misceffect)
  5936. {
  5937. int effect = 0;
  5938. nullpo_retr(-1, sd);
  5939. if (!message || !*message)
  5940. return -1;
  5941. if (sscanf(message, "%d", &effect) < 1)
  5942. return -1;
  5943. clif_misceffect(&sd->bl,effect);
  5944. return 0;
  5945. }
  5946. /*==========================================
  5947. * MAIL SYSTEM
  5948. *------------------------------------------*/
  5949. ACMD_FUNC(mail)
  5950. {
  5951. nullpo_ret(sd);
  5952. mail_openmail(sd);
  5953. return 0;
  5954. }
  5955. /*==========================================
  5956. * Show Monster DB Info v 1.0
  5957. * originally by [Lupus]
  5958. *------------------------------------------*/
  5959. ACMD_FUNC(mobinfo)
  5960. {
  5961. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  5962. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  5963. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  5964. char atcmd_output2[CHAT_SIZE_MAX];
  5965. struct item_data *item_data;
  5966. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5967. int count;
  5968. int i, k;
  5969. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5970. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5971. if (!message || !*message) {
  5972. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5973. return -1;
  5974. }
  5975. // If monster identifier/name argument is a name
  5976. if ((i = mobdb_checkid(atoi(message))))
  5977. {
  5978. mob_array[0] = mob_db(i);
  5979. count = 1;
  5980. } else
  5981. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5982. if (!count) {
  5983. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5984. return -1;
  5985. }
  5986. if (count > MAX_SEARCH) {
  5987. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5988. clif_displaymessage(fd, atcmd_output);
  5989. count = MAX_SEARCH;
  5990. }
  5991. for (k = 0; k < count; k++) {
  5992. unsigned int j,base_exp,job_exp;
  5993. mob = mob_array[k];
  5994. base_exp = mob->base_exp;
  5995. job_exp = mob->job_exp;
  5996. #ifdef RENEWAL_EXP
  5997. if( battle_config.atcommand_mobinfo_type ) {
  5998. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  5999. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  6000. }
  6001. #endif
  6002. #ifdef VIP_ENABLE
  6003. // Display EXP rate increase for VIP.
  6004. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  6005. base_exp += battle_config.vip_base_exp_increase;
  6006. job_exp += battle_config.vip_job_exp_increase;
  6007. }
  6008. #endif
  6009. // stats
  6010. if (mob->mexp)
  6011. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6012. else
  6013. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6014. clif_displaymessage(fd, atcmd_output);
  6015. 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
  6016. clif_displaymessage(fd, atcmd_output);
  6017. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6018. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6019. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6020. clif_displaymessage(fd, atcmd_output);
  6021. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6022. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6023. mob->range2 , mob->range3, msize[mob->status.size],
  6024. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6025. clif_displaymessage(fd, atcmd_output);
  6026. // drops
  6027. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6028. strcpy(atcmd_output, " ");
  6029. j = 0;
  6030. for (i = 0; i < MAX_MOB_DROP; i++) {
  6031. int droprate;
  6032. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6033. continue;
  6034. droprate = mob->dropitem[i].p;
  6035. #ifdef RENEWAL_DROP
  6036. if( battle_config.atcommand_mobinfo_type ) {
  6037. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 2) / 100;
  6038. if (droprate <= 0 && !battle_config.drop_rate0item)
  6039. droprate = 1;
  6040. }
  6041. #endif
  6042. #ifdef VIP_ENABLE
  6043. // Display item rate increase for VIP.
  6044. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6045. droprate += battle_config.vip_drop_increase;
  6046. #endif
  6047. if (item_data->slot)
  6048. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6049. else
  6050. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6051. strcat(atcmd_output, atcmd_output2);
  6052. if (++j % 3 == 0) {
  6053. clif_displaymessage(fd, atcmd_output);
  6054. strcpy(atcmd_output, " ");
  6055. }
  6056. }
  6057. if (j == 0)
  6058. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6059. else if (j % 3 != 0)
  6060. clif_displaymessage(fd, atcmd_output);
  6061. // mvp
  6062. if (mob->mexp) {
  6063. float mvppercent, mvpremain;
  6064. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6065. clif_displaymessage(fd, atcmd_output);
  6066. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6067. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6068. j = 0;
  6069. for (i = 0; i < MAX_MVP_DROP; i++) {
  6070. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6071. continue;
  6072. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6073. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6074. if(battle_config.item_drop_mvp_mode == 0) {
  6075. mvpremain -= mvppercent;
  6076. }
  6077. if (mvppercent > 0) {
  6078. j++;
  6079. if (j == 1) {
  6080. if (item_data->slot)
  6081. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6082. else
  6083. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6084. } else {
  6085. if (item_data->slot)
  6086. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6087. else
  6088. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6089. }
  6090. strcat(atcmd_output, atcmd_output2);
  6091. }
  6092. }
  6093. if (j == 0)
  6094. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6095. else
  6096. clif_displaymessage(fd, atcmd_output);
  6097. }
  6098. }
  6099. return 0;
  6100. }
  6101. /*=========================================
  6102. * @showmobs by KarLaeda
  6103. * => For 15 sec displays the mobs on minimap
  6104. *------------------------------------------*/
  6105. ACMD_FUNC(showmobs)
  6106. {
  6107. char mob_name[100];
  6108. int mob_id;
  6109. int number = 0;
  6110. struct s_mapiterator* it;
  6111. nullpo_retr(-1, sd);
  6112. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6113. return -1;
  6114. if((mob_id = atoi(mob_name)) == 0)
  6115. mob_id = mobdb_searchname(mob_name);
  6116. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6117. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6118. clif_displaymessage(fd, atcmd_output);
  6119. return 0;
  6120. }
  6121. if(mob_db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
  6122. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6123. return 0;
  6124. }
  6125. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6126. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6127. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6128. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6129. mob_name, mapindex_id2name(sd->mapindex));
  6130. clif_displaymessage(fd, atcmd_output);
  6131. it = mapit_geteachmob();
  6132. for(;;)
  6133. {
  6134. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6135. if( md == NULL )
  6136. break;// no more mobs
  6137. if( md->bl.m != sd->bl.m )
  6138. continue;
  6139. if( mob_id != -1 && md->mob_id != mob_id )
  6140. continue;
  6141. if( md->special_state.ai || md->master_id )
  6142. continue; // hide slaves and player summoned mobs
  6143. if( md->spawn_timer != INVALID_TIMER )
  6144. continue; // hide mobs waiting for respawn
  6145. ++number;
  6146. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6147. }
  6148. mapit_free(it);
  6149. return 0;
  6150. }
  6151. /*==========================================
  6152. * homunculus level up [orn]
  6153. *------------------------------------------*/
  6154. ACMD_FUNC(homlevel)
  6155. {
  6156. TBL_HOM * hd;
  6157. int level = 0, i = 0;
  6158. nullpo_retr(-1, sd);
  6159. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6160. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6161. return -1;
  6162. }
  6163. if ( !hom_is_active(sd->hd) ) {
  6164. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6165. return -1;
  6166. }
  6167. hd = sd->hd;
  6168. for (i = 1; i <= level && hd->exp_next; i++){
  6169. hd->homunculus.exp += hd->exp_next;
  6170. if( !hom_levelup(hd) )
  6171. break;
  6172. }
  6173. status_calc_homunculus(hd, SCO_NONE);
  6174. status_percent_heal(&hd->bl, 100, 100);
  6175. clif_specialeffect(&hd->bl,568,AREA);
  6176. return 0;
  6177. }
  6178. /*==========================================
  6179. * homunculus evolution H [orn]
  6180. *------------------------------------------*/
  6181. ACMD_FUNC(homevolution)
  6182. {
  6183. nullpo_retr(-1, sd);
  6184. if ( !hom_is_active(sd->hd) ) {
  6185. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6186. return -1;
  6187. }
  6188. if ( !hom_evolution(sd->hd) ) {
  6189. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6190. return -1;
  6191. }
  6192. clif_homskillinfoblock(sd);
  6193. return 0;
  6194. }
  6195. ACMD_FUNC(hommutate)
  6196. {
  6197. int homun_id, m_class = 0, m_id;
  6198. nullpo_retr(-1, sd);
  6199. if (!hom_is_active(sd->hd)) {
  6200. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6201. return -1;
  6202. }
  6203. if (!message || !*message) {
  6204. homun_id = 6048 + (rnd() % 4);
  6205. } else {
  6206. homun_id = atoi(message);
  6207. }
  6208. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6209. m_id = hom_class2mapid(homun_id);
  6210. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6211. hom_mutate(sd->hd, homun_id);
  6212. } else {
  6213. clif_emotion(&sd->hd->bl, E_SWT);
  6214. }
  6215. return 0;
  6216. }
  6217. /*==========================================
  6218. * call choosen homunculus [orn]
  6219. *------------------------------------------*/
  6220. ACMD_FUNC(makehomun)
  6221. {
  6222. int homunid;
  6223. nullpo_retr(-1, sd);
  6224. if ( sd->status.hom_id ) {
  6225. clif_displaymessage(fd, msg_txt(sd,450));
  6226. return -1;
  6227. }
  6228. if (!message || !*message) {
  6229. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6230. return -1;
  6231. }
  6232. homunid = atoi(message);
  6233. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6234. {
  6235. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6236. return -1;
  6237. }
  6238. hom_create_request(sd,homunid);
  6239. return 0;
  6240. }
  6241. /*==========================================
  6242. * modify homunculus intimacy [orn]
  6243. *------------------------------------------*/
  6244. ACMD_FUNC(homfriendly)
  6245. {
  6246. int friendly = 0;
  6247. nullpo_retr(-1, sd);
  6248. if ( !hom_is_active(sd->hd) ) {
  6249. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6250. return -1;
  6251. }
  6252. if (!message || !*message) {
  6253. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6254. return -1;
  6255. }
  6256. friendly = atoi(message);
  6257. friendly = cap_value(friendly, 0, 1000);
  6258. sd->hd->homunculus.intimacy = friendly * 100 ;
  6259. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6260. return 0;
  6261. }
  6262. /*==========================================
  6263. * modify homunculus hunger [orn]
  6264. *------------------------------------------*/
  6265. ACMD_FUNC(homhungry)
  6266. {
  6267. int hungry = 0;
  6268. nullpo_retr(-1, sd);
  6269. if ( !hom_is_active(sd->hd) ) {
  6270. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6271. return -1;
  6272. }
  6273. if (!message || !*message) {
  6274. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6275. return -1;
  6276. }
  6277. hungry = atoi(message);
  6278. hungry = cap_value(hungry, 0, 100);
  6279. sd->hd->homunculus.hunger = hungry;
  6280. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6281. return 0;
  6282. }
  6283. /*==========================================
  6284. * make the homunculus speak [orn]
  6285. *------------------------------------------*/
  6286. ACMD_FUNC(homtalk)
  6287. {
  6288. char mes[100],temp[100];
  6289. nullpo_retr(-1, sd);
  6290. if ( battle_config.min_chat_delay ) {
  6291. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6292. return 0;
  6293. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6294. }
  6295. if (sd->sc.cant.chat)
  6296. return -1; //no "chatting" while muted.
  6297. if ( !hom_is_active(sd->hd) ) {
  6298. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6299. return -1;
  6300. }
  6301. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6302. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6303. return -1;
  6304. }
  6305. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6306. clif_disp_overhead(&sd->hd->bl, temp);
  6307. return 0;
  6308. }
  6309. /*==========================================
  6310. * Show homunculus stats
  6311. *------------------------------------------*/
  6312. ACMD_FUNC(hominfo)
  6313. {
  6314. struct homun_data *hd;
  6315. struct status_data *status;
  6316. nullpo_retr(-1, sd);
  6317. if ( !hom_is_active(sd->hd) ) {
  6318. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6319. return -1;
  6320. }
  6321. hd = sd->hd;
  6322. status = status_get_status_data(&hd->bl);
  6323. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6324. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6325. status->hp, status->max_hp, status->sp, status->max_sp);
  6326. clif_displaymessage(fd, atcmd_output);
  6327. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6328. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6329. clif_displaymessage(fd, atcmd_output);
  6330. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6331. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6332. clif_displaymessage(fd, atcmd_output);
  6333. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6334. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6335. status->str, status->agi, status->vit,
  6336. status->int_, status->dex, status->luk);
  6337. clif_displaymessage(fd, atcmd_output);
  6338. return 0;
  6339. }
  6340. ACMD_FUNC(homstats)
  6341. {
  6342. struct homun_data *hd;
  6343. struct s_homunculus_db *db;
  6344. struct s_homunculus *hom;
  6345. int lv, min, max, evo;
  6346. nullpo_retr(-1, sd);
  6347. if ( !hom_is_active(sd->hd) ) {
  6348. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6349. return -1;
  6350. }
  6351. hd = sd->hd;
  6352. hom = &hd->homunculus;
  6353. db = hd->homunculusDB;
  6354. lv = hom->level;
  6355. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6356. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6357. clif_displaymessage(fd, atcmd_output);
  6358. lv--; //Since the first increase is at level 2.
  6359. evo = (hom->class_ == db->evo_class);
  6360. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6361. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6362. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6363. clif_displaymessage(fd, atcmd_output);
  6364. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6365. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6366. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6367. clif_displaymessage(fd, atcmd_output);
  6368. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6369. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6370. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6371. clif_displaymessage(fd, atcmd_output);
  6372. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6373. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6374. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6375. clif_displaymessage(fd, atcmd_output);
  6376. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6377. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6378. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6379. clif_displaymessage(fd, atcmd_output);
  6380. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6381. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6382. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6383. clif_displaymessage(fd, atcmd_output);
  6384. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6385. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6386. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6387. clif_displaymessage(fd, atcmd_output);
  6388. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6389. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6390. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6391. clif_displaymessage(fd, atcmd_output);
  6392. return 0;
  6393. }
  6394. ACMD_FUNC(homshuffle)
  6395. {
  6396. nullpo_retr(-1, sd);
  6397. if(!sd->hd)
  6398. return -1; // nothing to do
  6399. if(!hom_shuffle(sd->hd))
  6400. return -1;
  6401. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6402. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6403. return 0;
  6404. }
  6405. /*==========================================
  6406. * Show Items DB Info v 1.0
  6407. * originally by [Lupus]
  6408. *------------------------------------------*/
  6409. ACMD_FUNC(iteminfo)
  6410. {
  6411. struct item_data *item_array[MAX_SEARCH];
  6412. int i, count = 1;
  6413. if (!message || !*message) {
  6414. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6415. return -1;
  6416. }
  6417. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6418. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6419. if (!count) {
  6420. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6421. return -1;
  6422. }
  6423. if (count > MAX_SEARCH) {
  6424. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6425. clif_displaymessage(fd, atcmd_output);
  6426. count = MAX_SEARCH;
  6427. }
  6428. for (i = 0; i < count; i++) {
  6429. struct item_data * item_data = item_array[i];
  6430. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6431. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6432. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6433. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6434. );
  6435. clif_displaymessage(fd, atcmd_output);
  6436. 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
  6437. clif_displaymessage(fd, atcmd_output);
  6438. if (item_data->maxchance == -1)
  6439. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6440. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6441. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6442. else
  6443. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6444. clif_displaymessage(fd, atcmd_output);
  6445. }
  6446. return 0;
  6447. }
  6448. /*==========================================
  6449. * Show who drops the item.
  6450. *------------------------------------------*/
  6451. ACMD_FUNC(whodrops)
  6452. {
  6453. struct item_data *item_data, *item_array[MAX_SEARCH];
  6454. int i,j, count = 1;
  6455. if (!message || !*message) {
  6456. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6457. return -1;
  6458. }
  6459. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6460. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6461. if (!count) {
  6462. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6463. return -1;
  6464. }
  6465. if (count > MAX_SEARCH) {
  6466. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6467. clif_displaymessage(fd, atcmd_output);
  6468. count = MAX_SEARCH;
  6469. }
  6470. for (i = 0; i < count; i++) {
  6471. item_data = item_array[i];
  6472. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6473. clif_displaymessage(fd, atcmd_output);
  6474. if (item_data->mob[0].chance == 0) {
  6475. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6476. clif_displaymessage(fd, atcmd_output);
  6477. } else {
  6478. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6479. clif_displaymessage(fd, atcmd_output);
  6480. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6481. {
  6482. int dropchance = item_data->mob[j].chance;
  6483. #ifdef RENEWAL_DROP
  6484. if( battle_config.atcommand_mobinfo_type )
  6485. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.class_, 2) / 100;
  6486. #endif
  6487. #ifdef VIP_ENABLE
  6488. // Display item rate increase for VIP.
  6489. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6490. dropchance += battle_config.vip_drop_increase;
  6491. #endif
  6492. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6493. clif_displaymessage(fd, atcmd_output);
  6494. }
  6495. }
  6496. }
  6497. return 0;
  6498. }
  6499. ACMD_FUNC(whereis)
  6500. {
  6501. struct mob_db *mob_array[MAX_SEARCH];
  6502. int count;
  6503. int i, j, k;
  6504. if (!message || !*message) {
  6505. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6506. return -1;
  6507. }
  6508. // If monster identifier/name argument is a name
  6509. if ((i = mobdb_checkid(atoi(message))))
  6510. {
  6511. mob_array[0] = mob_db(i);
  6512. count = 1;
  6513. } else
  6514. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6515. if (!count) {
  6516. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6517. return -1;
  6518. }
  6519. if (count > MAX_SEARCH) {
  6520. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6521. clif_displaymessage(fd, atcmd_output);
  6522. count = MAX_SEARCH;
  6523. }
  6524. for (k = 0; k < count; k++) {
  6525. struct mob_db *mob = mob_array[k];
  6526. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6527. clif_displaymessage(fd, atcmd_output);
  6528. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6529. {
  6530. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6531. if (j < 0) continue;
  6532. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6533. clif_displaymessage(fd, atcmd_output);
  6534. }
  6535. if (i == 0)
  6536. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6537. }
  6538. return 0;
  6539. }
  6540. ACMD_FUNC(version)
  6541. {
  6542. pc_show_version(sd);
  6543. return 0;
  6544. }
  6545. /*==========================================
  6546. * @mutearea by MouseJstr
  6547. *------------------------------------------*/
  6548. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6549. {
  6550. int time, id;
  6551. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6552. if (pl_sd == NULL)
  6553. return 0;
  6554. id = va_arg(ap, int);
  6555. time = va_arg(ap, int);
  6556. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6557. pl_sd->status.manner -= time;
  6558. if (pl_sd->status.manner < 0)
  6559. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6560. else
  6561. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6562. }
  6563. return 0;
  6564. }
  6565. ACMD_FUNC(mutearea)
  6566. {
  6567. int time;
  6568. nullpo_ret(sd);
  6569. if (!message || !*message) {
  6570. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6571. return -1;
  6572. }
  6573. time = atoi(message);
  6574. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6575. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6576. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6577. return 0;
  6578. }
  6579. ACMD_FUNC(rates)
  6580. {
  6581. char buf[CHAT_SIZE_MAX];
  6582. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6583. nullpo_ret(sd);
  6584. memset(buf, '\0', sizeof(buf));
  6585. #ifdef VIP_ENABLE
  6586. // Display EXP and item rate increase for VIP.
  6587. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6588. base_exp_rate += battle_config.vip_base_exp_increase;
  6589. job_exp_rate += battle_config.vip_job_exp_increase;
  6590. item_rate += battle_config.vip_drop_increase;
  6591. }
  6592. #endif
  6593. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6594. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6595. clif_displaymessage(fd, buf);
  6596. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6597. (battle_config.item_rate_common+item_rate)/100., (battle_config.item_rate_heal+item_rate)/100., (battle_config.item_rate_use+item_rate)/100., (battle_config.item_rate_equip+item_rate)/100., (battle_config.item_rate_card+item_rate)/100.);
  6598. clif_displaymessage(fd, buf);
  6599. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6600. (battle_config.item_rate_common_boss+item_rate)/100., (battle_config.item_rate_heal_boss+item_rate)/100., (battle_config.item_rate_use_boss+item_rate)/100., (battle_config.item_rate_equip_boss+item_rate)/100., (battle_config.item_rate_card_boss+item_rate)/100.);
  6601. clif_displaymessage(fd, buf);
  6602. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6603. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6604. clif_displaymessage(fd, buf);
  6605. return 0;
  6606. }
  6607. /*==========================================
  6608. * @me by lordalfa
  6609. * => Displays the OUTPUT string on top of the Visible players Heads.
  6610. *------------------------------------------*/
  6611. ACMD_FUNC(me)
  6612. {
  6613. char tempmes[CHAT_SIZE_MAX];
  6614. nullpo_retr(-1, sd);
  6615. memset(tempmes, '\0', sizeof(tempmes));
  6616. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6617. if (sd->sc.cant.chat)
  6618. return -1; //no "chatting" while muted.
  6619. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6620. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6621. return -1;
  6622. }
  6623. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6624. clif_disp_overhead(&sd->bl, atcmd_output);
  6625. return 0;
  6626. }
  6627. /*==========================================
  6628. * @size
  6629. * => Resize your character sprite. [Valaris]
  6630. *------------------------------------------*/
  6631. ACMD_FUNC(size)
  6632. {
  6633. int size = 0;
  6634. nullpo_retr(-1, sd);
  6635. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6636. if(sd->state.size) {
  6637. sd->state.size = SZ_SMALL;
  6638. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6639. }
  6640. sd->state.size = size;
  6641. if( size == SZ_MEDIUM )
  6642. clif_specialeffect(&sd->bl,420,AREA);
  6643. else if( size == SZ_BIG )
  6644. clif_specialeffect(&sd->bl,422,AREA);
  6645. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6646. return 0;
  6647. }
  6648. ACMD_FUNC(sizeall)
  6649. {
  6650. int size;
  6651. struct map_session_data *pl_sd;
  6652. struct s_mapiterator* iter;
  6653. size = atoi(message);
  6654. size = cap_value(size,0,2);
  6655. iter = mapit_getallusers();
  6656. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6657. if( pl_sd->state.size != size ) {
  6658. if( pl_sd->state.size ) {
  6659. pl_sd->state.size = SZ_SMALL;
  6660. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6661. }
  6662. pl_sd->state.size = size;
  6663. if( size == SZ_MEDIUM )
  6664. clif_specialeffect(&pl_sd->bl,420,AREA);
  6665. else if( size == SZ_BIG )
  6666. clif_specialeffect(&pl_sd->bl,422,AREA);
  6667. }
  6668. }
  6669. mapit_free(iter);
  6670. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6671. return 0;
  6672. }
  6673. ACMD_FUNC(sizeguild)
  6674. {
  6675. int size = 0, i;
  6676. char guild[NAME_LENGTH];
  6677. struct map_session_data *pl_sd;
  6678. struct guild *g;
  6679. nullpo_retr(-1, sd);
  6680. memset(guild, '\0', sizeof(guild));
  6681. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6682. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6683. return -1;
  6684. }
  6685. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6686. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6687. return -1;
  6688. }
  6689. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6690. for( i = 0; i < g->max_member; i++ ) {
  6691. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6692. if( pl_sd->state.size ) {
  6693. pl_sd->state.size = SZ_SMALL;
  6694. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6695. }
  6696. pl_sd->state.size = size;
  6697. if( size == SZ_MEDIUM )
  6698. clif_specialeffect(&pl_sd->bl,420,AREA);
  6699. else if( size == SZ_BIG )
  6700. clif_specialeffect(&pl_sd->bl,422,AREA);
  6701. }
  6702. }
  6703. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6704. return 0;
  6705. }
  6706. /*==========================================
  6707. * @monsterignore
  6708. * => Makes monsters ignore you. [Valaris]
  6709. *------------------------------------------*/
  6710. ACMD_FUNC(monsterignore)
  6711. {
  6712. nullpo_retr(-1, sd);
  6713. if (!sd->state.monster_ignore) {
  6714. sd->state.monster_ignore = 1;
  6715. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6716. } else {
  6717. sd->state.monster_ignore = 0;
  6718. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6719. }
  6720. return 0;
  6721. }
  6722. /*==========================================
  6723. * @fakename
  6724. * => Gives your character a fake name. [Valaris]
  6725. *------------------------------------------*/
  6726. ACMD_FUNC(fakename)
  6727. {
  6728. nullpo_retr(-1, sd);
  6729. if( !message || !*message )
  6730. {
  6731. if( sd->fakename[0] )
  6732. {
  6733. sd->fakename[0] = '\0';
  6734. clif_charnameack(0, &sd->bl);
  6735. if (sd->disguise)
  6736. clif_charnameack(sd->fd, &sd->bl);
  6737. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6738. return 0;
  6739. }
  6740. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6741. return -1;
  6742. }
  6743. if( strlen(message) < 2 )
  6744. {
  6745. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6746. return -1;
  6747. }
  6748. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6749. clif_charnameack(0, &sd->bl);
  6750. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6751. clif_charnameack(sd->fd, &sd->bl);
  6752. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6753. return 0;
  6754. }
  6755. /*==========================================
  6756. * Ragnarok Resources
  6757. *------------------------------------------*/
  6758. ACMD_FUNC(mapflag) {
  6759. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6760. #define setflag( cmd ) \
  6761. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6762. map[ sd->bl.m ].flag.cmd = flag;\
  6763. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6764. clif_displaymessage(sd->fd,atcmd_output);\
  6765. return 0;\
  6766. }
  6767. char flag_name[100];
  6768. short flag=0,i;
  6769. nullpo_retr(-1, sd);
  6770. memset(flag_name, '\0', sizeof(flag_name));
  6771. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6772. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6773. clif_displaymessage(sd->fd,"----------------------------------");
  6774. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6775. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6776. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6777. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6778. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6779. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6780. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6781. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6782. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6783. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6784. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6785. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6786. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6787. checkflag(nolockon); checkflag(notomb);
  6788. #ifdef ADJUST_SKILL_DAMAGE
  6789. checkflag(skill_damage);
  6790. #endif
  6791. clif_displaymessage(sd->fd," ");
  6792. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6793. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6794. return 1;
  6795. }
  6796. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6797. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6798. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6799. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6800. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6801. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6802. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6803. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6804. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6805. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6806. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6807. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6808. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6809. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6810. setflag(nolockon); setflag(notomb);
  6811. #ifdef ADJUST_SKILL_DAMAGE
  6812. setflag(skill_damage);
  6813. #endif
  6814. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6815. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6816. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6817. clif_displaymessage(sd->fd,"----------------------------------");
  6818. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6819. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6820. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6821. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6822. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6823. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6824. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6825. #ifdef ADJUST_SKILL_DAMAGE
  6826. clif_displaymessage(sd->fd,"skill_damage");
  6827. #endif
  6828. #undef checkflag
  6829. #undef setflag
  6830. return 0;
  6831. }
  6832. /*===================================
  6833. * Remove some messages
  6834. *-----------------------------------*/
  6835. ACMD_FUNC(showexp)
  6836. {
  6837. if (sd->state.showexp) {
  6838. sd->state.showexp = 0;
  6839. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6840. return 0;
  6841. }
  6842. sd->state.showexp = 1;
  6843. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6844. return 0;
  6845. }
  6846. ACMD_FUNC(showzeny)
  6847. {
  6848. if (sd->state.showzeny) {
  6849. sd->state.showzeny = 0;
  6850. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6851. return 0;
  6852. }
  6853. sd->state.showzeny = 1;
  6854. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6855. return 0;
  6856. }
  6857. ACMD_FUNC(showdelay)
  6858. {
  6859. if (sd->state.showdelay) {
  6860. sd->state.showdelay = 0;
  6861. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6862. return 0;
  6863. }
  6864. sd->state.showdelay = 1;
  6865. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6866. return 0;
  6867. }
  6868. /*==========================================
  6869. * Duel organizing functions [LuzZza]
  6870. *
  6871. * @duel [limit|nick] - create a duel
  6872. * @invite <nick> - invite player
  6873. * @accept - accept invitation
  6874. * @reject - reject invitation
  6875. * @leave - leave duel
  6876. *------------------------------------------*/
  6877. ACMD_FUNC(invite)
  6878. {
  6879. unsigned int did = sd->duel_group;
  6880. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6881. if(did == 0) {
  6882. // "Duel: @invite without @duel."
  6883. clif_displaymessage(fd, msg_txt(sd,350));
  6884. return 0;
  6885. }
  6886. if(duel_list[did].max_players_limit > 0 &&
  6887. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6888. // "Duel: Limit of players is reached."
  6889. clif_displaymessage(fd, msg_txt(sd,351));
  6890. return 0;
  6891. }
  6892. if(target_sd == NULL) {
  6893. // "Duel: Player not found."
  6894. clif_displaymessage(fd, msg_txt(sd,352));
  6895. return 0;
  6896. }
  6897. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6898. // "Duel: Player already in duel."
  6899. clif_displaymessage(fd, msg_txt(sd,353));
  6900. return 0;
  6901. }
  6902. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6903. {
  6904. sprintf(atcmd_output, msg_txt(sd,364), message);
  6905. clif_displaymessage(fd, atcmd_output);
  6906. return 0;
  6907. }
  6908. duel_invite(did, sd, target_sd);
  6909. // "Duel: Invitation has been sent."
  6910. clif_displaymessage(fd, msg_txt(sd,354));
  6911. return 0;
  6912. }
  6913. ACMD_FUNC(duel)
  6914. {
  6915. unsigned int maxpl = 0;
  6916. if(sd->duel_group > 0) {
  6917. duel_showinfo(sd->duel_group, sd);
  6918. return 0;
  6919. }
  6920. if(sd->duel_invite > 0) {
  6921. // "Duel: @duel without @reject."
  6922. clif_displaymessage(fd, msg_txt(sd,355));
  6923. return 0;
  6924. }
  6925. if(!duel_checktime(sd)) {
  6926. char output[CHAT_SIZE_MAX];
  6927. // "Duel: You can take part in duel only one time per %d minutes."
  6928. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6929. clif_displaymessage(fd, output);
  6930. return 0;
  6931. }
  6932. if( message[0] ) {
  6933. if(sscanf(message, "%u", &maxpl) >= 1) {
  6934. if(maxpl < 2 || maxpl > 65535) {
  6935. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6936. return 0;
  6937. }
  6938. duel_create(sd, maxpl);
  6939. } else {
  6940. struct map_session_data *target_sd;
  6941. target_sd = map_nick2sd((char *)message);
  6942. if(target_sd != NULL) {
  6943. unsigned int newduel;
  6944. if((newduel = duel_create(sd, 2)) != -1) {
  6945. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6946. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6947. return 0;
  6948. }
  6949. duel_invite(newduel, sd, target_sd);
  6950. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6951. }
  6952. } else {
  6953. // "Duel: Player not found."
  6954. clif_displaymessage(fd, msg_txt(sd,352));
  6955. return 0;
  6956. }
  6957. }
  6958. } else
  6959. duel_create(sd, 0);
  6960. return 0;
  6961. }
  6962. ACMD_FUNC(leave)
  6963. {
  6964. if(sd->duel_group <= 0) {
  6965. // "Duel: @leave without @duel."
  6966. clif_displaymessage(fd, msg_txt(sd,358));
  6967. return 0;
  6968. }
  6969. duel_leave(sd->duel_group, sd);
  6970. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6971. return 0;
  6972. }
  6973. ACMD_FUNC(accept)
  6974. {
  6975. if(!duel_checktime(sd)) {
  6976. char output[CHAT_SIZE_MAX];
  6977. // "Duel: You can take part in duel only one time per %d minutes."
  6978. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6979. clif_displaymessage(fd, output);
  6980. return 0;
  6981. }
  6982. if(sd->duel_invite <= 0) {
  6983. // "Duel: @accept without invititation."
  6984. clif_displaymessage(fd, msg_txt(sd,360));
  6985. return 0;
  6986. }
  6987. if( duel_list[sd->duel_invite].max_players_limit > 0 && duel_list[sd->duel_invite].members_count >= duel_list[sd->duel_invite].max_players_limit )
  6988. {
  6989. // "Duel: Limit of players is reached."
  6990. clif_displaymessage(fd, msg_txt(sd,351));
  6991. return 0;
  6992. }
  6993. duel_accept(sd->duel_invite, sd);
  6994. // "Duel: Invitation has been accepted."
  6995. clif_displaymessage(fd, msg_txt(sd,361));
  6996. return 0;
  6997. }
  6998. ACMD_FUNC(reject)
  6999. {
  7000. if(sd->duel_invite <= 0) {
  7001. // "Duel: @reject without invititation."
  7002. clif_displaymessage(fd, msg_txt(sd,362));
  7003. return 0;
  7004. }
  7005. duel_reject(sd->duel_invite, sd);
  7006. // "Duel: Invitation has been rejected."
  7007. clif_displaymessage(fd, msg_txt(sd,363));
  7008. return 0;
  7009. }
  7010. /*===================================
  7011. * Cash Points
  7012. *-----------------------------------*/
  7013. ACMD_FUNC(cash)
  7014. {
  7015. char output[128];
  7016. int value;
  7017. int ret=0;
  7018. nullpo_retr(-1, sd);
  7019. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7020. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7021. return -1;
  7022. }
  7023. parent_cmd = atcommand_checkalias(command+1);
  7024. if( !strcmpi(parent_cmd,"cash") )
  7025. {
  7026. if( value > 0 ) {
  7027. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7028. // If this option is set, the message is already sent by pc function
  7029. if( !battle_config.cashshop_show_points ){
  7030. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7031. clif_disp_onlyself(sd, output, strlen(output));
  7032. }
  7033. }
  7034. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7035. } else {
  7036. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7037. value = -sd->cashPoints;
  7038. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7039. // If this option is set, the message is already sent by pc function
  7040. if( !battle_config.cashshop_show_points ){
  7041. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7042. clif_disp_onlyself(sd, output, strlen(output));
  7043. }
  7044. }
  7045. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7046. }
  7047. }
  7048. else
  7049. { // @points
  7050. if( value > 0 ) {
  7051. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7052. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7053. clif_disp_onlyself(sd, output, strlen(output));
  7054. }
  7055. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7056. } else {
  7057. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7058. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7059. clif_disp_onlyself(sd, output, strlen(output));
  7060. }
  7061. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7062. }
  7063. }
  7064. return 0;
  7065. }
  7066. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7067. ACMD_FUNC(clone)
  7068. {
  7069. int x=0,y=0,flag=0,master=0,i=0;
  7070. struct map_session_data *pl_sd=NULL;
  7071. if (!message || !*message) {
  7072. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7073. return 0;
  7074. }
  7075. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7076. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7077. return 0;
  7078. }
  7079. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7080. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7081. return 0;
  7082. }
  7083. parent_cmd = atcommand_checkalias(command+1);
  7084. if (strcmpi(parent_cmd, "clone") == 0)
  7085. flag = 1;
  7086. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7087. flag = 2;
  7088. if(pc_isdead(sd)){
  7089. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7090. return 0;
  7091. }
  7092. master = sd->bl.id;
  7093. if (battle_config.atc_slave_clone_limit
  7094. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7095. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7096. return 0;
  7097. }
  7098. }
  7099. do {
  7100. x = sd->bl.x + (rnd() % 10 - 5);
  7101. y = sd->bl.y + (rnd() % 10 - 5);
  7102. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7103. if (i >= 10) {
  7104. x = sd->bl.x;
  7105. y = sd->bl.y;
  7106. }
  7107. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7108. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7109. return 0;
  7110. }
  7111. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7112. return 0;
  7113. }
  7114. /*=====================================
  7115. * Autorejecting Invites/Deals [LuzZza]
  7116. * Usage: @noask
  7117. *-------------------------------------*/
  7118. ACMD_FUNC(noask)
  7119. {
  7120. if(sd->state.noask) {
  7121. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7122. sd->state.noask = 0;
  7123. } else {
  7124. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7125. sd->state.noask = 1;
  7126. }
  7127. return 0;
  7128. }
  7129. /*=====================================
  7130. * Send a @request message to all GMs of lowest_gm_level.
  7131. * Usage: @request <petition>
  7132. *-------------------------------------*/
  7133. ACMD_FUNC(request)
  7134. {
  7135. if (!message || !*message) {
  7136. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7137. return -1;
  7138. }
  7139. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7140. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7141. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7142. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7143. return 0;
  7144. }
  7145. /*==========================================
  7146. * Feel (SG save map) Reset [HiddenDragon]
  7147. *------------------------------------------*/
  7148. ACMD_FUNC(feelreset)
  7149. {
  7150. pc_resetfeel(sd);
  7151. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7152. return 0;
  7153. }
  7154. /*==========================================
  7155. * AUCTION SYSTEM
  7156. *------------------------------------------*/
  7157. ACMD_FUNC(auction)
  7158. {
  7159. nullpo_ret(sd);
  7160. if (!battle_config.feature_auction) {
  7161. clif_colormes(sd, color_table[COLOR_RED], msg_txt(sd, 517));
  7162. return 0;
  7163. }
  7164. clif_Auction_openwindow(sd);
  7165. return 0;
  7166. }
  7167. /*==========================================
  7168. * Kill Steal Protection
  7169. *------------------------------------------*/
  7170. ACMD_FUNC(ksprotection)
  7171. {
  7172. nullpo_retr(-1,sd);
  7173. if( sd->state.noks ) {
  7174. sd->state.noks = 0;
  7175. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7176. }
  7177. else
  7178. {
  7179. if( !message || !*message || !strcmpi(message, "party") )
  7180. { // Default is Party
  7181. sd->state.noks = 2;
  7182. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7183. }
  7184. else if( !strcmpi(message, "self") )
  7185. {
  7186. sd->state.noks = 1;
  7187. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7188. }
  7189. else if( !strcmpi(message, "guild") )
  7190. {
  7191. sd->state.noks = 3;
  7192. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7193. }
  7194. else
  7195. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7196. }
  7197. return 0;
  7198. }
  7199. /*==========================================
  7200. * Map Kill Steal Protection Setting
  7201. *------------------------------------------*/
  7202. ACMD_FUNC(allowks)
  7203. {
  7204. nullpo_retr(-1,sd);
  7205. if( map[sd->bl.m].flag.allowks ) {
  7206. map[sd->bl.m].flag.allowks = 0;
  7207. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7208. } else {
  7209. map[sd->bl.m].flag.allowks = 1;
  7210. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7211. }
  7212. return 0;
  7213. }
  7214. ACMD_FUNC(resetstat)
  7215. {
  7216. nullpo_retr(-1, sd);
  7217. pc_resetstate(sd);
  7218. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7219. clif_displaymessage(fd, atcmd_output);
  7220. return 0;
  7221. }
  7222. ACMD_FUNC(resetskill)
  7223. {
  7224. nullpo_retr(-1,sd);
  7225. pc_resetskill(sd,1);
  7226. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7227. clif_displaymessage(fd, atcmd_output);
  7228. return 0;
  7229. }
  7230. /*==========================================
  7231. * #storagelist: Displays the items list of a player's storage.
  7232. * #cartlist: Displays contents of target's cart.
  7233. * #itemlist: Displays contents of target's inventory.
  7234. *------------------------------------------*/
  7235. ACMD_FUNC(itemlist)
  7236. {
  7237. int i, j, count, counter;
  7238. const char* location;
  7239. const struct item* items;
  7240. int size;
  7241. StringBuf buf;
  7242. nullpo_retr(-1, sd);
  7243. parent_cmd = atcommand_checkalias(command+1);
  7244. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7245. location = "storage";
  7246. items = sd->status.storage.items;
  7247. size = sd->storage_size;
  7248. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7249. location = "cart";
  7250. items = sd->status.cart;
  7251. size = MAX_CART;
  7252. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7253. location = "inventory";
  7254. items = sd->status.inventory;
  7255. size = MAX_INVENTORY;
  7256. } else
  7257. return 1;
  7258. StringBuf_Init(&buf);
  7259. count = 0; // total slots occupied
  7260. counter = 0; // total items found
  7261. for( i = 0; i < size; ++i ) {
  7262. const struct item* it = &items[i];
  7263. struct item_data* itd;
  7264. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7265. continue;
  7266. counter += it->amount;
  7267. count++;
  7268. if( count == 1 ) {
  7269. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7270. clif_displaymessage(fd, StringBuf_Value(&buf));
  7271. StringBuf_Clear(&buf);
  7272. }
  7273. if( it->refine )
  7274. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7275. else
  7276. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7277. if( it->equip ) {
  7278. char equipstr[CHAT_SIZE_MAX];
  7279. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7280. if( it->equip&EQP_GARMENT )
  7281. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7282. if( it->equip&EQP_ACC_L )
  7283. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7284. if( it->equip&EQP_ARMOR )
  7285. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7286. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7287. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7288. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7289. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7290. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7291. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7292. if( it->equip&EQP_SHOES )
  7293. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7294. if( it->equip&EQP_ACC_R )
  7295. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7296. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7297. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7298. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7299. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7300. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7301. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7302. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7303. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7304. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7305. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7306. if( (it->equip&EQP_HELM) == EQP_HELM )
  7307. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7308. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7309. strcat(equipstr, msg_txt(sd,518));
  7310. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7311. strcat(equipstr, msg_txt(sd,519));
  7312. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7313. strcat(equipstr, msg_txt(sd,520));
  7314. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7315. strcat(equipstr, msg_txt(sd,521));
  7316. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7317. strcat(equipstr, msg_txt(sd,522));
  7318. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7319. strcat(equipstr, msg_txt(sd,523));
  7320. if( it->equip&EQP_COSTUME_GARMENT )
  7321. strcat(equipstr, msg_txt(sd,524));
  7322. //if( it->equip&EQP_COSTUME_FLOOR )
  7323. //strcat(equipstr, msg_txt(sd,525));
  7324. if( it->equip&EQP_AMMO )
  7325. strcat(equipstr, msg_txt(sd,526));
  7326. if( it->equip&EQP_SHADOW_ARMOR )
  7327. strcat(equipstr, msg_txt(sd,527));
  7328. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7329. strcat(equipstr, msg_txt(sd,528));
  7330. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7331. strcat(equipstr, msg_txt(sd,529));
  7332. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7333. strcat(equipstr, msg_txt(sd,530));
  7334. if( it->equip&EQP_SHADOW_SHOES )
  7335. strcat(equipstr, msg_txt(sd,531));
  7336. if( it->equip&EQP_SHADOW_ACC_R )
  7337. strcat(equipstr, msg_txt(sd,532));
  7338. if( it->equip&EQP_SHADOW_ACC_L )
  7339. strcat(equipstr, msg_txt(sd,533));
  7340. // remove final ', '
  7341. equipstr[strlen(equipstr) - 2] = '\0';
  7342. StringBuf_AppendStr(&buf, equipstr);
  7343. }
  7344. clif_displaymessage(fd, StringBuf_Value(&buf));
  7345. StringBuf_Clear(&buf);
  7346. if( it->card[0] == CARD0_PET ) { // pet egg
  7347. if (it->card[3])
  7348. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7349. else
  7350. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7351. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7352. 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)
  7353. } else if(it->card[0] == CARD0_CREATE) { // created item
  7354. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7355. } else { // normal item
  7356. int counter2 = 0;
  7357. for( j = 0; j < itd->slot; ++j ) {
  7358. struct item_data* card;
  7359. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7360. continue;
  7361. counter2++;
  7362. if( counter2 == 1 )
  7363. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7364. if( counter2 != 1 )
  7365. StringBuf_AppendStr(&buf, ", ");
  7366. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7367. }
  7368. if( counter2 > 0 )
  7369. StringBuf_AppendStr(&buf, ")");
  7370. }
  7371. if( StringBuf_Length(&buf) > 0 )
  7372. clif_displaymessage(fd, StringBuf_Value(&buf));
  7373. StringBuf_Clear(&buf);
  7374. }
  7375. if( count == 0 )
  7376. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7377. else
  7378. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7379. clif_displaymessage(fd, StringBuf_Value(&buf));
  7380. StringBuf_Destroy(&buf);
  7381. return 0;
  7382. }
  7383. ACMD_FUNC(stats)
  7384. {
  7385. char job_jobname[100];
  7386. char output[CHAT_SIZE_MAX];
  7387. int i;
  7388. struct {
  7389. const char* format;
  7390. int value;
  7391. } output_table[] = {
  7392. { "Base Level - %d", 0 },
  7393. { NULL, 0 },
  7394. { "Hp - %d", 0 },
  7395. { "MaxHp - %d", 0 },
  7396. { "Sp - %d", 0 },
  7397. { "MaxSp - %d", 0 },
  7398. { "Str - %3d", 0 },
  7399. { "Agi - %3d", 0 },
  7400. { "Vit - %3d", 0 },
  7401. { "Int - %3d", 0 },
  7402. { "Dex - %3d", 0 },
  7403. { "Luk - %3d", 0 },
  7404. { "Zeny - %d", 0 },
  7405. { "Free SK Points - %d", 0 },
  7406. { "JobChangeLvl (2nd) - %d", 0 },
  7407. { "JobChangeLvl (3rd) - %d", 0 },
  7408. { NULL, 0 }
  7409. };
  7410. memset(job_jobname, '\0', sizeof(job_jobname));
  7411. memset(output, '\0', sizeof(output));
  7412. //direct array initialization with variables is not standard C compliant.
  7413. output_table[0].value = sd->status.base_level;
  7414. output_table[1].format = job_jobname;
  7415. output_table[1].value = sd->status.job_level;
  7416. output_table[2].value = sd->status.hp;
  7417. output_table[3].value = sd->status.max_hp;
  7418. output_table[4].value = sd->status.sp;
  7419. output_table[5].value = sd->status.max_sp;
  7420. output_table[6].value = sd->status.str;
  7421. output_table[7].value = sd->status.agi;
  7422. output_table[8].value = sd->status.vit;
  7423. output_table[9].value = sd->status.int_;
  7424. output_table[10].value = sd->status.dex;
  7425. output_table[11].value = sd->status.luk;
  7426. output_table[12].value = sd->status.zeny;
  7427. output_table[13].value = sd->status.skill_point;
  7428. output_table[14].value = sd->change_level_2nd;
  7429. output_table[15].value = sd->change_level_3rd;
  7430. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7431. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7432. clif_displaymessage(fd, output);
  7433. for (i = 0; output_table[i].format != NULL; i++) {
  7434. sprintf(output, output_table[i].format, output_table[i].value);
  7435. clif_displaymessage(fd, output);
  7436. }
  7437. return 0;
  7438. }
  7439. ACMD_FUNC(delitem)
  7440. {
  7441. char item_name[100];
  7442. unsigned short nameid;
  7443. int amount = 0, total, idx;
  7444. struct item_data* id;
  7445. nullpo_retr(-1, sd);
  7446. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7447. {
  7448. 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>).
  7449. return -1;
  7450. }
  7451. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7452. {
  7453. nameid = id->nameid;
  7454. }
  7455. else
  7456. {
  7457. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7458. return -1;
  7459. }
  7460. total = amount;
  7461. // delete items
  7462. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7463. {
  7464. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7465. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7466. {// delete pet
  7467. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7468. }
  7469. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7470. amount-= delamount;
  7471. }
  7472. // notify target
  7473. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7474. clif_displaymessage(sd->fd, atcmd_output);
  7475. // notify source
  7476. if( amount == total )
  7477. {
  7478. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7479. }
  7480. else if( amount )
  7481. {
  7482. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7483. clif_displaymessage(fd, atcmd_output);
  7484. }
  7485. else
  7486. {
  7487. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7488. clif_displaymessage(fd, atcmd_output);
  7489. }
  7490. return 0;
  7491. }
  7492. /*==========================================
  7493. * Custom Fonts
  7494. *------------------------------------------*/
  7495. ACMD_FUNC(font)
  7496. {
  7497. int font_id;
  7498. nullpo_retr(-1,sd);
  7499. font_id = atoi(message);
  7500. if( font_id == 0 ) {
  7501. if( sd->status.font ) {
  7502. sd->status.font = 0;
  7503. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7504. clif_font(sd);
  7505. } else {
  7506. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7507. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7508. }
  7509. } else if( font_id < 0 || font_id > 9 )
  7510. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7511. else if( font_id != sd->status.font ) {
  7512. sd->status.font = font_id;
  7513. clif_font(sd);
  7514. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7515. } else
  7516. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7517. return 0;
  7518. }
  7519. /*==========================================
  7520. * type: 1 = commands (@), 2 = charcommands (#)
  7521. *------------------------------------------*/
  7522. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7523. {
  7524. char line_buff[CHATBOX_SIZE];
  7525. char* cur = line_buff;
  7526. AtCommandInfo* cmd;
  7527. DBIterator *iter = db_iterator(atcommand_db);
  7528. int count = 0;
  7529. memset(line_buff,' ',CHATBOX_SIZE);
  7530. line_buff[CHATBOX_SIZE-1] = 0;
  7531. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7532. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7533. unsigned int slen = 0;
  7534. switch( type ) {
  7535. case COMMAND_CHARCOMMAND:
  7536. if( cmd->char_groups[sd->group_pos] == 0 )
  7537. continue;
  7538. break;
  7539. case COMMAND_ATCOMMAND:
  7540. if( cmd->at_groups[sd->group_pos] == 0 )
  7541. continue;
  7542. break;
  7543. default:
  7544. continue;
  7545. }
  7546. slen = strlen(cmd->command);
  7547. // flush the text buffer if this command won't fit into it
  7548. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7549. clif_displaymessage(fd,line_buff);
  7550. cur = line_buff;
  7551. memset(line_buff,' ',CHATBOX_SIZE);
  7552. line_buff[CHATBOX_SIZE-1] = 0;
  7553. }
  7554. memcpy(cur,cmd->command,slen);
  7555. cur += slen+(10-slen%10);
  7556. count++;
  7557. }
  7558. dbi_destroy(iter);
  7559. clif_displaymessage(fd,line_buff);
  7560. if ( atcmd_binding_count ) {
  7561. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7562. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7563. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7564. unsigned int slen = strlen(atcmd_binding[i]->command);
  7565. if ( count_bind == 0 ) {
  7566. cur = line_buff;
  7567. memset(line_buff,' ',CHATBOX_SIZE);
  7568. line_buff[CHATBOX_SIZE-1] = 0;
  7569. clif_displaymessage(fd, "-----------------");
  7570. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7571. }
  7572. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7573. clif_displaymessage(fd,line_buff);
  7574. cur = line_buff;
  7575. memset(line_buff,' ',CHATBOX_SIZE);
  7576. line_buff[CHATBOX_SIZE-1] = 0;
  7577. }
  7578. memcpy(cur,atcmd_binding[i]->command,slen);
  7579. cur += slen+(10-slen%10);
  7580. count_bind++;
  7581. }
  7582. }
  7583. if ( count_bind )
  7584. clif_displaymessage(fd,line_buff);// last one
  7585. count += count_bind;
  7586. }
  7587. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7588. clif_displaymessage(fd, atcmd_output);
  7589. return;
  7590. }
  7591. /*==========================================
  7592. * @commands Lists available @ commands to you
  7593. *------------------------------------------*/
  7594. ACMD_FUNC(commands)
  7595. {
  7596. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7597. return 0;
  7598. }
  7599. /*==========================================
  7600. * @charcommands Lists available # commands to you
  7601. *------------------------------------------*/
  7602. ACMD_FUNC(charcommands) {
  7603. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7604. return 0;
  7605. }
  7606. /* for new mounts */
  7607. ACMD_FUNC(mount2) {
  7608. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7609. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7610. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7611. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7612. } else {
  7613. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7614. if (&sd->sc)
  7615. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7616. }
  7617. return 0;
  7618. }
  7619. ACMD_FUNC(accinfo) {
  7620. char query[NAME_LENGTH];
  7621. char type = 0; // type = 1, get only account name
  7622. if (!message || !*message || strlen(message) > NAME_LENGTH
  7623. || ( sscanf(message, "%31s %c", query, &type) < 1))
  7624. {
  7625. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7626. 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".
  7627. return -1;
  7628. } else if (type != 0) {
  7629. type = type-'0'; //make it int
  7630. if (type != 1) {
  7631. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7632. return -1;
  7633. }
  7634. }
  7635. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7636. return 0;
  7637. }
  7638. /* [Ind] */
  7639. ACMD_FUNC(set) {
  7640. char reg[32], val[128];
  7641. struct script_data* data;
  7642. int toset = 0, len;
  7643. bool is_str = false;
  7644. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7645. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7646. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7647. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7648. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7649. return -1;
  7650. }
  7651. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7652. if( reg[0] == '.' ) {
  7653. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7654. return -1;
  7655. } else if( reg[0] == '\'' ) {
  7656. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7657. return -1;
  7658. }
  7659. is_str = ( reg[strlen(reg) - 1] == '$' );
  7660. if( ( len = strlen(val) ) > 1 ) {
  7661. if( val[0] == '"' && val[len-1] == '"') {
  7662. val[len-1] = '\0'; //Strip quotes.
  7663. memmove(val, val+1, len-1);
  7664. }
  7665. }
  7666. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7667. if( is_str )
  7668. set_var(sd, reg, (void*) val);
  7669. else
  7670. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7671. }
  7672. CREATE(data, struct script_data,1);
  7673. if( is_str ) {// string variable
  7674. switch( reg[0] ) {
  7675. case '@':
  7676. data->u.str = pc_readregstr(sd, add_str(reg));
  7677. break;
  7678. case '$':
  7679. data->u.str = mapreg_readregstr(add_str(reg));
  7680. break;
  7681. case '#':
  7682. if( reg[1] == '#' )
  7683. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7684. else
  7685. data->u.str = pc_readaccountregstr(sd, reg);// local
  7686. break;
  7687. default:
  7688. data->u.str = pc_readglobalreg_str(sd, reg);
  7689. break;
  7690. }
  7691. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7692. data->type = C_CONSTSTR;
  7693. data->u.str = "";
  7694. } else {// duplicate string
  7695. data->type = C_STR;
  7696. data->u.str = aStrdup(data->u.str);
  7697. }
  7698. } else {// integer variable
  7699. data->type = C_INT;
  7700. switch( reg[0] ) {
  7701. case '@':
  7702. data->u.num = pc_readreg(sd, add_str(reg));
  7703. break;
  7704. case '$':
  7705. data->u.num = mapreg_readreg(add_str(reg));
  7706. break;
  7707. case '#':
  7708. if( reg[1] == '#' )
  7709. data->u.num = pc_readaccountreg2(sd, reg);// global
  7710. else
  7711. data->u.num = pc_readaccountreg(sd, reg);// local
  7712. break;
  7713. default:
  7714. data->u.num = pc_readglobalreg(sd, reg);
  7715. break;
  7716. }
  7717. }
  7718. switch( data->type ) {
  7719. case C_INT:
  7720. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7721. break;
  7722. case C_STR:
  7723. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7724. break;
  7725. case C_CONSTSTR:
  7726. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7727. break;
  7728. default:
  7729. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7730. break;
  7731. }
  7732. clif_displaymessage(fd, atcmd_output);
  7733. aFree(data);
  7734. return 0;
  7735. }
  7736. ACMD_FUNC(addperm) {
  7737. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7738. bool add;
  7739. int i;
  7740. parent_cmd = atcommand_checkalias(command+1);
  7741. add = (strcmpi(parent_cmd, "addperm") == 0);
  7742. if( !message || !*message ) {
  7743. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7744. clif_displaymessage(fd, atcmd_output);
  7745. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7746. for( i = 0; i < perm_size; i++ ) {
  7747. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7748. clif_displaymessage(fd, atcmd_output);
  7749. }
  7750. return -1;
  7751. }
  7752. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7753. if( i == perm_size ) {
  7754. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7755. clif_displaymessage(fd, atcmd_output);
  7756. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7757. for( i = 0; i < perm_size; i++ ) {
  7758. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7759. clif_displaymessage(fd, atcmd_output);
  7760. }
  7761. return -1;
  7762. }
  7763. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7764. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7765. clif_displaymessage(fd, atcmd_output);
  7766. return -1;
  7767. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7768. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7769. clif_displaymessage(fd, atcmd_output);
  7770. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7771. clif_displaymessage(fd, atcmd_output);
  7772. for( i = 0; i < perm_size; i++ ) {
  7773. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7774. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7775. clif_displaymessage(fd, atcmd_output);
  7776. }
  7777. }
  7778. return -1;
  7779. }
  7780. if( add )
  7781. sd->permissions |= pc_g_permission_name[i].permission;
  7782. else
  7783. sd->permissions &=~ pc_g_permission_name[i].permission;
  7784. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7785. clif_displaymessage(fd, atcmd_output);
  7786. return 0;
  7787. }
  7788. ACMD_FUNC(unloadnpcfile) {
  7789. if( !message || !*message ) {
  7790. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7791. return -1;
  7792. }
  7793. if( npc_unloadfile(message) )
  7794. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7795. else {
  7796. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7797. return -1;
  7798. }
  7799. return 0;
  7800. }
  7801. ACMD_FUNC(cart) {
  7802. #define MC_CART_MDFY(x) \
  7803. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7804. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7805. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7806. int val = atoi(message);
  7807. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7808. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7809. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7810. clif_displaymessage(fd, atcmd_output);
  7811. return -1;
  7812. }
  7813. if( val == 0 && !pc_iscarton(sd) ) {
  7814. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7815. return -1;
  7816. }
  7817. if( need_skill ) {
  7818. MC_CART_MDFY(1);
  7819. }
  7820. if( !pc_setcart(sd, val) ) {
  7821. if( need_skill ) {
  7822. MC_CART_MDFY(0);
  7823. }
  7824. return -1;/* @cart failed */
  7825. }
  7826. if( need_skill ) {
  7827. MC_CART_MDFY(0);
  7828. }
  7829. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7830. return 0;
  7831. #undef MC_CART_MDFY
  7832. }
  7833. /* Channel System [Ind] */
  7834. ACMD_FUNC(join){
  7835. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7836. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7837. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7838. clif_displaymessage(fd, atcmd_output);
  7839. return -1;
  7840. }
  7841. return channel_pcjoin(sd, chname, pass);
  7842. }
  7843. /*
  7844. * Display available option for @channel command
  7845. * @command : the name of used command (for alias case)
  7846. */
  7847. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7848. {
  7849. int fd = sd->fd;
  7850. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7851. bool can_create = (can_delete || channel_config.user_chenable);
  7852. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7853. //option create
  7854. if( can_create ) {
  7855. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7856. clif_displaymessage(fd, atcmd_output);
  7857. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7858. }
  7859. //option delete
  7860. if(can_delete){
  7861. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7862. clif_displaymessage(fd, atcmd_output);
  7863. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7864. }
  7865. //option list
  7866. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7867. clif_displaymessage(fd, atcmd_output);
  7868. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7869. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7870. clif_displaymessage(fd, atcmd_output);
  7871. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7872. if( can_create ) {
  7873. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7874. clif_displaymessage(fd, atcmd_output);
  7875. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7876. }
  7877. //option setcolor
  7878. if(can_create){
  7879. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7880. clif_displaymessage(fd, atcmd_output);
  7881. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7882. }
  7883. //option join
  7884. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7885. clif_displaymessage(fd, atcmd_output);
  7886. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7887. //option leave
  7888. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7889. clif_displaymessage(fd, atcmd_output);
  7890. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7891. //option bindto
  7892. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7893. clif_displaymessage(fd, atcmd_output);
  7894. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7895. //option unbind
  7896. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7897. clif_displaymessage(fd, atcmd_output);
  7898. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7899. //option ban/unban/banlist
  7900. if( can_create ) {
  7901. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7902. clif_displaymessage(fd, atcmd_output);
  7903. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7904. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7905. clif_displaymessage(fd, atcmd_output);
  7906. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7907. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7908. clif_displaymessage(fd, atcmd_output);
  7909. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7910. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7911. clif_displaymessage(fd, atcmd_output);
  7912. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7913. }
  7914. //option setopt
  7915. if(can_create){
  7916. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7917. clif_displaymessage(fd, atcmd_output);
  7918. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7919. }
  7920. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7921. clif_displaymessage(fd, atcmd_output);
  7922. }
  7923. ACMD_FUNC(channel) {
  7924. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  7925. sub1[0] = sub2[0] = '\0';
  7926. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  7927. atcmd_channel_help(sd,command);
  7928. return 0;
  7929. }
  7930. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7931. return channel_pcdelete(sd,sub1);
  7932. } else if ( strcmpi(key,"list") == 0 ) {
  7933. return channel_display_list(sd,sub1);
  7934. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7935. return channel_pccolor(sd, sub1, sub2);
  7936. } else if ( strcmpi(key,"join") == 0 ) {
  7937. return channel_pcjoin(sd, sub1, sub2);
  7938. }else if ( strcmpi(key,"leave") == 0 ) {
  7939. return channel_pcleave(sd, sub1);
  7940. } else if ( strcmpi(key,"bindto") == 0 ) {
  7941. return channel_pcbind(sd, sub1);
  7942. } else if ( strcmpi(key,"unbind") == 0 ) {
  7943. return channel_pcunbind(sd);
  7944. } else if ( strcmpi(key,"ban") == 0 ) {
  7945. return channel_pcban(sd,sub1,sub2,0);
  7946. } else if ( strcmpi(key,"banlist") == 0 ) {
  7947. return channel_pcban(sd,sub1,NULL,3);
  7948. } else if ( strcmpi(key,"unban") == 0 ) {
  7949. return channel_pcban(sd,sub1,sub2,1);
  7950. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7951. return channel_pcban(sd,sub1,NULL,2);
  7952. } else {
  7953. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  7954. sub3[0] = sub4[0] = '\0';
  7955. sscanf(sub2, "%19s %19s", sub3, sub4);
  7956. if( strcmpi(key,"create") == 0 && ( channel_config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7957. if (sub4[0] != '\0') {
  7958. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  7959. return -1;
  7960. }
  7961. return channel_pccreate(sd,sub1,sub3);
  7962. } else if ( strcmpi(key,"setopt") == 0 ) {
  7963. return channel_pcsetopt(sd,sub1,sub3,sub4);
  7964. }
  7965. atcmd_channel_help(sd,command);
  7966. }
  7967. return 0;
  7968. }
  7969. ACMD_FUNC(fontcolor)
  7970. {
  7971. if( !message || !*message ) {
  7972. channel_display_list(sd,"colors");
  7973. return -1;
  7974. }
  7975. if( strcmpi(message,"Normal") == 0 ) {
  7976. sd->fontcolor = 0;
  7977. } else {
  7978. unsigned char k;
  7979. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  7980. if( k == channel_config.colors_count ) {
  7981. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7982. clif_displaymessage(fd, atcmd_output);
  7983. return -1;
  7984. }
  7985. sd->fontcolor = k;
  7986. }
  7987. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7988. clif_displaymessage(fd, atcmd_output);
  7989. return 0;
  7990. }
  7991. ACMD_FUNC(langtype)
  7992. {
  7993. char langstr[8];
  7994. int i=0, fail=0;
  7995. memset(langstr, '\0', sizeof(langstr));
  7996. if(sscanf(message, "%3s", langstr) >= 1){
  7997. int lang=0;
  7998. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7999. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8000. char output[100];
  8001. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  8002. sd->langtype = lang;
  8003. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8004. clif_displaymessage(fd,output);
  8005. return 0;
  8006. } else if (lang != -1) { //defined langage but failed check
  8007. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8008. return -1;
  8009. }
  8010. }
  8011. //wrong or no entry
  8012. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8013. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8014. while(fail != -1){ //out of range
  8015. fail = msg_checklangtype(i,false);
  8016. if(fail == 1)
  8017. clif_displaymessage(fd,msg_langtype2langstr(i));
  8018. i++;
  8019. }
  8020. return -1;
  8021. }
  8022. #ifdef VIP_ENABLE
  8023. ACMD_FUNC(vip) {
  8024. struct map_session_data *pl_sd = NULL;
  8025. char * modif_p;
  8026. int32 vipdifftime = 0;
  8027. time_t now=time(NULL);
  8028. nullpo_retr(-1, sd);
  8029. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8030. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8031. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8032. return -1;
  8033. }
  8034. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8035. modif_p = atcmd_output;
  8036. vipdifftime = (int32)solve_time(modif_p);
  8037. if (vipdifftime == 0) {
  8038. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8039. 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.
  8040. return -1;
  8041. }
  8042. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  8043. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8044. return -1;
  8045. }
  8046. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8047. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8048. return -1;
  8049. }
  8050. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8051. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8052. if (pl_sd->vip.time <= now) {
  8053. pl_sd->vip.time = 0;
  8054. pl_sd->vip.enabled = 0;
  8055. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8056. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8057. } else {
  8058. int year,month,day,hour,minute,second;
  8059. char timestr[21];
  8060. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8061. 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.
  8062. clif_displaymessage(pl_sd->fd,atcmd_output);
  8063. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8064. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8065. clif_displaymessage(pl_sd->fd,atcmd_output);
  8066. if (pl_sd != sd) {
  8067. 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.
  8068. clif_displaymessage(fd,atcmd_output);
  8069. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8070. clif_displaymessage(fd,atcmd_output);
  8071. }
  8072. }
  8073. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8074. return 0;
  8075. }
  8076. /** Enable/disable rate info */
  8077. ACMD_FUNC(showrate) {
  8078. nullpo_retr(-1,sd);
  8079. if (!sd->disableshowrate) {
  8080. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8081. sd->disableshowrate = 1;
  8082. }
  8083. else {
  8084. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8085. sd->disableshowrate = 0;
  8086. }
  8087. clif_displaymessage(fd,atcmd_output);
  8088. return 0;
  8089. }
  8090. #endif
  8091. ACMD_FUNC(fullstrip) {
  8092. int i;
  8093. TBL_PC *tsd;
  8094. nullpo_retr(-1,sd);
  8095. if (!message || !*message) {
  8096. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8097. return -1;
  8098. }
  8099. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8100. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8101. return -1;
  8102. }
  8103. for( i = 0; i < EQI_MAX; i++ ) {
  8104. if( tsd->equip_index[ i ] >= 0 )
  8105. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8106. }
  8107. return 0;
  8108. }
  8109. ACMD_FUNC(costume) {
  8110. const char* names[] = {
  8111. "Wedding",
  8112. "Xmas",
  8113. "Summer",
  8114. "Hanbok",
  8115. "Oktoberfest",
  8116. };
  8117. const int name2id[] = {
  8118. SC_WEDDING,
  8119. SC_XMAS,
  8120. SC_SUMMER,
  8121. SC_HANBOK,
  8122. SC_OKTOBERFEST
  8123. };
  8124. unsigned short k = 0, len = ARRAYLENGTH(names);
  8125. if( !message || !*message ) {
  8126. for( k = 0; k < len; k++ ) {
  8127. if( sd->sc.data[name2id[k]] ) {
  8128. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8129. clif_displaymessage(sd->fd, atcmd_output);
  8130. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8131. return 0;
  8132. }
  8133. }
  8134. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8135. for( k = 0; k < len; k++ ) {
  8136. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8137. clif_displaymessage(sd->fd, atcmd_output);
  8138. }
  8139. return -1;
  8140. }
  8141. for( k = 0; k < len; k++ ) {
  8142. if( sd->sc.data[name2id[k]] ) {
  8143. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8144. clif_displaymessage(sd->fd, atcmd_output);
  8145. return -1;
  8146. }
  8147. }
  8148. for( k = 0; k < len; k++ )
  8149. if( strcmpi(message, names[k]) == 0 )
  8150. break;
  8151. if( k == len ) {
  8152. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8153. clif_displaymessage(sd->fd, atcmd_output);
  8154. return -1;
  8155. }
  8156. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8157. return 0;
  8158. }
  8159. /**
  8160. * Clone other player's equipments
  8161. * Usage: @cloneequip <char_id or "char name">
  8162. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8163. * @author [Cydh], [Antares]
  8164. */
  8165. ACMD_FUNC(cloneequip) {
  8166. struct map_session_data *pl_sd;
  8167. uint32 char_id = 0;
  8168. nullpo_retr(-1, sd);
  8169. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8170. if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8171. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8172. return -1;
  8173. }
  8174. if (char_id)
  8175. pl_sd = map_charid2sd(char_id);
  8176. else
  8177. pl_sd = map_nick2sd(atcmd_output);
  8178. if (!pl_sd) {
  8179. clif_displaymessage(fd, msg_txt(sd, 3));
  8180. return -1;
  8181. }
  8182. if (sd == pl_sd) {
  8183. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8184. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8185. clif_displaymessage(fd, atcmd_output);
  8186. return -1;
  8187. }
  8188. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8189. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8190. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8191. clif_displaymessage(fd, atcmd_output);
  8192. return -1;
  8193. }
  8194. else {
  8195. int8 i;
  8196. for (i = 0; i < EQI_MAX; i++) {
  8197. short idx;
  8198. char flag = 0;
  8199. struct item tmp_item;
  8200. if ((idx = pl_sd->equip_index[i]) < 0)
  8201. continue;
  8202. if (i == EQI_AMMO)
  8203. continue;
  8204. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8205. continue;
  8206. tmp_item = pl_sd->status.inventory[idx];
  8207. if (itemdb_isspecial(tmp_item.card[0]))
  8208. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8209. tmp_item.bound = 0;
  8210. tmp_item.expire_time = 0;
  8211. tmp_item.unique_id = 0;
  8212. tmp_item.favorite = 0;
  8213. tmp_item.amount = 1;
  8214. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8215. clif_additem(sd, 0, 0, flag);
  8216. else
  8217. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8218. }
  8219. }
  8220. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8221. sprintf(atcmd_output, msg_txt(sd, 738), "equip");
  8222. clif_displaymessage(fd, atcmd_output);
  8223. return 0;
  8224. }
  8225. /**
  8226. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8227. * Usage: @clonestat <char_id or "char name">
  8228. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8229. * @author [Cydh], [Antares]
  8230. */
  8231. ACMD_FUNC(clonestat) {
  8232. struct map_session_data *pl_sd;
  8233. uint32 char_id = 0;
  8234. nullpo_retr(-1, sd);
  8235. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8236. if( !message || !*message || (sscanf(message, "%d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8237. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8238. return -1;
  8239. }
  8240. if (char_id)
  8241. pl_sd = map_charid2sd(char_id);
  8242. else
  8243. pl_sd = map_nick2sd(atcmd_output);
  8244. if (!pl_sd) {
  8245. clif_displaymessage(fd, msg_txt(sd, 3));
  8246. return -1;
  8247. }
  8248. if (sd == pl_sd) {
  8249. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8250. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8251. clif_displaymessage(fd, atcmd_output);
  8252. return -1;
  8253. }
  8254. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8255. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8256. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8257. clif_displaymessage(fd, atcmd_output);
  8258. return -1;
  8259. }
  8260. else {
  8261. uint8 i;
  8262. short max_status[6];
  8263. pc_resetstate(sd);
  8264. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8265. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8266. else {
  8267. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8268. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8269. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8270. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8271. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8272. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8273. }
  8274. #define clonestat_check(cmd,stat)\
  8275. {\
  8276. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8277. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8278. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8279. clif_displaymessage(fd, atcmd_output);\
  8280. sd->status.cmd = max_status[(stat)];\
  8281. }\
  8282. else\
  8283. sd->status.cmd = pl_sd->status.cmd;\
  8284. }
  8285. clonestat_check(str, PARAM_STR);
  8286. clonestat_check(agi, PARAM_AGI);
  8287. clonestat_check(vit, PARAM_VIT);
  8288. clonestat_check(int_, PARAM_INT);
  8289. clonestat_check(dex, PARAM_DEX);
  8290. clonestat_check(luk, PARAM_LUK);
  8291. for (i = 0; i < PARAM_MAX; i++) {
  8292. clif_updatestatus(sd, SP_STR + i);
  8293. clif_updatestatus(sd, SP_USTR + i);
  8294. }
  8295. status_calc_pc(sd, SCO_FORCE);
  8296. }
  8297. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8298. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8299. clif_displaymessage(fd, atcmd_output);
  8300. #undef clonestat_check
  8301. return 0;
  8302. }
  8303. #include "../custom/atcommand.inc"
  8304. /**
  8305. * Fills the reference of available commands in atcommand DBMap
  8306. **/
  8307. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8308. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8309. // Define with restriction
  8310. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8311. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8312. void atcommand_basecommands(void) {
  8313. /**
  8314. * Command reference list, place the base of your commands here
  8315. * TODO: List all commands that causing crash
  8316. **/
  8317. AtCommandInfo atcommand_base[] = {
  8318. #include "../custom/atcommand_def.inc"
  8319. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8320. ACMD_DEF(where),
  8321. ACMD_DEF(jumpto),
  8322. ACMD_DEF(jump),
  8323. ACMD_DEF(who),
  8324. ACMD_DEF2("who2", who),
  8325. ACMD_DEF2("who3", who),
  8326. ACMD_DEF2("whomap", who),
  8327. ACMD_DEF2("whomap2", who),
  8328. ACMD_DEF2("whomap3", who),
  8329. ACMD_DEF(whogm),
  8330. ACMD_DEF(save),
  8331. ACMD_DEF(load),
  8332. ACMD_DEF(speed),
  8333. ACMD_DEF(storage),
  8334. ACMD_DEF(guildstorage),
  8335. ACMD_DEF(option),
  8336. ACMD_DEF(hide), // + /hide
  8337. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8338. ACMD_DEF(kill),
  8339. ACMD_DEF(alive),
  8340. ACMD_DEF(kami),
  8341. ACMD_DEF2("kamib", kami),
  8342. ACMD_DEF2("kamic", kami),
  8343. ACMD_DEF2("lkami", kami),
  8344. ACMD_DEF(heal),
  8345. ACMD_DEF(item),
  8346. ACMD_DEF(item2),
  8347. ACMD_DEF2("itembound",item),
  8348. ACMD_DEF2("itembound2",item2),
  8349. ACMD_DEF(itemreset),
  8350. ACMD_DEF(clearstorage),
  8351. ACMD_DEF(cleargstorage),
  8352. ACMD_DEF(clearcart),
  8353. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8354. ACMD_DEF2("jlvl", joblevelup),
  8355. ACMD_DEF(help),
  8356. ACMD_DEF(pvpoff),
  8357. ACMD_DEF(pvpon),
  8358. ACMD_DEF(gvgoff),
  8359. ACMD_DEF(gvgon),
  8360. ACMD_DEF(model),
  8361. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8362. ACMD_DEF(monster),
  8363. ACMD_DEF2("monstersmall", monster),
  8364. ACMD_DEF2("monsterbig", monster),
  8365. ACMD_DEF(killmonster),
  8366. ACMD_DEF2("killmonster2", killmonster),
  8367. ACMD_DEF(refine),
  8368. ACMD_DEF(produce),
  8369. ACMD_DEF(memo),
  8370. ACMD_DEF(gat),
  8371. ACMD_DEF(displaystatus),
  8372. ACMD_DEF2("stpoint", statuspoint),
  8373. ACMD_DEF2("skpoint", skillpoint),
  8374. ACMD_DEF(zeny),
  8375. ACMD_DEF2("str", param),
  8376. ACMD_DEF2("agi", param),
  8377. ACMD_DEF2("vit", param),
  8378. ACMD_DEF2("int", param),
  8379. ACMD_DEF2("dex", param),
  8380. ACMD_DEF2("luk", param),
  8381. ACMD_DEF2("glvl", guildlevelup),
  8382. ACMD_DEF(makeegg),
  8383. ACMD_DEF(hatch),
  8384. ACMD_DEF(petfriendly),
  8385. ACMD_DEF(pethungry),
  8386. ACMD_DEF(petrename),
  8387. ACMD_DEF(recall), // + /recall
  8388. ACMD_DEF(night),
  8389. ACMD_DEF(day),
  8390. ACMD_DEF(doom),
  8391. ACMD_DEF(doommap),
  8392. ACMD_DEF(raise),
  8393. ACMD_DEF(raisemap),
  8394. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8395. ACMD_DEF(kickall),
  8396. ACMD_DEF(allskill),
  8397. ACMD_DEF(questskill),
  8398. ACMD_DEF(lostskill),
  8399. ACMD_DEF(spiritball),
  8400. ACMD_DEF(party),
  8401. ACMD_DEF(guild),
  8402. ACMD_DEF(breakguild),
  8403. ACMD_DEF(agitstart),
  8404. ACMD_DEF(agitend),
  8405. ACMD_DEF(mapexit),
  8406. ACMD_DEF(idsearch),
  8407. ACMD_DEF(broadcast), // + /b and /nb
  8408. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8409. ACMD_DEF(recallall),
  8410. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8411. ACMD_DEF2("reloaditemdb", reload),
  8412. ACMD_DEF2("reloadmobdb", reload),
  8413. ACMD_DEF2("reloadskilldb", reload),
  8414. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8415. ACMD_DEF2("reloadatcommand", reload),
  8416. ACMD_DEF2("reloadbattleconf", reload),
  8417. ACMD_DEF2("reloadstatusdb", reload),
  8418. ACMD_DEF2("reloadpcdb", reload),
  8419. ACMD_DEF2("reloadmotd", reload),
  8420. ACMD_DEF2("reloadquestdb", reload),
  8421. ACMD_DEF2("reloadmsgconf", reload),
  8422. ACMD_DEF2("reloadpacketdb", reload),
  8423. ACMD_DEF2("reloadinstancedb", reload),
  8424. ACMD_DEF(partysharelvl),
  8425. ACMD_DEF(mapinfo),
  8426. ACMD_DEF(dye),
  8427. ACMD_DEF2("hairstyle", hair_style),
  8428. ACMD_DEF2("haircolor", hair_color),
  8429. ACMD_DEF2("allstats", stat_all),
  8430. ACMD_DEF2("block", char_block),
  8431. ACMD_DEF2("ban", char_ban),
  8432. ACMD_DEF2("unblock", char_unblock),
  8433. ACMD_DEF2("unban", char_unban),
  8434. ACMD_DEF2("charban", char_ban),
  8435. ACMD_DEF2("charunban", char_unban),
  8436. ACMD_DEF2("mount", mount_peco),
  8437. ACMD_DEF(guildspy),
  8438. ACMD_DEF(partyspy),
  8439. ACMD_DEF(repairall),
  8440. ACMD_DEF(guildrecall),
  8441. ACMD_DEF(partyrecall),
  8442. ACMD_DEF(nuke),
  8443. ACMD_DEF(shownpc),
  8444. ACMD_DEF(hidenpc),
  8445. ACMD_DEF(loadnpc),
  8446. ACMD_DEF(unloadnpc),
  8447. ACMD_DEF2("time", servertime),
  8448. ACMD_DEF(jail),
  8449. ACMD_DEF(unjail),
  8450. ACMD_DEF(jailfor),
  8451. ACMD_DEF(jailtime),
  8452. ACMD_DEF(disguise),
  8453. ACMD_DEF(undisguise),
  8454. ACMD_DEF(email),
  8455. ACMD_DEF(effect),
  8456. ACMD_DEF(follow),
  8457. ACMD_DEF(addwarp),
  8458. ACMD_DEF(skillon),
  8459. ACMD_DEF(skilloff),
  8460. ACMD_DEF(killer),
  8461. ACMD_DEF(npcmove),
  8462. ACMD_DEF(killable),
  8463. ACMD_DEF(dropall),
  8464. ACMD_DEF(storeall),
  8465. ACMD_DEF(skillid),
  8466. ACMD_DEF(useskill),
  8467. ACMD_DEF(displayskill),
  8468. ACMD_DEF(snow),
  8469. ACMD_DEF(sakura),
  8470. ACMD_DEF(clouds),
  8471. ACMD_DEF(clouds2),
  8472. ACMD_DEF(fog),
  8473. ACMD_DEF(fireworks),
  8474. ACMD_DEF(leaves),
  8475. ACMD_DEF(summon),
  8476. ACMD_DEF(adjgroup),
  8477. ACMD_DEF(trade),
  8478. ACMD_DEF(send),
  8479. ACMD_DEF(setbattleflag),
  8480. ACMD_DEF(unmute),
  8481. ACMD_DEF(clearweather),
  8482. ACMD_DEF(uptime),
  8483. ACMD_DEF(changesex),
  8484. ACMD_DEF(mute),
  8485. ACMD_DEF(refresh),
  8486. ACMD_DEF(refreshall),
  8487. ACMD_DEF(identify),
  8488. ACMD_DEF(identifyall),
  8489. ACMD_DEF(gmotd),
  8490. ACMD_DEF(misceffect),
  8491. ACMD_DEF(mobsearch),
  8492. ACMD_DEF(cleanmap),
  8493. ACMD_DEF(cleanarea),
  8494. ACMD_DEF(npctalk),
  8495. ACMD_DEF(pettalk),
  8496. ACMD_DEF(users),
  8497. ACMD_DEF(reset),
  8498. ACMD_DEF(skilltree),
  8499. ACMD_DEF(marry),
  8500. ACMD_DEF(divorce),
  8501. ACMD_DEF(sound),
  8502. ACMD_DEF(undisguiseall),
  8503. ACMD_DEF(disguiseall),
  8504. ACMD_DEF(changelook),
  8505. ACMD_DEF(autoloot),
  8506. ACMD_DEF2("alootid", autolootitem),
  8507. ACMD_DEF(autoloottype),
  8508. ACMD_DEF(mobinfo),
  8509. ACMD_DEF(exp),
  8510. ACMD_DEF(version),
  8511. ACMD_DEF(mutearea),
  8512. ACMD_DEF(rates),
  8513. ACMD_DEF(iteminfo),
  8514. ACMD_DEF(whodrops),
  8515. ACMD_DEF(whereis),
  8516. ACMD_DEF(mapflag),
  8517. ACMD_DEF(me),
  8518. ACMD_DEF(monsterignore),
  8519. ACMD_DEF(fakename),
  8520. ACMD_DEF(size),
  8521. ACMD_DEF(showexp),
  8522. ACMD_DEF(showzeny),
  8523. ACMD_DEF(showdelay),
  8524. ACMD_DEF(autotrade),
  8525. ACMD_DEF(changegm),
  8526. ACMD_DEF(changeleader),
  8527. ACMD_DEF(partyoption),
  8528. ACMD_DEF(invite),
  8529. ACMD_DEF(duel),
  8530. ACMD_DEF(leave),
  8531. ACMD_DEF(accept),
  8532. ACMD_DEF(reject),
  8533. ACMD_DEF(clone),
  8534. ACMD_DEF2("slaveclone", clone),
  8535. ACMD_DEF2("evilclone", clone),
  8536. ACMD_DEF(tonpc),
  8537. ACMD_DEF(commands),
  8538. ACMD_DEF(noask),
  8539. ACMD_DEF(request),
  8540. ACMD_DEF(homlevel),
  8541. ACMD_DEF(homevolution),
  8542. ACMD_DEF(hommutate),
  8543. ACMD_DEF(makehomun),
  8544. ACMD_DEF(homfriendly),
  8545. ACMD_DEF(homhungry),
  8546. ACMD_DEF(homtalk),
  8547. ACMD_DEF(hominfo),
  8548. ACMD_DEF(homstats),
  8549. ACMD_DEF(homshuffle),
  8550. ACMD_DEF(showmobs),
  8551. ACMD_DEF(feelreset),
  8552. ACMD_DEF(auction),
  8553. ACMD_DEF(mail),
  8554. ACMD_DEF2("noks", ksprotection),
  8555. ACMD_DEF(allowks),
  8556. ACMD_DEF(cash),
  8557. ACMD_DEF2("points", cash),
  8558. ACMD_DEF(agitstart2),
  8559. ACMD_DEF(agitend2),
  8560. ACMD_DEF(resetskill),
  8561. ACMD_DEF(resetstat),
  8562. ACMD_DEF2("storagelist", itemlist),
  8563. ACMD_DEF2("cartlist", itemlist),
  8564. ACMD_DEF2("itemlist", itemlist),
  8565. ACMD_DEF(stats),
  8566. ACMD_DEF(delitem),
  8567. ACMD_DEF(charcommands),
  8568. ACMD_DEF(font),
  8569. ACMD_DEF(accinfo),
  8570. ACMD_DEF(set),
  8571. ACMD_DEF(undisguiseguild),
  8572. ACMD_DEF(disguiseguild),
  8573. ACMD_DEF(sizeall),
  8574. ACMD_DEF(sizeguild),
  8575. ACMD_DEF(addperm),
  8576. ACMD_DEF2("rmvperm", addperm),
  8577. ACMD_DEF(unloadnpcfile),
  8578. ACMD_DEF(cart),
  8579. ACMD_DEF(mount2),
  8580. ACMD_DEF(join),
  8581. ACMD_DEF(channel),
  8582. ACMD_DEF(fontcolor),
  8583. ACMD_DEF(langtype),
  8584. #ifdef VIP_ENABLE
  8585. ACMD_DEF(vip),
  8586. ACMD_DEF(showrate),
  8587. #endif
  8588. ACMD_DEF(fullstrip),
  8589. ACMD_DEF(costume),
  8590. ACMD_DEF(cloneequip),
  8591. ACMD_DEF(clonestat),
  8592. };
  8593. AtCommandInfo* atcommand;
  8594. int i;
  8595. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8596. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8597. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8598. continue;
  8599. }
  8600. CREATE(atcommand, AtCommandInfo, 1);
  8601. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8602. atcommand->func = atcommand_base[i].func;
  8603. atcommand->restriction = atcommand_base[i].restriction;
  8604. strdb_put(atcommand_db, atcommand->command, atcommand);
  8605. }
  8606. return;
  8607. }
  8608. /*==========================================
  8609. * Command lookup functions
  8610. *------------------------------------------*/
  8611. bool atcommand_exists(const char* name)
  8612. {
  8613. return strdb_exists(atcommand_db, name);
  8614. }
  8615. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8616. {
  8617. if (strdb_exists(atcommand_db, name))
  8618. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8619. return NULL;
  8620. }
  8621. static const char* atcommand_checkalias(const char *aliasname)
  8622. {
  8623. AliasInfo *alias_info = NULL;
  8624. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8625. return alias_info->command->command;
  8626. return aliasname;
  8627. }
  8628. /// AtCommand suggestion
  8629. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8630. DBIterator* atcommand_iter;
  8631. DBIterator* alias_iter;
  8632. AtCommandInfo* command_info = NULL;
  8633. AliasInfo* alias_info = NULL;
  8634. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8635. char* full_match[MAX_SUGGESTIONS];
  8636. char* suggestions[MAX_SUGGESTIONS];
  8637. char* match;
  8638. int prefix_count = 0, full_count = 0;
  8639. bool can_use;
  8640. if (!battle_config.atcommand_suggestions_enabled)
  8641. return;
  8642. atcommand_iter = db_iterator(atcommand_db);
  8643. alias_iter = db_iterator(atcommand_alias_db);
  8644. // Build the matches
  8645. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8646. match = strstr(command_info->command, name);
  8647. can_use = pc_can_use_command(sd, command_info->command, type);
  8648. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8649. suggestions[prefix_count] = command_info->command;
  8650. ++prefix_count;
  8651. }
  8652. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8653. full_match[full_count] = command_info->command;
  8654. ++full_count;
  8655. }
  8656. }
  8657. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8658. match = strstr(alias_info->alias, name);
  8659. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8660. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8661. suggestions[prefix_count] = alias_info->alias;
  8662. ++prefix_count;
  8663. }
  8664. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8665. full_match[full_count] = alias_info->alias;
  8666. ++full_count;
  8667. }
  8668. }
  8669. if ((full_count+prefix_count) > 0) {
  8670. char buffer[512];
  8671. int i;
  8672. // Merge full match and prefix match results
  8673. if (prefix_count < MAX_SUGGESTIONS) {
  8674. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8675. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8676. }
  8677. // Build the suggestion string
  8678. strcpy(buffer, msg_txt(sd,205));
  8679. strcat(buffer,"\n");
  8680. for(i=0; i < prefix_count; ++i) {
  8681. strcat(buffer,suggestions[i]);
  8682. strcat(buffer," ");
  8683. }
  8684. clif_displaymessage(sd->fd, buffer);
  8685. }
  8686. dbi_destroy(atcommand_iter);
  8687. dbi_destroy(alias_iter);
  8688. }
  8689. /**
  8690. * Executes an at-command
  8691. * @param fd
  8692. * @param sd
  8693. * @param message
  8694. * @param type
  8695. * 0 : script call (atcommand)
  8696. * 1 : normal player @atcommand
  8697. * 2 : console (admin:@atcommand)
  8698. * 3 : script call (useatcmd)
  8699. */
  8700. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8701. {
  8702. char charname[NAME_LENGTH], params[100];
  8703. char charname2[NAME_LENGTH];
  8704. char command[100];
  8705. char output[CHAT_SIZE_MAX];
  8706. //Reconstructed message
  8707. char atcmd_msg[CHAT_SIZE_MAX];
  8708. TBL_PC * ssd = NULL; //sd for target
  8709. AtCommandInfo * info;
  8710. nullpo_retr(false, sd);
  8711. //Shouldn't happen
  8712. if ( !message || !*message )
  8713. return false;
  8714. //If cannot use atcomamnd while talking with NPC [Kichi]
  8715. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8716. return false;
  8717. //Block NOCHAT but do not display it as a normal message
  8718. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8719. return true;
  8720. // skip 10/11-langtype's codepage indicator, if detected
  8721. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8722. message += 3;
  8723. //Should display as a normal message
  8724. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8725. return false;
  8726. // type value 0|2 = script|console invoked: bypass restrictions
  8727. if ( type == 1 || type == 3) {
  8728. //Commands are disabled on maps flagged as 'nocommand'
  8729. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8730. clif_displaymessage(fd, msg_txt(sd,143));
  8731. return false;
  8732. }
  8733. }
  8734. if (*message == charcommand_symbol) {
  8735. do {
  8736. int x, y, z;
  8737. char params2[100];
  8738. //Checks to see if #command has a name or a name + parameters.
  8739. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8740. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8741. //z always has the value of the scan that was successful
  8742. z = ( x > 1 ) ? x : y;
  8743. //#command + name means the sufficient target was used and anything else after
  8744. //can be looked at by the actual command function since most scan to see if the
  8745. //right parameters are used.
  8746. if ( x > 2 ) {
  8747. sprintf(atcmd_msg, "%s %s", command, params);
  8748. break;
  8749. }
  8750. else if ( y > 2 ) {
  8751. sprintf(atcmd_msg, "%s %s", command, params2);
  8752. break;
  8753. }
  8754. //Regardless of what style the #command is used, if it's correct, it will always have
  8755. //this value if there is no parameter. Send it as just the #command
  8756. else if ( z == 2 ) {
  8757. sprintf(atcmd_msg, "%s", command);
  8758. break;
  8759. }
  8760. if( !pc_get_group_level(sd) ) {
  8761. if( x >= 1 || y >= 1 ) { /* we have command */
  8762. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8763. 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 */
  8764. return false;
  8765. } else
  8766. return false;/* display as normal message */
  8767. }
  8768. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8769. clif_displaymessage(fd, output);
  8770. return true;
  8771. } while(0);
  8772. }
  8773. else if (*message == atcommand_symbol) {
  8774. //atcmd_msg is constructed above differently for charcommands
  8775. //it's copied from message if not a charcommand so it can
  8776. //pass through the rest of the code compatible with both symbols
  8777. sprintf(atcmd_msg, "%s", message);
  8778. }
  8779. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8780. sd->idletime = last_tick;
  8781. //Clearing these to be used once more.
  8782. memset(command, '\0', sizeof(command));
  8783. memset(params, '\0', sizeof(params));
  8784. //check to see if any params exist within this command
  8785. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8786. params[0] = '\0';
  8787. // @commands (script based)
  8788. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8789. struct atcmd_binding_data * binding;
  8790. // Check if the command initiated is a character command
  8791. if (*message == charcommand_symbol &&
  8792. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8793. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8794. clif_displaymessage(fd, output);
  8795. return true;
  8796. }
  8797. // Get atcommand binding
  8798. binding = get_atcommandbind_byname(command);
  8799. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8800. if( binding != NULL && binding->npc_event[0] &&
  8801. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8802. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8803. {
  8804. // Check if self or character invoking; if self == character invoked, then self invoke.
  8805. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8806. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8807. return true;
  8808. }
  8809. }
  8810. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8811. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8812. if (info == NULL) {
  8813. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8814. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8815. clif_displaymessage(fd, output);
  8816. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8817. return true;
  8818. } else
  8819. return false;
  8820. }
  8821. //check restriction
  8822. if (info->restriction) {
  8823. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  8824. return true;
  8825. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  8826. return true;
  8827. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  8828. && ((*atcmd_msg == atcommand_symbol && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  8829. return true;
  8830. }
  8831. // type == 1 : player invoked
  8832. if (type == 1) {
  8833. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8834. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8835. return false;
  8836. }
  8837. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8838. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8839. return true;
  8840. }
  8841. }
  8842. // Check if target is valid only if confirmed that player can use command.
  8843. if (*message == charcommand_symbol &&
  8844. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8845. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8846. clif_displaymessage(fd, output);
  8847. return true;
  8848. }
  8849. //Attempt to use the command
  8850. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8851. {
  8852. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8853. clif_displaymessage(fd, output);
  8854. return true;
  8855. }
  8856. //Log only if successful.
  8857. if ( *atcmd_msg == atcommand_symbol )
  8858. log_atcommand(sd, atcmd_msg);
  8859. else if ( *atcmd_msg == charcommand_symbol )
  8860. log_atcommand(sd, message);
  8861. return true;
  8862. }
  8863. /*==========================================
  8864. *
  8865. *------------------------------------------*/
  8866. static void atcommand_config_read(const char* config_filename)
  8867. {
  8868. config_setting_t *aliases = NULL, *help = NULL;
  8869. const char *symbol = NULL;
  8870. int num_aliases = 0;
  8871. if (conf_read_file(&atcommand_config, config_filename))
  8872. return;
  8873. // Command symbols
  8874. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8875. if (ISPRINT(*symbol) && // no control characters
  8876. *symbol != '/' && // symbol of client commands
  8877. *symbol != '%' && // symbol of party chat
  8878. *symbol != '$' && // symbol of guild chat
  8879. *symbol != charcommand_symbol)
  8880. atcommand_symbol = *symbol;
  8881. }
  8882. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8883. if (ISPRINT(*symbol) && // no control characters
  8884. *symbol != '/' && // symbol of client commands
  8885. *symbol != '%' && // symbol of party chat
  8886. *symbol != '$' && // symbol of guild chat
  8887. *symbol != atcommand_symbol)
  8888. charcommand_symbol = *symbol;
  8889. }
  8890. // Command aliases
  8891. aliases = config_lookup(&atcommand_config, "aliases");
  8892. if (aliases != NULL) {
  8893. int i = 0;
  8894. int count = config_setting_length(aliases);
  8895. for (i = 0; i < count; ++i) {
  8896. config_setting_t *command;
  8897. const char *commandname = NULL;
  8898. int j = 0, alias_count = 0;
  8899. AtCommandInfo *commandinfo = NULL;
  8900. command = config_setting_get_elem(aliases, i);
  8901. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8902. continue;
  8903. commandname = config_setting_name(command);
  8904. if (!atcommand_exists(commandname)) {
  8905. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8906. continue;
  8907. }
  8908. commandinfo = get_atcommandinfo_byname(commandname);
  8909. alias_count = config_setting_length(command);
  8910. for (j = 0; j < alias_count; ++j) {
  8911. const char *alias = config_setting_get_string_elem(command, j);
  8912. if (alias != NULL) {
  8913. AliasInfo *alias_info;
  8914. if (strdb_exists(atcommand_alias_db, alias)) {
  8915. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8916. continue;
  8917. }
  8918. CREATE(alias_info, AliasInfo, 1);
  8919. alias_info->command = commandinfo;
  8920. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8921. strdb_put(atcommand_alias_db, alias, alias_info);
  8922. ++num_aliases;
  8923. }
  8924. }
  8925. }
  8926. }
  8927. // Commands help
  8928. // We only check if all commands exist
  8929. help = config_lookup(&atcommand_config, "help");
  8930. if (help != NULL) {
  8931. int count = config_setting_length(help);
  8932. int i;
  8933. for (i = 0; i < count; ++i) {
  8934. config_setting_t *command;
  8935. const char *commandname;
  8936. command = config_setting_get_elem(help, i);
  8937. commandname = config_setting_name(command);
  8938. if (!atcommand_exists(commandname))
  8939. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8940. }
  8941. }
  8942. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8943. return;
  8944. }
  8945. void atcommand_db_load_groups(int* group_ids) {
  8946. DBIterator *iter = db_iterator(atcommand_db);
  8947. AtCommandInfo* cmd;
  8948. int i;
  8949. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8950. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8951. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8952. for(i = 0; i < pc_group_max; i++) {
  8953. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8954. cmd->at_groups[i] = 1;
  8955. else
  8956. cmd->at_groups[i] = 0;
  8957. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8958. cmd->char_groups[i] = 1;
  8959. else
  8960. cmd->char_groups[i] = 0;
  8961. }
  8962. }
  8963. dbi_destroy(iter);
  8964. return;
  8965. }
  8966. void atcommand_db_clear(void) {
  8967. if (atcommand_db != NULL) {
  8968. DBIterator *iter = db_iterator(atcommand_db);
  8969. AtCommandInfo* cmd;
  8970. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8971. aFree(cmd->at_groups);
  8972. aFree(cmd->char_groups);
  8973. }
  8974. dbi_destroy(iter);
  8975. db_destroy(atcommand_db);
  8976. }
  8977. if (atcommand_alias_db != NULL)
  8978. db_destroy(atcommand_alias_db);
  8979. config_destroy(&atcommand_config);
  8980. }
  8981. void atcommand_doload(void) {
  8982. atcommand_db_clear();
  8983. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8984. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8985. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8986. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8987. }
  8988. void do_init_atcommand(void) {
  8989. atcommand_doload();
  8990. }
  8991. void do_final_atcommand(void) {
  8992. atcommand_db_clear();
  8993. }