atcommand.c 314 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496
  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 "script.h"
  30. #include "storage.h"
  31. #include "trade.h"
  32. #include "mapreg.h"
  33. #include "quest.h"
  34. #include "pc.h"
  35. #include <stdlib.h>
  36. #include <math.h>
  37. #define ATCOMMAND_LENGTH 50
  38. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  39. typedef struct AtCommandInfo AtCommandInfo;
  40. typedef struct AliasInfo AliasInfo;
  41. int atcmd_binding_count = 0;
  42. /// Atcommand restriction usage
  43. enum e_atcmd_restict {
  44. ATCMD_NOCONSOLE = 0x1, /// Cannot be used via console (is_atcommand type 2)
  45. ATCMD_NOSCRIPT = 0x2, /// Cannot be used via script command 'atcommand' or 'useatcmd' (is_atcommand type 0 and 3)
  46. ATCMD_NOAUTOTRADE = 0x4, /// Like ATCMD_NOSCRIPT, but if the player is autotrader. Example: atcommand "@kick "+strcharinfo(0);
  47. };
  48. struct AtCommandInfo {
  49. char command[ATCOMMAND_LENGTH];
  50. AtCommandFunc func;
  51. char* at_groups; /// Quick @commands "can-use" lookup
  52. char* char_groups; /// Quick @charcommands "can-use" lookup
  53. uint8 restriction; /// Restrictions see enum e_restict
  54. };
  55. struct AliasInfo {
  56. AtCommandInfo *command;
  57. char alias[ATCOMMAND_LENGTH];
  58. };
  59. char atcommand_symbol = '@'; // first char of the commands
  60. char charcommand_symbol = '#';
  61. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  62. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  63. static config_t atcommand_config;
  64. static char atcmd_output[CHAT_SIZE_MAX];
  65. static char atcmd_player_name[NAME_LENGTH];
  66. const char *parent_cmd;
  67. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  68. static const char* atcommand_checkalias(const char *aliasname); // @help
  69. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  70. static void warp_get_suggestions(struct map_session_data* sd, const char *name); // @rura, @warp, @mapmove
  71. // @commands (script-based)
  72. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  73. int i = 0;
  74. if( *name == atcommand_symbol || *name == charcommand_symbol )
  75. name++; // for backwards compatibility
  76. ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
  77. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  78. }
  79. /**
  80. * retrieves the help string associated with a given command.
  81. *
  82. * @param name the name of the command to retrieve help information for
  83. * @return the string associated with the command, or NULL
  84. */
  85. static const char* atcommand_help_string(const char* command)
  86. {
  87. const char* str = NULL;
  88. config_setting_t* info;
  89. if( *command == atcommand_symbol || *command == charcommand_symbol )
  90. {// remove the prefix symbol for the raw name of the command
  91. command ++;
  92. }
  93. // convert alias to the real command name
  94. command = atcommand_checkalias(command);
  95. // attempt to find the first default help command
  96. info = config_lookup(&atcommand_config, "help");
  97. if( info == NULL )
  98. {// failed to find the help property in the configuration file
  99. return NULL;
  100. }
  101. if( !config_setting_lookup_string( info, command, &str ) )
  102. {// failed to find the matching help string
  103. return NULL;
  104. }
  105. // push the result from the method
  106. return str;
  107. }
  108. /*==========================================
  109. * @send (used for testing packet sends from the client)
  110. *------------------------------------------*/
  111. ACMD_FUNC(send)
  112. {
  113. int len=0,type;
  114. // read message type as hex number (without the 0x)
  115. if(!message || !*message ||
  116. !((sscanf(message, "len %8x", &type)==1 && (len=1))
  117. || sscanf(message, "%8x", &type)==1) )
  118. {
  119. int i;
  120. for (i = 900; i <= 903; ++i)
  121. clif_displaymessage(fd, msg_txt(sd,i));
  122. return -1;
  123. }
  124. #define PARSE_ERROR(error,p) \
  125. {\
  126. clif_displaymessage(fd, (error));\
  127. sprintf(atcmd_output, ">%s", (p));\
  128. clif_displaymessage(fd, atcmd_output);\
  129. }
  130. //define PARSE_ERROR
  131. #define CHECK_EOS(p) \
  132. if(*(p) == 0){\
  133. clif_displaymessage(fd, "Unexpected end of string");\
  134. return -1;\
  135. }
  136. //define CHECK_EOS
  137. #define SKIP_VALUE(p) \
  138. {\
  139. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  140. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  141. }
  142. //define SKIP_VALUE
  143. #define GET_VALUE(p,num) \
  144. {\
  145. if(sscanf((p), "x%16lx", &(num)) < 1 && sscanf((p), "%20ld ", &(num)) < 1){\
  146. PARSE_ERROR("Invalid number in:",(p));\
  147. return -1;\
  148. }\
  149. }
  150. //define GET_VALUE
  151. if (type > 0 && type < MAX_PACKET_DB) {
  152. int off,end;
  153. long num;
  154. if(len)
  155. {// show packet length
  156. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  157. clif_displaymessage(fd, atcmd_output);
  158. return 0;
  159. }
  160. len=packet_db[sd->packet_ver][type].len;
  161. off=2;
  162. if(len == 0)
  163. {// unknown packet - ERROR
  164. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  165. clif_displaymessage(fd, atcmd_output);
  166. return -1;
  167. } else if(len == -1)
  168. {// dynamic packet
  169. len=SHRT_MAX-4; // maximum length
  170. off=4;
  171. }
  172. WFIFOHEAD(fd, len);
  173. WFIFOW(fd,0)=TOW(type);
  174. // parse packet contents
  175. SKIP_VALUE(message);
  176. while(*message != 0 && off < len){
  177. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  178. {// default (byte)
  179. GET_VALUE(message,num);
  180. WFIFOB(fd,off)=TOB(num);
  181. ++off;
  182. } else if(TOUPPER(*message) == 'B')
  183. {// byte
  184. ++message;
  185. GET_VALUE(message,num);
  186. WFIFOB(fd,off)=TOB(num);
  187. ++off;
  188. } else if(TOUPPER(*message) == 'W')
  189. {// word (2 bytes)
  190. ++message;
  191. GET_VALUE(message,num);
  192. WFIFOW(fd,off)=TOW(num);
  193. off+=2;
  194. } else if(TOUPPER(*message) == 'L')
  195. {// long word (4 bytes)
  196. ++message;
  197. GET_VALUE(message,num);
  198. WFIFOL(fd,off)=TOL(num);
  199. off+=4;
  200. } else if(TOUPPER(*message) == 'S')
  201. {// string - escapes are valid
  202. // get string length - num <= 0 means not fixed length (default)
  203. ++message;
  204. if(*message == '"'){
  205. num=0;
  206. } else {
  207. GET_VALUE(message,num);
  208. while(*message != '"')
  209. {// find start of string
  210. if(*message == 0 || ISSPACE(*message)){
  211. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  212. return -1;
  213. }
  214. ++message;
  215. }
  216. }
  217. // parse string
  218. ++message;
  219. CHECK_EOS(message);
  220. end=(num<=0? 0: min(off+((int)num),len));
  221. for(; *message != '"' && (off < end || end == 0); ++off){
  222. if(*message == '\\'){
  223. ++message;
  224. CHECK_EOS(message);
  225. switch(*message){
  226. case 'a': num=0x07; break; // Bell
  227. case 'b': num=0x08; break; // Backspace
  228. case 't': num=0x09; break; // Horizontal tab
  229. case 'n': num=0x0A; break; // Line feed
  230. case 'v': num=0x0B; break; // Vertical tab
  231. case 'f': num=0x0C; break; // Form feed
  232. case 'r': num=0x0D; break; // Carriage return
  233. case 'e': num=0x1B; break; // Escape
  234. default: num=*message; break;
  235. case 'x': // Hexadecimal
  236. {
  237. ++message;
  238. CHECK_EOS(message);
  239. if(!ISXDIGIT(*message)){
  240. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  241. return -1;
  242. }
  243. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  244. if(ISXDIGIT(*message)){
  245. ++message;
  246. CHECK_EOS(message);
  247. num<<=8;
  248. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  249. }
  250. WFIFOB(fd,off)=TOB(num);
  251. ++message;
  252. CHECK_EOS(message);
  253. continue;
  254. }
  255. case '0':
  256. case '1':
  257. case '2':
  258. case '3':
  259. case '4':
  260. case '5':
  261. case '6':
  262. case '7': // Octal
  263. {
  264. num=*message-'0'; // 1st octal digit
  265. ++message;
  266. CHECK_EOS(message);
  267. if(ISDIGIT(*message) && *message < '8'){
  268. num<<=3;
  269. num+=*message-'0'; // 2nd octal digit
  270. ++message;
  271. CHECK_EOS(message);
  272. if(ISDIGIT(*message) && *message < '8'){
  273. num<<=3;
  274. num+=*message-'0'; // 3rd octal digit
  275. ++message;
  276. CHECK_EOS(message);
  277. }
  278. }
  279. WFIFOB(fd,off)=TOB(num);
  280. continue;
  281. }
  282. }
  283. } else
  284. num=*message;
  285. WFIFOB(fd,off)=TOB(num);
  286. ++message;
  287. CHECK_EOS(message);
  288. }//for
  289. while(*message != '"')
  290. {// ignore extra characters
  291. ++message;
  292. CHECK_EOS(message);
  293. }
  294. // terminate the string
  295. if(off < end)
  296. {// fill the rest with 0's
  297. memset(WFIFOP(fd,off),0,end-off);
  298. off=end;
  299. }
  300. } else
  301. {// unknown
  302. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  303. return -1;
  304. }
  305. SKIP_VALUE(message);
  306. }
  307. if(packet_db[sd->packet_ver][type].len == -1)
  308. {// send dynamic packet
  309. WFIFOW(fd,2)=TOW(off);
  310. WFIFOSET(fd,off);
  311. } else
  312. {// send static packet
  313. if(off < len)
  314. memset(WFIFOP(fd,off),0,len-off);
  315. WFIFOSET(fd,len);
  316. }
  317. } else {
  318. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  319. return -1;
  320. }
  321. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  322. clif_displaymessage(fd, atcmd_output);
  323. return 0;
  324. #undef PARSE_ERROR
  325. #undef CHECK_EOS
  326. #undef SKIP_VALUE
  327. #undef GET_VALUE
  328. }
  329. /**
  330. * Retrieves map name suggestions for a given string.
  331. * This will first check if any map names contain the given string, and will
  332. * print out MAX_SUGGESTIONS results if any maps are found.
  333. * Otherwise, suggestions will be calculated through Levenshtein distance,
  334. * and up to 5 of the closest matches will be printed.
  335. *
  336. * @author Euphy
  337. */
  338. static void warp_get_suggestions(struct map_session_data* sd, const char *name) {
  339. char buffer[512];
  340. int i, count = 0;
  341. if (strlen(name) < 2)
  342. return;
  343. // build the suggestion string
  344. strcpy(buffer, msg_txt(sd, 205)); // Maybe you meant:
  345. strcat(buffer, "\n");
  346. // check for maps that contain string
  347. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  348. if (count < MAX_SUGGESTIONS && strstr(map[i].name, name) != NULL) {
  349. strcat(buffer, map[i].name);
  350. strcat(buffer, " ");
  351. if (++count >= MAX_SUGGESTIONS)
  352. break;
  353. }
  354. }
  355. // if no maps found, search by edit distance
  356. if (!count) {
  357. unsigned int distance[MAX_MAP_PER_SERVER][2];
  358. int j;
  359. // calculate Levenshtein distance for all maps
  360. for (i = 0; i < MAX_MAP_PER_SERVER; i++) {
  361. if (strlen(map[i].name) < 4) // invalid map name?
  362. distance[i][0] = INT_MAX;
  363. else {
  364. distance[i][0] = levenshtein(map[i].name, name);
  365. distance[i][1] = i;
  366. }
  367. }
  368. // selection sort elements as needed
  369. count = min(MAX_SUGGESTIONS, 5); // results past 5 aren't worth showing
  370. for (i = 0; i < count; i++) {
  371. int min = i;
  372. for (j = i+1; j < MAX_MAP_PER_SERVER; j++) {
  373. if (distance[j][0] < distance[min][0])
  374. min = j;
  375. }
  376. // print map name
  377. if (distance[min][0] > 4) { // awful results, don't bother
  378. if (!i) return;
  379. break;
  380. }
  381. strcat(buffer, map[distance[min][1]].name);
  382. strcat(buffer, " ");
  383. // swap elements
  384. swap(distance[i][0], distance[min][0]);
  385. swap(distance[i][1], distance[min][1]);
  386. }
  387. }
  388. clif_displaymessage(sd->fd, buffer);
  389. }
  390. /*==========================================
  391. * @rura, @warp, @mapmove
  392. *------------------------------------------*/
  393. ACMD_FUNC(mapmove)
  394. {
  395. char map_name[MAP_NAME_LENGTH_EXT];
  396. unsigned short mapindex;
  397. short x = 0, y = 0;
  398. int16 m = -1;
  399. nullpo_retr(-1, sd);
  400. memset(map_name, '\0', sizeof(map_name));
  401. if (!message || !*message ||
  402. (sscanf(message, "%15s %6hd %6hd", map_name, &x, &y) < 3 &&
  403. sscanf(message, "%15[^,],%6hd,%6hd", map_name, &x, &y) < 1)) {
  404. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  405. return -1;
  406. }
  407. mapindex = mapindex_name2id(map_name);
  408. if (mapindex)
  409. m = map_mapindex2mapid(mapindex);
  410. if (!mapindex) { // m < 0 means on different server! [Kevin]
  411. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  412. if (battle_config.warp_suggestions_enabled)
  413. warp_get_suggestions(sd, map_name);
  414. return -1;
  415. }
  416. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  417. { //This is to prevent the pc_setpos call from printing an error.
  418. clif_displaymessage(fd, msg_txt(sd,2));
  419. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  420. x = y = 0; //Invalid cell, use random spot.
  421. }
  422. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  423. clif_displaymessage(fd, msg_txt(sd,247));
  424. return -1;
  425. }
  426. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  427. clif_displaymessage(fd, msg_txt(sd,248));
  428. return -1;
  429. }
  430. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  431. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  432. return -1;
  433. }
  434. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  435. return 0;
  436. }
  437. /*==========================================
  438. * Displays where a character is. Corrected version by Silent. [Skotlex]
  439. *------------------------------------------*/
  440. ACMD_FUNC(where)
  441. {
  442. struct map_session_data* pl_sd;
  443. nullpo_retr(-1, sd);
  444. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  445. if (!message || !*message || sscanf(message, "%23s[^\n]", atcmd_player_name) < 1) {
  446. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  447. return -1;
  448. }
  449. pl_sd = map_nick2sd(atcmd_player_name);
  450. if (pl_sd == NULL ||
  451. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  452. (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))
  453. ) {
  454. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  455. return -1;
  456. }
  457. 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);
  458. clif_displaymessage(fd, atcmd_output);
  459. return 0;
  460. }
  461. /*==========================================
  462. *
  463. *------------------------------------------*/
  464. ACMD_FUNC(jumpto)
  465. {
  466. struct map_session_data *pl_sd = NULL;
  467. nullpo_retr(-1, sd);
  468. if (!message || !*message) {
  469. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  470. return -1;
  471. }
  472. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  473. {
  474. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  475. return -1;
  476. }
  477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  478. {
  479. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  480. return -1;
  481. }
  482. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  483. {
  484. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  485. return -1;
  486. }
  487. if( pc_isdead(sd) )
  488. {
  489. clif_displaymessage(fd, msg_txt(sd,664));
  490. return -1;
  491. }
  492. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  493. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  494. clif_displaymessage(fd, atcmd_output);
  495. return 0;
  496. }
  497. /*==========================================
  498. *
  499. *------------------------------------------*/
  500. ACMD_FUNC(jump)
  501. {
  502. short x = 0, y = 0;
  503. nullpo_retr(-1, sd);
  504. memset(atcmd_output, '\0', sizeof(atcmd_output));
  505. sscanf(message, "%6hd %6hd", &x, &y);
  506. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  507. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  508. return -1;
  509. }
  510. if( pc_isdead(sd) )
  511. {
  512. clif_displaymessage(fd, msg_txt(sd,664));
  513. return -1;
  514. }
  515. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  516. { //This is to prevent the pc_setpos call from printing an error.
  517. clif_displaymessage(fd, msg_txt(sd,2));
  518. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  519. x = y = 0; //Invalid cell, use random spot.
  520. }
  521. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  522. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  523. clif_displaymessage(fd, atcmd_output);
  524. return 0;
  525. }
  526. /*==========================================
  527. * Display list of online characters with
  528. * various info.
  529. *------------------------------------------*/
  530. ACMD_FUNC(who) {
  531. struct map_session_data *pl_sd = NULL;
  532. struct s_mapiterator *iter = NULL;
  533. char player_name[NAME_LENGTH] = "";
  534. int count = 0;
  535. int level = 0;
  536. StringBuf buf;
  537. /**
  538. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  539. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  540. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  541. */
  542. int display_type = 1;
  543. int map_id = -1;
  544. nullpo_retr(-1, sd);
  545. if (strstr(command, "map") != NULL) {
  546. char map_name[MAP_NAME_LENGTH_EXT] = "";
  547. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  548. map_id = sd->bl.m;
  549. } else {
  550. sscanf(message, "%23s", player_name);
  551. }
  552. if (strstr(command, "2") != NULL)
  553. display_type = 2;
  554. else if (strstr(command, "3") != NULL)
  555. display_type = 3;
  556. level = pc_get_group_level(sd);
  557. StringBuf_Init(&buf);
  558. iter = mapit_getallusers();
  559. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  560. 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
  561. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  562. || (map_id >= 0 && pl_sd->bl.m != map_id))
  563. continue;
  564. switch (display_type) {
  565. case 2: {
  566. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  567. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  568. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  569. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  570. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  571. break;
  572. }
  573. case 3: {
  574. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  575. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  576. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  577. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  578. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  579. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  580. break;
  581. }
  582. default: {
  583. struct party_data *p = party_search(pl_sd->status.party_id);
  584. struct guild *g = pl_sd->guild;
  585. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  586. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  587. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  588. if (p != NULL)
  589. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  590. if (g != NULL)
  591. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  592. break;
  593. }
  594. }
  595. clif_displaymessage(fd, StringBuf_Value(&buf));
  596. StringBuf_Clear(&buf);
  597. count++;
  598. }
  599. }
  600. mapit_free(iter);
  601. if (map_id < 0) {
  602. if (count == 0)
  603. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  604. else if (count == 1)
  605. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  606. else
  607. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  608. } else {
  609. if (count == 0)
  610. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  611. else if (count == 1)
  612. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  613. else
  614. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  615. }
  616. clif_displaymessage(fd, StringBuf_Value(&buf));
  617. StringBuf_Destroy(&buf);
  618. return 0;
  619. }
  620. /*==========================================
  621. *
  622. *------------------------------------------*/
  623. ACMD_FUNC(whogm)
  624. {
  625. struct map_session_data* pl_sd;
  626. struct s_mapiterator* iter;
  627. int j, count;
  628. int level;
  629. char match_text[CHAT_SIZE_MAX];
  630. char player_name[NAME_LENGTH];
  631. struct guild *g;
  632. struct party_data *p;
  633. nullpo_retr(-1, sd);
  634. memset(atcmd_output, '\0', sizeof(atcmd_output));
  635. memset(match_text, '\0', sizeof(match_text));
  636. memset(player_name, '\0', sizeof(player_name));
  637. if (sscanf(message, "%255[^\n]", match_text) < 1)
  638. strcpy(match_text, "");
  639. for (j = 0; match_text[j]; j++)
  640. match_text[j] = TOLOWER(match_text[j]);
  641. count = 0;
  642. level = pc_get_group_level(sd);
  643. iter = mapit_getallusers();
  644. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  645. {
  646. int pl_level = pc_get_group_level(pl_sd);
  647. if (!pl_level)
  648. continue;
  649. if (match_text[0])
  650. {
  651. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  652. for (j = 0; player_name[j]; j++)
  653. player_name[j] = TOLOWER(player_name[j]);
  654. // search with no case sensitive
  655. if (strstr(player_name, match_text) == NULL)
  656. continue;
  657. }
  658. if (pl_level > level) {
  659. if (pl_sd->sc.option & OPTION_INVISIBLE)
  660. continue;
  661. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  662. clif_displaymessage(fd, atcmd_output);
  663. count++;
  664. continue;
  665. }
  666. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  667. pl_sd->status.name, pl_level,
  668. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  669. clif_displaymessage(fd, atcmd_output);
  670. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  671. pl_sd->status.base_level,
  672. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  673. clif_displaymessage(fd, atcmd_output);
  674. p = party_search(pl_sd->status.party_id);
  675. g = pl_sd->guild;
  676. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  677. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  678. clif_displaymessage(fd, atcmd_output);
  679. count++;
  680. }
  681. mapit_free(iter);
  682. if (count == 0)
  683. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  684. else if (count == 1)
  685. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  686. else {
  687. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  688. clif_displaymessage(fd, atcmd_output);
  689. }
  690. return 0;
  691. }
  692. /*==========================================
  693. *
  694. *------------------------------------------*/
  695. ACMD_FUNC(save)
  696. {
  697. nullpo_retr(-1, sd);
  698. if( map[sd->bl.m].instance_id ) {
  699. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  700. return 1;
  701. }
  702. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  703. if (sd->status.pet_id > 0 && sd->pd)
  704. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  705. chrif_save(sd,0);
  706. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  707. return 0;
  708. }
  709. /*==========================================
  710. *
  711. *------------------------------------------*/
  712. ACMD_FUNC(load)
  713. {
  714. int16 m;
  715. nullpo_retr(-1, sd);
  716. m = map_mapindex2mapid(sd->status.save_point.map);
  717. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  718. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  719. return -1;
  720. }
  721. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  722. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  723. return -1;
  724. }
  725. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  726. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  727. return 0;
  728. }
  729. /*==========================================
  730. *
  731. *------------------------------------------*/
  732. ACMD_FUNC(speed)
  733. {
  734. short speed;
  735. nullpo_retr(-1, sd);
  736. memset(atcmd_output, '\0', sizeof(atcmd_output));
  737. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  738. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  739. clif_displaymessage(fd, atcmd_output);
  740. return -1;
  741. }
  742. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  743. if (speed < 0)
  744. sd->base_status.speed = DEFAULT_WALK_SPEED;
  745. else
  746. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  747. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  748. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  749. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  750. } else
  751. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  752. status_calc_bl(&sd->bl, SCB_SPEED);
  753. return 0;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD_FUNC(storage)
  759. {
  760. nullpo_retr(-1, sd);
  761. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  762. return -1;
  763. if (storage_storageopen(sd) == 1)
  764. { //Already open.
  765. clif_displaymessage(fd, msg_txt(sd,250));
  766. return -1;
  767. }
  768. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  769. return 0;
  770. }
  771. /*==========================================
  772. *
  773. *------------------------------------------*/
  774. ACMD_FUNC(guildstorage)
  775. {
  776. nullpo_retr(-1, sd);
  777. if (!sd->status.guild_id) {
  778. clif_displaymessage(fd, msg_txt(sd,252));
  779. return -1;
  780. }
  781. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  782. return -1;
  783. if (sd->state.storage_flag == 1) {
  784. clif_displaymessage(fd, msg_txt(sd,250));
  785. return -1;
  786. }
  787. if (sd->state.storage_flag == 2) {
  788. clif_displaymessage(fd, msg_txt(sd,251));
  789. return -1;
  790. }
  791. gstorage_storageopen(sd);
  792. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  793. return 0;
  794. }
  795. /*==========================================
  796. *
  797. *------------------------------------------*/
  798. ACMD_FUNC(option)
  799. {
  800. int param1 = 0, param2 = 0, param3 = 0;
  801. nullpo_retr(-1, sd);
  802. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  803. {// failed to match the parameters so inform the user of the options
  804. const char* text;
  805. // attempt to find the setting information for this command
  806. text = atcommand_help_string( command );
  807. // notify the user of the requirement to enter an option
  808. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  809. if( text )
  810. {// send the help text associated with this command
  811. clif_displaymessage( fd, text );
  812. }
  813. return -1;
  814. }
  815. sd->sc.opt1 = param1;
  816. sd->sc.opt2 = param2;
  817. pc_setoption(sd, param3);
  818. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  819. return 0;
  820. }
  821. /*==========================================
  822. *
  823. *------------------------------------------*/
  824. ACMD_FUNC(hide)
  825. {
  826. nullpo_retr(-1, sd);
  827. if (sd->sc.option & OPTION_INVISIBLE) {
  828. sd->sc.option &= ~OPTION_INVISIBLE;
  829. if (sd->disguise)
  830. status_set_viewdata(&sd->bl, sd->disguise);
  831. else
  832. status_set_viewdata(&sd->bl, sd->status.class_);
  833. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  834. // increment the number of pvp players on the map
  835. map[sd->bl.m].users_pvp++;
  836. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  837. {// register the player for ranking calculations
  838. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  839. }
  840. //bugreport:2266
  841. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  842. } else {
  843. sd->sc.option |= OPTION_INVISIBLE;
  844. sd->vd.class_ = INVISIBLE_CLASS;
  845. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  846. // decrement the number of pvp players on the map
  847. map[sd->bl.m].users_pvp--;
  848. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  849. {// unregister the player for ranking
  850. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  851. sd->pvp_timer = INVALID_TIMER;
  852. }
  853. }
  854. clif_changeoption(&sd->bl);
  855. return 0;
  856. }
  857. /*==========================================
  858. * Changes a character's class
  859. *------------------------------------------*/
  860. ACMD_FUNC(jobchange)
  861. {
  862. int job = 0, upper = 0;
  863. const char* text;
  864. nullpo_retr(-1, sd);
  865. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  866. int i;
  867. bool found = false;
  868. upper = 0;
  869. // Normal Jobs
  870. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  871. if (strncmpi(message, job_name(i), 16) == 0) {
  872. job = i;
  873. found = true;
  874. }
  875. }
  876. // High Jobs, Babys and Third
  877. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  878. if (strncmpi(message, job_name(i), 16) == 0) {
  879. job = i;
  880. found = true;
  881. }
  882. }
  883. if (!found) {
  884. text = atcommand_help_string(command);
  885. if (text)
  886. clif_displaymessage(fd, text);
  887. return -1;
  888. }
  889. }
  890. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  891. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  892. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  893. { // Deny direct transformation into dummy jobs
  894. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  895. return 0;
  896. }
  897. if (pcdb_checkid(job))
  898. {
  899. if (pc_jobchange(sd, job, upper))
  900. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  901. else {
  902. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  903. return -1;
  904. }
  905. } else {
  906. text = atcommand_help_string(command);
  907. if (text)
  908. clif_displaymessage(fd, text);
  909. return -1;
  910. }
  911. return 0;
  912. }
  913. /*==========================================
  914. *
  915. *------------------------------------------*/
  916. ACMD_FUNC(kill)
  917. {
  918. nullpo_retr(-1, sd);
  919. status_kill(&sd->bl);
  920. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  921. if (fd != sd->fd)
  922. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  923. return 0;
  924. }
  925. /*==========================================
  926. *
  927. *------------------------------------------*/
  928. ACMD_FUNC(alive)
  929. {
  930. nullpo_retr(-1, sd);
  931. if (!status_revive(&sd->bl, 100, 100))
  932. {
  933. clif_displaymessage(fd, msg_txt(sd,667));
  934. return -1;
  935. }
  936. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  937. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  938. return 0;
  939. }
  940. /*==========================================
  941. * +kamic [LuzZza]
  942. *------------------------------------------*/
  943. ACMD_FUNC(kami)
  944. {
  945. unsigned long color=0;
  946. nullpo_retr(-1, sd);
  947. memset(atcmd_output, '\0', sizeof(atcmd_output));
  948. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  949. if (!message || !*message) {
  950. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  951. return -1;
  952. }
  953. sscanf(message, "%255[^\n]", atcmd_output);
  954. if (strstr(command, "l") != NULL)
  955. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  956. else
  957. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  958. } else {
  959. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  960. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  961. return -1;
  962. }
  963. if(color > 0xFFFFFF) {
  964. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  965. return -1;
  966. }
  967. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  968. }
  969. return 0;
  970. }
  971. /*==========================================
  972. *
  973. *------------------------------------------*/
  974. ACMD_FUNC(heal)
  975. {
  976. int hp = 0, sp = 0; // [Valaris] thanks to fov
  977. nullpo_retr(-1, sd);
  978. sscanf(message, "%11d %11d", &hp, &sp);
  979. // some overflow checks
  980. if( hp == INT_MIN ) hp++;
  981. if( sp == INT_MIN ) sp++;
  982. if ( hp == 0 && sp == 0 ) {
  983. if (!status_percent_heal(&sd->bl, 100, 100))
  984. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  985. else
  986. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  987. return 0;
  988. }
  989. if ( hp > 0 && sp >= 0 ) {
  990. if(!status_heal(&sd->bl, hp, sp, 0))
  991. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  992. else
  993. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  994. return 0;
  995. }
  996. if ( hp < 0 && sp <= 0 ) {
  997. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  998. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  999. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1000. return 0;
  1001. }
  1002. //Opposing signs.
  1003. if ( hp ) {
  1004. if (hp > 0)
  1005. status_heal(&sd->bl, hp, 0, 0);
  1006. else {
  1007. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1008. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1009. }
  1010. }
  1011. if ( sp ) {
  1012. if (sp > 0)
  1013. status_heal(&sd->bl, 0, sp, 0);
  1014. else
  1015. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1016. }
  1017. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1018. return 0;
  1019. }
  1020. /*==========================================
  1021. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1022. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1023. *------------------------------------------*/
  1024. ACMD_FUNC(item)
  1025. {
  1026. char item_name[100];
  1027. int number = 0, bound = BOUND_NONE;
  1028. char flag = 0;
  1029. struct item item_tmp;
  1030. struct item_data *item_data[10];
  1031. int get_count, i, j=0;
  1032. char *itemlist;
  1033. nullpo_retr(-1, sd);
  1034. memset(item_name, '\0', sizeof(item_name));
  1035. parent_cmd = atcommand_checkalias(command+1);
  1036. if (!strcmpi(parent_cmd,"itembound")) {
  1037. if (!message || !*message || (
  1038. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1039. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1040. {
  1041. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1042. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1043. return -1;
  1044. }
  1045. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1046. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1047. return -1;
  1048. }
  1049. } else if (!message || !*message || (
  1050. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1051. sscanf(message, "%99s %11d", item_name, &number) < 1
  1052. )) {
  1053. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1054. return -1;
  1055. }
  1056. itemlist = strtok(item_name, ":");
  1057. while (itemlist != NULL && j<10) {
  1058. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1059. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1060. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1061. return -1;
  1062. }
  1063. itemlist = strtok(NULL, ":"); //next itemline
  1064. j++;
  1065. }
  1066. if (number <= 0)
  1067. number = 1;
  1068. get_count = number;
  1069. for(j--; j>=0; j--){ //produce items in list
  1070. unsigned short item_id = item_data[j]->nameid;
  1071. //Check if it's stackable.
  1072. if (!itemdb_isstackable2(item_data[j]))
  1073. get_count = 1;
  1074. for (i = 0; i < number; i += get_count) {
  1075. // if not pet egg
  1076. if (!pet_create_egg(sd, item_id)) {
  1077. memset(&item_tmp, 0, sizeof(item_tmp));
  1078. item_tmp.nameid = item_id;
  1079. item_tmp.identify = 1;
  1080. item_tmp.bound = bound;
  1081. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1082. clif_additem(sd, 0, 0, flag);
  1083. }
  1084. }
  1085. }
  1086. if (flag == 0)
  1087. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1088. return 0;
  1089. }
  1090. /*==========================================
  1091. *
  1092. *------------------------------------------*/
  1093. ACMD_FUNC(item2)
  1094. {
  1095. struct item item_tmp;
  1096. struct item_data *item_data;
  1097. char item_name[100];
  1098. unsigned short item_id;
  1099. int number = 0, bound = BOUND_NONE;
  1100. int identify = 0, refine = 0, attr = 0;
  1101. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1102. nullpo_retr(-1, sd);
  1103. memset(item_name, '\0', sizeof(item_name));
  1104. parent_cmd = atcommand_checkalias(command+1);
  1105. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1106. if (!message || !*message || (
  1107. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1108. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1109. {
  1110. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1111. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1112. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1113. return -1;
  1114. }
  1115. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1116. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1117. return -1;
  1118. }
  1119. } else if ( !message || !*message || (
  1120. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1121. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1122. )) {
  1123. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1124. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1125. return -1;
  1126. }
  1127. if (number <= 0)
  1128. number = 1;
  1129. item_id = 0;
  1130. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1131. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1132. item_id = item_data->nameid;
  1133. if (item_id > 500) {
  1134. int loop, get_count, i;
  1135. char flag = 0;
  1136. loop = 1;
  1137. get_count = number;
  1138. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1139. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1140. loop = number;
  1141. get_count = 1;
  1142. if (item_data->type == IT_PETEGG) {
  1143. identify = 1;
  1144. refine = 0;
  1145. }
  1146. if (item_data->type == IT_PETARMOR)
  1147. refine = 0;
  1148. if (refine > MAX_REFINE)
  1149. refine = MAX_REFINE;
  1150. } else {
  1151. identify = 1;
  1152. refine = attr = 0;
  1153. }
  1154. for (i = 0; i < loop; i++) {
  1155. memset(&item_tmp, 0, sizeof(item_tmp));
  1156. item_tmp.nameid = item_id;
  1157. item_tmp.identify = identify;
  1158. item_tmp.refine = refine;
  1159. item_tmp.attribute = attr;
  1160. item_tmp.card[0] = c1;
  1161. item_tmp.card[1] = c2;
  1162. item_tmp.card[2] = c3;
  1163. item_tmp.card[3] = c4;
  1164. item_tmp.bound = bound;
  1165. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1166. clif_additem(sd, 0, 0, flag);
  1167. }
  1168. if (flag == 0)
  1169. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1170. } else {
  1171. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1172. return -1;
  1173. }
  1174. return 0;
  1175. }
  1176. /*==========================================
  1177. *
  1178. *------------------------------------------*/
  1179. ACMD_FUNC(itemreset)
  1180. {
  1181. int i;
  1182. nullpo_retr(-1, sd);
  1183. for (i = 0; i < MAX_INVENTORY; i++) {
  1184. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1185. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1186. }
  1187. }
  1188. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1189. return 0;
  1190. }
  1191. /*==========================================
  1192. * Atcommand @lvlup
  1193. *------------------------------------------*/
  1194. ACMD_FUNC(baselevelup)
  1195. {
  1196. int level=0, i=0, status_point=0;
  1197. nullpo_retr(-1, sd);
  1198. level = atoi(message);
  1199. if (!message || !*message || !level) {
  1200. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1201. return -1;
  1202. }
  1203. if (level > 0) {
  1204. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1205. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1206. return -1;
  1207. } // End Addition
  1208. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1209. level = pc_maxbaselv(sd) - sd->status.base_level;
  1210. for (i = 0; i < level; i++)
  1211. status_point += pc_gets_status_point(sd->status.base_level + i);
  1212. sd->status.status_point += status_point;
  1213. sd->status.base_level += (unsigned int)level;
  1214. status_calc_pc(sd, SCO_FORCE);
  1215. status_percent_heal(&sd->bl, 100, 100);
  1216. clif_misceffect(&sd->bl, 0);
  1217. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1218. } else {
  1219. if (sd->status.base_level == 1) {
  1220. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1221. return -1;
  1222. }
  1223. level*=-1;
  1224. if ((unsigned int)level >= sd->status.base_level)
  1225. level = sd->status.base_level-1;
  1226. for (i = 0; i > -level; i--)
  1227. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1228. if (sd->status.status_point < status_point)
  1229. pc_resetstate(sd);
  1230. if (sd->status.status_point < status_point)
  1231. sd->status.status_point = 0;
  1232. else
  1233. sd->status.status_point -= status_point;
  1234. sd->status.base_level -= (unsigned int)level;
  1235. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1236. status_calc_pc(sd, SCO_FORCE);
  1237. }
  1238. sd->status.base_exp = 0;
  1239. clif_updatestatus(sd, SP_STATUSPOINT);
  1240. clif_updatestatus(sd, SP_BASELEVEL);
  1241. clif_updatestatus(sd, SP_BASEEXP);
  1242. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1243. pc_baselevelchanged(sd);
  1244. if(sd->status.party_id)
  1245. party_send_levelup(sd);
  1246. return 0;
  1247. }
  1248. /*==========================================
  1249. *
  1250. *------------------------------------------*/
  1251. ACMD_FUNC(joblevelup)
  1252. {
  1253. int level=0;
  1254. nullpo_retr(-1, sd);
  1255. level = atoi(message);
  1256. if (!message || !*message || !level) {
  1257. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1258. return -1;
  1259. }
  1260. if (level > 0) {
  1261. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1262. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1263. return -1;
  1264. }
  1265. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1266. level = pc_maxjoblv(sd) - sd->status.job_level;
  1267. sd->status.job_level += (unsigned int)level;
  1268. sd->status.skill_point += level;
  1269. clif_misceffect(&sd->bl, 1);
  1270. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1271. } else {
  1272. if (sd->status.job_level == 1) {
  1273. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1274. return -1;
  1275. }
  1276. level *=-1;
  1277. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1278. level = sd->status.job_level-1;
  1279. sd->status.job_level -= (unsigned int)level;
  1280. if (sd->status.skill_point < level)
  1281. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1282. if (sd->status.skill_point < level)
  1283. sd->status.skill_point = 0;
  1284. else
  1285. sd->status.skill_point -= level;
  1286. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1287. }
  1288. sd->status.job_exp = 0;
  1289. clif_updatestatus(sd, SP_JOBLEVEL);
  1290. clif_updatestatus(sd, SP_JOBEXP);
  1291. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1292. clif_updatestatus(sd, SP_SKILLPOINT);
  1293. status_calc_pc(sd, SCO_FORCE);
  1294. return 0;
  1295. }
  1296. /*==========================================
  1297. * @help
  1298. *------------------------------------------*/
  1299. ACMD_FUNC(help)
  1300. {
  1301. config_setting_t *help;
  1302. const char *text = NULL;
  1303. const char *command_name = NULL;
  1304. char *default_command = "help";
  1305. nullpo_retr(-1, sd);
  1306. help = config_lookup(&atcommand_config, "help");
  1307. if (help == NULL) {
  1308. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1309. return -1;
  1310. }
  1311. if (!message || !*message) {
  1312. command_name = default_command; // If no command_name specified, display help for @help.
  1313. } else {
  1314. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1315. ++message;
  1316. command_name = atcommand_checkalias(message);
  1317. }
  1318. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1319. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1320. clif_displaymessage(fd, atcmd_output);
  1321. atcommand_get_suggestions(sd, command_name, true);
  1322. return -1;
  1323. }
  1324. if (!config_setting_lookup_string(help, command_name, &text)) {
  1325. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1326. clif_displaymessage(fd, atcmd_output);
  1327. atcommand_get_suggestions(sd, command_name, true);
  1328. return -1;
  1329. }
  1330. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1331. clif_displaymessage(fd, atcmd_output);
  1332. { // Display aliases
  1333. DBIterator* iter;
  1334. AtCommandInfo *command_info;
  1335. AliasInfo *alias_info = NULL;
  1336. StringBuf buf;
  1337. bool has_aliases = false;
  1338. StringBuf_Init(&buf);
  1339. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1340. command_info = get_atcommandinfo_byname(command_name);
  1341. iter = db_iterator(atcommand_alias_db);
  1342. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1343. if (alias_info->command == command_info) {
  1344. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1345. has_aliases = true;
  1346. }
  1347. }
  1348. dbi_destroy(iter);
  1349. if (has_aliases)
  1350. clif_displaymessage(fd, StringBuf_Value(&buf));
  1351. StringBuf_Destroy(&buf);
  1352. }
  1353. // Display help contents
  1354. clif_displaymessage(fd, text);
  1355. return 0;
  1356. }
  1357. // helper function, used in foreach calls to stop auto-attack timers
  1358. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1359. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1360. {
  1361. struct unit_data *ud = unit_bl2ud(bl);
  1362. int id = va_arg(ap, int);
  1363. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1364. {
  1365. unit_stop_attack(bl);
  1366. return 1;
  1367. }
  1368. return 0;
  1369. }
  1370. /*==========================================
  1371. *
  1372. *------------------------------------------*/
  1373. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1374. {
  1375. TBL_PC* sd = (TBL_PC*)bl;
  1376. clif_pvpset(sd, 0, 0, 2);
  1377. if (sd->pvp_timer != INVALID_TIMER) {
  1378. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1379. sd->pvp_timer = INVALID_TIMER;
  1380. }
  1381. return 0;
  1382. }
  1383. ACMD_FUNC(pvpoff)
  1384. {
  1385. nullpo_retr(-1, sd);
  1386. if (!map[sd->bl.m].flag.pvp) {
  1387. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1388. return -1;
  1389. }
  1390. map[sd->bl.m].flag.pvp = 0;
  1391. if (!battle_config.pk_mode){
  1392. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1393. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1394. }
  1395. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1396. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1397. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1398. return 0;
  1399. }
  1400. /*==========================================
  1401. *
  1402. *------------------------------------------*/
  1403. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1404. {
  1405. TBL_PC* sd = (TBL_PC*)bl;
  1406. if (sd->pvp_timer == INVALID_TIMER) {
  1407. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1408. sd->pvp_rank = 0;
  1409. sd->pvp_lastusers = 0;
  1410. sd->pvp_point = 5;
  1411. sd->pvp_won = 0;
  1412. sd->pvp_lost = 0;
  1413. }
  1414. return 0;
  1415. }
  1416. ACMD_FUNC(pvpon)
  1417. {
  1418. nullpo_retr(-1, sd);
  1419. if (map[sd->bl.m].flag.pvp) {
  1420. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1421. return -1;
  1422. }
  1423. map[sd->bl.m].flag.pvp = 1;
  1424. if (!battle_config.pk_mode) {// display pvp circle and rank
  1425. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1426. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1427. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1428. }
  1429. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1430. return 0;
  1431. }
  1432. /*==========================================
  1433. *
  1434. *------------------------------------------*/
  1435. ACMD_FUNC(gvgoff)
  1436. {
  1437. nullpo_retr(-1, sd);
  1438. if (!map[sd->bl.m].flag.gvg) {
  1439. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1440. return -1;
  1441. }
  1442. map[sd->bl.m].flag.gvg = 0;
  1443. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1444. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1445. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1446. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1447. return 0;
  1448. }
  1449. /*==========================================
  1450. *
  1451. *------------------------------------------*/
  1452. ACMD_FUNC(gvgon)
  1453. {
  1454. nullpo_retr(-1, sd);
  1455. if (map[sd->bl.m].flag.gvg) {
  1456. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1457. return -1;
  1458. }
  1459. map[sd->bl.m].flag.gvg = 1;
  1460. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1461. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1462. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1463. return 0;
  1464. }
  1465. /*==========================================
  1466. *
  1467. *------------------------------------------*/
  1468. ACMD_FUNC(model)
  1469. {
  1470. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1471. nullpo_retr(-1, sd);
  1472. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1473. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1474. 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>).
  1475. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1476. clif_displaymessage(fd, atcmd_output);
  1477. return -1;
  1478. }
  1479. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1480. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1481. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1482. pc_changelook(sd, LOOK_HAIR, hair_style);
  1483. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1484. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1485. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1486. } else {
  1487. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1488. return -1;
  1489. }
  1490. return 0;
  1491. }
  1492. /*==========================================
  1493. * @dye && @ccolor
  1494. *------------------------------------------*/
  1495. ACMD_FUNC(dye)
  1496. {
  1497. int cloth_color = 0;
  1498. nullpo_retr(-1, sd);
  1499. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1500. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1501. 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>).
  1502. clif_displaymessage(fd, atcmd_output);
  1503. return -1;
  1504. }
  1505. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1506. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1507. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1508. } else {
  1509. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1510. return -1;
  1511. }
  1512. return 0;
  1513. }
  1514. /*==========================================
  1515. * @hairstyle && @hstyle
  1516. *------------------------------------------*/
  1517. ACMD_FUNC(hair_style)
  1518. {
  1519. int hair_style = 0;
  1520. nullpo_retr(-1, sd);
  1521. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1522. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1523. 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>).
  1524. clif_displaymessage(fd, atcmd_output);
  1525. return -1;
  1526. }
  1527. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1528. pc_changelook(sd, LOOK_HAIR, hair_style);
  1529. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1530. } else {
  1531. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1532. return -1;
  1533. }
  1534. return 0;
  1535. }
  1536. /*==========================================
  1537. * @haircolor && @hcolor
  1538. *------------------------------------------*/
  1539. ACMD_FUNC(hair_color)
  1540. {
  1541. int hair_color = 0;
  1542. nullpo_retr(-1, sd);
  1543. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1544. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1545. 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>).
  1546. clif_displaymessage(fd, atcmd_output);
  1547. return -1;
  1548. }
  1549. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1550. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1551. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1552. } else {
  1553. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1554. return -1;
  1555. }
  1556. return 0;
  1557. }
  1558. /*==========================================
  1559. * @go [city_number or city_name] - Updated by Harbin
  1560. *------------------------------------------*/
  1561. ACMD_FUNC(go)
  1562. {
  1563. int i;
  1564. int town;
  1565. char map_name[MAP_NAME_LENGTH];
  1566. const struct {
  1567. char map[MAP_NAME_LENGTH];
  1568. int x, y;
  1569. } data[] = {
  1570. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1571. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1572. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1573. { MAP_PAYON, 162, 233 }, // 3=Payon
  1574. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1575. #ifdef RENEWAL
  1576. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1577. #else
  1578. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1579. #endif
  1580. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1581. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1582. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1583. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1584. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1585. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1586. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1587. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1588. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1589. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1590. { MAP_JAIL, 23, 61 }, // 16=Prison
  1591. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1592. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1593. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1594. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1595. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1596. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1597. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1598. { MAP_VEINS, 216, 123 }, // 24=Veins
  1599. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1600. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1601. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1602. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1603. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1604. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1605. { MAP_MORA, 44, 151 }, // 31=Mora
  1606. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1607. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1608. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1609. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1610. };
  1611. nullpo_retr(-1, sd);
  1612. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1613. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1614. return 0;
  1615. }
  1616. memset(map_name, '\0', sizeof(map_name));
  1617. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1618. // get the number
  1619. town = atoi(message);
  1620. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1621. {// no value matched so send the list of locations
  1622. const char* text;
  1623. // attempt to find the text help string
  1624. text = atcommand_help_string( command );
  1625. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1626. if( text )
  1627. {// send the text to the client
  1628. clif_displaymessage( fd, text );
  1629. }
  1630. return -1;
  1631. }
  1632. // get possible name of the city
  1633. map_name[MAP_NAME_LENGTH-1] = '\0';
  1634. for (i = 0; map_name[i]; i++)
  1635. map_name[i] = TOLOWER(map_name[i]);
  1636. // try to identify the map name
  1637. if (strncmp(map_name, "prontera", 3) == 0) {
  1638. town = 0;
  1639. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1640. strncmp(map_name, "morroc", 4) == 0) {
  1641. town = 1;
  1642. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1643. town = 2;
  1644. } else if (strncmp(map_name, "payon", 3) == 0) {
  1645. town = 3;
  1646. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1647. town = 4;
  1648. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1649. town = 5;
  1650. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1651. town = 6;
  1652. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1653. strcmp(map_name, "christmas") == 0 ||
  1654. strncmp(map_name, "xmas", 3) == 0 ||
  1655. strncmp(map_name, "x-mas", 3) == 0) {
  1656. town = 7;
  1657. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1658. town = 8;
  1659. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1660. strncmp(map_name, "yuno", 3) == 0) {
  1661. town = 9;
  1662. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1663. town = 10;
  1664. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1665. strncmp(map_name, "gonryun", 3) == 0) {
  1666. town = 11;
  1667. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1668. town = 12;
  1669. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1670. town = 13;
  1671. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1672. town = 14;
  1673. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1674. strncmp(map_name, "startpoint", 3) == 0 ||
  1675. strncmp(map_name, "beginning", 3) == 0) {
  1676. town = 15;
  1677. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1678. strncmp(map_name, "prison", 3) == 0 ||
  1679. strncmp(map_name, "jail", 3) == 0) {
  1680. town = 16;
  1681. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1682. town = 17;
  1683. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1684. town = 18;
  1685. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1686. town = 19;
  1687. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1688. town = 20;
  1689. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1690. town = 21;
  1691. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1692. town = 22;
  1693. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1694. town = 23;
  1695. } else if (strncmp(map_name, "veins", 3) == 0) {
  1696. town = 24;
  1697. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1698. town = 25;
  1699. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1700. town = 26;
  1701. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1702. town = 27;
  1703. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1704. town = 28;
  1705. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1706. town = 29;
  1707. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1708. town = 30;
  1709. } else if (strcmp(map_name, "mora") == 0) {
  1710. town = 31;
  1711. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1712. town = 32;
  1713. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1714. town = 33;
  1715. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1716. town = 34;
  1717. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1718. town = 35;
  1719. }
  1720. if (town >= 0 && town < ARRAYLENGTH(data))
  1721. {
  1722. int16 m = map_mapname2mapid(data[town].map);
  1723. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1724. clif_displaymessage(fd, msg_txt(sd,247));
  1725. return -1;
  1726. }
  1727. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1728. clif_displaymessage(fd, msg_txt(sd,248));
  1729. return -1;
  1730. }
  1731. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1732. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1733. } else {
  1734. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1735. return -1;
  1736. }
  1737. } else { // if you arrive here, you have an error in town variable when reading of names
  1738. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1739. return -1;
  1740. }
  1741. return 0;
  1742. }
  1743. /*==========================================
  1744. *
  1745. *------------------------------------------*/
  1746. ACMD_FUNC(monster)
  1747. {
  1748. char name[NAME_LENGTH];
  1749. char monster[NAME_LENGTH];
  1750. char eventname[EVENT_NAME_LENGTH] = "";
  1751. int mob_id;
  1752. int number = 0;
  1753. int count;
  1754. int i, range;
  1755. short mx, my;
  1756. unsigned int size;
  1757. nullpo_retr(-1, sd);
  1758. memset(name, '\0', sizeof(name));
  1759. memset(monster, '\0', sizeof(monster));
  1760. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1761. if (!message || !*message) {
  1762. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1763. return -1;
  1764. }
  1765. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1766. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1767. //All data can be left as it is.
  1768. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1769. //Here, it is possible name was not given and we are using monster for it.
  1770. if (count < 3) //Blank mob's name.
  1771. name[0] = '\0';
  1772. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1773. //All data can be left as it is.
  1774. } else if (sscanf(message, "%23s", monster) > 0) {
  1775. //As before, name may be already filled.
  1776. name[0] = '\0';
  1777. } else {
  1778. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1779. return -1;
  1780. }
  1781. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1782. mob_id = mobdb_checkid(atoi(monster));
  1783. if (mob_id == 0) {
  1784. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1785. return -1;
  1786. }
  1787. if (mob_id == MOBID_EMPERIUM) {
  1788. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1789. return -1;
  1790. }
  1791. if (number <= 0)
  1792. number = 1;
  1793. if( !name[0] )
  1794. strcpy(name, "--ja--");
  1795. // 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
  1796. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1797. number = battle_config.atc_spawn_quantity_limit;
  1798. parent_cmd = atcommand_checkalias(command+1);
  1799. if (strcmp(parent_cmd, "monstersmall") == 0)
  1800. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1801. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1802. size = SZ_BIG;
  1803. else
  1804. size = SZ_SMALL;
  1805. if (battle_config.etc_log)
  1806. 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);
  1807. count = 0;
  1808. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1809. for (i = 0; i < number; i++) {
  1810. int k;
  1811. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1812. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1813. if(k) {
  1814. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1815. count ++;
  1816. }
  1817. }
  1818. if (count != 0)
  1819. if (number == count)
  1820. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1821. else {
  1822. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1823. clif_displaymessage(fd, atcmd_output);
  1824. }
  1825. else {
  1826. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1827. return -1;
  1828. }
  1829. return 0;
  1830. }
  1831. /*==========================================
  1832. *
  1833. *------------------------------------------*/
  1834. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1835. {
  1836. struct mob_data *md;
  1837. int flag;
  1838. nullpo_ret(md=(struct mob_data *)bl);
  1839. flag = va_arg(ap, int);
  1840. if (md->guardian_data)
  1841. return 0; //Do not touch WoE mobs!
  1842. if (flag)
  1843. status_zap(bl,md->status.hp, 0);
  1844. else
  1845. status_kill(bl);
  1846. return 1;
  1847. }
  1848. ACMD_FUNC(killmonster)
  1849. {
  1850. int map_id, drop_flag;
  1851. char map_name[MAP_NAME_LENGTH_EXT];
  1852. nullpo_retr(-1, sd);
  1853. memset(map_name, '\0', sizeof(map_name));
  1854. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1855. map_id = sd->bl.m;
  1856. else {
  1857. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1858. map_id = sd->bl.m;
  1859. }
  1860. parent_cmd = atcommand_checkalias(command+1);
  1861. drop_flag = strcmp(parent_cmd, "killmonster2");
  1862. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1863. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1864. return 0;
  1865. }
  1866. /*==========================================
  1867. *
  1868. *------------------------------------------*/
  1869. ACMD_FUNC(refine)
  1870. {
  1871. int j, position = 0, refine = 0, current_position, final_refine;
  1872. int count;
  1873. nullpo_retr(-1, sd);
  1874. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1875. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1876. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1877. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1878. clif_displaymessage(fd, atcmd_output);
  1879. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1880. clif_displaymessage(fd, atcmd_output);
  1881. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1882. clif_displaymessage(fd, atcmd_output);
  1883. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1884. clif_displaymessage(fd, atcmd_output);
  1885. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1886. clif_displaymessage(fd, atcmd_output);
  1887. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1888. clif_displaymessage(fd, atcmd_output);
  1889. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1890. clif_displaymessage(fd, atcmd_output);
  1891. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1892. clif_displaymessage(fd, atcmd_output);
  1893. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1894. clif_displaymessage(fd, atcmd_output);
  1895. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1896. clif_displaymessage(fd, atcmd_output);
  1897. return -1;
  1898. }
  1899. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1900. count = 0;
  1901. for (j = 0; j < EQI_MAX; j++) {
  1902. int i;
  1903. if ((i = sd->equip_index[j]) < 0)
  1904. continue;
  1905. if(j == EQI_AMMO)
  1906. continue;
  1907. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1908. continue;
  1909. if(position && !(sd->status.inventory[i].equip & position))
  1910. continue;
  1911. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1912. if (sd->status.inventory[i].refine != final_refine) {
  1913. sd->status.inventory[i].refine = final_refine;
  1914. current_position = sd->status.inventory[i].equip;
  1915. pc_unequipitem(sd, i, 3);
  1916. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1917. clif_delitem(sd, i, 1, 3);
  1918. clif_additem(sd, i, 1, 0);
  1919. pc_equipitem(sd, i, current_position);
  1920. clif_misceffect(&sd->bl, 3);
  1921. count++;
  1922. }
  1923. }
  1924. if (count == 0)
  1925. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1926. else if (count == 1)
  1927. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1928. else {
  1929. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1930. clif_displaymessage(fd, atcmd_output);
  1931. }
  1932. return 0;
  1933. }
  1934. /*==========================================
  1935. *
  1936. *------------------------------------------*/
  1937. ACMD_FUNC(produce)
  1938. {
  1939. char item_name[100];
  1940. unsigned short item_id;
  1941. int attribute = 0, star = 0;
  1942. struct item_data *item_data;
  1943. struct item tmp_item;
  1944. nullpo_retr(-1, sd);
  1945. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1946. memset(item_name, '\0', sizeof(item_name));
  1947. if (!message || !*message || (
  1948. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  1949. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  1950. )) {
  1951. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1952. return -1;
  1953. }
  1954. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1955. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1956. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1957. return -1;
  1958. }
  1959. item_id = item_data->nameid;
  1960. if (itemdb_isequip2(item_data)) {
  1961. char flag = 0;
  1962. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1963. attribute = ATTRIBUTE_NORMAL;
  1964. if (star < MIN_STAR || star > MAX_STAR)
  1965. star = 0;
  1966. memset(&tmp_item, 0, sizeof tmp_item);
  1967. tmp_item.nameid = item_id;
  1968. tmp_item.amount = 1;
  1969. tmp_item.identify = 1;
  1970. tmp_item.card[0] = CARD0_FORGE;
  1971. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1972. ((star*5) << 8) + attribute:0;
  1973. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1974. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1975. clif_produceeffect(sd, 0, item_id);
  1976. clif_misceffect(&sd->bl, 3);
  1977. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1978. clif_additem(sd, 0, 0, flag);
  1979. } else {
  1980. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  1981. clif_displaymessage(fd, atcmd_output);
  1982. return -1;
  1983. }
  1984. return 0;
  1985. }
  1986. /*==========================================
  1987. *
  1988. *------------------------------------------*/
  1989. ACMD_FUNC(memo)
  1990. {
  1991. int position = 0;
  1992. nullpo_retr(-1, sd);
  1993. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1994. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  1995. {
  1996. int i;
  1997. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1998. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1999. {
  2000. if( sd->status.memo_point[i].map )
  2001. 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);
  2002. else
  2003. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2004. clif_displaymessage(sd->fd, atcmd_output);
  2005. }
  2006. return 0;
  2007. }
  2008. if( position < 0 || position >= MAX_MEMOPOINTS )
  2009. {
  2010. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2011. clif_displaymessage(fd, atcmd_output);
  2012. return -1;
  2013. }
  2014. return !pc_memo( sd, position );
  2015. }
  2016. /*==========================================
  2017. *
  2018. *------------------------------------------*/
  2019. ACMD_FUNC(gat)
  2020. {
  2021. int y;
  2022. nullpo_retr(-1, sd);
  2023. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2024. for (y = 2; y >= -2; y--) {
  2025. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2026. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2027. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2028. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2029. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2030. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2031. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2032. clif_displaymessage(fd, atcmd_output);
  2033. }
  2034. return 0;
  2035. }
  2036. /*==========================================
  2037. *
  2038. *------------------------------------------*/
  2039. ACMD_FUNC(displaystatus)
  2040. {
  2041. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2042. nullpo_retr(-1, sd);
  2043. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2044. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2045. return -1;
  2046. }
  2047. if (i < 2) flag = 1;
  2048. if (i < 3) tick = 0;
  2049. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2050. return 0;
  2051. }
  2052. /*==========================================
  2053. * @stpoint (Rewritten by [Yor])
  2054. *------------------------------------------*/
  2055. ACMD_FUNC(statuspoint)
  2056. {
  2057. int point;
  2058. unsigned int new_status_point;
  2059. if (!message || !*message || (point = atoi(message)) == 0) {
  2060. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2061. return -1;
  2062. }
  2063. if(point < 0)
  2064. {
  2065. if(sd->status.status_point < (unsigned int)(-point))
  2066. {
  2067. new_status_point = 0;
  2068. }
  2069. else
  2070. {
  2071. new_status_point = sd->status.status_point + point;
  2072. }
  2073. }
  2074. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2075. {
  2076. new_status_point = UINT_MAX;
  2077. }
  2078. else
  2079. {
  2080. new_status_point = sd->status.status_point + point;
  2081. }
  2082. if (new_status_point != sd->status.status_point) {
  2083. sd->status.status_point = new_status_point;
  2084. clif_updatestatus(sd, SP_STATUSPOINT);
  2085. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2086. } else {
  2087. if (point < 0)
  2088. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2089. else
  2090. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2091. return -1;
  2092. }
  2093. return 0;
  2094. }
  2095. /*==========================================
  2096. * @skpoint (Rewritten by [Yor])
  2097. *------------------------------------------*/
  2098. ACMD_FUNC(skillpoint)
  2099. {
  2100. int point;
  2101. unsigned int new_skill_point;
  2102. nullpo_retr(-1, sd);
  2103. if (!message || !*message || (point = atoi(message)) == 0) {
  2104. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2105. return -1;
  2106. }
  2107. if(point < 0)
  2108. {
  2109. if(sd->status.skill_point < (unsigned int)(-point))
  2110. {
  2111. new_skill_point = 0;
  2112. }
  2113. else
  2114. {
  2115. new_skill_point = sd->status.skill_point + point;
  2116. }
  2117. }
  2118. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2119. {
  2120. new_skill_point = UINT_MAX;
  2121. }
  2122. else
  2123. {
  2124. new_skill_point = sd->status.skill_point + point;
  2125. }
  2126. if (new_skill_point != sd->status.skill_point) {
  2127. sd->status.skill_point = new_skill_point;
  2128. clif_updatestatus(sd, SP_SKILLPOINT);
  2129. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2130. } else {
  2131. if (point < 0)
  2132. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2133. else
  2134. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2135. return -1;
  2136. }
  2137. return 0;
  2138. }
  2139. /*==========================================
  2140. * @zeny
  2141. *------------------------------------------*/
  2142. ACMD_FUNC(zeny)
  2143. {
  2144. int zeny=0, ret=-1;
  2145. nullpo_retr(-1, sd);
  2146. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2147. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2148. return -1;
  2149. }
  2150. if(zeny > 0){
  2151. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2152. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2153. }
  2154. else {
  2155. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2156. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2157. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2158. }
  2159. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2160. return 0;
  2161. }
  2162. /*==========================================
  2163. *
  2164. *------------------------------------------*/
  2165. ACMD_FUNC(param)
  2166. {
  2167. uint8 i;
  2168. int value = 0;
  2169. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2170. unsigned short new_value, *status[6], max_status[6];
  2171. //we don't use direct initialization because it isn't part of the c standard.
  2172. nullpo_retr(-1, sd);
  2173. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2174. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2175. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2176. return -1;
  2177. }
  2178. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2179. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2180. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2181. return -1;
  2182. }
  2183. status[0] = &sd->status.str;
  2184. status[1] = &sd->status.agi;
  2185. status[2] = &sd->status.vit;
  2186. status[3] = &sd->status.int_;
  2187. status[4] = &sd->status.dex;
  2188. status[5] = &sd->status.luk;
  2189. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2190. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2191. else {
  2192. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2193. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2194. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2195. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2196. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2197. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2198. }
  2199. if(value > 0 && *status[i] + value >= max_status[i])
  2200. new_value = max_status[i];
  2201. else if(value < 0 && *status[i] <= -value)
  2202. new_value = 1;
  2203. else
  2204. new_value = *status[i] + value;
  2205. if (new_value != *status[i]) {
  2206. *status[i] = new_value;
  2207. clif_updatestatus(sd, SP_STR + i);
  2208. clif_updatestatus(sd, SP_USTR + i);
  2209. status_calc_pc(sd, SCO_FORCE);
  2210. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2211. } else {
  2212. if (value < 0)
  2213. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2214. else
  2215. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2216. return -1;
  2217. }
  2218. return 0;
  2219. }
  2220. /*==========================================
  2221. * Stat all by fritz (rewritten by [Yor])
  2222. *------------------------------------------*/
  2223. ACMD_FUNC(stat_all)
  2224. {
  2225. int value = 0;
  2226. uint8 count, i;
  2227. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2228. //we don't use direct initialization because it isn't part of the c standard.
  2229. nullpo_retr(-1, sd);
  2230. status[0] = &sd->status.str;
  2231. status[1] = &sd->status.agi;
  2232. status[2] = &sd->status.vit;
  2233. status[3] = &sd->status.int_;
  2234. status[4] = &sd->status.dex;
  2235. status[5] = &sd->status.luk;
  2236. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2237. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2238. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2239. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2240. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2241. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2242. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2243. value = SHRT_MAX;
  2244. } else {
  2245. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2246. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2247. else {
  2248. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2249. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2250. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2251. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2252. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2253. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2254. }
  2255. }
  2256. count = 0;
  2257. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2258. short new_value;
  2259. if (value > 0 && *status[i] + value >= max_status[i])
  2260. new_value = max_status[i];
  2261. else if (value < 0 && *status[i] <= -value)
  2262. new_value = 1;
  2263. else
  2264. new_value = *status[i] + value;
  2265. if (new_value != *status[i]) {
  2266. *status[i] = new_value;
  2267. clif_updatestatus(sd, SP_STR + i);
  2268. clif_updatestatus(sd, SP_USTR + i);
  2269. count++;
  2270. }
  2271. }
  2272. if (count > 0) { // if at least 1 stat modified
  2273. status_calc_pc(sd, SCO_FORCE);
  2274. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2275. } else {
  2276. if (value < 0)
  2277. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2278. else
  2279. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2280. return -1;
  2281. }
  2282. return 0;
  2283. }
  2284. /*==========================================
  2285. *
  2286. *------------------------------------------*/
  2287. ACMD_FUNC(guildlevelup) {
  2288. int level = 0;
  2289. short added_level;
  2290. struct guild *guild_info;
  2291. nullpo_retr(-1, sd);
  2292. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2293. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2294. return -1;
  2295. }
  2296. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2297. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2298. return -1;
  2299. }
  2300. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2301. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2302. // return -1;
  2303. //}
  2304. added_level = (short)level;
  2305. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2306. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2307. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2308. added_level = 1 - guild_info->guild_lv;
  2309. if (added_level != 0) {
  2310. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2311. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2312. } else {
  2313. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2314. return -1;
  2315. }
  2316. return 0;
  2317. }
  2318. /*==========================================
  2319. *
  2320. *------------------------------------------*/
  2321. ACMD_FUNC(makeegg) {
  2322. struct item_data *item_data;
  2323. int id, pet_id;
  2324. nullpo_retr(-1, sd);
  2325. if (!message || !*message) {
  2326. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2327. return -1;
  2328. }
  2329. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2330. id = item_data->nameid;
  2331. else
  2332. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2333. ;
  2334. else
  2335. id = atoi(message);
  2336. pet_id = search_petDB_index(id, PET_CLASS);
  2337. if (pet_id < 0)
  2338. pet_id = search_petDB_index(id, PET_EGG);
  2339. if (pet_id >= 0) {
  2340. sd->catch_target_class = pet_db[pet_id].class_;
  2341. intif_create_pet(
  2342. sd->status.account_id, sd->status.char_id,
  2343. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2344. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2345. 100, 0, 1, pet_db[pet_id].jname);
  2346. } else {
  2347. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2348. return -1;
  2349. }
  2350. return 0;
  2351. }
  2352. /*==========================================
  2353. *
  2354. *------------------------------------------*/
  2355. ACMD_FUNC(hatch) {
  2356. nullpo_retr(-1, sd);
  2357. if (sd->status.pet_id <= 0)
  2358. clif_sendegg(sd);
  2359. else {
  2360. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2361. return -1;
  2362. }
  2363. return 0;
  2364. }
  2365. /*==========================================
  2366. *
  2367. *------------------------------------------*/
  2368. ACMD_FUNC(petfriendly) {
  2369. int friendly;
  2370. struct pet_data *pd;
  2371. nullpo_retr(-1, sd);
  2372. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2373. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2374. return -1;
  2375. }
  2376. pd = sd->pd;
  2377. if (!pd) {
  2378. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2379. return -1;
  2380. }
  2381. if (friendly < 0 || friendly > 1000)
  2382. {
  2383. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2384. return -1;
  2385. }
  2386. if (friendly == pd->pet.intimate) {
  2387. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2388. return -1;
  2389. }
  2390. pet_set_intimate(pd, friendly);
  2391. clif_send_petstatus(sd);
  2392. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2393. return 0;
  2394. }
  2395. /*==========================================
  2396. *
  2397. *------------------------------------------*/
  2398. ACMD_FUNC(pethungry)
  2399. {
  2400. int hungry;
  2401. struct pet_data *pd;
  2402. nullpo_retr(-1, sd);
  2403. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2404. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2405. return -1;
  2406. }
  2407. pd = sd->pd;
  2408. if (!sd->status.pet_id || !pd) {
  2409. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2410. return -1;
  2411. }
  2412. if (hungry < 0 || hungry > 100) {
  2413. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2414. return -1;
  2415. }
  2416. if (hungry == pd->pet.hungry) {
  2417. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2418. return -1;
  2419. }
  2420. pd->pet.hungry = hungry;
  2421. clif_send_petstatus(sd);
  2422. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2423. return 0;
  2424. }
  2425. /*==========================================
  2426. *
  2427. *------------------------------------------*/
  2428. ACMD_FUNC(petrename)
  2429. {
  2430. struct pet_data *pd;
  2431. nullpo_retr(-1, sd);
  2432. if (!sd->status.pet_id || !sd->pd) {
  2433. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2434. return -1;
  2435. }
  2436. pd = sd->pd;
  2437. if (!pd->pet.rename_flag) {
  2438. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2439. return -1;
  2440. }
  2441. pd->pet.rename_flag = 0;
  2442. intif_save_petdata(sd->status.account_id, &pd->pet);
  2443. clif_send_petstatus(sd);
  2444. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2445. return 0;
  2446. }
  2447. /*==========================================
  2448. *
  2449. *------------------------------------------*/
  2450. ACMD_FUNC(recall) {
  2451. struct map_session_data *pl_sd = NULL;
  2452. nullpo_retr(-1, sd);
  2453. if (!message || !*message) {
  2454. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2455. return -1;
  2456. }
  2457. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2458. {
  2459. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2460. return -1;
  2461. }
  2462. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2463. {
  2464. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2465. return -1;
  2466. }
  2467. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2468. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2469. return -1;
  2470. }
  2471. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2472. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2473. return -1;
  2474. }
  2475. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2476. return -1;
  2477. }
  2478. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2479. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2480. clif_displaymessage(fd, atcmd_output);
  2481. return 0;
  2482. }
  2483. /*==========================================
  2484. * charblock command (usage: charblock <player_name>)
  2485. * This command do a definitiv ban on a player
  2486. *------------------------------------------*/
  2487. ACMD_FUNC(char_block)
  2488. {
  2489. nullpo_retr(-1, sd);
  2490. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2491. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2492. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2493. clif_displaymessage(fd, atcmd_output);
  2494. return -1;
  2495. }
  2496. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2497. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2498. clif_displaymessage(fd, atcmd_output);
  2499. return 0;
  2500. }
  2501. /*==========================================
  2502. * accountban command (usage: ban <%time> <player_name>)
  2503. * charban command (usage: charban <%time> <player_name>)
  2504. * %time see common/timer.c::solve_time()
  2505. *------------------------------------------*/
  2506. ACMD_FUNC(char_ban)
  2507. {
  2508. char *modif_p, output[CHAT_SIZE_MAX];
  2509. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2510. int bantype = 0;
  2511. nullpo_retr(-1, sd);
  2512. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2513. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2514. parent_cmd = atcommand_checkalias(command+1);
  2515. if (strcmpi(parent_cmd,"charban") == 0)
  2516. bantype = CHRIF_OP_BAN;
  2517. else if (strcmpi(parent_cmd,"ban") == 0)
  2518. bantype = CHRIF_OP_LOGIN_BAN;
  2519. else
  2520. return -1;
  2521. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2522. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2523. clif_displaymessage(fd, output);
  2524. return -1;
  2525. }
  2526. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2527. modif_p = atcmd_output;
  2528. timediff = (int32)solve_time(modif_p); //discard seconds
  2529. if (timediff == 0) { //allow negative ?
  2530. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2531. clif_displaymessage(fd, output);
  2532. 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.
  2533. return -1;
  2534. }
  2535. if( timediff < 0 && (
  2536. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2537. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2538. ))
  2539. {
  2540. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2541. return -1;
  2542. }
  2543. if (bantype == CHRIF_OP_BAN)
  2544. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2545. else
  2546. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2547. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2548. clif_displaymessage(fd, output);
  2549. return 0;
  2550. }
  2551. /*==========================================
  2552. * charunblock command (usage: charunblock <player_name>)
  2553. *------------------------------------------*/
  2554. ACMD_FUNC(char_unblock)
  2555. {
  2556. nullpo_retr(-1, sd);
  2557. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2558. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2559. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2560. clif_displaymessage(fd, atcmd_output);
  2561. return -1;
  2562. }
  2563. // send answer to login server via char-server
  2564. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2565. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2566. clif_displaymessage(fd, atcmd_output);
  2567. return 0;
  2568. }
  2569. /*==========================================
  2570. * acc unban command (usage: unban <player_name>)
  2571. * char unban command (usage: charunban <player_name>)
  2572. *------------------------------------------*/
  2573. ACMD_FUNC(char_unban){
  2574. int unbantype = 0;
  2575. nullpo_retr(-1, sd);
  2576. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2577. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2578. parent_cmd = atcommand_checkalias(command+1);
  2579. if (strcmpi(parent_cmd,"charunban") == 0)
  2580. unbantype = CHRIF_OP_UNBAN;
  2581. else if (strcmpi(parent_cmd,"unban") == 0)
  2582. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2583. else
  2584. return -1;
  2585. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2586. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2587. clif_displaymessage(fd, atcmd_output);
  2588. return -1;
  2589. }
  2590. if (unbantype == CHRIF_OP_UNBAN)
  2591. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2592. else
  2593. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2594. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2595. clif_displaymessage(fd, atcmd_output);
  2596. return 0;
  2597. }
  2598. /*==========================================
  2599. *
  2600. *------------------------------------------*/
  2601. ACMD_FUNC(night)
  2602. {
  2603. nullpo_retr(-1, sd);
  2604. if (night_flag != 1) {
  2605. map_night_timer(night_timer_tid, 0, 0, 1);
  2606. } else {
  2607. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2608. return -1;
  2609. }
  2610. return 0;
  2611. }
  2612. /*==========================================
  2613. *
  2614. *------------------------------------------*/
  2615. ACMD_FUNC(day)
  2616. {
  2617. nullpo_retr(-1, sd);
  2618. if (night_flag != 0) {
  2619. map_day_timer(day_timer_tid, 0, 0, 1);
  2620. } else {
  2621. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2622. return -1;
  2623. }
  2624. return 0;
  2625. }
  2626. /*==========================================
  2627. *
  2628. *------------------------------------------*/
  2629. ACMD_FUNC(doom)
  2630. {
  2631. struct map_session_data* pl_sd;
  2632. struct s_mapiterator* iter;
  2633. nullpo_retr(-1, sd);
  2634. iter = mapit_getallusers();
  2635. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2636. {
  2637. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2638. {
  2639. status_kill(&pl_sd->bl);
  2640. clif_specialeffect(&pl_sd->bl,450,AREA);
  2641. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2642. }
  2643. }
  2644. mapit_free(iter);
  2645. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2646. return 0;
  2647. }
  2648. /*==========================================
  2649. *
  2650. *------------------------------------------*/
  2651. ACMD_FUNC(doommap)
  2652. {
  2653. struct map_session_data* pl_sd;
  2654. struct s_mapiterator* iter;
  2655. nullpo_retr(-1, sd);
  2656. iter = mapit_getallusers();
  2657. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2658. {
  2659. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2660. {
  2661. status_kill(&pl_sd->bl);
  2662. clif_specialeffect(&pl_sd->bl,450,AREA);
  2663. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2664. }
  2665. }
  2666. mapit_free(iter);
  2667. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2668. return 0;
  2669. }
  2670. /*==========================================
  2671. *
  2672. *------------------------------------------*/
  2673. static void atcommand_raise_sub(struct map_session_data* sd) {
  2674. status_revive(&sd->bl, 100, 100);
  2675. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2676. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2677. }
  2678. /*==========================================
  2679. *
  2680. *------------------------------------------*/
  2681. ACMD_FUNC(raise)
  2682. {
  2683. struct map_session_data* pl_sd;
  2684. struct s_mapiterator* iter;
  2685. nullpo_retr(-1, sd);
  2686. iter = mapit_getallusers();
  2687. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2688. if( pc_isdead(pl_sd) )
  2689. atcommand_raise_sub(pl_sd);
  2690. mapit_free(iter);
  2691. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2692. return 0;
  2693. }
  2694. /*==========================================
  2695. *
  2696. *------------------------------------------*/
  2697. ACMD_FUNC(raisemap)
  2698. {
  2699. struct map_session_data* pl_sd;
  2700. struct s_mapiterator* iter;
  2701. nullpo_retr(-1, sd);
  2702. iter = mapit_getallusers();
  2703. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2704. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2705. atcommand_raise_sub(pl_sd);
  2706. mapit_free(iter);
  2707. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2708. return 0;
  2709. }
  2710. /*==========================================
  2711. *
  2712. *------------------------------------------*/
  2713. ACMD_FUNC(kick)
  2714. {
  2715. struct map_session_data *pl_sd;
  2716. nullpo_retr(-1, sd);
  2717. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2718. if (!message || !*message) {
  2719. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2720. return -1;
  2721. }
  2722. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2723. {
  2724. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2725. return -1;
  2726. }
  2727. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2728. {
  2729. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2730. return -1;
  2731. }
  2732. clif_GM_kick(sd, pl_sd);
  2733. return 0;
  2734. }
  2735. /*==========================================
  2736. *
  2737. *------------------------------------------*/
  2738. ACMD_FUNC(kickall)
  2739. {
  2740. struct map_session_data* pl_sd;
  2741. struct s_mapiterator* iter;
  2742. nullpo_retr(-1, sd);
  2743. iter = mapit_getallusers();
  2744. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2745. {
  2746. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2747. if (sd->status.account_id != pl_sd->status.account_id)
  2748. clif_GM_kick(NULL, pl_sd);
  2749. }
  2750. }
  2751. mapit_free(iter);
  2752. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2753. return 0;
  2754. }
  2755. /*==========================================
  2756. *
  2757. *------------------------------------------*/
  2758. ACMD_FUNC(allskill)
  2759. {
  2760. nullpo_retr(-1, sd);
  2761. pc_allskillup(sd); // all skills
  2762. sd->status.skill_point = 0; // 0 skill points
  2763. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2764. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2765. return 0;
  2766. }
  2767. /*==========================================
  2768. *
  2769. *------------------------------------------*/
  2770. ACMD_FUNC(questskill)
  2771. {
  2772. uint16 skill_id;
  2773. nullpo_retr(-1, sd);
  2774. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2775. {// also send a list of skills applicable to this command
  2776. const char* text;
  2777. // attempt to find the text corresponding to this command
  2778. text = atcommand_help_string( command );
  2779. // send the error message as always
  2780. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2781. if( text )
  2782. {// send the skill ID list associated with this command
  2783. clif_displaymessage( fd, text );
  2784. }
  2785. return -1;
  2786. }
  2787. if (skill_id >= MAX_SKILL_ID) {
  2788. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2789. return -1;
  2790. }
  2791. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2792. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2793. return -1;
  2794. }
  2795. if (pc_checkskill(sd, skill_id) > 0) {
  2796. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2797. return -1;
  2798. }
  2799. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2800. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2801. return 0;
  2802. }
  2803. /*==========================================
  2804. *
  2805. *------------------------------------------*/
  2806. ACMD_FUNC(lostskill)
  2807. {
  2808. uint16 skill_id = 0, sk_idx = 0;
  2809. nullpo_retr(-1, sd);
  2810. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2811. {// also send a list of skills applicable to this command
  2812. const char* text;
  2813. // attempt to find the text corresponding to this command
  2814. text = atcommand_help_string( command );
  2815. // send the error message as always
  2816. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2817. if( text )
  2818. {// send the skill ID list associated with this command
  2819. clif_displaymessage( fd, text );
  2820. }
  2821. return -1;
  2822. }
  2823. if (!(sk_idx = skill_get_index(skill_id))) {
  2824. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2825. return -1;
  2826. }
  2827. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2828. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2829. return -1;
  2830. }
  2831. if (pc_checkskill(sd, skill_id) == 0) {
  2832. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2833. return -1;
  2834. }
  2835. sd->status.skill[sk_idx].lv = 0;
  2836. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2837. clif_deleteskill(sd,skill_id);
  2838. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2839. return 0;
  2840. }
  2841. /*==========================================
  2842. *
  2843. *------------------------------------------*/
  2844. ACMD_FUNC(spiritball)
  2845. {
  2846. uint32 max_spiritballs;
  2847. int number;
  2848. nullpo_retr(-1, sd);
  2849. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2850. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2851. {
  2852. char msg[CHAT_SIZE_MAX];
  2853. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2854. clif_displaymessage(fd, msg);
  2855. return -1;
  2856. }
  2857. if( sd->spiritball > 0 )
  2858. pc_delspiritball(sd, sd->spiritball, 1);
  2859. sd->spiritball = number;
  2860. clif_spiritball(&sd->bl);
  2861. // no message, player can look the difference
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(party)
  2868. {
  2869. char party[NAME_LENGTH];
  2870. nullpo_retr(-1, sd);
  2871. memset(party, '\0', sizeof(party));
  2872. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2873. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2874. return -1;
  2875. }
  2876. party_create(sd, party, 0, 0);
  2877. return 0;
  2878. }
  2879. /*==========================================
  2880. *
  2881. *------------------------------------------*/
  2882. ACMD_FUNC(guild)
  2883. {
  2884. char guild[NAME_LENGTH];
  2885. int prev;
  2886. nullpo_retr(-1, sd);
  2887. memset(guild, '\0', sizeof(guild));
  2888. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2889. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2890. return -1;
  2891. }
  2892. prev = battle_config.guild_emperium_check;
  2893. battle_config.guild_emperium_check = 0;
  2894. guild_create(sd, guild);
  2895. battle_config.guild_emperium_check = prev;
  2896. return 0;
  2897. }
  2898. ACMD_FUNC(breakguild)
  2899. {
  2900. nullpo_retr(-1, sd);
  2901. if (sd->status.guild_id) { // Check if the player has a guild
  2902. struct guild *g;
  2903. g = sd->guild; // Search the guild
  2904. if (g) { // Check if guild was found
  2905. if (sd->state.gmaster_flag) { // Check if player is guild master
  2906. int ret = 0;
  2907. ret = guild_break(sd, g->name); // Break guild
  2908. if (ret) { // Check if anything went wrong
  2909. return 0; // Guild was broken
  2910. } else {
  2911. return -1; // Something went wrong
  2912. }
  2913. } else { // Not guild master
  2914. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2915. return -1;
  2916. }
  2917. } else { // Guild was not found. HOW?
  2918. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2919. return -1;
  2920. }
  2921. } else { // Player does not have a guild
  2922. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2923. return -1;
  2924. }
  2925. return 0;
  2926. }
  2927. /*==========================================
  2928. *
  2929. *------------------------------------------*/
  2930. ACMD_FUNC(agitstart)
  2931. {
  2932. nullpo_retr(-1, sd);
  2933. if (agit_flag == 1) {
  2934. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2935. return -1;
  2936. }
  2937. agit_flag = 1;
  2938. guild_agit_start();
  2939. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2940. return 0;
  2941. }
  2942. /*==========================================
  2943. *
  2944. *------------------------------------------*/
  2945. ACMD_FUNC(agitstart2)
  2946. {
  2947. nullpo_retr(-1, sd);
  2948. if (agit2_flag == 1) {
  2949. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2950. return -1;
  2951. }
  2952. agit2_flag = 1;
  2953. guild_agit2_start();
  2954. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2955. return 0;
  2956. }
  2957. /*==========================================
  2958. *
  2959. *------------------------------------------*/
  2960. ACMD_FUNC(agitend)
  2961. {
  2962. nullpo_retr(-1, sd);
  2963. if (agit_flag == 0) {
  2964. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2965. return -1;
  2966. }
  2967. agit_flag = 0;
  2968. guild_agit_end();
  2969. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2970. return 0;
  2971. }
  2972. /*==========================================
  2973. *
  2974. *------------------------------------------*/
  2975. ACMD_FUNC(agitend2)
  2976. {
  2977. nullpo_retr(-1, sd);
  2978. if (agit2_flag == 0) {
  2979. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2980. return -1;
  2981. }
  2982. agit2_flag = 0;
  2983. guild_agit2_end();
  2984. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2985. return 0;
  2986. }
  2987. /*==========================================
  2988. * @mapexit - shuts down the map server
  2989. *------------------------------------------*/
  2990. ACMD_FUNC(mapexit)
  2991. {
  2992. nullpo_retr(-1, sd);
  2993. do_shutdown();
  2994. return 0;
  2995. }
  2996. /*==========================================
  2997. * idsearch <part_of_name>: revrited by [Yor]
  2998. *------------------------------------------*/
  2999. ACMD_FUNC(idsearch)
  3000. {
  3001. char item_name[100];
  3002. unsigned int i, match;
  3003. struct item_data *item_array[MAX_SEARCH];
  3004. nullpo_retr(-1, sd);
  3005. memset(item_name, '\0', sizeof(item_name));
  3006. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3007. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3008. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3009. return -1;
  3010. }
  3011. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3012. clif_displaymessage(fd, atcmd_output);
  3013. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3014. if (match > MAX_SEARCH) {
  3015. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3016. clif_displaymessage(fd, atcmd_output);
  3017. match = MAX_SEARCH;
  3018. }
  3019. for(i = 0; i < match; i++) {
  3020. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3021. clif_displaymessage(fd, atcmd_output);
  3022. }
  3023. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3024. clif_displaymessage(fd, atcmd_output);
  3025. return 0;
  3026. }
  3027. /*==========================================
  3028. * Recall All Characters Online To Your Location
  3029. *------------------------------------------*/
  3030. ACMD_FUNC(recallall)
  3031. {
  3032. struct map_session_data* pl_sd;
  3033. struct s_mapiterator* iter;
  3034. int count;
  3035. nullpo_retr(-1, sd);
  3036. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3037. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3038. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3039. return -1;
  3040. }
  3041. count = 0;
  3042. iter = mapit_getallusers();
  3043. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3044. {
  3045. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3046. {
  3047. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3048. continue; // Don't waste time warping the character to the same place.
  3049. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3050. count++;
  3051. else {
  3052. if (pc_isdead(pl_sd)) { //Wake them up
  3053. pc_setstand(pl_sd, true);
  3054. pc_setrestartvalue(pl_sd,1);
  3055. }
  3056. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3057. }
  3058. }
  3059. }
  3060. mapit_free(iter);
  3061. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3062. if (count) {
  3063. 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.
  3064. clif_displaymessage(fd, atcmd_output);
  3065. }
  3066. return 0;
  3067. }
  3068. /*==========================================
  3069. * Recall online characters of a guild to your location
  3070. *------------------------------------------*/
  3071. ACMD_FUNC(guildrecall)
  3072. {
  3073. struct map_session_data* pl_sd;
  3074. struct s_mapiterator* iter;
  3075. int count;
  3076. char guild_name[NAME_LENGTH];
  3077. struct guild *g;
  3078. nullpo_retr(-1, sd);
  3079. memset(guild_name, '\0', sizeof(guild_name));
  3080. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3081. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3082. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3083. return -1;
  3084. }
  3085. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3086. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3087. return -1;
  3088. }
  3089. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3090. (g = guild_search(atoi(message))) == NULL)
  3091. {
  3092. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3093. return -1;
  3094. }
  3095. count = 0;
  3096. iter = mapit_getallusers();
  3097. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3098. {
  3099. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3100. {
  3101. 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))
  3102. continue; // Skip GMs greater than you... or chars already on the cell
  3103. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3104. count++;
  3105. else
  3106. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3107. }
  3108. }
  3109. mapit_free(iter);
  3110. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3111. clif_displaymessage(fd, atcmd_output);
  3112. if (count) {
  3113. 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.
  3114. clif_displaymessage(fd, atcmd_output);
  3115. }
  3116. return 0;
  3117. }
  3118. /*==========================================
  3119. * Recall online characters of a party to your location
  3120. *------------------------------------------*/
  3121. ACMD_FUNC(partyrecall)
  3122. {
  3123. struct map_session_data* pl_sd;
  3124. struct s_mapiterator* iter;
  3125. char party_name[NAME_LENGTH];
  3126. struct party_data *p;
  3127. int count;
  3128. nullpo_retr(-1, sd);
  3129. memset(party_name, '\0', sizeof(party_name));
  3130. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3131. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3132. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3133. return -1;
  3134. }
  3135. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3136. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3137. return -1;
  3138. }
  3139. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3140. (p = party_search(atoi(message))) == NULL)
  3141. {
  3142. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3143. return -1;
  3144. }
  3145. count = 0;
  3146. iter = mapit_getallusers();
  3147. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3148. {
  3149. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3150. {
  3151. 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))
  3152. continue; // Skip GMs greater than you... or chars already on the cell
  3153. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3154. count++;
  3155. else
  3156. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3157. }
  3158. }
  3159. mapit_free(iter);
  3160. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3161. clif_displaymessage(fd, atcmd_output);
  3162. if (count) {
  3163. 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.
  3164. clif_displaymessage(fd, atcmd_output);
  3165. }
  3166. return 0;
  3167. }
  3168. /*==========================================
  3169. *
  3170. *------------------------------------------*/
  3171. void atcommand_doload();
  3172. ACMD_FUNC(reload) {
  3173. nullpo_retr(-1, sd);
  3174. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3175. const char* text;
  3176. text = atcommand_help_string( command );
  3177. if(text)
  3178. clif_displaymessage( fd, text );
  3179. return -1;
  3180. }
  3181. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3182. itemdb_reload();
  3183. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3184. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3185. mob_reload();
  3186. read_petdb();
  3187. hom_reload();
  3188. mercenary_readdb();
  3189. mercenary_read_skilldb();
  3190. reload_elementaldb();
  3191. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3192. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3193. skill_reload();
  3194. hom_reload_skill();
  3195. reload_elemental_skilldb();
  3196. mercenary_read_skilldb();
  3197. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3198. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3199. config_t run_test;
  3200. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3201. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3202. return -1;
  3203. }
  3204. config_destroy(&run_test);
  3205. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3206. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3207. return -1;
  3208. }
  3209. config_destroy(&run_test);
  3210. atcommand_doload();
  3211. pc_groups_reload();
  3212. clif_displaymessage(fd, msg_txt(sd,254));
  3213. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3214. struct Battle_Config prev_config;
  3215. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3216. battle_config_read(BATTLE_CONF_FILENAME);
  3217. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3218. || prev_config.item_rate_common != battle_config.item_rate_common
  3219. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3220. || prev_config.item_rate_card != battle_config.item_rate_card
  3221. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3222. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3223. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3224. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3225. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3226. || prev_config.item_rate_use != battle_config.item_rate_use
  3227. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3228. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3229. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3230. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3231. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3232. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3233. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3234. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3235. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3236. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3237. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3238. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3239. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3240. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3241. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3242. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3243. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3244. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3245. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3246. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3247. )
  3248. { // Exp or Drop rates changed.
  3249. mob_reload(); //Needed as well so rate changes take effect.
  3250. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3251. }
  3252. clif_displaymessage(fd, msg_txt(sd,255));
  3253. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3254. status_readdb();
  3255. clif_displaymessage(fd, msg_txt(sd,256));
  3256. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3257. pc_readdb();
  3258. clif_displaymessage(fd, msg_txt(sd,257));
  3259. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3260. pc_read_motd();
  3261. clif_displaymessage(fd, msg_txt(sd,268));
  3262. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3263. struct s_mapiterator* iter;
  3264. struct map_session_data* pl_sd;
  3265. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3266. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3267. iter = mapit_getallusers();
  3268. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3269. pc_close_npc(pl_sd,2);
  3270. mapit_free(iter);
  3271. flush_fifos();
  3272. map_reloadnpc(true); // reload config files seeking for npcs
  3273. script_reload();
  3274. npc_reload();
  3275. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3276. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3277. map_msg_reload();
  3278. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3279. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3280. do_reload_quest();
  3281. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3282. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3283. packetdb_readdb(true);
  3284. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3285. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3286. instance_reload();
  3287. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3288. }
  3289. return 0;
  3290. }
  3291. /*==========================================
  3292. * @partysharelvl <share_range> [Akinari]
  3293. * Updates char server party share level range in runtime
  3294. * Temporary - Permanent update in inter_athena.conf
  3295. *------------------------------------------*/
  3296. ACMD_FUNC(partysharelvl) {
  3297. unsigned int share_lvl;
  3298. nullpo_retr(-1, sd);
  3299. if(!message || !*message) {
  3300. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3301. return -1;
  3302. } else {
  3303. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3304. }
  3305. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3306. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3307. else //Char server offline
  3308. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3309. return 0;
  3310. }
  3311. /*==========================================
  3312. * @mapinfo [0-3] <map name> by MC_Cameri
  3313. * => Shows information about the map [map name]
  3314. * 0 = no additional information
  3315. * 1 = Show users in that map and their location
  3316. * 2 = Shows NPCs in that map
  3317. * 3 = Shows the chats in that map
  3318. *------------------------------------------*/
  3319. ACMD_FUNC(mapinfo) {
  3320. struct map_session_data* pl_sd;
  3321. struct s_mapiterator* iter;
  3322. struct chat_data *cd = NULL;
  3323. char direction[12];
  3324. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3325. unsigned short m_index;
  3326. char mapname[24];
  3327. nullpo_retr(-1, sd);
  3328. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3329. memset(mapname, '\0', sizeof(mapname));
  3330. memset(direction, '\0', sizeof(direction));
  3331. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3332. if (list < 0 || list > 3) {
  3333. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3334. return -1;
  3335. }
  3336. if (mapname[0] == '\0') {
  3337. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3338. m_id = map_mapindex2mapid(sd->mapindex);
  3339. } else {
  3340. m_id = map_mapname2mapid(mapname);
  3341. }
  3342. if (m_id < 0) {
  3343. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3344. return -1;
  3345. }
  3346. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3347. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3348. // count chats (for initial message)
  3349. chat_num = 0;
  3350. iter = mapit_getallusers();
  3351. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3352. if( pl_sd->mapindex == m_index ) {
  3353. if( pl_sd->state.vending )
  3354. vend_num++;
  3355. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3356. chat_num++;
  3357. }
  3358. }
  3359. mapit_free(iter);
  3360. 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
  3361. clif_displaymessage(fd, atcmd_output);
  3362. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3363. if (map[m_id].flag.town)
  3364. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3365. if (map[m_id].flag.restricted){
  3366. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3367. clif_displaymessage(fd, atcmd_output);
  3368. }
  3369. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3370. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3371. else
  3372. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3373. if (map[m_id].flag.battleground){
  3374. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3375. clif_displaymessage(fd, atcmd_output);
  3376. }
  3377. /* Skill damage adjustment info [Cydh] */
  3378. #ifdef ADJUST_SKILL_DAMAGE
  3379. if (map[m_id].flag.skill_damage) {
  3380. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3381. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3382. ,map[m_id].adjust.damage.pc
  3383. ,map[m_id].adjust.damage.mob
  3384. ,map[m_id].adjust.damage.boss
  3385. ,map[m_id].adjust.damage.other
  3386. ,map[m_id].adjust.damage.caster);
  3387. clif_displaymessage(fd, atcmd_output);
  3388. if (map[m_id].skill_damage.count) {
  3389. uint8 j;
  3390. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3391. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3392. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3393. ,j+1
  3394. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3395. ,map[m_id].skill_damage.entries[j]->pc
  3396. ,map[m_id].skill_damage.entries[j]->mob
  3397. ,map[m_id].skill_damage.entries[j]->boss
  3398. ,map[m_id].skill_damage.entries[j]->other
  3399. ,map[m_id].skill_damage.entries[j]->caster);
  3400. clif_displaymessage(fd,atcmd_output);
  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, "%11d", &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. short 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, "%6hd %6hd %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[MAP_NAME_LENGTH_EXT];
  4505. short 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 %6hd %6hd %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 = gstorage_get_storage(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. if (gstorage->opened) {
  4664. struct map_session_data *tsd = map_charid2sd(gstorage->opened);
  4665. if (tsd)
  4666. gstorage_storageclose(tsd);
  4667. }
  4668. j = gstorage->storage_amount;
  4669. gstorage->locked = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4670. for (i = 0; i < j; ++i) {
  4671. gstorage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4672. }
  4673. gstorage_storageclose(sd);
  4674. gstorage->locked = false; // Cleaning done, release lock
  4675. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4676. return 0;
  4677. }
  4678. ACMD_FUNC(clearcart)
  4679. {
  4680. int i;
  4681. nullpo_retr(-1, sd);
  4682. if (pc_iscarton(sd) == 0) {
  4683. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4684. return -1;
  4685. }
  4686. if (sd->state.vending == 1) { //Somehow...
  4687. return -1;
  4688. }
  4689. for( i = 0; i < MAX_CART; i++ )
  4690. if(sd->status.cart[i].nameid > 0)
  4691. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4692. clif_clearcart(fd);
  4693. clif_updatestatus(sd,SP_CARTINFO);
  4694. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4695. return 0;
  4696. }
  4697. /*==========================================
  4698. * @skillid by [MouseJstr]
  4699. * lookup a skill by name
  4700. *------------------------------------------*/
  4701. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4702. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4703. ACMD_FUNC(skillid) {
  4704. int skillen, i, found = 0;
  4705. DBIterator* iter;
  4706. DBKey key;
  4707. DBData *data;
  4708. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4709. nullpo_retr(-1, sd);
  4710. if (!message || !*message) {
  4711. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4712. return -1;
  4713. }
  4714. skillen = strlen(message);
  4715. iter = db_iterator(skilldb_name2id);
  4716. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4717. int idx = skill_get_index(db_data2i(data));
  4718. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4719. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4720. clif_displaymessage(fd, atcmd_output);
  4721. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4722. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str);
  4723. }
  4724. }
  4725. dbi_destroy(iter);
  4726. if( found ) {
  4727. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4728. clif_displaymessage(fd, atcmd_output);
  4729. }
  4730. for(i = 0; i < found; i++) { /* partials */
  4731. clif_displaymessage(fd, partials[i]);
  4732. }
  4733. return 0;
  4734. }
  4735. /*==========================================
  4736. * @useskill by [MouseJstr]
  4737. * A way of using skills without having to find them in the skills menu
  4738. *------------------------------------------*/
  4739. ACMD_FUNC(useskill)
  4740. {
  4741. struct map_session_data *pl_sd = NULL;
  4742. struct block_list *bl;
  4743. uint16 skill_id;
  4744. uint16 skill_lv;
  4745. char target[100];
  4746. nullpo_retr(-1, sd);
  4747. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4748. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4749. return -1;
  4750. }
  4751. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4752. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4753. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4754. return -1;
  4755. }
  4756. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4757. {
  4758. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4759. return -1;
  4760. }
  4761. if (SKILL_CHK_HOMUN(skill_id)
  4762. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4763. bl = &sd->hd->bl;
  4764. else
  4765. bl = &sd->bl;
  4766. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4767. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4768. else
  4769. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4770. return 0;
  4771. }
  4772. /*==========================================
  4773. * @displayskill by [Skotlex]
  4774. * Debug command to locate new skill IDs. It sends the
  4775. * three possible skill-effect packets to the area.
  4776. *------------------------------------------*/
  4777. ACMD_FUNC(displayskill)
  4778. {
  4779. struct status_data * status;
  4780. unsigned int tick;
  4781. uint16 skill_id;
  4782. uint16 skill_lv = 1;
  4783. nullpo_retr(-1, sd);
  4784. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4785. {
  4786. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4787. return -1;
  4788. }
  4789. status = status_get_status_data(&sd->bl);
  4790. tick = gettick();
  4791. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4792. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4793. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4794. return 0;
  4795. }
  4796. /*==========================================
  4797. * @skilltree by [MouseJstr]
  4798. * prints the skill tree for a player required to get to a skill
  4799. *------------------------------------------*/
  4800. ACMD_FUNC(skilltree)
  4801. {
  4802. struct map_session_data *pl_sd = NULL;
  4803. uint16 skill_id;
  4804. int meets, j, c=0;
  4805. char target[NAME_LENGTH];
  4806. struct skill_tree_entry *ent;
  4807. nullpo_retr(-1, sd);
  4808. if(!message || !*message || sscanf(message, "%6hu %23[^\r\n]", &skill_id, target) != 2) {
  4809. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4810. return -1;
  4811. }
  4812. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4813. {
  4814. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4815. return -1;
  4816. }
  4817. c = pc_calc_skilltree_normalize_job(pl_sd);
  4818. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4819. 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).
  4820. clif_displaymessage(fd, atcmd_output);
  4821. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4822. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4823. {
  4824. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4825. return 0;
  4826. }
  4827. ent = &skill_tree[c][j];
  4828. meets = 1;
  4829. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4830. {
  4831. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4832. {
  4833. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[skill_get_index(ent->need[j].id)]->desc); // Player requires level %d of skill %s.
  4834. clif_displaymessage(fd, atcmd_output);
  4835. meets = 0;
  4836. }
  4837. }
  4838. if (meets == 1) {
  4839. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4840. }
  4841. return 0;
  4842. }
  4843. // Hand a ring with partners name on it to this char
  4844. void getring (struct map_session_data* sd)
  4845. {
  4846. char flag = 0;
  4847. unsigned short item_id;
  4848. struct item item_tmp;
  4849. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4850. memset(&item_tmp, 0, sizeof(item_tmp));
  4851. item_tmp.nameid = item_id;
  4852. item_tmp.identify = 1;
  4853. item_tmp.card[0] = 255;
  4854. item_tmp.card[2] = sd->status.partner_id;
  4855. item_tmp.card[3] = sd->status.partner_id >> 16;
  4856. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4857. clif_additem(sd,0,0,flag);
  4858. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4859. }
  4860. }
  4861. /*==========================================
  4862. * @marry by [MouseJstr], fixed by Lupus
  4863. * Marry two players
  4864. *------------------------------------------*/
  4865. ACMD_FUNC(marry)
  4866. {
  4867. struct map_session_data *pl_sd = NULL;
  4868. char player_name[NAME_LENGTH] = "";
  4869. nullpo_retr(-1, sd);
  4870. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4871. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4872. return -1;
  4873. }
  4874. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4875. clif_displaymessage(fd, msg_txt(sd,3));
  4876. return -1;
  4877. }
  4878. if (pc_marriage(sd, pl_sd)) {
  4879. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4880. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4881. getring(sd); // Auto-give named rings (Aru)
  4882. getring(pl_sd);
  4883. return 0;
  4884. }
  4885. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4886. return -1;
  4887. }
  4888. /*==========================================
  4889. * @divorce by [MouseJstr], fixed by [Lupus]
  4890. * divorce two players
  4891. *------------------------------------------*/
  4892. ACMD_FUNC(divorce)
  4893. {
  4894. nullpo_retr(-1, sd);
  4895. if (!pc_divorce(sd)) {
  4896. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4897. clif_displaymessage(fd, atcmd_output);
  4898. return -1;
  4899. }
  4900. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4901. clif_displaymessage(fd, atcmd_output);
  4902. return 0;
  4903. }
  4904. /*==========================================
  4905. * @changelook by [Celest]
  4906. *------------------------------------------*/
  4907. ACMD_FUNC(changelook)
  4908. {
  4909. int i, j = 0, k = 0;
  4910. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4911. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  4912. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4913. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4914. return -1;
  4915. } else if ( i == 2 ) {
  4916. if (j < 1 || j > 7)
  4917. j = 1;
  4918. j = pos[j - 1];
  4919. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4920. k = j; // swap
  4921. j = LOOK_HEAD_TOP;
  4922. }
  4923. clif_changelook(&sd->bl,j,k);
  4924. return 0;
  4925. }
  4926. /*==========================================
  4927. * @autotrade by durf [Lupus] [Paradox924X]
  4928. * Turns on/off Autotrade for a specific player
  4929. *------------------------------------------*/
  4930. ACMD_FUNC(autotrade) {
  4931. nullpo_retr(-1, sd);
  4932. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4933. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4934. return -1;
  4935. }
  4936. if( pc_isdead(sd) ) {
  4937. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4938. return -1;
  4939. }
  4940. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4941. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4942. return -1;
  4943. }
  4944. sd->state.autotrade = 1;
  4945. if (battle_config.autotrade_monsterignore)
  4946. sd->state.monster_ignore = 1;
  4947. if( sd->state.vending ){
  4948. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4949. Sql_ShowDebug( mmysql_handle );
  4950. }
  4951. }else if( sd->state.buyingstore ){
  4952. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
  4953. Sql_ShowDebug( mmysql_handle );
  4954. }
  4955. }
  4956. if( battle_config.at_timeout ) {
  4957. int timeout = atoi(message);
  4958. 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);
  4959. }
  4960. channel_pcquit(sd,0xF); //leave all chan
  4961. clif_authfail_fd(sd->fd, 15);
  4962. chrif_save(sd,3);
  4963. return 0;
  4964. }
  4965. /*==========================================
  4966. * @changegm by durf (changed by Lupus)
  4967. * Changes Master of your Guild to a specified guild member
  4968. *------------------------------------------*/
  4969. ACMD_FUNC(changegm)
  4970. {
  4971. struct guild *g;
  4972. struct map_session_data *pl_sd;
  4973. nullpo_retr(-1, sd);
  4974. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4975. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4976. return -1;
  4977. }
  4978. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4979. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4980. return -1;
  4981. }
  4982. if( !message[0] ) {
  4983. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4984. return -1;
  4985. }
  4986. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4987. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4988. return -1;
  4989. }
  4990. guild_gm_change(sd->status.guild_id, pl_sd);
  4991. return 0;
  4992. }
  4993. /*==========================================
  4994. * @changeleader by Skotlex
  4995. * Changes the leader of a party.
  4996. *------------------------------------------*/
  4997. ACMD_FUNC(changeleader)
  4998. {
  4999. nullpo_retr(-1, sd);
  5000. if( !message[0] )
  5001. {
  5002. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5003. return -1;
  5004. }
  5005. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  5006. return 0;
  5007. return -1;
  5008. }
  5009. /*==========================================
  5010. * @partyoption by Skotlex
  5011. * Used to change the item share setting of a party.
  5012. *------------------------------------------*/
  5013. ACMD_FUNC(partyoption)
  5014. {
  5015. struct party_data *p;
  5016. int mi, option;
  5017. char w1[16], w2[16];
  5018. nullpo_retr(-1, sd);
  5019. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5020. {
  5021. clif_displaymessage(fd, msg_txt(sd,282));
  5022. return -1;
  5023. }
  5024. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5025. if (mi == MAX_PARTY)
  5026. return -1; //Shouldn't happen
  5027. if (!p->party.member[mi].leader)
  5028. {
  5029. clif_displaymessage(fd, msg_txt(sd,282));
  5030. return -1;
  5031. }
  5032. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5033. {
  5034. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5035. return -1;
  5036. }
  5037. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5038. //Change item share type.
  5039. if (option != p->party.item)
  5040. party_changeoption(sd, p->party.exp, option);
  5041. else
  5042. clif_displaymessage(fd, msg_txt(sd,286));
  5043. return 0;
  5044. }
  5045. /*==========================================
  5046. * @autoloot by Upa-Kun
  5047. * Turns on/off AutoLoot for a specific player
  5048. *------------------------------------------*/
  5049. ACMD_FUNC(autoloot)
  5050. {
  5051. int rate;
  5052. nullpo_retr(-1, sd);
  5053. // autoloot command without value
  5054. if(!message || !*message)
  5055. {
  5056. if (sd->state.autoloot)
  5057. rate = 0;
  5058. else
  5059. rate = 10000;
  5060. } else {
  5061. double drate;
  5062. drate = atof(message);
  5063. rate = (int)(drate*100);
  5064. }
  5065. if (rate < 0) rate = 0;
  5066. if (rate > 10000) rate = 10000;
  5067. sd->state.autoloot = rate;
  5068. if (sd->state.autoloot) {
  5069. 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.
  5070. clif_displaymessage(fd, atcmd_output);
  5071. }else
  5072. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5073. return 0;
  5074. }
  5075. /*==========================================
  5076. * @alootid
  5077. *------------------------------------------*/
  5078. ACMD_FUNC(autolootitem)
  5079. {
  5080. struct item_data *item_data = NULL;
  5081. int i;
  5082. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5083. nullpo_retr(-1, sd);
  5084. if (message && *message) {
  5085. if (message[0] == '+') {
  5086. message++;
  5087. action = 1;
  5088. }
  5089. else if (message[0] == '-') {
  5090. message++;
  5091. action = 2;
  5092. }
  5093. else if (!strcmp(message,"reset"))
  5094. action = 4;
  5095. }
  5096. if (action < 3) // add or remove
  5097. {
  5098. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5099. item_data = itemdb_searchname(message);
  5100. if (!item_data) {
  5101. // No items founds in the DB with Id or Name
  5102. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5103. return -1;
  5104. }
  5105. }
  5106. switch(action) {
  5107. case 1:
  5108. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5109. if (i != AUTOLOOTITEM_SIZE) {
  5110. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5111. return -1;
  5112. }
  5113. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5114. if (i == AUTOLOOTITEM_SIZE) {
  5115. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5116. return -1;
  5117. }
  5118. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5119. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5120. clif_displaymessage(fd, atcmd_output);
  5121. sd->state.autolooting = 1;
  5122. break;
  5123. case 2:
  5124. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5125. if (i == AUTOLOOTITEM_SIZE) {
  5126. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5127. return -1;
  5128. }
  5129. sd->state.autolootid[i] = 0;
  5130. 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.
  5131. clif_displaymessage(fd, atcmd_output);
  5132. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5133. if (i == AUTOLOOTITEM_SIZE) {
  5134. sd->state.autolooting = 0;
  5135. }
  5136. break;
  5137. case 3:
  5138. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5139. clif_displaymessage(fd, atcmd_output);
  5140. 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>".
  5141. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5142. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5143. if (i == AUTOLOOTITEM_SIZE) {
  5144. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5145. } else {
  5146. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5147. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5148. {
  5149. if (sd->state.autolootid[i] == 0)
  5150. continue;
  5151. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5152. 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);
  5153. continue;
  5154. }
  5155. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5156. clif_displaymessage(fd, atcmd_output);
  5157. }
  5158. }
  5159. break;
  5160. case 4:
  5161. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5162. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5163. sd->state.autolooting = 0;
  5164. break;
  5165. }
  5166. return 0;
  5167. }
  5168. /*==========================================
  5169. * @autoloottype
  5170. * Flags:
  5171. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5172. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5173. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5174. * 262144: IT_CASH
  5175. *------------------------------------------
  5176. * Credits:
  5177. * chriser
  5178. * Aleos
  5179. *------------------------------------------*/
  5180. ACMD_FUNC(autoloottype)
  5181. {
  5182. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5183. enum item_types type = -1;
  5184. int ITEM_MAX = 1533;
  5185. nullpo_retr(-1, sd);
  5186. if (message && *message) {
  5187. if (message[0] == '+') {
  5188. message++;
  5189. action = 1;
  5190. }
  5191. else if (message[0] == '-') {
  5192. message++;
  5193. action = 2;
  5194. }
  5195. else if (!strcmp(message,"reset"))
  5196. action = 4;
  5197. }
  5198. if (action < 3) { // add or remove
  5199. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5200. type = IT_HEALING;
  5201. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5202. type = IT_USABLE;
  5203. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5204. type = IT_ETC;
  5205. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5206. type = IT_ARMOR;
  5207. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5208. type = IT_WEAPON;
  5209. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5210. type = IT_CARD;
  5211. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5212. type = IT_PETEGG;
  5213. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5214. type = IT_PETARMOR;
  5215. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5216. type = IT_AMMO;
  5217. else {
  5218. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5219. return -1;
  5220. }
  5221. }
  5222. switch (action) {
  5223. case 1:
  5224. if (sd->state.autoloottype&(1<<type)) {
  5225. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5226. return -1;
  5227. }
  5228. if (sd->state.autoloottype == ITEM_MAX) {
  5229. 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>.
  5230. return -1;
  5231. }
  5232. sd->state.autoloottype |= (1<<type); // Stores the type
  5233. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5234. clif_displaymessage(fd, atcmd_output);
  5235. break;
  5236. case 2:
  5237. if (!(sd->state.autoloottype&(1<<type))) {
  5238. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5239. return -1;
  5240. }
  5241. sd->state.autoloottype &= ~(1<<type);
  5242. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5243. clif_displaymessage(fd, atcmd_output);
  5244. break;
  5245. case 3:
  5246. 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>".
  5247. 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
  5248. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5249. if (sd->state.autoloottype == 0)
  5250. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5251. else {
  5252. uint8 i = 0;
  5253. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5254. while (i < IT_MAX) {
  5255. if (sd->state.autoloottype&(1<<i)) {
  5256. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5257. clif_displaymessage(fd, atcmd_output);
  5258. }
  5259. i++;
  5260. }
  5261. }
  5262. break;
  5263. case 4:
  5264. sd->state.autoloottype = 0;
  5265. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5266. break;
  5267. }
  5268. return 0;
  5269. }
  5270. /**
  5271. * No longer available, keeping here just in case it's back someday. [Ind]
  5272. **/
  5273. /*==========================================
  5274. * It is made to rain.
  5275. *------------------------------------------*/
  5276. //ACMD_FUNC(rain)
  5277. //{
  5278. // nullpo_retr(-1, sd);
  5279. // if (map[sd->bl.m].flag.rain) {
  5280. // map[sd->bl.m].flag.rain=0;
  5281. // clif_weather(sd->bl.m);
  5282. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5283. // } else {
  5284. // map[sd->bl.m].flag.rain=1;
  5285. // clif_weather(sd->bl.m);
  5286. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5287. // }
  5288. // return 0;
  5289. //}
  5290. /*==========================================
  5291. * It is made to snow.
  5292. *------------------------------------------*/
  5293. ACMD_FUNC(snow)
  5294. {
  5295. nullpo_retr(-1, sd);
  5296. if (map[sd->bl.m].flag.snow) {
  5297. map[sd->bl.m].flag.snow=0;
  5298. clif_weather(sd->bl.m);
  5299. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5300. } else {
  5301. map[sd->bl.m].flag.snow=1;
  5302. clif_weather(sd->bl.m);
  5303. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5304. }
  5305. return 0;
  5306. }
  5307. /*==========================================
  5308. * Cherry tree snowstorm is made to fall. (Sakura)
  5309. *------------------------------------------*/
  5310. ACMD_FUNC(sakura)
  5311. {
  5312. nullpo_retr(-1, sd);
  5313. if (map[sd->bl.m].flag.sakura) {
  5314. map[sd->bl.m].flag.sakura=0;
  5315. clif_weather(sd->bl.m);
  5316. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5317. } else {
  5318. map[sd->bl.m].flag.sakura=1;
  5319. clif_weather(sd->bl.m);
  5320. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5321. }
  5322. return 0;
  5323. }
  5324. /*==========================================
  5325. * Clouds appear.
  5326. *------------------------------------------*/
  5327. ACMD_FUNC(clouds)
  5328. {
  5329. nullpo_retr(-1, sd);
  5330. if (map[sd->bl.m].flag.clouds) {
  5331. map[sd->bl.m].flag.clouds=0;
  5332. clif_weather(sd->bl.m);
  5333. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5334. } else {
  5335. map[sd->bl.m].flag.clouds=1;
  5336. clif_weather(sd->bl.m);
  5337. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5338. }
  5339. return 0;
  5340. }
  5341. /*==========================================
  5342. * Different type of clouds using effect 516
  5343. *------------------------------------------*/
  5344. ACMD_FUNC(clouds2)
  5345. {
  5346. nullpo_retr(-1, sd);
  5347. if (map[sd->bl.m].flag.clouds2) {
  5348. map[sd->bl.m].flag.clouds2=0;
  5349. clif_weather(sd->bl.m);
  5350. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5351. } else {
  5352. map[sd->bl.m].flag.clouds2=1;
  5353. clif_weather(sd->bl.m);
  5354. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5355. }
  5356. return 0;
  5357. }
  5358. /*==========================================
  5359. * Fog hangs over.
  5360. *------------------------------------------*/
  5361. ACMD_FUNC(fog)
  5362. {
  5363. nullpo_retr(-1, sd);
  5364. if (map[sd->bl.m].flag.fog) {
  5365. map[sd->bl.m].flag.fog=0;
  5366. clif_weather(sd->bl.m);
  5367. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5368. } else {
  5369. map[sd->bl.m].flag.fog=1;
  5370. clif_weather(sd->bl.m);
  5371. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5372. }
  5373. return 0;
  5374. }
  5375. /*==========================================
  5376. * Fallen leaves fall.
  5377. *------------------------------------------*/
  5378. ACMD_FUNC(leaves)
  5379. {
  5380. nullpo_retr(-1, sd);
  5381. if (map[sd->bl.m].flag.leaves) {
  5382. map[sd->bl.m].flag.leaves=0;
  5383. clif_weather(sd->bl.m);
  5384. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5385. } else {
  5386. map[sd->bl.m].flag.leaves=1;
  5387. clif_weather(sd->bl.m);
  5388. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5389. }
  5390. return 0;
  5391. }
  5392. /*==========================================
  5393. * Fireworks appear.
  5394. *------------------------------------------*/
  5395. ACMD_FUNC(fireworks)
  5396. {
  5397. nullpo_retr(-1, sd);
  5398. if (map[sd->bl.m].flag.fireworks) {
  5399. map[sd->bl.m].flag.fireworks=0;
  5400. clif_weather(sd->bl.m);
  5401. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5402. } else {
  5403. map[sd->bl.m].flag.fireworks=1;
  5404. clif_weather(sd->bl.m);
  5405. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5406. }
  5407. return 0;
  5408. }
  5409. /*==========================================
  5410. * Clearing Weather Effects by Dexity
  5411. *------------------------------------------*/
  5412. ACMD_FUNC(clearweather)
  5413. {
  5414. nullpo_retr(-1, sd);
  5415. /**
  5416. * No longer available, keeping here just in case it's back someday. [Ind]
  5417. **/
  5418. //map[sd->bl.m].flag.rain=0;
  5419. map[sd->bl.m].flag.snow=0;
  5420. map[sd->bl.m].flag.sakura=0;
  5421. map[sd->bl.m].flag.clouds=0;
  5422. map[sd->bl.m].flag.clouds2=0;
  5423. map[sd->bl.m].flag.fog=0;
  5424. map[sd->bl.m].flag.fireworks=0;
  5425. map[sd->bl.m].flag.leaves=0;
  5426. clif_weather(sd->bl.m);
  5427. clif_displaymessage(fd, msg_txt(sd,291));
  5428. return 0;
  5429. }
  5430. /*===============================================================
  5431. * Sound Command - plays a sound for everyone around! [Codemaster]
  5432. *---------------------------------------------------------------*/
  5433. ACMD_FUNC(sound)
  5434. {
  5435. char sound_file[100];
  5436. memset(sound_file, '\0', sizeof(sound_file));
  5437. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5438. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5439. return -1;
  5440. }
  5441. if(strstr(sound_file, ".wav") == NULL)
  5442. strcat(sound_file, ".wav");
  5443. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5444. return 0;
  5445. }
  5446. /*==========================================
  5447. * MOB Search
  5448. *------------------------------------------*/
  5449. ACMD_FUNC(mobsearch)
  5450. {
  5451. char mob_name[100];
  5452. int mob_id;
  5453. int number = 0;
  5454. struct s_mapiterator* it;
  5455. nullpo_retr(-1, sd);
  5456. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5457. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5458. return -1;
  5459. }
  5460. if ((mob_id = atoi(mob_name)) == 0)
  5461. mob_id = mobdb_searchname(mob_name);
  5462. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5463. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5464. clif_displaymessage(fd, atcmd_output);
  5465. return -1;
  5466. }
  5467. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5468. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5469. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5470. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5471. clif_displaymessage(fd, atcmd_output);
  5472. it = mapit_geteachmob();
  5473. for(;;)
  5474. {
  5475. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5476. if( md == NULL )
  5477. break;// no more mobs
  5478. if( md->bl.m != sd->bl.m )
  5479. continue;
  5480. if( mob_id != -1 && md->mob_id != mob_id )
  5481. continue;
  5482. ++number;
  5483. if( md->spawn_timer == INVALID_TIMER )
  5484. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5485. else
  5486. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5487. clif_displaymessage(fd, atcmd_output);
  5488. }
  5489. mapit_free(it);
  5490. return 0;
  5491. }
  5492. /*==========================================
  5493. * @cleanmap - cleans items on the ground
  5494. * @cleanarea - cleans items on the ground within an specified area
  5495. *------------------------------------------*/
  5496. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5497. {
  5498. nullpo_ret(bl);
  5499. map_clearflooritem(bl);
  5500. return 0;
  5501. }
  5502. ACMD_FUNC(cleanmap)
  5503. {
  5504. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5505. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5506. return 0;
  5507. }
  5508. ACMD_FUNC(cleanarea)
  5509. {
  5510. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5511. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5512. 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);
  5513. }
  5514. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5515. 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);
  5516. }
  5517. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5518. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5519. }
  5520. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5521. return 0;
  5522. }
  5523. /*==========================================
  5524. * make a NPC/PET talk
  5525. * @npctalkc [SnakeDrak]
  5526. *------------------------------------------*/
  5527. ACMD_FUNC(npctalk)
  5528. {
  5529. char name[NAME_LENGTH],mes[100],temp[100];
  5530. struct npc_data *nd;
  5531. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5532. unsigned long color=0;
  5533. if (sd->sc.cant.chat)
  5534. return -1; //no "chatting" while muted.
  5535. if(!ifcolor) {
  5536. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5537. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5538. return -1;
  5539. }
  5540. }
  5541. else {
  5542. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5543. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5544. return -1;
  5545. }
  5546. }
  5547. if (!(nd = npc_name2id(name))) {
  5548. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5549. return -1;
  5550. }
  5551. strtok(name, "#"); // discard extra name identifier if present
  5552. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5553. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5554. else clif_disp_overhead(&nd->bl, temp);
  5555. return 0;
  5556. }
  5557. ACMD_FUNC(pettalk)
  5558. {
  5559. char mes[100],temp[100];
  5560. struct pet_data *pd;
  5561. nullpo_retr(-1, sd);
  5562. if ( battle_config.min_chat_delay ) {
  5563. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5564. return 0;
  5565. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5566. }
  5567. if(!sd->status.pet_id || !(pd=sd->pd))
  5568. {
  5569. clif_displaymessage(fd, msg_txt(sd,184));
  5570. return -1;
  5571. }
  5572. if (sd->sc.cant.chat)
  5573. return -1; //no "chatting" while muted.
  5574. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5575. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5576. return -1;
  5577. }
  5578. if (message[0] == '/')
  5579. {// pet emotion processing
  5580. const char* emo[] = {
  5581. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5582. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5583. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5584. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5585. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5586. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5587. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5588. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5589. "/whisp"
  5590. };
  5591. int i;
  5592. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5593. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5594. if( i < ARRAYLENGTH(emo) )
  5595. {
  5596. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5597. sd->emotionlasttime = time(NULL);
  5598. return 0;
  5599. }
  5600. sd->emotionlasttime = time(NULL);
  5601. clif_emotion(&pd->bl, i);
  5602. return 0;
  5603. }
  5604. }
  5605. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5606. clif_disp_overhead(&pd->bl, temp);
  5607. return 0;
  5608. }
  5609. /// @users - displays the number of players present on each map (and percentage)
  5610. /// #users displays on the target user instead of self
  5611. ACMD_FUNC(users)
  5612. {
  5613. char buf[CHAT_SIZE_MAX];
  5614. int i;
  5615. int users[MAX_MAPINDEX];
  5616. int users_all;
  5617. struct s_mapiterator* iter;
  5618. memset(users, 0, sizeof(users));
  5619. users_all = 0;
  5620. // count users on each map
  5621. iter = mapit_getallusers();
  5622. for(;;)
  5623. {
  5624. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5625. if( sd2 == NULL )
  5626. break;// no more users
  5627. if( sd2->mapindex >= MAX_MAPINDEX )
  5628. continue;// invalid mapindex
  5629. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5630. if( users_all < INT_MAX ) ++users_all;
  5631. }
  5632. mapit_free(iter);
  5633. // display results for each map
  5634. for( i = 0; i < MAX_MAPINDEX; ++i )
  5635. {
  5636. if( users[i] == 0 )
  5637. continue;// empty
  5638. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5639. clif_displaymessage(sd->fd, buf);
  5640. }
  5641. // display overall count
  5642. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5643. clif_displaymessage(sd->fd, buf);
  5644. return 0;
  5645. }
  5646. /*==========================================
  5647. *
  5648. *------------------------------------------*/
  5649. ACMD_FUNC(reset)
  5650. {
  5651. pc_resetstate(sd);
  5652. pc_resetskill(sd,1);
  5653. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5654. clif_displaymessage(fd, atcmd_output);
  5655. return 0;
  5656. }
  5657. /*==========================================
  5658. *
  5659. *------------------------------------------*/
  5660. ACMD_FUNC(summon)
  5661. {
  5662. char name[NAME_LENGTH];
  5663. int mob_id = 0;
  5664. int duration = 0;
  5665. struct mob_data *md;
  5666. unsigned int tick=gettick();
  5667. nullpo_retr(-1, sd);
  5668. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5669. {
  5670. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5671. return -1;
  5672. }
  5673. if (duration < 1)
  5674. duration =1;
  5675. else if (duration > 60)
  5676. duration =60;
  5677. if ((mob_id = atoi(name)) == 0)
  5678. mob_id = mobdb_searchname(name);
  5679. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5680. {
  5681. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5682. return -1;
  5683. }
  5684. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5685. if(!md)
  5686. return -1;
  5687. md->master_id=sd->bl.id;
  5688. md->special_state.ai=AI_ATTACK;
  5689. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5690. clif_specialeffect(&md->bl,344,AREA);
  5691. mob_spawn(md);
  5692. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5693. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5694. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5695. return 0;
  5696. }
  5697. /*==========================================
  5698. * @adjgroup
  5699. * Temporarily move player to another group
  5700. * Useful during beta testing to allow players to use GM commands for short periods of time
  5701. *------------------------------------------*/
  5702. ACMD_FUNC(adjgroup)
  5703. {
  5704. int new_group = 0;
  5705. nullpo_retr(-1, sd);
  5706. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5707. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5708. return -1;
  5709. }
  5710. if (!pc_group_exists(new_group)) {
  5711. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5712. return -1;
  5713. }
  5714. sd->group_id = new_group;
  5715. pc_group_pc_load(sd);/* update cache */
  5716. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5717. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5718. return 0;
  5719. }
  5720. /*==========================================
  5721. * @trade by [MouseJstr]
  5722. * Open a trade window with a remote player
  5723. *------------------------------------------*/
  5724. ACMD_FUNC(trade)
  5725. {
  5726. struct map_session_data *pl_sd = NULL;
  5727. nullpo_retr(-1, sd);
  5728. if (!message || !*message) {
  5729. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5730. return -1;
  5731. }
  5732. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5733. {
  5734. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5735. return -1;
  5736. }
  5737. trade_traderequest(sd, pl_sd);
  5738. return 0;
  5739. }
  5740. /*==========================================
  5741. * @setbattleflag by [MouseJstr]
  5742. * set a battle_config flag without having to reboot
  5743. *------------------------------------------*/
  5744. ACMD_FUNC(setbattleflag)
  5745. {
  5746. char flag[128], value[128];
  5747. nullpo_retr(-1, sd);
  5748. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5749. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5750. return -1;
  5751. }
  5752. if (battle_set_value(flag, value) == 0)
  5753. {
  5754. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5755. return -1;
  5756. }
  5757. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5758. return 0;
  5759. }
  5760. /*==========================================
  5761. * @unmute [Valaris]
  5762. *------------------------------------------*/
  5763. ACMD_FUNC(unmute)
  5764. {
  5765. struct map_session_data *pl_sd = NULL;
  5766. nullpo_retr(-1, sd);
  5767. if (!message || !*message) {
  5768. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5769. return -1;
  5770. }
  5771. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5772. {
  5773. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5774. return -1;
  5775. }
  5776. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5777. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5778. return -1;
  5779. }
  5780. pl_sd->status.manner = 0;
  5781. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5782. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5783. return 0;
  5784. }
  5785. /*==========================================
  5786. * @uptime by MC Cameri
  5787. *------------------------------------------*/
  5788. ACMD_FUNC(uptime)
  5789. {
  5790. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5791. minute = 60, days = 0, hours = 0, minutes = 0;
  5792. nullpo_retr(-1, sd);
  5793. seconds = get_uptime();
  5794. days = seconds/day;
  5795. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5796. hours = seconds/hour;
  5797. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5798. minutes = seconds/minute;
  5799. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5800. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5801. clif_displaymessage(fd, atcmd_output);
  5802. return 0;
  5803. }
  5804. /*==========================================
  5805. * @changesex
  5806. * => Changes one's account sex. Switch from male to female or visversa
  5807. *------------------------------------------*/
  5808. ACMD_FUNC(changesex)
  5809. {
  5810. int i;
  5811. nullpo_retr(-1, sd);
  5812. pc_resetskill(sd,4);
  5813. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5814. for (i = 0; i < EQI_MAX; i++) {
  5815. if (sd->equip_index[i] >= 0)
  5816. pc_unequipitem(sd, sd->equip_index[i], 3);
  5817. }
  5818. chrif_changesex(sd, true);
  5819. return 0;
  5820. }
  5821. /*==========================================
  5822. * @changecharsex
  5823. * => Changes one's character sex. Switch from male to female or visversa.
  5824. *------------------------------------------*/
  5825. ACMD_FUNC(changecharsex)
  5826. {
  5827. int i;
  5828. nullpo_retr(-1, sd);
  5829. pc_resetskill(sd,4);
  5830. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5831. for (i = 0; i < EQI_MAX; i++) {
  5832. if (sd->equip_index[i] >= 0)
  5833. pc_unequipitem(sd, sd->equip_index[i], 3);
  5834. }
  5835. chrif_changesex(sd, false);
  5836. return 0;
  5837. }
  5838. /*================================================
  5839. * @mute - Mutes a player for a set amount of time
  5840. *------------------------------------------------*/
  5841. ACMD_FUNC(mute)
  5842. {
  5843. struct map_session_data *pl_sd = NULL;
  5844. int manner;
  5845. nullpo_retr(-1, sd);
  5846. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5847. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5848. return -1;
  5849. }
  5850. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5851. {
  5852. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5853. return -1;
  5854. }
  5855. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5856. {
  5857. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5858. return -1;
  5859. }
  5860. clif_manner_message(sd, 0);
  5861. clif_manner_message(pl_sd, 5);
  5862. if( pl_sd->status.manner < manner ) {
  5863. pl_sd->status.manner -= manner;
  5864. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5865. } else {
  5866. pl_sd->status.manner = 0;
  5867. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5868. }
  5869. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5870. return 0;
  5871. }
  5872. /*==========================================
  5873. * @refresh (like @jumpto <<yourself>>)
  5874. *------------------------------------------*/
  5875. ACMD_FUNC(refresh)
  5876. {
  5877. nullpo_retr(-1, sd);
  5878. clif_refresh(sd);
  5879. return 0;
  5880. }
  5881. ACMD_FUNC(refreshall)
  5882. {
  5883. struct map_session_data* iter_sd;
  5884. struct s_mapiterator* iter;
  5885. nullpo_retr(-1, sd);
  5886. iter = mapit_getallusers();
  5887. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5888. clif_refresh(iter_sd);
  5889. mapit_free(iter);
  5890. return 0;
  5891. }
  5892. /*==========================================
  5893. * @identify
  5894. * => GM's magnifier.
  5895. *------------------------------------------*/
  5896. ACMD_FUNC(identify)
  5897. {
  5898. int i,num;
  5899. nullpo_retr(-1, sd);
  5900. for(i=num=0;i<MAX_INVENTORY;i++){
  5901. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5902. num++;
  5903. }
  5904. }
  5905. if (num > 0) {
  5906. clif_item_identify_list(sd);
  5907. } else {
  5908. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5909. }
  5910. return 0;
  5911. }
  5912. /*===============================================
  5913. * @identifyall
  5914. * => Indentify all items in inventory - Akinari
  5915. *-----------------------------------------------*/
  5916. ACMD_FUNC(identifyall)
  5917. {
  5918. int i;
  5919. nullpo_retr(-1, sd);
  5920. for(i=0; i<MAX_INVENTORY; i++) {
  5921. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5922. sd->status.inventory[i].identify=1;
  5923. clif_item_identified(sd,i,0);
  5924. }
  5925. }
  5926. return 0;
  5927. }
  5928. /*==========================================
  5929. * @gmotd (Global MOTD)
  5930. * by davidsiaw :P
  5931. *------------------------------------------*/
  5932. ACMD_FUNC(gmotd)
  5933. {
  5934. FILE* fp;
  5935. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5936. {
  5937. char buf[CHAT_SIZE_MAX];
  5938. size_t len;
  5939. while( fgets(buf, sizeof(buf), fp) )
  5940. {
  5941. if( buf[0] == '/' && buf[1] == '/' )
  5942. {
  5943. continue;
  5944. }
  5945. len = strlen(buf);
  5946. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5947. {// strip trailing EOL characters
  5948. len--;
  5949. }
  5950. if( len )
  5951. {
  5952. buf[len] = 0;
  5953. intif_broadcast(buf, len+1, 0);
  5954. }
  5955. }
  5956. fclose(fp);
  5957. }
  5958. return 0;
  5959. }
  5960. ACMD_FUNC(misceffect)
  5961. {
  5962. int effect = 0;
  5963. nullpo_retr(-1, sd);
  5964. if (!message || !*message)
  5965. return -1;
  5966. if (sscanf(message, "%11d", &effect) < 1)
  5967. return -1;
  5968. clif_misceffect(&sd->bl,effect);
  5969. return 0;
  5970. }
  5971. /*==========================================
  5972. * MAIL SYSTEM
  5973. *------------------------------------------*/
  5974. ACMD_FUNC(mail)
  5975. {
  5976. nullpo_ret(sd);
  5977. mail_openmail(sd);
  5978. return 0;
  5979. }
  5980. /*==========================================
  5981. * Show Monster DB Info v 1.0
  5982. * originally by [Lupus]
  5983. *------------------------------------------*/
  5984. ACMD_FUNC(mobinfo)
  5985. {
  5986. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  5987. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  5988. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  5989. char atcmd_output2[CHAT_SIZE_MAX];
  5990. struct item_data *item_data;
  5991. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5992. int count;
  5993. int i, k;
  5994. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5995. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5996. if (!message || !*message) {
  5997. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5998. return -1;
  5999. }
  6000. // If monster identifier/name argument is a name
  6001. if ((i = mobdb_checkid(atoi(message))))
  6002. {
  6003. mob_array[0] = mob_db(i);
  6004. count = 1;
  6005. } else
  6006. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6007. if (!count) {
  6008. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6009. return -1;
  6010. }
  6011. if (count > MAX_SEARCH) {
  6012. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6013. clif_displaymessage(fd, atcmd_output);
  6014. count = MAX_SEARCH;
  6015. }
  6016. for (k = 0; k < count; k++) {
  6017. unsigned int j,base_exp,job_exp;
  6018. mob = mob_array[k];
  6019. base_exp = mob->base_exp;
  6020. job_exp = mob->job_exp;
  6021. #ifdef RENEWAL_EXP
  6022. if( battle_config.atcommand_mobinfo_type ) {
  6023. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  6024. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  6025. }
  6026. #endif
  6027. #ifdef VIP_ENABLE
  6028. // Display EXP rate increase for VIP.
  6029. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  6030. base_exp += battle_config.vip_base_exp_increase;
  6031. job_exp += battle_config.vip_job_exp_increase;
  6032. }
  6033. #endif
  6034. // stats
  6035. if (mob->mexp)
  6036. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6037. else
  6038. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6039. clif_displaymessage(fd, atcmd_output);
  6040. 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
  6041. clif_displaymessage(fd, atcmd_output);
  6042. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6043. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6044. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6045. clif_displaymessage(fd, atcmd_output);
  6046. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6047. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6048. mob->range2 , mob->range3, msize[mob->status.size],
  6049. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6050. clif_displaymessage(fd, atcmd_output);
  6051. // drops
  6052. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6053. strcpy(atcmd_output, " ");
  6054. j = 0;
  6055. for (i = 0; i < MAX_MOB_DROP; i++) {
  6056. int droprate;
  6057. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6058. continue;
  6059. droprate = mob->dropitem[i].p;
  6060. #ifdef RENEWAL_DROP
  6061. if( battle_config.atcommand_mobinfo_type ) {
  6062. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 2) / 100;
  6063. if (droprate <= 0 && !battle_config.drop_rate0item)
  6064. droprate = 1;
  6065. }
  6066. #endif
  6067. #ifdef VIP_ENABLE
  6068. // Display item rate increase for VIP.
  6069. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6070. droprate += battle_config.vip_drop_increase;
  6071. #endif
  6072. if (item_data->slot)
  6073. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6074. else
  6075. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6076. strcat(atcmd_output, atcmd_output2);
  6077. if (++j % 3 == 0) {
  6078. clif_displaymessage(fd, atcmd_output);
  6079. strcpy(atcmd_output, " ");
  6080. }
  6081. }
  6082. if (j == 0)
  6083. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6084. else if (j % 3 != 0)
  6085. clif_displaymessage(fd, atcmd_output);
  6086. // mvp
  6087. if (mob->mexp) {
  6088. float mvppercent, mvpremain;
  6089. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6090. clif_displaymessage(fd, atcmd_output);
  6091. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6092. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6093. j = 0;
  6094. for (i = 0; i < MAX_MVP_DROP; i++) {
  6095. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6096. continue;
  6097. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6098. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6099. if(battle_config.item_drop_mvp_mode == 0) {
  6100. mvpremain -= mvppercent;
  6101. }
  6102. if (mvppercent > 0) {
  6103. j++;
  6104. if (j == 1) {
  6105. if (item_data->slot)
  6106. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6107. else
  6108. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6109. } else {
  6110. if (item_data->slot)
  6111. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6112. else
  6113. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6114. }
  6115. strcat(atcmd_output, atcmd_output2);
  6116. }
  6117. }
  6118. if (j == 0)
  6119. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6120. else
  6121. clif_displaymessage(fd, atcmd_output);
  6122. }
  6123. }
  6124. return 0;
  6125. }
  6126. /*=========================================
  6127. * @showmobs by KarLaeda
  6128. * => For 15 sec displays the mobs on minimap
  6129. *------------------------------------------*/
  6130. ACMD_FUNC(showmobs)
  6131. {
  6132. char mob_name[100];
  6133. int mob_id;
  6134. int number = 0;
  6135. struct s_mapiterator* it;
  6136. nullpo_retr(-1, sd);
  6137. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6138. return -1;
  6139. if((mob_id = atoi(mob_name)) == 0)
  6140. mob_id = mobdb_searchname(mob_name);
  6141. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6142. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6143. clif_displaymessage(fd, atcmd_output);
  6144. return 0;
  6145. }
  6146. 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.
  6147. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6148. return 0;
  6149. }
  6150. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6151. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6152. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6153. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6154. mob_name, mapindex_id2name(sd->mapindex));
  6155. clif_displaymessage(fd, atcmd_output);
  6156. it = mapit_geteachmob();
  6157. for(;;)
  6158. {
  6159. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6160. if( md == NULL )
  6161. break;// no more mobs
  6162. if( md->bl.m != sd->bl.m )
  6163. continue;
  6164. if( mob_id != -1 && md->mob_id != mob_id )
  6165. continue;
  6166. if( md->special_state.ai || md->master_id )
  6167. continue; // hide slaves and player summoned mobs
  6168. if( md->spawn_timer != INVALID_TIMER )
  6169. continue; // hide mobs waiting for respawn
  6170. ++number;
  6171. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6172. }
  6173. mapit_free(it);
  6174. return 0;
  6175. }
  6176. /*==========================================
  6177. * homunculus level up [orn]
  6178. *------------------------------------------*/
  6179. ACMD_FUNC(homlevel)
  6180. {
  6181. TBL_HOM * hd;
  6182. int level = 0, i = 0;
  6183. nullpo_retr(-1, sd);
  6184. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6185. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6186. return -1;
  6187. }
  6188. if ( !hom_is_active(sd->hd) ) {
  6189. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6190. return -1;
  6191. }
  6192. hd = sd->hd;
  6193. for (i = 1; i <= level && hd->exp_next; i++){
  6194. hd->homunculus.exp += hd->exp_next;
  6195. if( !hom_levelup(hd) )
  6196. break;
  6197. }
  6198. status_calc_homunculus(hd, SCO_NONE);
  6199. status_percent_heal(&hd->bl, 100, 100);
  6200. clif_specialeffect(&hd->bl,568,AREA);
  6201. return 0;
  6202. }
  6203. /*==========================================
  6204. * homunculus evolution H [orn]
  6205. *------------------------------------------*/
  6206. ACMD_FUNC(homevolution)
  6207. {
  6208. nullpo_retr(-1, sd);
  6209. if ( !hom_is_active(sd->hd) ) {
  6210. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6211. return -1;
  6212. }
  6213. if ( !hom_evolution(sd->hd) ) {
  6214. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6215. return -1;
  6216. }
  6217. clif_homskillinfoblock(sd);
  6218. return 0;
  6219. }
  6220. ACMD_FUNC(hommutate)
  6221. {
  6222. int homun_id, m_class = 0, m_id;
  6223. nullpo_retr(-1, sd);
  6224. if (!hom_is_active(sd->hd)) {
  6225. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6226. return -1;
  6227. }
  6228. if (!message || !*message) {
  6229. homun_id = 6048 + (rnd() % 4);
  6230. } else {
  6231. homun_id = atoi(message);
  6232. }
  6233. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6234. m_id = hom_class2mapid(homun_id);
  6235. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6236. hom_mutate(sd->hd, homun_id);
  6237. } else {
  6238. clif_emotion(&sd->hd->bl, E_SWT);
  6239. }
  6240. return 0;
  6241. }
  6242. /*==========================================
  6243. * call choosen homunculus [orn]
  6244. *------------------------------------------*/
  6245. ACMD_FUNC(makehomun)
  6246. {
  6247. int homunid;
  6248. nullpo_retr(-1, sd);
  6249. if ( sd->status.hom_id ) {
  6250. clif_displaymessage(fd, msg_txt(sd,450));
  6251. return -1;
  6252. }
  6253. if (!message || !*message) {
  6254. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6255. return -1;
  6256. }
  6257. homunid = atoi(message);
  6258. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6259. {
  6260. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6261. return -1;
  6262. }
  6263. hom_create_request(sd,homunid);
  6264. return 0;
  6265. }
  6266. /*==========================================
  6267. * modify homunculus intimacy [orn]
  6268. *------------------------------------------*/
  6269. ACMD_FUNC(homfriendly)
  6270. {
  6271. int friendly = 0;
  6272. nullpo_retr(-1, sd);
  6273. if ( !hom_is_active(sd->hd) ) {
  6274. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6275. return -1;
  6276. }
  6277. if (!message || !*message) {
  6278. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6279. return -1;
  6280. }
  6281. friendly = atoi(message);
  6282. friendly = cap_value(friendly, 0, 1000);
  6283. sd->hd->homunculus.intimacy = friendly * 100 ;
  6284. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6285. return 0;
  6286. }
  6287. /*==========================================
  6288. * modify homunculus hunger [orn]
  6289. *------------------------------------------*/
  6290. ACMD_FUNC(homhungry)
  6291. {
  6292. int hungry = 0;
  6293. nullpo_retr(-1, sd);
  6294. if ( !hom_is_active(sd->hd) ) {
  6295. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6296. return -1;
  6297. }
  6298. if (!message || !*message) {
  6299. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6300. return -1;
  6301. }
  6302. hungry = atoi(message);
  6303. hungry = cap_value(hungry, 0, 100);
  6304. sd->hd->homunculus.hunger = hungry;
  6305. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6306. return 0;
  6307. }
  6308. /*==========================================
  6309. * make the homunculus speak [orn]
  6310. *------------------------------------------*/
  6311. ACMD_FUNC(homtalk)
  6312. {
  6313. char mes[100],temp[100];
  6314. nullpo_retr(-1, sd);
  6315. if ( battle_config.min_chat_delay ) {
  6316. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6317. return 0;
  6318. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6319. }
  6320. if (sd->sc.cant.chat)
  6321. return -1; //no "chatting" while muted.
  6322. if ( !hom_is_active(sd->hd) ) {
  6323. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6324. return -1;
  6325. }
  6326. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6327. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6328. return -1;
  6329. }
  6330. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6331. clif_disp_overhead(&sd->hd->bl, temp);
  6332. return 0;
  6333. }
  6334. /*==========================================
  6335. * Show homunculus stats
  6336. *------------------------------------------*/
  6337. ACMD_FUNC(hominfo)
  6338. {
  6339. struct homun_data *hd;
  6340. struct status_data *status;
  6341. nullpo_retr(-1, sd);
  6342. if ( !hom_is_active(sd->hd) ) {
  6343. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6344. return -1;
  6345. }
  6346. hd = sd->hd;
  6347. status = status_get_status_data(&hd->bl);
  6348. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6349. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6350. status->hp, status->max_hp, status->sp, status->max_sp);
  6351. clif_displaymessage(fd, atcmd_output);
  6352. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6353. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6354. clif_displaymessage(fd, atcmd_output);
  6355. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6356. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6357. clif_displaymessage(fd, atcmd_output);
  6358. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6359. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6360. status->str, status->agi, status->vit,
  6361. status->int_, status->dex, status->luk);
  6362. clif_displaymessage(fd, atcmd_output);
  6363. return 0;
  6364. }
  6365. ACMD_FUNC(homstats)
  6366. {
  6367. struct homun_data *hd;
  6368. struct s_homunculus_db *db;
  6369. struct s_homunculus *hom;
  6370. int lv, min, max, evo;
  6371. nullpo_retr(-1, sd);
  6372. if ( !hom_is_active(sd->hd) ) {
  6373. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6374. return -1;
  6375. }
  6376. hd = sd->hd;
  6377. hom = &hd->homunculus;
  6378. db = hd->homunculusDB;
  6379. lv = hom->level;
  6380. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6381. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6382. clif_displaymessage(fd, atcmd_output);
  6383. lv--; //Since the first increase is at level 2.
  6384. evo = (hom->class_ == db->evo_class);
  6385. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6386. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6387. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6388. clif_displaymessage(fd, atcmd_output);
  6389. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6390. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6391. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6392. clif_displaymessage(fd, atcmd_output);
  6393. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6394. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6395. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6396. clif_displaymessage(fd, atcmd_output);
  6397. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6398. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6399. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6400. clif_displaymessage(fd, atcmd_output);
  6401. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6402. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6403. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6404. clif_displaymessage(fd, atcmd_output);
  6405. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6406. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6407. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6408. clif_displaymessage(fd, atcmd_output);
  6409. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6410. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6411. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6412. clif_displaymessage(fd, atcmd_output);
  6413. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6414. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6415. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6416. clif_displaymessage(fd, atcmd_output);
  6417. return 0;
  6418. }
  6419. ACMD_FUNC(homshuffle)
  6420. {
  6421. nullpo_retr(-1, sd);
  6422. if(!sd->hd)
  6423. return -1; // nothing to do
  6424. if(!hom_shuffle(sd->hd))
  6425. return -1;
  6426. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6427. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6428. return 0;
  6429. }
  6430. /*==========================================
  6431. * Show Items DB Info v 1.0
  6432. * originally by [Lupus]
  6433. *------------------------------------------*/
  6434. ACMD_FUNC(iteminfo)
  6435. {
  6436. struct item_data *item_array[MAX_SEARCH];
  6437. int i, count = 1;
  6438. if (!message || !*message) {
  6439. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6440. return -1;
  6441. }
  6442. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6443. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6444. if (!count) {
  6445. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6446. return -1;
  6447. }
  6448. if (count > MAX_SEARCH) {
  6449. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6450. clif_displaymessage(fd, atcmd_output);
  6451. count = MAX_SEARCH;
  6452. }
  6453. for (i = 0; i < count; i++) {
  6454. struct item_data * item_data = item_array[i];
  6455. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6456. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6457. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6458. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6459. );
  6460. clif_displaymessage(fd, atcmd_output);
  6461. 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
  6462. clif_displaymessage(fd, atcmd_output);
  6463. if (item_data->maxchance == -1)
  6464. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6465. else if (!battle_config.atcommand_mobinfo_type) {
  6466. if (item_data->maxchance)
  6467. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6468. else
  6469. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6470. }
  6471. clif_displaymessage(fd, atcmd_output);
  6472. }
  6473. return 0;
  6474. }
  6475. /*==========================================
  6476. * Show who drops the item.
  6477. *------------------------------------------*/
  6478. ACMD_FUNC(whodrops)
  6479. {
  6480. struct item_data *item_data, *item_array[MAX_SEARCH];
  6481. int i,j, count = 1;
  6482. if (!message || !*message) {
  6483. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6484. return -1;
  6485. }
  6486. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6487. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6488. if (!count) {
  6489. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6490. return -1;
  6491. }
  6492. if (count > MAX_SEARCH) {
  6493. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6494. clif_displaymessage(fd, atcmd_output);
  6495. count = MAX_SEARCH;
  6496. }
  6497. for (i = 0; i < count; i++) {
  6498. item_data = item_array[i];
  6499. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6500. clif_displaymessage(fd, atcmd_output);
  6501. if (item_data->mob[0].chance == 0) {
  6502. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6503. clif_displaymessage(fd, atcmd_output);
  6504. } else {
  6505. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6506. clif_displaymessage(fd, atcmd_output);
  6507. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6508. {
  6509. int dropchance = item_data->mob[j].chance;
  6510. #ifdef RENEWAL_DROP
  6511. if( battle_config.atcommand_mobinfo_type )
  6512. 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;
  6513. #endif
  6514. #ifdef VIP_ENABLE
  6515. // Display item rate increase for VIP.
  6516. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6517. dropchance += battle_config.vip_drop_increase;
  6518. #endif
  6519. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6520. clif_displaymessage(fd, atcmd_output);
  6521. }
  6522. }
  6523. }
  6524. return 0;
  6525. }
  6526. ACMD_FUNC(whereis)
  6527. {
  6528. struct mob_db *mob_array[MAX_SEARCH];
  6529. int count;
  6530. int i, j, k;
  6531. if (!message || !*message) {
  6532. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6533. return -1;
  6534. }
  6535. // If monster identifier/name argument is a name
  6536. if ((i = mobdb_checkid(atoi(message))))
  6537. {
  6538. mob_array[0] = mob_db(i);
  6539. count = 1;
  6540. } else
  6541. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6542. if (!count) {
  6543. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6544. return -1;
  6545. }
  6546. if (count > MAX_SEARCH) {
  6547. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6548. clif_displaymessage(fd, atcmd_output);
  6549. count = MAX_SEARCH;
  6550. }
  6551. for (k = 0; k < count; k++) {
  6552. struct mob_db *mob = mob_array[k];
  6553. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6554. clif_displaymessage(fd, atcmd_output);
  6555. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6556. {
  6557. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6558. if (j < 0) continue;
  6559. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6560. clif_displaymessage(fd, atcmd_output);
  6561. }
  6562. if (i == 0)
  6563. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6564. }
  6565. return 0;
  6566. }
  6567. ACMD_FUNC(version)
  6568. {
  6569. pc_show_version(sd);
  6570. return 0;
  6571. }
  6572. /*==========================================
  6573. * @mutearea by MouseJstr
  6574. *------------------------------------------*/
  6575. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6576. {
  6577. int time, id;
  6578. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6579. if (pl_sd == NULL)
  6580. return 0;
  6581. id = va_arg(ap, int);
  6582. time = va_arg(ap, int);
  6583. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6584. pl_sd->status.manner -= time;
  6585. if (pl_sd->status.manner < 0)
  6586. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6587. else
  6588. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6589. }
  6590. return 0;
  6591. }
  6592. ACMD_FUNC(mutearea)
  6593. {
  6594. int time;
  6595. nullpo_ret(sd);
  6596. if (!message || !*message) {
  6597. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6598. return -1;
  6599. }
  6600. time = atoi(message);
  6601. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6602. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6603. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6604. return 0;
  6605. }
  6606. ACMD_FUNC(rates)
  6607. {
  6608. char buf[CHAT_SIZE_MAX];
  6609. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6610. nullpo_ret(sd);
  6611. memset(buf, '\0', sizeof(buf));
  6612. #ifdef VIP_ENABLE
  6613. // Display EXP and item rate increase for VIP.
  6614. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6615. base_exp_rate += battle_config.vip_base_exp_increase;
  6616. job_exp_rate += battle_config.vip_job_exp_increase;
  6617. item_rate += battle_config.vip_drop_increase;
  6618. }
  6619. #endif
  6620. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6621. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6622. clif_displaymessage(fd, buf);
  6623. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6624. (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.);
  6625. clif_displaymessage(fd, buf);
  6626. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6627. (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.);
  6628. clif_displaymessage(fd, buf);
  6629. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6630. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6631. clif_displaymessage(fd, buf);
  6632. return 0;
  6633. }
  6634. /*==========================================
  6635. * @me by lordalfa
  6636. * => Displays the OUTPUT string on top of the Visible players Heads.
  6637. *------------------------------------------*/
  6638. ACMD_FUNC(me)
  6639. {
  6640. char tempmes[CHAT_SIZE_MAX];
  6641. nullpo_retr(-1, sd);
  6642. memset(tempmes, '\0', sizeof(tempmes));
  6643. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6644. if (sd->sc.cant.chat)
  6645. return -1; //no "chatting" while muted.
  6646. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6647. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6648. return -1;
  6649. }
  6650. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6651. clif_disp_overhead(&sd->bl, atcmd_output);
  6652. return 0;
  6653. }
  6654. /*==========================================
  6655. * @size
  6656. * => Resize your character sprite. [Valaris]
  6657. *------------------------------------------*/
  6658. ACMD_FUNC(size)
  6659. {
  6660. int size = 0;
  6661. nullpo_retr(-1, sd);
  6662. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6663. if(sd->state.size) {
  6664. sd->state.size = SZ_SMALL;
  6665. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6666. }
  6667. sd->state.size = size;
  6668. if( size == SZ_MEDIUM )
  6669. clif_specialeffect(&sd->bl,420,AREA);
  6670. else if( size == SZ_BIG )
  6671. clif_specialeffect(&sd->bl,422,AREA);
  6672. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6673. return 0;
  6674. }
  6675. ACMD_FUNC(sizeall)
  6676. {
  6677. int size;
  6678. struct map_session_data *pl_sd;
  6679. struct s_mapiterator* iter;
  6680. size = atoi(message);
  6681. size = cap_value(size,0,2);
  6682. iter = mapit_getallusers();
  6683. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6684. if( pl_sd->state.size != size ) {
  6685. if( pl_sd->state.size ) {
  6686. pl_sd->state.size = SZ_SMALL;
  6687. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6688. }
  6689. pl_sd->state.size = size;
  6690. if( size == SZ_MEDIUM )
  6691. clif_specialeffect(&pl_sd->bl,420,AREA);
  6692. else if( size == SZ_BIG )
  6693. clif_specialeffect(&pl_sd->bl,422,AREA);
  6694. }
  6695. }
  6696. mapit_free(iter);
  6697. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6698. return 0;
  6699. }
  6700. ACMD_FUNC(sizeguild)
  6701. {
  6702. int size = 0, i;
  6703. char guild[NAME_LENGTH];
  6704. struct map_session_data *pl_sd;
  6705. struct guild *g;
  6706. nullpo_retr(-1, sd);
  6707. memset(guild, '\0', sizeof(guild));
  6708. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6709. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6710. return -1;
  6711. }
  6712. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6713. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6714. return -1;
  6715. }
  6716. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6717. for( i = 0; i < g->max_member; i++ ) {
  6718. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6719. if( pl_sd->state.size ) {
  6720. pl_sd->state.size = SZ_SMALL;
  6721. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6722. }
  6723. pl_sd->state.size = size;
  6724. if( size == SZ_MEDIUM )
  6725. clif_specialeffect(&pl_sd->bl,420,AREA);
  6726. else if( size == SZ_BIG )
  6727. clif_specialeffect(&pl_sd->bl,422,AREA);
  6728. }
  6729. }
  6730. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6731. return 0;
  6732. }
  6733. /*==========================================
  6734. * @monsterignore
  6735. * => Makes monsters ignore you. [Valaris]
  6736. *------------------------------------------*/
  6737. ACMD_FUNC(monsterignore)
  6738. {
  6739. nullpo_retr(-1, sd);
  6740. if (!sd->state.monster_ignore) {
  6741. sd->state.monster_ignore = 1;
  6742. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6743. } else {
  6744. sd->state.monster_ignore = 0;
  6745. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6746. }
  6747. return 0;
  6748. }
  6749. /*==========================================
  6750. * @fakename
  6751. * => Gives your character a fake name. [Valaris]
  6752. *------------------------------------------*/
  6753. ACMD_FUNC(fakename)
  6754. {
  6755. nullpo_retr(-1, sd);
  6756. if( !message || !*message )
  6757. {
  6758. if( sd->fakename[0] )
  6759. {
  6760. sd->fakename[0] = '\0';
  6761. clif_charnameack(0, &sd->bl);
  6762. if (sd->disguise)
  6763. clif_charnameack(sd->fd, &sd->bl);
  6764. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6765. return 0;
  6766. }
  6767. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6768. return -1;
  6769. }
  6770. if( strlen(message) < 2 )
  6771. {
  6772. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6773. return -1;
  6774. }
  6775. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6776. clif_charnameack(0, &sd->bl);
  6777. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6778. clif_charnameack(sd->fd, &sd->bl);
  6779. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6780. return 0;
  6781. }
  6782. /*==========================================
  6783. * Ragnarok Resources
  6784. *------------------------------------------*/
  6785. ACMD_FUNC(mapflag) {
  6786. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6787. #define setflag( cmd ) \
  6788. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6789. map[ sd->bl.m ].flag.cmd = flag;\
  6790. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6791. clif_displaymessage(sd->fd,atcmd_output);\
  6792. return 0;\
  6793. }
  6794. char flag_name[100];
  6795. short flag=0,i;
  6796. nullpo_retr(-1, sd);
  6797. memset(flag_name, '\0', sizeof(flag_name));
  6798. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6799. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6800. clif_displaymessage(sd->fd,"----------------------------------");
  6801. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6802. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6803. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6804. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6805. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6806. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6807. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6808. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6809. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6810. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6811. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6812. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6813. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6814. checkflag(nolockon); checkflag(notomb);
  6815. #ifdef ADJUST_SKILL_DAMAGE
  6816. checkflag(skill_damage);
  6817. #endif
  6818. clif_displaymessage(sd->fd," ");
  6819. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6820. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6821. return 1;
  6822. }
  6823. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6824. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6825. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6826. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6827. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6828. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6829. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6830. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6831. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6832. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6833. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6834. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6835. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6836. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6837. setflag(nolockon); setflag(notomb);
  6838. #ifdef ADJUST_SKILL_DAMAGE
  6839. setflag(skill_damage);
  6840. #endif
  6841. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6842. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6843. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6844. clif_displaymessage(sd->fd,"----------------------------------");
  6845. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6846. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6847. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6848. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6849. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6850. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6851. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6852. #ifdef ADJUST_SKILL_DAMAGE
  6853. clif_displaymessage(sd->fd,"skill_damage");
  6854. #endif
  6855. #undef checkflag
  6856. #undef setflag
  6857. return 0;
  6858. }
  6859. /*===================================
  6860. * Remove some messages
  6861. *-----------------------------------*/
  6862. ACMD_FUNC(showexp)
  6863. {
  6864. if (sd->state.showexp) {
  6865. sd->state.showexp = 0;
  6866. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6867. return 0;
  6868. }
  6869. sd->state.showexp = 1;
  6870. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6871. return 0;
  6872. }
  6873. ACMD_FUNC(showzeny)
  6874. {
  6875. if (sd->state.showzeny) {
  6876. sd->state.showzeny = 0;
  6877. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6878. return 0;
  6879. }
  6880. sd->state.showzeny = 1;
  6881. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6882. return 0;
  6883. }
  6884. ACMD_FUNC(showdelay)
  6885. {
  6886. if (sd->state.showdelay) {
  6887. sd->state.showdelay = 0;
  6888. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6889. return 0;
  6890. }
  6891. sd->state.showdelay = 1;
  6892. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6893. return 0;
  6894. }
  6895. /*==========================================
  6896. * Duel organizing functions [LuzZza]
  6897. *
  6898. * @duel [limit|nick] - create a duel
  6899. * @invite <nick> - invite player
  6900. * @accept - accept invitation
  6901. * @reject - reject invitation
  6902. * @leave - leave duel
  6903. *------------------------------------------*/
  6904. ACMD_FUNC(invite)
  6905. {
  6906. unsigned int did = sd->duel_group;
  6907. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6908. if(did == 0) {
  6909. // "Duel: @invite without @duel."
  6910. clif_displaymessage(fd, msg_txt(sd,350));
  6911. return 0;
  6912. }
  6913. if(duel_list[did].max_players_limit > 0 &&
  6914. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6915. // "Duel: Limit of players is reached."
  6916. clif_displaymessage(fd, msg_txt(sd,351));
  6917. return 0;
  6918. }
  6919. if(target_sd == NULL) {
  6920. // "Duel: Player not found."
  6921. clif_displaymessage(fd, msg_txt(sd,352));
  6922. return 0;
  6923. }
  6924. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6925. // "Duel: Player already in duel."
  6926. clif_displaymessage(fd, msg_txt(sd,353));
  6927. return 0;
  6928. }
  6929. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6930. {
  6931. sprintf(atcmd_output, msg_txt(sd,364), message);
  6932. clif_displaymessage(fd, atcmd_output);
  6933. return 0;
  6934. }
  6935. duel_invite(did, sd, target_sd);
  6936. // "Duel: Invitation has been sent."
  6937. clif_displaymessage(fd, msg_txt(sd,354));
  6938. return 0;
  6939. }
  6940. ACMD_FUNC(duel)
  6941. {
  6942. unsigned int maxpl = 0;
  6943. if(sd->duel_group > 0) {
  6944. duel_showinfo(sd->duel_group, sd);
  6945. return 0;
  6946. }
  6947. if(sd->duel_invite > 0) {
  6948. // "Duel: @duel without @reject."
  6949. clif_displaymessage(fd, msg_txt(sd,355));
  6950. return 0;
  6951. }
  6952. if(!duel_checktime(sd)) {
  6953. char output[CHAT_SIZE_MAX];
  6954. // "Duel: You can take part in duel only one time per %d minutes."
  6955. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6956. clif_displaymessage(fd, output);
  6957. return 0;
  6958. }
  6959. if( message[0] ) {
  6960. if(sscanf(message, "%11u", &maxpl) >= 1) {
  6961. if(maxpl < 2 || maxpl > 65535) {
  6962. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6963. return 0;
  6964. }
  6965. duel_create(sd, maxpl);
  6966. } else {
  6967. struct map_session_data *target_sd;
  6968. target_sd = map_nick2sd((char *)message);
  6969. if(target_sd != NULL) {
  6970. unsigned int newduel;
  6971. if((newduel = duel_create(sd, 2)) != -1) {
  6972. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6973. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6974. return 0;
  6975. }
  6976. duel_invite(newduel, sd, target_sd);
  6977. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6978. }
  6979. } else {
  6980. // "Duel: Player not found."
  6981. clif_displaymessage(fd, msg_txt(sd,352));
  6982. return 0;
  6983. }
  6984. }
  6985. } else
  6986. duel_create(sd, 0);
  6987. return 0;
  6988. }
  6989. ACMD_FUNC(leave)
  6990. {
  6991. if(sd->duel_group <= 0) {
  6992. // "Duel: @leave without @duel."
  6993. clif_displaymessage(fd, msg_txt(sd,358));
  6994. return 0;
  6995. }
  6996. duel_leave(sd->duel_group, sd);
  6997. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6998. return 0;
  6999. }
  7000. ACMD_FUNC(accept)
  7001. {
  7002. if(!duel_checktime(sd)) {
  7003. char output[CHAT_SIZE_MAX];
  7004. // "Duel: You can take part in duel only one time per %d minutes."
  7005. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7006. clif_displaymessage(fd, output);
  7007. return 0;
  7008. }
  7009. if(sd->duel_invite <= 0) {
  7010. // "Duel: @accept without invititation."
  7011. clif_displaymessage(fd, msg_txt(sd,360));
  7012. return 0;
  7013. }
  7014. 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 )
  7015. {
  7016. // "Duel: Limit of players is reached."
  7017. clif_displaymessage(fd, msg_txt(sd,351));
  7018. return 0;
  7019. }
  7020. duel_accept(sd->duel_invite, sd);
  7021. // "Duel: Invitation has been accepted."
  7022. clif_displaymessage(fd, msg_txt(sd,361));
  7023. return 0;
  7024. }
  7025. ACMD_FUNC(reject)
  7026. {
  7027. if(sd->duel_invite <= 0) {
  7028. // "Duel: @reject without invititation."
  7029. clif_displaymessage(fd, msg_txt(sd,362));
  7030. return 0;
  7031. }
  7032. duel_reject(sd->duel_invite, sd);
  7033. // "Duel: Invitation has been rejected."
  7034. clif_displaymessage(fd, msg_txt(sd,363));
  7035. return 0;
  7036. }
  7037. /*===================================
  7038. * Cash Points
  7039. *-----------------------------------*/
  7040. ACMD_FUNC(cash)
  7041. {
  7042. char output[128];
  7043. int value;
  7044. int ret=0;
  7045. nullpo_retr(-1, sd);
  7046. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7047. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7048. return -1;
  7049. }
  7050. parent_cmd = atcommand_checkalias(command+1);
  7051. if( !strcmpi(parent_cmd,"cash") )
  7052. {
  7053. if( value > 0 ) {
  7054. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7055. // If this option is set, the message is already sent by pc function
  7056. if( !battle_config.cashshop_show_points ){
  7057. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7058. clif_disp_onlyself(sd, output, strlen(output));
  7059. }
  7060. }
  7061. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7062. } else {
  7063. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7064. value = -sd->cashPoints;
  7065. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7066. // If this option is set, the message is already sent by pc function
  7067. if( !battle_config.cashshop_show_points ){
  7068. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7069. clif_disp_onlyself(sd, output, strlen(output));
  7070. }
  7071. }
  7072. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7073. }
  7074. }
  7075. else
  7076. { // @points
  7077. if( value > 0 ) {
  7078. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7079. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7080. clif_disp_onlyself(sd, output, strlen(output));
  7081. }
  7082. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7083. } else {
  7084. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7085. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7086. clif_disp_onlyself(sd, output, strlen(output));
  7087. }
  7088. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7089. }
  7090. }
  7091. return 0;
  7092. }
  7093. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7094. ACMD_FUNC(clone)
  7095. {
  7096. int x=0,y=0,flag=0,master=0,i=0;
  7097. struct map_session_data *pl_sd=NULL;
  7098. if (!message || !*message) {
  7099. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7100. return 0;
  7101. }
  7102. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7103. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7104. return 0;
  7105. }
  7106. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7107. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7108. return 0;
  7109. }
  7110. parent_cmd = atcommand_checkalias(command+1);
  7111. if (strcmpi(parent_cmd, "clone") == 0)
  7112. flag = 1;
  7113. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7114. flag = 2;
  7115. if(pc_isdead(sd)){
  7116. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7117. return 0;
  7118. }
  7119. master = sd->bl.id;
  7120. if (battle_config.atc_slave_clone_limit
  7121. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7122. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7123. return 0;
  7124. }
  7125. }
  7126. do {
  7127. x = sd->bl.x + (rnd() % 10 - 5);
  7128. y = sd->bl.y + (rnd() % 10 - 5);
  7129. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7130. if (i >= 10) {
  7131. x = sd->bl.x;
  7132. y = sd->bl.y;
  7133. }
  7134. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7135. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7136. return 0;
  7137. }
  7138. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7139. return 0;
  7140. }
  7141. /*=====================================
  7142. * Autorejecting Invites/Deals [LuzZza]
  7143. * Usage: @noask
  7144. *-------------------------------------*/
  7145. ACMD_FUNC(noask)
  7146. {
  7147. if(sd->state.noask) {
  7148. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7149. sd->state.noask = 0;
  7150. } else {
  7151. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7152. sd->state.noask = 1;
  7153. }
  7154. return 0;
  7155. }
  7156. /*=====================================
  7157. * Send a @request message to all GMs of lowest_gm_level.
  7158. * Usage: @request <petition>
  7159. *-------------------------------------*/
  7160. ACMD_FUNC(request)
  7161. {
  7162. if (!message || !*message) {
  7163. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7164. return -1;
  7165. }
  7166. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7167. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7168. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7169. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7170. return 0;
  7171. }
  7172. /*==========================================
  7173. * Feel (SG save map) Reset [HiddenDragon]
  7174. *------------------------------------------*/
  7175. ACMD_FUNC(feelreset)
  7176. {
  7177. pc_resetfeel(sd);
  7178. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7179. return 0;
  7180. }
  7181. /*==========================================
  7182. * AUCTION SYSTEM
  7183. *------------------------------------------*/
  7184. ACMD_FUNC(auction)
  7185. {
  7186. nullpo_ret(sd);
  7187. if (!battle_config.feature_auction) {
  7188. clif_colormes(sd->fd, color_table[COLOR_RED], msg_txt(sd, 517));
  7189. return 0;
  7190. }
  7191. clif_Auction_openwindow(sd);
  7192. return 0;
  7193. }
  7194. /*==========================================
  7195. * Kill Steal Protection
  7196. *------------------------------------------*/
  7197. ACMD_FUNC(ksprotection)
  7198. {
  7199. nullpo_retr(-1,sd);
  7200. if( sd->state.noks ) {
  7201. sd->state.noks = 0;
  7202. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7203. }
  7204. else
  7205. {
  7206. if( !message || !*message || !strcmpi(message, "party") )
  7207. { // Default is Party
  7208. sd->state.noks = 2;
  7209. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7210. }
  7211. else if( !strcmpi(message, "self") )
  7212. {
  7213. sd->state.noks = 1;
  7214. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7215. }
  7216. else if( !strcmpi(message, "guild") )
  7217. {
  7218. sd->state.noks = 3;
  7219. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7220. }
  7221. else
  7222. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7223. }
  7224. return 0;
  7225. }
  7226. /*==========================================
  7227. * Map Kill Steal Protection Setting
  7228. *------------------------------------------*/
  7229. ACMD_FUNC(allowks)
  7230. {
  7231. nullpo_retr(-1,sd);
  7232. if( map[sd->bl.m].flag.allowks ) {
  7233. map[sd->bl.m].flag.allowks = 0;
  7234. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7235. } else {
  7236. map[sd->bl.m].flag.allowks = 1;
  7237. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7238. }
  7239. return 0;
  7240. }
  7241. ACMD_FUNC(resetstat)
  7242. {
  7243. nullpo_retr(-1, sd);
  7244. pc_resetstate(sd);
  7245. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7246. clif_displaymessage(fd, atcmd_output);
  7247. return 0;
  7248. }
  7249. ACMD_FUNC(resetskill)
  7250. {
  7251. nullpo_retr(-1,sd);
  7252. pc_resetskill(sd,1);
  7253. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7254. clif_displaymessage(fd, atcmd_output);
  7255. return 0;
  7256. }
  7257. /*==========================================
  7258. * #storagelist: Displays the items list of a player's storage.
  7259. * #cartlist: Displays contents of target's cart.
  7260. * #itemlist: Displays contents of target's inventory.
  7261. *------------------------------------------*/
  7262. ACMD_FUNC(itemlist)
  7263. {
  7264. int i, j, count, counter;
  7265. const char* location;
  7266. const struct item* items;
  7267. int size;
  7268. StringBuf buf;
  7269. nullpo_retr(-1, sd);
  7270. parent_cmd = atcommand_checkalias(command+1);
  7271. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7272. location = "storage";
  7273. items = sd->status.storage.items;
  7274. size = sd->storage_size;
  7275. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7276. location = "cart";
  7277. items = sd->status.cart;
  7278. size = MAX_CART;
  7279. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7280. location = "inventory";
  7281. items = sd->status.inventory;
  7282. size = MAX_INVENTORY;
  7283. } else
  7284. return 1;
  7285. StringBuf_Init(&buf);
  7286. count = 0; // total slots occupied
  7287. counter = 0; // total items found
  7288. for( i = 0; i < size; ++i ) {
  7289. const struct item* it = &items[i];
  7290. struct item_data* itd;
  7291. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7292. continue;
  7293. counter += it->amount;
  7294. count++;
  7295. if( count == 1 ) {
  7296. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7297. clif_displaymessage(fd, StringBuf_Value(&buf));
  7298. StringBuf_Clear(&buf);
  7299. }
  7300. if( it->refine )
  7301. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7302. else
  7303. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7304. if( it->equip ) {
  7305. char equipstr[CHAT_SIZE_MAX];
  7306. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7307. if( it->equip&EQP_GARMENT )
  7308. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7309. if( it->equip&EQP_ACC_L )
  7310. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7311. if( it->equip&EQP_ARMOR )
  7312. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7313. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7314. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7315. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7316. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7317. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7318. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7319. if( it->equip&EQP_SHOES )
  7320. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7321. if( it->equip&EQP_ACC_R )
  7322. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7323. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7324. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7325. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7326. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7327. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7328. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7329. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7330. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7331. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7332. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7333. if( (it->equip&EQP_HELM) == EQP_HELM )
  7334. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7335. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7336. strcat(equipstr, msg_txt(sd,518));
  7337. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7338. strcat(equipstr, msg_txt(sd,519));
  7339. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7340. strcat(equipstr, msg_txt(sd,520));
  7341. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7342. strcat(equipstr, msg_txt(sd,521));
  7343. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7344. strcat(equipstr, msg_txt(sd,522));
  7345. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7346. strcat(equipstr, msg_txt(sd,523));
  7347. if( it->equip&EQP_COSTUME_GARMENT )
  7348. strcat(equipstr, msg_txt(sd,524));
  7349. //if( it->equip&EQP_COSTUME_FLOOR )
  7350. //strcat(equipstr, msg_txt(sd,525));
  7351. if( it->equip&EQP_AMMO )
  7352. strcat(equipstr, msg_txt(sd,526));
  7353. if( it->equip&EQP_SHADOW_ARMOR )
  7354. strcat(equipstr, msg_txt(sd,527));
  7355. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7356. strcat(equipstr, msg_txt(sd,528));
  7357. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7358. strcat(equipstr, msg_txt(sd,529));
  7359. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7360. strcat(equipstr, msg_txt(sd,530));
  7361. if( it->equip&EQP_SHADOW_SHOES )
  7362. strcat(equipstr, msg_txt(sd,531));
  7363. if( it->equip&EQP_SHADOW_ACC_R )
  7364. strcat(equipstr, msg_txt(sd,532));
  7365. if( it->equip&EQP_SHADOW_ACC_L )
  7366. strcat(equipstr, msg_txt(sd,533));
  7367. // remove final ', '
  7368. equipstr[strlen(equipstr) - 2] = '\0';
  7369. StringBuf_AppendStr(&buf, equipstr);
  7370. }
  7371. clif_displaymessage(fd, StringBuf_Value(&buf));
  7372. StringBuf_Clear(&buf);
  7373. if( it->card[0] == CARD0_PET ) { // pet egg
  7374. if (it->card[3])
  7375. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7376. else
  7377. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7378. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7379. 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)
  7380. } else if(it->card[0] == CARD0_CREATE) { // created item
  7381. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7382. } else { // normal item
  7383. int counter2 = 0;
  7384. for( j = 0; j < itd->slot; ++j ) {
  7385. struct item_data* card;
  7386. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7387. continue;
  7388. counter2++;
  7389. if( counter2 == 1 )
  7390. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7391. if( counter2 != 1 )
  7392. StringBuf_AppendStr(&buf, ", ");
  7393. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7394. }
  7395. if( counter2 > 0 )
  7396. StringBuf_AppendStr(&buf, ")");
  7397. }
  7398. if( StringBuf_Length(&buf) > 0 )
  7399. clif_displaymessage(fd, StringBuf_Value(&buf));
  7400. StringBuf_Clear(&buf);
  7401. }
  7402. if( count == 0 )
  7403. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7404. else
  7405. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7406. clif_displaymessage(fd, StringBuf_Value(&buf));
  7407. StringBuf_Destroy(&buf);
  7408. return 0;
  7409. }
  7410. ACMD_FUNC(stats)
  7411. {
  7412. char job_jobname[100];
  7413. char output[CHAT_SIZE_MAX];
  7414. int i;
  7415. struct {
  7416. const char* format;
  7417. int value;
  7418. } output_table[] = {
  7419. { "Base Level - %d", 0 },
  7420. { NULL, 0 },
  7421. { "Hp - %d", 0 },
  7422. { "MaxHp - %d", 0 },
  7423. { "Sp - %d", 0 },
  7424. { "MaxSp - %d", 0 },
  7425. { "Str - %3d", 0 },
  7426. { "Agi - %3d", 0 },
  7427. { "Vit - %3d", 0 },
  7428. { "Int - %3d", 0 },
  7429. { "Dex - %3d", 0 },
  7430. { "Luk - %3d", 0 },
  7431. { "Zeny - %d", 0 },
  7432. { "Free SK Points - %d", 0 },
  7433. { "JobChangeLvl (2nd) - %d", 0 },
  7434. { "JobChangeLvl (3rd) - %d", 0 },
  7435. { NULL, 0 }
  7436. };
  7437. memset(job_jobname, '\0', sizeof(job_jobname));
  7438. memset(output, '\0', sizeof(output));
  7439. //direct array initialization with variables is not standard C compliant.
  7440. output_table[0].value = sd->status.base_level;
  7441. output_table[1].format = job_jobname;
  7442. output_table[1].value = sd->status.job_level;
  7443. output_table[2].value = sd->status.hp;
  7444. output_table[3].value = sd->status.max_hp;
  7445. output_table[4].value = sd->status.sp;
  7446. output_table[5].value = sd->status.max_sp;
  7447. output_table[6].value = sd->status.str;
  7448. output_table[7].value = sd->status.agi;
  7449. output_table[8].value = sd->status.vit;
  7450. output_table[9].value = sd->status.int_;
  7451. output_table[10].value = sd->status.dex;
  7452. output_table[11].value = sd->status.luk;
  7453. output_table[12].value = sd->status.zeny;
  7454. output_table[13].value = sd->status.skill_point;
  7455. output_table[14].value = sd->change_level_2nd;
  7456. output_table[15].value = sd->change_level_3rd;
  7457. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7458. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7459. clif_displaymessage(fd, output);
  7460. for (i = 0; output_table[i].format != NULL; i++) {
  7461. sprintf(output, output_table[i].format, output_table[i].value);
  7462. clif_displaymessage(fd, output);
  7463. }
  7464. return 0;
  7465. }
  7466. ACMD_FUNC(delitem)
  7467. {
  7468. char item_name[100];
  7469. unsigned short nameid;
  7470. int amount = 0, total, idx;
  7471. struct item_data* id;
  7472. nullpo_retr(-1, sd);
  7473. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7474. {
  7475. 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>).
  7476. return -1;
  7477. }
  7478. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7479. {
  7480. nameid = id->nameid;
  7481. }
  7482. else
  7483. {
  7484. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7485. return -1;
  7486. }
  7487. total = amount;
  7488. // delete items
  7489. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7490. {
  7491. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7492. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7493. {// delete pet
  7494. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7495. }
  7496. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7497. amount-= delamount;
  7498. }
  7499. // notify target
  7500. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7501. clif_displaymessage(sd->fd, atcmd_output);
  7502. // notify source
  7503. if( amount == total )
  7504. {
  7505. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7506. }
  7507. else if( amount )
  7508. {
  7509. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7510. clif_displaymessage(fd, atcmd_output);
  7511. }
  7512. else
  7513. {
  7514. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7515. clif_displaymessage(fd, atcmd_output);
  7516. }
  7517. return 0;
  7518. }
  7519. /*==========================================
  7520. * Custom Fonts
  7521. *------------------------------------------*/
  7522. ACMD_FUNC(font)
  7523. {
  7524. int font_id;
  7525. nullpo_retr(-1,sd);
  7526. font_id = atoi(message);
  7527. if( font_id == 0 ) {
  7528. if( sd->status.font ) {
  7529. sd->status.font = 0;
  7530. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7531. clif_font(sd);
  7532. } else {
  7533. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7534. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7535. }
  7536. } else if( font_id < 0 || font_id > 9 )
  7537. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7538. else if( font_id != sd->status.font ) {
  7539. sd->status.font = font_id;
  7540. clif_font(sd);
  7541. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7542. } else
  7543. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7544. return 0;
  7545. }
  7546. /*==========================================
  7547. * type: 1 = commands (@), 2 = charcommands (#)
  7548. *------------------------------------------*/
  7549. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7550. {
  7551. char line_buff[CHATBOX_SIZE];
  7552. char* cur = line_buff;
  7553. AtCommandInfo* cmd;
  7554. DBIterator *iter = db_iterator(atcommand_db);
  7555. int count = 0;
  7556. memset(line_buff,' ',CHATBOX_SIZE);
  7557. line_buff[CHATBOX_SIZE-1] = 0;
  7558. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7559. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7560. unsigned int slen = 0;
  7561. switch( type ) {
  7562. case COMMAND_CHARCOMMAND:
  7563. if( cmd->char_groups[sd->group_pos] == 0 )
  7564. continue;
  7565. break;
  7566. case COMMAND_ATCOMMAND:
  7567. if( cmd->at_groups[sd->group_pos] == 0 )
  7568. continue;
  7569. break;
  7570. default:
  7571. continue;
  7572. }
  7573. slen = strlen(cmd->command);
  7574. // flush the text buffer if this command won't fit into it
  7575. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7576. clif_displaymessage(fd,line_buff);
  7577. cur = line_buff;
  7578. memset(line_buff,' ',CHATBOX_SIZE);
  7579. line_buff[CHATBOX_SIZE-1] = 0;
  7580. }
  7581. memcpy(cur,cmd->command,slen);
  7582. cur += slen+(10-slen%10);
  7583. count++;
  7584. }
  7585. dbi_destroy(iter);
  7586. clif_displaymessage(fd,line_buff);
  7587. if ( atcmd_binding_count ) {
  7588. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7589. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7590. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7591. unsigned int slen = strlen(atcmd_binding[i]->command);
  7592. if ( count_bind == 0 ) {
  7593. cur = line_buff;
  7594. memset(line_buff,' ',CHATBOX_SIZE);
  7595. line_buff[CHATBOX_SIZE-1] = 0;
  7596. clif_displaymessage(fd, "-----------------");
  7597. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7598. }
  7599. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7600. clif_displaymessage(fd,line_buff);
  7601. cur = line_buff;
  7602. memset(line_buff,' ',CHATBOX_SIZE);
  7603. line_buff[CHATBOX_SIZE-1] = 0;
  7604. }
  7605. memcpy(cur,atcmd_binding[i]->command,slen);
  7606. cur += slen+(10-slen%10);
  7607. count_bind++;
  7608. }
  7609. }
  7610. if ( count_bind )
  7611. clif_displaymessage(fd,line_buff);// last one
  7612. count += count_bind;
  7613. }
  7614. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7615. clif_displaymessage(fd, atcmd_output);
  7616. return;
  7617. }
  7618. /*==========================================
  7619. * @commands Lists available @ commands to you
  7620. *------------------------------------------*/
  7621. ACMD_FUNC(commands)
  7622. {
  7623. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7624. return 0;
  7625. }
  7626. /*==========================================
  7627. * @charcommands Lists available # commands to you
  7628. *------------------------------------------*/
  7629. ACMD_FUNC(charcommands) {
  7630. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7631. return 0;
  7632. }
  7633. /* for new mounts */
  7634. ACMD_FUNC(mount2) {
  7635. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7636. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7637. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7638. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7639. } else {
  7640. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7641. if (&sd->sc)
  7642. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7643. }
  7644. return 0;
  7645. }
  7646. ACMD_FUNC(accinfo) {
  7647. char query[NAME_LENGTH];
  7648. char type = 0; // type = 1, get only account name
  7649. if (!message || !*message || strlen(message) > NAME_LENGTH
  7650. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7651. {
  7652. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7653. 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".
  7654. return -1;
  7655. } else if (type != 0) {
  7656. type = type-'0'; //make it int
  7657. if (type != 1) {
  7658. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7659. return -1;
  7660. }
  7661. }
  7662. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7663. return 0;
  7664. }
  7665. /* [Ind] */
  7666. ACMD_FUNC(set) {
  7667. char reg[32], val[128];
  7668. struct script_data* data;
  7669. int toset = 0, len;
  7670. bool is_str = false;
  7671. if( !message || !*message || (toset = sscanf(message, "%31s %127[^\n]s", reg, val)) < 1 ) {
  7672. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7673. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7674. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7675. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7676. return -1;
  7677. }
  7678. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7679. if( reg[0] == '.' ) {
  7680. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7681. return -1;
  7682. } else if( reg[0] == '\'' ) {
  7683. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7684. return -1;
  7685. }
  7686. is_str = ( reg[strlen(reg) - 1] == '$' );
  7687. if( ( len = strlen(val) ) > 1 ) {
  7688. if( val[0] == '"' && val[len-1] == '"') {
  7689. val[len-1] = '\0'; //Strip quotes.
  7690. memmove(val, val+1, len-1);
  7691. }
  7692. }
  7693. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7694. if( is_str )
  7695. set_var(sd, reg, (void*) val);
  7696. else
  7697. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7698. }
  7699. CREATE(data, struct script_data,1);
  7700. if( is_str ) {// string variable
  7701. switch( reg[0] ) {
  7702. case '@':
  7703. data->u.str = pc_readregstr(sd, add_str(reg));
  7704. break;
  7705. case '$':
  7706. data->u.str = mapreg_readregstr(add_str(reg));
  7707. break;
  7708. case '#':
  7709. if( reg[1] == '#' )
  7710. data->u.str = pc_readaccountreg2str(sd, add_str(reg));// global
  7711. else
  7712. data->u.str = pc_readaccountregstr(sd, add_str(reg));// local
  7713. break;
  7714. default:
  7715. data->u.str = pc_readglobalreg_str(sd, add_str(reg));
  7716. break;
  7717. }
  7718. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7719. data->type = C_CONSTSTR;
  7720. data->u.str = "";
  7721. } else {// duplicate string
  7722. data->type = C_STR;
  7723. data->u.str = aStrdup(data->u.str);
  7724. }
  7725. } else {// integer variable
  7726. data->type = C_INT;
  7727. switch( reg[0] ) {
  7728. case '@':
  7729. data->u.num = pc_readreg(sd, add_str(reg));
  7730. break;
  7731. case '$':
  7732. data->u.num = mapreg_readreg(add_str(reg));
  7733. break;
  7734. case '#':
  7735. if( reg[1] == '#' )
  7736. data->u.num = pc_readaccountreg2(sd, add_str(reg));// global
  7737. else
  7738. data->u.num = pc_readaccountreg(sd, add_str(reg));// local
  7739. break;
  7740. default:
  7741. data->u.num = pc_readglobalreg(sd, add_str(reg));
  7742. break;
  7743. }
  7744. }
  7745. switch( data->type ) {
  7746. case C_INT:
  7747. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7748. break;
  7749. case C_STR:
  7750. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7751. break;
  7752. case C_CONSTSTR:
  7753. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7754. break;
  7755. default:
  7756. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7757. break;
  7758. }
  7759. clif_displaymessage(fd, atcmd_output);
  7760. if (is_str && data->u.str)
  7761. aFree(data->u.str);
  7762. aFree(data);
  7763. return 0;
  7764. }
  7765. ACMD_FUNC(addperm) {
  7766. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7767. bool add;
  7768. int i;
  7769. parent_cmd = atcommand_checkalias(command+1);
  7770. add = (strcmpi(parent_cmd, "addperm") == 0);
  7771. if( !message || !*message ) {
  7772. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7773. clif_displaymessage(fd, atcmd_output);
  7774. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7775. for( i = 0; i < perm_size; i++ ) {
  7776. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7777. clif_displaymessage(fd, atcmd_output);
  7778. }
  7779. return -1;
  7780. }
  7781. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7782. if( i == perm_size ) {
  7783. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7784. clif_displaymessage(fd, atcmd_output);
  7785. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7786. for( i = 0; i < perm_size; i++ ) {
  7787. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7788. clif_displaymessage(fd, atcmd_output);
  7789. }
  7790. return -1;
  7791. }
  7792. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7793. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7794. clif_displaymessage(fd, atcmd_output);
  7795. return -1;
  7796. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7797. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7798. clif_displaymessage(fd, atcmd_output);
  7799. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7800. clif_displaymessage(fd, atcmd_output);
  7801. for( i = 0; i < perm_size; i++ ) {
  7802. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7803. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7804. clif_displaymessage(fd, atcmd_output);
  7805. }
  7806. }
  7807. return -1;
  7808. }
  7809. if( add )
  7810. sd->permissions |= pc_g_permission_name[i].permission;
  7811. else
  7812. sd->permissions &=~ pc_g_permission_name[i].permission;
  7813. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7814. clif_displaymessage(fd, atcmd_output);
  7815. return 0;
  7816. }
  7817. ACMD_FUNC(unloadnpcfile) {
  7818. if( !message || !*message ) {
  7819. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7820. return -1;
  7821. }
  7822. if( npc_unloadfile(message) )
  7823. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7824. else {
  7825. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7826. return -1;
  7827. }
  7828. return 0;
  7829. }
  7830. ACMD_FUNC(cart) {
  7831. #define MC_CART_MDFY(idx, x) \
  7832. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7833. sd->status.skill[(idx)].lv = (x)?1:0; \
  7834. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7835. int val = atoi(message);
  7836. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7837. uint16 sk_idx = 0;
  7838. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7839. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7840. clif_displaymessage(fd, atcmd_output);
  7841. return -1;
  7842. }
  7843. if( val == 0 && !pc_iscarton(sd) ) {
  7844. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7845. return -1;
  7846. }
  7847. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7848. return -1;
  7849. if( need_skill ) {
  7850. MC_CART_MDFY(sk_idx,1);
  7851. }
  7852. if( !pc_setcart(sd, val) ) {
  7853. if( need_skill ) {
  7854. MC_CART_MDFY(sk_idx,0);
  7855. }
  7856. return -1;/* @cart failed */
  7857. }
  7858. if( need_skill ) {
  7859. MC_CART_MDFY(sk_idx,0);
  7860. }
  7861. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7862. return 0;
  7863. #undef MC_CART_MDFY
  7864. }
  7865. /* Channel System [Ind] */
  7866. ACMD_FUNC(join){
  7867. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7868. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7869. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7870. clif_displaymessage(fd, atcmd_output);
  7871. return -1;
  7872. }
  7873. return channel_pcjoin(sd, chname, pass);
  7874. }
  7875. /*
  7876. * Display available option for @channel command
  7877. * @command : the name of used command (for alias case)
  7878. */
  7879. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7880. {
  7881. int fd = sd->fd;
  7882. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7883. bool can_create = (can_delete || channel_config.user_chenable);
  7884. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7885. //option create
  7886. if( can_create ) {
  7887. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7888. clif_displaymessage(fd, atcmd_output);
  7889. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7890. }
  7891. //option delete
  7892. if(can_delete){
  7893. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7894. clif_displaymessage(fd, atcmd_output);
  7895. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7896. }
  7897. //option list
  7898. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7899. clif_displaymessage(fd, atcmd_output);
  7900. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7901. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7902. clif_displaymessage(fd, atcmd_output);
  7903. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7904. if( can_create ) {
  7905. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7906. clif_displaymessage(fd, atcmd_output);
  7907. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7908. }
  7909. //option setcolor
  7910. if(can_create){
  7911. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7912. clif_displaymessage(fd, atcmd_output);
  7913. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7914. }
  7915. //option join
  7916. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7917. clif_displaymessage(fd, atcmd_output);
  7918. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7919. //option leave
  7920. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7921. clif_displaymessage(fd, atcmd_output);
  7922. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7923. //option bindto
  7924. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7925. clif_displaymessage(fd, atcmd_output);
  7926. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7927. //option unbind
  7928. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7929. clif_displaymessage(fd, atcmd_output);
  7930. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7931. //option ban/unban/banlist
  7932. if( can_create ) {
  7933. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7934. clif_displaymessage(fd, atcmd_output);
  7935. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7936. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7937. clif_displaymessage(fd, atcmd_output);
  7938. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7939. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7940. clif_displaymessage(fd, atcmd_output);
  7941. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7942. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7943. clif_displaymessage(fd, atcmd_output);
  7944. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7945. }
  7946. //option setopt
  7947. if(can_create){
  7948. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7949. clif_displaymessage(fd, atcmd_output);
  7950. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7951. }
  7952. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7953. clif_displaymessage(fd, atcmd_output);
  7954. }
  7955. ACMD_FUNC(channel) {
  7956. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  7957. sub1[0] = sub2[0] = '\0';
  7958. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  7959. atcmd_channel_help(sd,command);
  7960. return 0;
  7961. }
  7962. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7963. return channel_pcdelete(sd,sub1);
  7964. } else if ( strcmpi(key,"list") == 0 ) {
  7965. return channel_display_list(sd,sub1);
  7966. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7967. return channel_pccolor(sd, sub1, sub2);
  7968. } else if ( strcmpi(key,"join") == 0 ) {
  7969. return channel_pcjoin(sd, sub1, sub2);
  7970. }else if ( strcmpi(key,"leave") == 0 ) {
  7971. return channel_pcleave(sd, sub1);
  7972. } else if ( strcmpi(key,"bindto") == 0 ) {
  7973. return channel_pcbind(sd, sub1);
  7974. } else if ( strcmpi(key,"unbind") == 0 ) {
  7975. return channel_pcunbind(sd);
  7976. } else if ( strcmpi(key,"ban") == 0 ) {
  7977. return channel_pcban(sd,sub1,sub2,0);
  7978. } else if ( strcmpi(key,"banlist") == 0 ) {
  7979. return channel_pcban(sd,sub1,NULL,3);
  7980. } else if ( strcmpi(key,"unban") == 0 ) {
  7981. return channel_pcban(sd,sub1,sub2,1);
  7982. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7983. return channel_pcban(sd,sub1,NULL,2);
  7984. } else {
  7985. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  7986. sub3[0] = sub4[0] = '\0';
  7987. sscanf(sub2, "%19s %19s", sub3, sub4);
  7988. if( strcmpi(key,"create") == 0 && ( channel_config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7989. if (sub4[0] != '\0') {
  7990. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  7991. return -1;
  7992. }
  7993. return channel_pccreate(sd,sub1,sub3);
  7994. } else if ( strcmpi(key,"setopt") == 0 ) {
  7995. return channel_pcsetopt(sd,sub1,sub3,sub4);
  7996. }
  7997. atcmd_channel_help(sd,command);
  7998. }
  7999. return 0;
  8000. }
  8001. ACMD_FUNC(fontcolor)
  8002. {
  8003. if( !message || !*message ) {
  8004. channel_display_list(sd,"colors");
  8005. return -1;
  8006. }
  8007. if( strcmpi(message,"Normal") == 0 ) {
  8008. sd->fontcolor = 0;
  8009. } else {
  8010. unsigned char k;
  8011. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8012. if( k == channel_config.colors_count ) {
  8013. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8014. clif_displaymessage(fd, atcmd_output);
  8015. return -1;
  8016. }
  8017. sd->fontcolor = k;
  8018. }
  8019. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8020. clif_displaymessage(fd, atcmd_output);
  8021. return 0;
  8022. }
  8023. ACMD_FUNC(langtype)
  8024. {
  8025. char langstr[8];
  8026. int i=0, fail=0;
  8027. memset(langstr, '\0', sizeof(langstr));
  8028. if(sscanf(message, "%3s", langstr) >= 1){
  8029. int lang=0;
  8030. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8031. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8032. char output[100];
  8033. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8034. sd->langtype = lang;
  8035. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8036. clif_displaymessage(fd,output);
  8037. return 0;
  8038. } else if (lang != -1) { //defined langage but failed check
  8039. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8040. return -1;
  8041. }
  8042. }
  8043. //wrong or no entry
  8044. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8045. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8046. while(fail != -1){ //out of range
  8047. fail = msg_checklangtype(i,false);
  8048. if(fail == 1)
  8049. clif_displaymessage(fd,msg_langtype2langstr(i));
  8050. i++;
  8051. }
  8052. return -1;
  8053. }
  8054. #ifdef VIP_ENABLE
  8055. ACMD_FUNC(vip) {
  8056. struct map_session_data *pl_sd = NULL;
  8057. char * modif_p;
  8058. int32 vipdifftime = 0;
  8059. time_t now=time(NULL);
  8060. nullpo_retr(-1, sd);
  8061. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8062. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8063. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8064. return -1;
  8065. }
  8066. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8067. modif_p = atcmd_output;
  8068. vipdifftime = (int32)solve_time(modif_p);
  8069. if (vipdifftime == 0) {
  8070. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8071. 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.
  8072. return -1;
  8073. }
  8074. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  8075. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8076. return -1;
  8077. }
  8078. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8079. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8080. return -1;
  8081. }
  8082. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8083. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8084. if (pl_sd->vip.time <= now) {
  8085. pl_sd->vip.time = 0;
  8086. pl_sd->vip.enabled = 0;
  8087. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8088. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8089. } else {
  8090. int year,month,day,hour,minute,second;
  8091. char timestr[21];
  8092. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8093. 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.
  8094. clif_displaymessage(pl_sd->fd,atcmd_output);
  8095. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8096. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8097. clif_displaymessage(pl_sd->fd,atcmd_output);
  8098. if (pl_sd != sd) {
  8099. 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.
  8100. clif_displaymessage(fd,atcmd_output);
  8101. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8102. clif_displaymessage(fd,atcmd_output);
  8103. }
  8104. }
  8105. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8106. return 0;
  8107. }
  8108. /** Enable/disable rate info */
  8109. ACMD_FUNC(showrate) {
  8110. nullpo_retr(-1,sd);
  8111. if (!sd->disableshowrate) {
  8112. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8113. sd->disableshowrate = 1;
  8114. }
  8115. else {
  8116. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8117. sd->disableshowrate = 0;
  8118. }
  8119. clif_displaymessage(fd,atcmd_output);
  8120. return 0;
  8121. }
  8122. #endif
  8123. ACMD_FUNC(fullstrip) {
  8124. int i;
  8125. TBL_PC *tsd;
  8126. nullpo_retr(-1,sd);
  8127. if (!message || !*message) {
  8128. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8129. return -1;
  8130. }
  8131. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8132. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8133. return -1;
  8134. }
  8135. for( i = 0; i < EQI_MAX; i++ ) {
  8136. if( tsd->equip_index[ i ] >= 0 )
  8137. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8138. }
  8139. return 0;
  8140. }
  8141. ACMD_FUNC(costume) {
  8142. const char* names[] = {
  8143. "Wedding",
  8144. "Xmas",
  8145. "Summer",
  8146. "Hanbok",
  8147. "Oktoberfest",
  8148. };
  8149. const int name2id[] = {
  8150. SC_WEDDING,
  8151. SC_XMAS,
  8152. SC_SUMMER,
  8153. SC_HANBOK,
  8154. SC_OKTOBERFEST
  8155. };
  8156. unsigned short k = 0, len = ARRAYLENGTH(names);
  8157. if( !message || !*message ) {
  8158. for( k = 0; k < len; k++ ) {
  8159. if( sd->sc.data[name2id[k]] ) {
  8160. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8161. clif_displaymessage(sd->fd, atcmd_output);
  8162. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8163. return 0;
  8164. }
  8165. }
  8166. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8167. for( k = 0; k < len; k++ ) {
  8168. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8169. clif_displaymessage(sd->fd, atcmd_output);
  8170. }
  8171. return -1;
  8172. }
  8173. for( k = 0; k < len; k++ ) {
  8174. if( sd->sc.data[name2id[k]] ) {
  8175. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8176. clif_displaymessage(sd->fd, atcmd_output);
  8177. return -1;
  8178. }
  8179. }
  8180. for( k = 0; k < len; k++ )
  8181. if( strcmpi(message, names[k]) == 0 )
  8182. break;
  8183. if( k == len ) {
  8184. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8185. clif_displaymessage(sd->fd, atcmd_output);
  8186. return -1;
  8187. }
  8188. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8189. return 0;
  8190. }
  8191. /**
  8192. * Clone other player's equipments
  8193. * Usage: @cloneequip <char_id or "char name">
  8194. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8195. * @author [Cydh], [Antares]
  8196. */
  8197. ACMD_FUNC(cloneequip) {
  8198. struct map_session_data *pl_sd;
  8199. uint32 char_id = 0;
  8200. nullpo_retr(-1, sd);
  8201. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8202. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8203. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8204. return -1;
  8205. }
  8206. if (char_id)
  8207. pl_sd = map_charid2sd(char_id);
  8208. else
  8209. pl_sd = map_nick2sd(atcmd_output);
  8210. if (!pl_sd) {
  8211. clif_displaymessage(fd, msg_txt(sd, 3));
  8212. return -1;
  8213. }
  8214. if (sd == pl_sd) {
  8215. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8216. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8217. clif_displaymessage(fd, atcmd_output);
  8218. return -1;
  8219. }
  8220. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8221. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8222. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8223. clif_displaymessage(fd, atcmd_output);
  8224. return -1;
  8225. }
  8226. else {
  8227. int8 i;
  8228. for (i = 0; i < EQI_MAX; i++) {
  8229. short idx;
  8230. char flag = 0;
  8231. struct item tmp_item;
  8232. if ((idx = pl_sd->equip_index[i]) < 0)
  8233. continue;
  8234. if (i == EQI_AMMO)
  8235. continue;
  8236. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8237. continue;
  8238. tmp_item = pl_sd->status.inventory[idx];
  8239. if (itemdb_isspecial(tmp_item.card[0]))
  8240. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8241. tmp_item.bound = 0;
  8242. tmp_item.expire_time = 0;
  8243. tmp_item.unique_id = 0;
  8244. tmp_item.favorite = 0;
  8245. tmp_item.amount = 1;
  8246. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8247. clif_additem(sd, 0, 0, flag);
  8248. else
  8249. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8250. }
  8251. }
  8252. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8253. sprintf(atcmd_output, msg_txt(sd, 738), "equip");
  8254. clif_displaymessage(fd, atcmd_output);
  8255. return 0;
  8256. }
  8257. /**
  8258. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8259. * Usage: @clonestat <char_id or "char name">
  8260. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8261. * @author [Cydh], [Antares]
  8262. */
  8263. ACMD_FUNC(clonestat) {
  8264. struct map_session_data *pl_sd;
  8265. uint32 char_id = 0;
  8266. nullpo_retr(-1, sd);
  8267. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8268. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8269. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8270. return -1;
  8271. }
  8272. if (char_id)
  8273. pl_sd = map_charid2sd(char_id);
  8274. else
  8275. pl_sd = map_nick2sd(atcmd_output);
  8276. if (!pl_sd) {
  8277. clif_displaymessage(fd, msg_txt(sd, 3));
  8278. return -1;
  8279. }
  8280. if (sd == pl_sd) {
  8281. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8282. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8283. clif_displaymessage(fd, atcmd_output);
  8284. return -1;
  8285. }
  8286. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8287. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8288. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8289. clif_displaymessage(fd, atcmd_output);
  8290. return -1;
  8291. }
  8292. else {
  8293. uint8 i;
  8294. short max_status[6];
  8295. pc_resetstate(sd);
  8296. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8297. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8298. else {
  8299. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8300. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8301. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8302. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8303. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8304. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8305. }
  8306. #define clonestat_check(cmd,stat)\
  8307. {\
  8308. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8309. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8310. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8311. clif_displaymessage(fd, atcmd_output);\
  8312. sd->status.cmd = max_status[(stat)];\
  8313. }\
  8314. else\
  8315. sd->status.cmd = pl_sd->status.cmd;\
  8316. }
  8317. clonestat_check(str, PARAM_STR);
  8318. clonestat_check(agi, PARAM_AGI);
  8319. clonestat_check(vit, PARAM_VIT);
  8320. clonestat_check(int_, PARAM_INT);
  8321. clonestat_check(dex, PARAM_DEX);
  8322. clonestat_check(luk, PARAM_LUK);
  8323. for (i = 0; i < PARAM_MAX; i++) {
  8324. clif_updatestatus(sd, SP_STR + i);
  8325. clif_updatestatus(sd, SP_USTR + i);
  8326. }
  8327. status_calc_pc(sd, SCO_FORCE);
  8328. }
  8329. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8330. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8331. clif_displaymessage(fd, atcmd_output);
  8332. #undef clonestat_check
  8333. return 0;
  8334. }
  8335. #include "../custom/atcommand.inc"
  8336. /**
  8337. * Fills the reference of available commands in atcommand DBMap
  8338. **/
  8339. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8340. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8341. // Define with restriction
  8342. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8343. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8344. void atcommand_basecommands(void) {
  8345. /**
  8346. * Command reference list, place the base of your commands here
  8347. * TODO: List all commands that causing crash
  8348. **/
  8349. AtCommandInfo atcommand_base[] = {
  8350. #include "../custom/atcommand_def.inc"
  8351. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8352. ACMD_DEF(where),
  8353. ACMD_DEF(jumpto),
  8354. ACMD_DEF(jump),
  8355. ACMD_DEF(who),
  8356. ACMD_DEF2("who2", who),
  8357. ACMD_DEF2("who3", who),
  8358. ACMD_DEF2("whomap", who),
  8359. ACMD_DEF2("whomap2", who),
  8360. ACMD_DEF2("whomap3", who),
  8361. ACMD_DEF(whogm),
  8362. ACMD_DEF(save),
  8363. ACMD_DEF(load),
  8364. ACMD_DEF(speed),
  8365. ACMD_DEF(storage),
  8366. ACMD_DEF(guildstorage),
  8367. ACMD_DEF(option),
  8368. ACMD_DEF(hide), // + /hide
  8369. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8370. ACMD_DEF(kill),
  8371. ACMD_DEF(alive),
  8372. ACMD_DEF(kami),
  8373. ACMD_DEF2("kamib", kami),
  8374. ACMD_DEF2("kamic", kami),
  8375. ACMD_DEF2("lkami", kami),
  8376. ACMD_DEF(heal),
  8377. ACMD_DEF(item),
  8378. ACMD_DEF(item2),
  8379. ACMD_DEF2("itembound",item),
  8380. ACMD_DEF2("itembound2",item2),
  8381. ACMD_DEF(itemreset),
  8382. ACMD_DEF(clearstorage),
  8383. ACMD_DEF(cleargstorage),
  8384. ACMD_DEF(clearcart),
  8385. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8386. ACMD_DEF2("jlvl", joblevelup),
  8387. ACMD_DEF(help),
  8388. ACMD_DEF(pvpoff),
  8389. ACMD_DEF(pvpon),
  8390. ACMD_DEF(gvgoff),
  8391. ACMD_DEF(gvgon),
  8392. ACMD_DEF(model),
  8393. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8394. ACMD_DEF(monster),
  8395. ACMD_DEF2("monstersmall", monster),
  8396. ACMD_DEF2("monsterbig", monster),
  8397. ACMD_DEF(killmonster),
  8398. ACMD_DEF2("killmonster2", killmonster),
  8399. ACMD_DEF(refine),
  8400. ACMD_DEF(produce),
  8401. ACMD_DEF(memo),
  8402. ACMD_DEF(gat),
  8403. ACMD_DEF(displaystatus),
  8404. ACMD_DEF2("stpoint", statuspoint),
  8405. ACMD_DEF2("skpoint", skillpoint),
  8406. ACMD_DEF(zeny),
  8407. ACMD_DEF2("str", param),
  8408. ACMD_DEF2("agi", param),
  8409. ACMD_DEF2("vit", param),
  8410. ACMD_DEF2("int", param),
  8411. ACMD_DEF2("dex", param),
  8412. ACMD_DEF2("luk", param),
  8413. ACMD_DEF2("glvl", guildlevelup),
  8414. ACMD_DEF(makeegg),
  8415. ACMD_DEF(hatch),
  8416. ACMD_DEF(petfriendly),
  8417. ACMD_DEF(pethungry),
  8418. ACMD_DEF(petrename),
  8419. ACMD_DEF(recall), // + /recall
  8420. ACMD_DEF(night),
  8421. ACMD_DEF(day),
  8422. ACMD_DEF(doom),
  8423. ACMD_DEF(doommap),
  8424. ACMD_DEF(raise),
  8425. ACMD_DEF(raisemap),
  8426. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8427. ACMD_DEF(kickall),
  8428. ACMD_DEF(allskill),
  8429. ACMD_DEF(questskill),
  8430. ACMD_DEF(lostskill),
  8431. ACMD_DEF(spiritball),
  8432. ACMD_DEF(party),
  8433. ACMD_DEF(guild),
  8434. ACMD_DEF(breakguild),
  8435. ACMD_DEF(agitstart),
  8436. ACMD_DEF(agitend),
  8437. ACMD_DEF(mapexit),
  8438. ACMD_DEF(idsearch),
  8439. ACMD_DEF(broadcast), // + /b and /nb
  8440. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8441. ACMD_DEF(recallall),
  8442. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8443. ACMD_DEF2("reloaditemdb", reload),
  8444. ACMD_DEF2("reloadmobdb", reload),
  8445. ACMD_DEF2("reloadskilldb", reload),
  8446. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8447. ACMD_DEF2("reloadatcommand", reload),
  8448. ACMD_DEF2("reloadbattleconf", reload),
  8449. ACMD_DEF2("reloadstatusdb", reload),
  8450. ACMD_DEF2("reloadpcdb", reload),
  8451. ACMD_DEF2("reloadmotd", reload),
  8452. ACMD_DEF2("reloadquestdb", reload),
  8453. ACMD_DEF2("reloadmsgconf", reload),
  8454. ACMD_DEF2("reloadpacketdb", reload),
  8455. ACMD_DEF2("reloadinstancedb", reload),
  8456. ACMD_DEF(partysharelvl),
  8457. ACMD_DEF(mapinfo),
  8458. ACMD_DEF(dye),
  8459. ACMD_DEF2("hairstyle", hair_style),
  8460. ACMD_DEF2("haircolor", hair_color),
  8461. ACMD_DEF2("allstats", stat_all),
  8462. ACMD_DEF2("block", char_block),
  8463. ACMD_DEF2("ban", char_ban),
  8464. ACMD_DEF2("unblock", char_unblock),
  8465. ACMD_DEF2("unban", char_unban),
  8466. ACMD_DEF2("charban", char_ban),
  8467. ACMD_DEF2("charunban", char_unban),
  8468. ACMD_DEF2("mount", mount_peco),
  8469. ACMD_DEF(guildspy),
  8470. ACMD_DEF(partyspy),
  8471. ACMD_DEF(repairall),
  8472. ACMD_DEF(guildrecall),
  8473. ACMD_DEF(partyrecall),
  8474. ACMD_DEF(nuke),
  8475. ACMD_DEF(shownpc),
  8476. ACMD_DEF(hidenpc),
  8477. ACMD_DEF(loadnpc),
  8478. ACMD_DEF(unloadnpc),
  8479. ACMD_DEF2("time", servertime),
  8480. ACMD_DEF(jail),
  8481. ACMD_DEF(unjail),
  8482. ACMD_DEF(jailfor),
  8483. ACMD_DEF(jailtime),
  8484. ACMD_DEF(disguise),
  8485. ACMD_DEF(undisguise),
  8486. ACMD_DEF(email),
  8487. ACMD_DEF(effect),
  8488. ACMD_DEF(follow),
  8489. ACMD_DEF(addwarp),
  8490. ACMD_DEF(skillon),
  8491. ACMD_DEF(skilloff),
  8492. ACMD_DEF(killer),
  8493. ACMD_DEF(npcmove),
  8494. ACMD_DEF(killable),
  8495. ACMD_DEF(dropall),
  8496. ACMD_DEF(storeall),
  8497. ACMD_DEF(skillid),
  8498. ACMD_DEF(useskill),
  8499. ACMD_DEF(displayskill),
  8500. ACMD_DEF(snow),
  8501. ACMD_DEF(sakura),
  8502. ACMD_DEF(clouds),
  8503. ACMD_DEF(clouds2),
  8504. ACMD_DEF(fog),
  8505. ACMD_DEF(fireworks),
  8506. ACMD_DEF(leaves),
  8507. ACMD_DEF(summon),
  8508. ACMD_DEF(adjgroup),
  8509. ACMD_DEF(trade),
  8510. ACMD_DEF(send),
  8511. ACMD_DEF(setbattleflag),
  8512. ACMD_DEF(unmute),
  8513. ACMD_DEF(clearweather),
  8514. ACMD_DEF(uptime),
  8515. ACMD_DEF(changesex),
  8516. ACMD_DEF(changecharsex),
  8517. ACMD_DEF(mute),
  8518. ACMD_DEF(refresh),
  8519. ACMD_DEF(refreshall),
  8520. ACMD_DEF(identify),
  8521. ACMD_DEF(identifyall),
  8522. ACMD_DEF(gmotd),
  8523. ACMD_DEF(misceffect),
  8524. ACMD_DEF(mobsearch),
  8525. ACMD_DEF(cleanmap),
  8526. ACMD_DEF(cleanarea),
  8527. ACMD_DEF(npctalk),
  8528. ACMD_DEF(pettalk),
  8529. ACMD_DEF(users),
  8530. ACMD_DEF(reset),
  8531. ACMD_DEF(skilltree),
  8532. ACMD_DEF(marry),
  8533. ACMD_DEF(divorce),
  8534. ACMD_DEF(sound),
  8535. ACMD_DEF(undisguiseall),
  8536. ACMD_DEF(disguiseall),
  8537. ACMD_DEF(changelook),
  8538. ACMD_DEF(autoloot),
  8539. ACMD_DEF2("alootid", autolootitem),
  8540. ACMD_DEF(autoloottype),
  8541. ACMD_DEF(mobinfo),
  8542. ACMD_DEF(exp),
  8543. ACMD_DEF(version),
  8544. ACMD_DEF(mutearea),
  8545. ACMD_DEF(rates),
  8546. ACMD_DEF(iteminfo),
  8547. ACMD_DEF(whodrops),
  8548. ACMD_DEF(whereis),
  8549. ACMD_DEF(mapflag),
  8550. ACMD_DEF(me),
  8551. ACMD_DEF(monsterignore),
  8552. ACMD_DEF(fakename),
  8553. ACMD_DEF(size),
  8554. ACMD_DEF(showexp),
  8555. ACMD_DEF(showzeny),
  8556. ACMD_DEF(showdelay),
  8557. ACMD_DEF(autotrade),
  8558. ACMD_DEF(changegm),
  8559. ACMD_DEF(changeleader),
  8560. ACMD_DEF(partyoption),
  8561. ACMD_DEF(invite),
  8562. ACMD_DEF(duel),
  8563. ACMD_DEF(leave),
  8564. ACMD_DEF(accept),
  8565. ACMD_DEF(reject),
  8566. ACMD_DEF(clone),
  8567. ACMD_DEF2("slaveclone", clone),
  8568. ACMD_DEF2("evilclone", clone),
  8569. ACMD_DEF(tonpc),
  8570. ACMD_DEF(commands),
  8571. ACMD_DEF(noask),
  8572. ACMD_DEF(request),
  8573. ACMD_DEF(homlevel),
  8574. ACMD_DEF(homevolution),
  8575. ACMD_DEF(hommutate),
  8576. ACMD_DEF(makehomun),
  8577. ACMD_DEF(homfriendly),
  8578. ACMD_DEF(homhungry),
  8579. ACMD_DEF(homtalk),
  8580. ACMD_DEF(hominfo),
  8581. ACMD_DEF(homstats),
  8582. ACMD_DEF(homshuffle),
  8583. ACMD_DEF(showmobs),
  8584. ACMD_DEF(feelreset),
  8585. ACMD_DEF(auction),
  8586. ACMD_DEF(mail),
  8587. ACMD_DEF2("noks", ksprotection),
  8588. ACMD_DEF(allowks),
  8589. ACMD_DEF(cash),
  8590. ACMD_DEF2("points", cash),
  8591. ACMD_DEF(agitstart2),
  8592. ACMD_DEF(agitend2),
  8593. ACMD_DEF(resetskill),
  8594. ACMD_DEF(resetstat),
  8595. ACMD_DEF2("storagelist", itemlist),
  8596. ACMD_DEF2("cartlist", itemlist),
  8597. ACMD_DEF2("itemlist", itemlist),
  8598. ACMD_DEF(stats),
  8599. ACMD_DEF(delitem),
  8600. ACMD_DEF(charcommands),
  8601. ACMD_DEF(font),
  8602. ACMD_DEF(accinfo),
  8603. ACMD_DEF(set),
  8604. ACMD_DEF(undisguiseguild),
  8605. ACMD_DEF(disguiseguild),
  8606. ACMD_DEF(sizeall),
  8607. ACMD_DEF(sizeguild),
  8608. ACMD_DEF(addperm),
  8609. ACMD_DEF2("rmvperm", addperm),
  8610. ACMD_DEF(unloadnpcfile),
  8611. ACMD_DEF(cart),
  8612. ACMD_DEF(mount2),
  8613. ACMD_DEF(join),
  8614. ACMD_DEF(channel),
  8615. ACMD_DEF(fontcolor),
  8616. ACMD_DEF(langtype),
  8617. #ifdef VIP_ENABLE
  8618. ACMD_DEF(vip),
  8619. ACMD_DEF(showrate),
  8620. #endif
  8621. ACMD_DEF(fullstrip),
  8622. ACMD_DEF(costume),
  8623. ACMD_DEF(cloneequip),
  8624. ACMD_DEF(clonestat),
  8625. };
  8626. AtCommandInfo* atcommand;
  8627. int i;
  8628. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8629. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8630. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8631. continue;
  8632. }
  8633. CREATE(atcommand, AtCommandInfo, 1);
  8634. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8635. atcommand->func = atcommand_base[i].func;
  8636. atcommand->restriction = atcommand_base[i].restriction;
  8637. strdb_put(atcommand_db, atcommand->command, atcommand);
  8638. }
  8639. return;
  8640. }
  8641. /*==========================================
  8642. * Command lookup functions
  8643. *------------------------------------------*/
  8644. bool atcommand_exists(const char* name)
  8645. {
  8646. return strdb_exists(atcommand_db, name);
  8647. }
  8648. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8649. {
  8650. if (strdb_exists(atcommand_db, name))
  8651. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8652. return NULL;
  8653. }
  8654. static const char* atcommand_checkalias(const char *aliasname)
  8655. {
  8656. AliasInfo *alias_info = NULL;
  8657. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8658. return alias_info->command->command;
  8659. return aliasname;
  8660. }
  8661. /// AtCommand suggestion
  8662. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8663. DBIterator* atcommand_iter;
  8664. DBIterator* alias_iter;
  8665. AtCommandInfo* command_info = NULL;
  8666. AliasInfo* alias_info = NULL;
  8667. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8668. char* full_match[MAX_SUGGESTIONS];
  8669. char* suggestions[MAX_SUGGESTIONS];
  8670. char* match;
  8671. int prefix_count = 0, full_count = 0;
  8672. bool can_use;
  8673. if (!battle_config.atcommand_suggestions_enabled)
  8674. return;
  8675. atcommand_iter = db_iterator(atcommand_db);
  8676. alias_iter = db_iterator(atcommand_alias_db);
  8677. // Build the matches
  8678. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8679. match = strstr(command_info->command, name);
  8680. can_use = pc_can_use_command(sd, command_info->command, type);
  8681. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8682. suggestions[prefix_count] = command_info->command;
  8683. ++prefix_count;
  8684. }
  8685. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8686. full_match[full_count] = command_info->command;
  8687. ++full_count;
  8688. }
  8689. }
  8690. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8691. match = strstr(alias_info->alias, name);
  8692. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8693. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8694. suggestions[prefix_count] = alias_info->alias;
  8695. ++prefix_count;
  8696. }
  8697. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8698. full_match[full_count] = alias_info->alias;
  8699. ++full_count;
  8700. }
  8701. }
  8702. if ((full_count+prefix_count) > 0) {
  8703. char buffer[512];
  8704. int i;
  8705. // Merge full match and prefix match results
  8706. if (prefix_count < MAX_SUGGESTIONS) {
  8707. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8708. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8709. }
  8710. // Build the suggestion string
  8711. strcpy(buffer, msg_txt(sd,205));
  8712. strcat(buffer,"\n");
  8713. for(i=0; i < prefix_count; ++i) {
  8714. strcat(buffer,suggestions[i]);
  8715. strcat(buffer," ");
  8716. }
  8717. clif_displaymessage(sd->fd, buffer);
  8718. }
  8719. dbi_destroy(atcommand_iter);
  8720. dbi_destroy(alias_iter);
  8721. }
  8722. /**
  8723. * Executes an at-command
  8724. * @param fd
  8725. * @param sd
  8726. * @param message
  8727. * @param type
  8728. * 0 : script call (atcommand)
  8729. * 1 : normal player @atcommand
  8730. * 2 : console (admin:@atcommand)
  8731. * 3 : script call (useatcmd)
  8732. */
  8733. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8734. {
  8735. char charname[NAME_LENGTH], charname2[NAME_LENGTH];
  8736. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8737. char output[CHAT_SIZE_MAX];
  8738. //Reconstructed message
  8739. char atcmd_msg[CHAT_SIZE_MAX];
  8740. TBL_PC * ssd = NULL; //sd for target
  8741. AtCommandInfo * info;
  8742. nullpo_retr(false, sd);
  8743. //Shouldn't happen
  8744. if ( !message || !*message )
  8745. return false;
  8746. //If cannot use atcomamnd while talking with NPC [Kichi]
  8747. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8748. return false;
  8749. //Block NOCHAT but do not display it as a normal message
  8750. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8751. return true;
  8752. // skip 10/11-langtype's codepage indicator, if detected
  8753. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8754. message += 3;
  8755. //Should display as a normal message
  8756. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8757. return false;
  8758. // type value 0|2 = script|console invoked: bypass restrictions
  8759. if ( type == 1 || type == 3) {
  8760. //Commands are disabled on maps flagged as 'nocommand'
  8761. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8762. clif_displaymessage(fd, msg_txt(sd,143));
  8763. return false;
  8764. }
  8765. }
  8766. if (*message == charcommand_symbol) {
  8767. do {
  8768. int x, y, z;
  8769. char params2[CHAT_SIZE_MAX];
  8770. //Checks to see if #command has a name or a name + parameters.
  8771. x = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params);
  8772. y = sscanf(message, "%255s %23s %255[^\n]", command, charname2, params2);
  8773. //z always has the value of the scan that was successful
  8774. z = ( x > 1 ) ? x : y;
  8775. //#command + name means the sufficient target was used and anything else after
  8776. //can be looked at by the actual command function since most scan to see if the
  8777. //right parameters are used.
  8778. if ( x > 2 ) {
  8779. sprintf(atcmd_msg, "%s %s", command, params);
  8780. break;
  8781. }
  8782. else if ( y > 2 ) {
  8783. sprintf(atcmd_msg, "%s %s", command, params2);
  8784. break;
  8785. }
  8786. //Regardless of what style the #command is used, if it's correct, it will always have
  8787. //this value if there is no parameter. Send it as just the #command
  8788. else if ( z == 2 ) {
  8789. sprintf(atcmd_msg, "%s", command);
  8790. break;
  8791. }
  8792. if( !pc_get_group_level(sd) ) {
  8793. if( x >= 1 || y >= 1 ) { /* we have command */
  8794. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8795. 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 */
  8796. return false;
  8797. } else
  8798. return false;/* display as normal message */
  8799. }
  8800. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8801. clif_displaymessage(fd, output);
  8802. return true;
  8803. } while(0);
  8804. }
  8805. else if (*message == atcommand_symbol) {
  8806. //atcmd_msg is constructed above differently for charcommands
  8807. //it's copied from message if not a charcommand so it can
  8808. //pass through the rest of the code compatible with both symbols
  8809. sprintf(atcmd_msg, "%s", message);
  8810. }
  8811. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8812. sd->idletime = last_tick;
  8813. //Clearing these to be used once more.
  8814. memset(command, '\0', sizeof(command));
  8815. memset(params, '\0', sizeof(params));
  8816. //check to see if any params exist within this command
  8817. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  8818. params[0] = '\0';
  8819. // @commands (script based)
  8820. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8821. struct atcmd_binding_data * binding;
  8822. // Check if the command initiated is a character command
  8823. if (*message == charcommand_symbol &&
  8824. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8825. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8826. clif_displaymessage(fd, output);
  8827. return true;
  8828. }
  8829. // Get atcommand binding
  8830. binding = get_atcommandbind_byname(command);
  8831. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8832. if( binding != NULL && binding->npc_event[0] &&
  8833. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8834. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8835. {
  8836. // Check if self or character invoking; if self == character invoked, then self invoke.
  8837. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8838. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8839. return true;
  8840. }
  8841. }
  8842. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8843. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8844. if (info == NULL) {
  8845. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8846. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8847. clif_displaymessage(fd, output);
  8848. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8849. return true;
  8850. } else
  8851. return false;
  8852. }
  8853. //check restriction
  8854. if (info->restriction) {
  8855. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  8856. return true;
  8857. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  8858. return true;
  8859. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  8860. && ((*atcmd_msg == atcommand_symbol && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  8861. return true;
  8862. }
  8863. // type == 1 : player invoked
  8864. if (type == 1) {
  8865. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8866. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8867. return false;
  8868. }
  8869. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8870. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8871. return true;
  8872. }
  8873. }
  8874. // Check if target is valid only if confirmed that player can use command.
  8875. if (*message == charcommand_symbol &&
  8876. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8877. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8878. clif_displaymessage(fd, output);
  8879. return true;
  8880. }
  8881. //Attempt to use the command
  8882. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8883. {
  8884. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8885. clif_displaymessage(fd, output);
  8886. return true;
  8887. }
  8888. //Log only if successful.
  8889. if ( *atcmd_msg == atcommand_symbol )
  8890. log_atcommand(sd, atcmd_msg);
  8891. else if ( *atcmd_msg == charcommand_symbol )
  8892. log_atcommand(sd, message);
  8893. return true;
  8894. }
  8895. /*==========================================
  8896. *
  8897. *------------------------------------------*/
  8898. static void atcommand_config_read(const char* config_filename)
  8899. {
  8900. config_setting_t *aliases = NULL, *help = NULL;
  8901. const char *symbol = NULL;
  8902. int num_aliases = 0;
  8903. if (conf_read_file(&atcommand_config, config_filename))
  8904. return;
  8905. // Command symbols
  8906. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8907. if (ISPRINT(*symbol) && // no control characters
  8908. *symbol != '/' && // symbol of client commands
  8909. *symbol != '%' && // symbol of party chat
  8910. *symbol != '$' && // symbol of guild chat
  8911. *symbol != charcommand_symbol)
  8912. atcommand_symbol = *symbol;
  8913. }
  8914. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8915. if (ISPRINT(*symbol) && // no control characters
  8916. *symbol != '/' && // symbol of client commands
  8917. *symbol != '%' && // symbol of party chat
  8918. *symbol != '$' && // symbol of guild chat
  8919. *symbol != atcommand_symbol)
  8920. charcommand_symbol = *symbol;
  8921. }
  8922. // Command aliases
  8923. aliases = config_lookup(&atcommand_config, "aliases");
  8924. if (aliases != NULL) {
  8925. int i = 0;
  8926. int count = config_setting_length(aliases);
  8927. for (i = 0; i < count; ++i) {
  8928. config_setting_t *command;
  8929. const char *commandname = NULL;
  8930. int j = 0, alias_count = 0;
  8931. AtCommandInfo *commandinfo = NULL;
  8932. command = config_setting_get_elem(aliases, i);
  8933. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8934. continue;
  8935. commandname = config_setting_name(command);
  8936. if (!atcommand_exists(commandname)) {
  8937. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8938. continue;
  8939. }
  8940. commandinfo = get_atcommandinfo_byname(commandname);
  8941. alias_count = config_setting_length(command);
  8942. for (j = 0; j < alias_count; ++j) {
  8943. const char *alias = config_setting_get_string_elem(command, j);
  8944. if (alias != NULL) {
  8945. AliasInfo *alias_info;
  8946. if (strdb_exists(atcommand_alias_db, alias)) {
  8947. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8948. continue;
  8949. }
  8950. CREATE(alias_info, AliasInfo, 1);
  8951. alias_info->command = commandinfo;
  8952. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8953. strdb_put(atcommand_alias_db, alias, alias_info);
  8954. ++num_aliases;
  8955. }
  8956. }
  8957. }
  8958. }
  8959. // Commands help
  8960. // We only check if all commands exist
  8961. help = config_lookup(&atcommand_config, "help");
  8962. if (help != NULL) {
  8963. int count = config_setting_length(help);
  8964. int i;
  8965. for (i = 0; i < count; ++i) {
  8966. config_setting_t *command;
  8967. const char *commandname;
  8968. command = config_setting_get_elem(help, i);
  8969. commandname = config_setting_name(command);
  8970. if (!atcommand_exists(commandname))
  8971. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8972. }
  8973. }
  8974. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8975. return;
  8976. }
  8977. void atcommand_db_load_groups(int* group_ids) {
  8978. DBIterator *iter = db_iterator(atcommand_db);
  8979. AtCommandInfo* cmd;
  8980. int i;
  8981. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8982. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  8983. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  8984. for(i = 0; i < pc_group_max; i++) {
  8985. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8986. cmd->at_groups[i] = 1;
  8987. else
  8988. cmd->at_groups[i] = 0;
  8989. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8990. cmd->char_groups[i] = 1;
  8991. else
  8992. cmd->char_groups[i] = 0;
  8993. }
  8994. }
  8995. dbi_destroy(iter);
  8996. return;
  8997. }
  8998. void atcommand_db_clear(void) {
  8999. if (atcommand_db != NULL) {
  9000. DBIterator *iter = db_iterator(atcommand_db);
  9001. AtCommandInfo* cmd;
  9002. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9003. aFree(cmd->at_groups);
  9004. aFree(cmd->char_groups);
  9005. }
  9006. dbi_destroy(iter);
  9007. db_destroy(atcommand_db);
  9008. }
  9009. if (atcommand_alias_db != NULL)
  9010. db_destroy(atcommand_alias_db);
  9011. config_destroy(&atcommand_config);
  9012. }
  9013. void atcommand_doload(void) {
  9014. atcommand_db_clear();
  9015. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9016. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9017. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9018. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9019. }
  9020. void do_init_atcommand(void) {
  9021. atcommand_doload();
  9022. }
  9023. void do_final_atcommand(void) {
  9024. atcommand_db_clear();
  9025. }