atcommand.c 314 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502
  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. if (sscanf(message, "%6hd %6hd", &x, &y) != 2) {
  506. clif_displaymessage(fd, msg_txt(sd,407));
  507. return -1;
  508. }
  509. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  510. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  511. return -1;
  512. }
  513. if( pc_isdead(sd) )
  514. {
  515. clif_displaymessage(fd, msg_txt(sd,664));
  516. return -1;
  517. }
  518. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  519. { //This is to prevent the pc_setpos call from printing an error.
  520. clif_displaymessage(fd, msg_txt(sd,2));
  521. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  522. x = y = 0; //Invalid cell, use random spot.
  523. }
  524. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  525. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  526. clif_displaymessage(fd, atcmd_output);
  527. return 0;
  528. }
  529. /*==========================================
  530. * Display list of online characters with
  531. * various info.
  532. *------------------------------------------*/
  533. ACMD_FUNC(who) {
  534. struct map_session_data *pl_sd = NULL;
  535. struct s_mapiterator *iter = NULL;
  536. char player_name[NAME_LENGTH] = "";
  537. int count = 0;
  538. int level = 0;
  539. StringBuf buf;
  540. /**
  541. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  542. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  543. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  544. */
  545. int display_type = 1;
  546. int map_id = -1;
  547. nullpo_retr(-1, sd);
  548. if (strstr(command, "map") != NULL) {
  549. char map_name[MAP_NAME_LENGTH_EXT] = "";
  550. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  551. map_id = sd->bl.m;
  552. } else {
  553. sscanf(message, "%23s", player_name);
  554. }
  555. if (strstr(command, "2") != NULL)
  556. display_type = 2;
  557. else if (strstr(command, "3") != NULL)
  558. display_type = 3;
  559. level = pc_get_group_level(sd);
  560. StringBuf_Init(&buf);
  561. iter = mapit_getallusers();
  562. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  563. 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
  564. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  565. || (map_id >= 0 && pl_sd->bl.m != map_id))
  566. continue;
  567. switch (display_type) {
  568. case 2: {
  569. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  570. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  571. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  572. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  573. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  574. break;
  575. }
  576. case 3: {
  577. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  578. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  579. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  580. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  581. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  582. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  583. break;
  584. }
  585. default: {
  586. struct party_data *p = party_search(pl_sd->status.party_id);
  587. struct guild *g = pl_sd->guild;
  588. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  589. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  590. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  591. if (p != NULL)
  592. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  593. if (g != NULL)
  594. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  595. break;
  596. }
  597. }
  598. clif_displaymessage(fd, StringBuf_Value(&buf));
  599. StringBuf_Clear(&buf);
  600. count++;
  601. }
  602. }
  603. mapit_free(iter);
  604. if (map_id < 0) {
  605. if (count == 0)
  606. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  607. else if (count == 1)
  608. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  609. else
  610. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  611. } else {
  612. if (count == 0)
  613. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  614. else if (count == 1)
  615. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  616. else
  617. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  618. }
  619. clif_displaymessage(fd, StringBuf_Value(&buf));
  620. StringBuf_Destroy(&buf);
  621. return 0;
  622. }
  623. /*==========================================
  624. *
  625. *------------------------------------------*/
  626. ACMD_FUNC(whogm)
  627. {
  628. struct map_session_data* pl_sd;
  629. struct s_mapiterator* iter;
  630. int j, count;
  631. int level;
  632. char match_text[CHAT_SIZE_MAX];
  633. char player_name[NAME_LENGTH];
  634. struct guild *g;
  635. struct party_data *p;
  636. nullpo_retr(-1, sd);
  637. memset(atcmd_output, '\0', sizeof(atcmd_output));
  638. memset(match_text, '\0', sizeof(match_text));
  639. memset(player_name, '\0', sizeof(player_name));
  640. if (sscanf(message, "%255[^\n]", match_text) < 1)
  641. strcpy(match_text, "");
  642. for (j = 0; match_text[j]; j++)
  643. match_text[j] = TOLOWER(match_text[j]);
  644. count = 0;
  645. level = pc_get_group_level(sd);
  646. iter = mapit_getallusers();
  647. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  648. {
  649. int pl_level = pc_get_group_level(pl_sd);
  650. if (!pl_level)
  651. continue;
  652. if (match_text[0])
  653. {
  654. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  655. for (j = 0; player_name[j]; j++)
  656. player_name[j] = TOLOWER(player_name[j]);
  657. // search with no case sensitive
  658. if (strstr(player_name, match_text) == NULL)
  659. continue;
  660. }
  661. if (pl_level > level) {
  662. if (pl_sd->sc.option & OPTION_INVISIBLE)
  663. continue;
  664. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  665. clif_displaymessage(fd, atcmd_output);
  666. count++;
  667. continue;
  668. }
  669. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  670. pl_sd->status.name, pl_level,
  671. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  672. clif_displaymessage(fd, atcmd_output);
  673. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  674. pl_sd->status.base_level,
  675. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  676. clif_displaymessage(fd, atcmd_output);
  677. p = party_search(pl_sd->status.party_id);
  678. g = pl_sd->guild;
  679. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  680. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  681. clif_displaymessage(fd, atcmd_output);
  682. count++;
  683. }
  684. mapit_free(iter);
  685. if (count == 0)
  686. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  687. else if (count == 1)
  688. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  689. else {
  690. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  691. clif_displaymessage(fd, atcmd_output);
  692. }
  693. return 0;
  694. }
  695. /*==========================================
  696. *
  697. *------------------------------------------*/
  698. ACMD_FUNC(save)
  699. {
  700. nullpo_retr(-1, sd);
  701. if( map[sd->bl.m].instance_id ) {
  702. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  703. return 1;
  704. }
  705. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  706. if (sd->status.pet_id > 0 && sd->pd)
  707. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  708. chrif_save(sd,0);
  709. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  710. return 0;
  711. }
  712. /*==========================================
  713. *
  714. *------------------------------------------*/
  715. ACMD_FUNC(load)
  716. {
  717. int16 m;
  718. nullpo_retr(-1, sd);
  719. m = map_mapindex2mapid(sd->status.save_point.map);
  720. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  721. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  722. return -1;
  723. }
  724. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  725. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  726. return -1;
  727. }
  728. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  729. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  730. return 0;
  731. }
  732. /*==========================================
  733. *
  734. *------------------------------------------*/
  735. ACMD_FUNC(speed)
  736. {
  737. short speed;
  738. nullpo_retr(-1, sd);
  739. memset(atcmd_output, '\0', sizeof(atcmd_output));
  740. if (!message || !*message || sscanf(message, "%6hd", &speed) < 1) {
  741. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  742. clif_displaymessage(fd, atcmd_output);
  743. return -1;
  744. }
  745. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  746. if (speed < 0)
  747. sd->base_status.speed = DEFAULT_WALK_SPEED;
  748. else
  749. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  750. if (sd->base_status.speed != DEFAULT_WALK_SPEED) {
  751. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  752. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  753. } else
  754. clif_displaymessage(fd, msg_txt(sd,389)); // Speed returned to normal.
  755. status_calc_bl(&sd->bl, SCB_SPEED);
  756. return 0;
  757. }
  758. /*==========================================
  759. *
  760. *------------------------------------------*/
  761. ACMD_FUNC(storage)
  762. {
  763. nullpo_retr(-1, sd);
  764. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  765. return -1;
  766. if (storage_storageopen(sd) == 1)
  767. { //Already open.
  768. clif_displaymessage(fd, msg_txt(sd,250));
  769. return -1;
  770. }
  771. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  772. return 0;
  773. }
  774. /*==========================================
  775. *
  776. *------------------------------------------*/
  777. ACMD_FUNC(guildstorage)
  778. {
  779. nullpo_retr(-1, sd);
  780. if (!sd->status.guild_id) {
  781. clif_displaymessage(fd, msg_txt(sd,252));
  782. return -1;
  783. }
  784. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  785. return -1;
  786. if (sd->state.storage_flag == 1) {
  787. clif_displaymessage(fd, msg_txt(sd,250));
  788. return -1;
  789. }
  790. if (sd->state.storage_flag == 2) {
  791. clif_displaymessage(fd, msg_txt(sd,251));
  792. return -1;
  793. }
  794. gstorage_storageopen(sd);
  795. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  796. return 0;
  797. }
  798. /*==========================================
  799. *
  800. *------------------------------------------*/
  801. ACMD_FUNC(option)
  802. {
  803. int param1 = 0, param2 = 0, param3 = 0;
  804. nullpo_retr(-1, sd);
  805. if (!message || !*message || sscanf(message, "%11d %11d %11d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  806. {// failed to match the parameters so inform the user of the options
  807. const char* text;
  808. // attempt to find the setting information for this command
  809. text = atcommand_help_string( command );
  810. // notify the user of the requirement to enter an option
  811. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  812. if( text )
  813. {// send the help text associated with this command
  814. clif_displaymessage( fd, text );
  815. }
  816. return -1;
  817. }
  818. sd->sc.opt1 = param1;
  819. sd->sc.opt2 = param2;
  820. pc_setoption(sd, param3);
  821. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  822. return 0;
  823. }
  824. /*==========================================
  825. *
  826. *------------------------------------------*/
  827. ACMD_FUNC(hide)
  828. {
  829. nullpo_retr(-1, sd);
  830. if (sd->sc.option & OPTION_INVISIBLE) {
  831. sd->sc.option &= ~OPTION_INVISIBLE;
  832. if (sd->disguise)
  833. status_set_viewdata(&sd->bl, sd->disguise);
  834. else
  835. status_set_viewdata(&sd->bl, sd->status.class_);
  836. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  837. // increment the number of pvp players on the map
  838. map[sd->bl.m].users_pvp++;
  839. if( !battle_config.pk_mode && map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  840. {// register the player for ranking calculations
  841. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  842. }
  843. //bugreport:2266
  844. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  845. } else {
  846. sd->sc.option |= OPTION_INVISIBLE;
  847. sd->vd.class_ = INVISIBLE_CLASS;
  848. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  849. // decrement the number of pvp players on the map
  850. map[sd->bl.m].users_pvp--;
  851. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  852. {// unregister the player for ranking
  853. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  854. sd->pvp_timer = INVALID_TIMER;
  855. }
  856. }
  857. clif_changeoption(&sd->bl);
  858. return 0;
  859. }
  860. /*==========================================
  861. * Changes a character's class
  862. *------------------------------------------*/
  863. ACMD_FUNC(jobchange)
  864. {
  865. int job = 0, upper = 0;
  866. const char* text;
  867. nullpo_retr(-1, sd);
  868. if (!message || !*message || sscanf(message, "%11d %11d", &job, &upper) < 1) {
  869. int i;
  870. bool found = false;
  871. upper = 0;
  872. // Normal Jobs
  873. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  874. if (strncmpi(message, job_name(i), 16) == 0) {
  875. job = i;
  876. found = true;
  877. }
  878. }
  879. // High Jobs, Babys and Third
  880. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  881. if (strncmpi(message, job_name(i), 16) == 0) {
  882. job = i;
  883. found = true;
  884. }
  885. }
  886. if (!found) {
  887. text = atcommand_help_string(command);
  888. if (text)
  889. clif_displaymessage(fd, text);
  890. return -1;
  891. }
  892. }
  893. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK || job == JOB_OKTOBERFEST
  894. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  895. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  896. { // Deny direct transformation into dummy jobs
  897. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  898. return 0;
  899. }
  900. if (pcdb_checkid(job))
  901. {
  902. if (pc_jobchange(sd, job, upper))
  903. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  904. else {
  905. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  906. return -1;
  907. }
  908. } else {
  909. text = atcommand_help_string(command);
  910. if (text)
  911. clif_displaymessage(fd, text);
  912. return -1;
  913. }
  914. return 0;
  915. }
  916. /*==========================================
  917. *
  918. *------------------------------------------*/
  919. ACMD_FUNC(kill)
  920. {
  921. nullpo_retr(-1, sd);
  922. status_kill(&sd->bl);
  923. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  924. if (fd != sd->fd)
  925. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  926. return 0;
  927. }
  928. /*==========================================
  929. *
  930. *------------------------------------------*/
  931. ACMD_FUNC(alive)
  932. {
  933. nullpo_retr(-1, sd);
  934. if (!status_revive(&sd->bl, 100, 100))
  935. {
  936. clif_displaymessage(fd, msg_txt(sd,667));
  937. return -1;
  938. }
  939. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  940. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  941. return 0;
  942. }
  943. /*==========================================
  944. * +kamic [LuzZza]
  945. *------------------------------------------*/
  946. ACMD_FUNC(kami)
  947. {
  948. unsigned long color=0;
  949. nullpo_retr(-1, sd);
  950. memset(atcmd_output, '\0', sizeof(atcmd_output));
  951. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  952. if (!message || !*message) {
  953. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  954. return -1;
  955. }
  956. sscanf(message, "%255[^\n]", atcmd_output);
  957. if (strstr(command, "l") != NULL)
  958. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  959. else
  960. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
  961. } else {
  962. if(!message || !*message || (sscanf(message, "%20lx %199[^\n]", &color, atcmd_output) < 2)) {
  963. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  964. return -1;
  965. }
  966. if(color > 0xFFFFFF) {
  967. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  968. return -1;
  969. }
  970. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  971. }
  972. return 0;
  973. }
  974. /*==========================================
  975. *
  976. *------------------------------------------*/
  977. ACMD_FUNC(heal)
  978. {
  979. int hp = 0, sp = 0; // [Valaris] thanks to fov
  980. nullpo_retr(-1, sd);
  981. if (sscanf(message, "%11d %11d", &hp, &sp) != 2) {
  982. clif_displaymessage(fd, msg_txt(sd,407));
  983. return -1;
  984. }
  985. // some overflow checks
  986. if( hp == INT_MIN ) hp++;
  987. if( sp == INT_MIN ) sp++;
  988. if ( hp == 0 && sp == 0 ) {
  989. if (!status_percent_heal(&sd->bl, 100, 100))
  990. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  991. else
  992. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  993. return 0;
  994. }
  995. if ( hp > 0 && sp >= 0 ) {
  996. if(!status_heal(&sd->bl, hp, sp, 0))
  997. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  998. else
  999. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  1000. return 0;
  1001. }
  1002. if ( hp < 0 && sp <= 0 ) {
  1003. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  1004. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1005. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1006. return 0;
  1007. }
  1008. //Opposing signs.
  1009. if ( hp ) {
  1010. if (hp > 0)
  1011. status_heal(&sd->bl, hp, 0, 0);
  1012. else {
  1013. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  1014. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0);
  1015. }
  1016. }
  1017. if ( sp ) {
  1018. if (sp > 0)
  1019. status_heal(&sd->bl, 0, sp, 0);
  1020. else
  1021. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  1022. }
  1023. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  1024. return 0;
  1025. }
  1026. /*==========================================
  1027. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  1028. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  1029. *------------------------------------------*/
  1030. ACMD_FUNC(item)
  1031. {
  1032. char item_name[100];
  1033. int number = 0, bound = BOUND_NONE;
  1034. char flag = 0;
  1035. struct item item_tmp;
  1036. struct item_data *item_data[10];
  1037. int get_count, i, j=0;
  1038. char *itemlist;
  1039. nullpo_retr(-1, sd);
  1040. memset(item_name, '\0', sizeof(item_name));
  1041. parent_cmd = atcommand_checkalias(command+1);
  1042. if (!strcmpi(parent_cmd,"itembound")) {
  1043. if (!message || !*message || (
  1044. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &number, &bound) < 3 &&
  1045. sscanf(message, "%99s %11d %11d", item_name, &number, &bound) < 3))
  1046. {
  1047. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  1048. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1049. return -1;
  1050. }
  1051. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1052. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1053. return -1;
  1054. }
  1055. } else if (!message || !*message || (
  1056. sscanf(message, "\"%99[^\"]\" %11d", item_name, &number) < 1 &&
  1057. sscanf(message, "%99s %11d", item_name, &number) < 1
  1058. )) {
  1059. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  1060. return -1;
  1061. }
  1062. itemlist = strtok(item_name, ":");
  1063. while (itemlist != NULL && j<10) {
  1064. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  1065. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  1066. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1067. return -1;
  1068. }
  1069. itemlist = strtok(NULL, ":"); //next itemline
  1070. j++;
  1071. }
  1072. if (number <= 0)
  1073. number = 1;
  1074. get_count = number;
  1075. for(j--; j>=0; j--){ //produce items in list
  1076. unsigned short item_id = item_data[j]->nameid;
  1077. //Check if it's stackable.
  1078. if (!itemdb_isstackable2(item_data[j]))
  1079. get_count = 1;
  1080. for (i = 0; i < number; i += get_count) {
  1081. // if not pet egg
  1082. if (!pet_create_egg(sd, item_id)) {
  1083. memset(&item_tmp, 0, sizeof(item_tmp));
  1084. item_tmp.nameid = item_id;
  1085. item_tmp.identify = 1;
  1086. item_tmp.bound = bound;
  1087. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1088. clif_additem(sd, 0, 0, flag);
  1089. }
  1090. }
  1091. }
  1092. if (flag == 0)
  1093. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1094. return 0;
  1095. }
  1096. /*==========================================
  1097. *
  1098. *------------------------------------------*/
  1099. ACMD_FUNC(item2)
  1100. {
  1101. struct item item_tmp;
  1102. struct item_data *item_data;
  1103. char item_name[100];
  1104. unsigned short item_id;
  1105. int number = 0, bound = BOUND_NONE;
  1106. int identify = 0, refine = 0, attr = 0;
  1107. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1108. nullpo_retr(-1, sd);
  1109. memset(item_name, '\0', sizeof(item_name));
  1110. parent_cmd = atcommand_checkalias(command+1);
  1111. if (!strcmpi(parent_cmd+1,"itembound2")) {
  1112. if (!message || !*message || (
  1113. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1114. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))
  1115. {
  1116. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1117. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1118. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1119. return -1;
  1120. }
  1121. if( bound <= BOUND_NONE || bound >= BOUND_MAX ) {
  1122. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1123. return -1;
  1124. }
  1125. } else if ( !message || !*message || (
  1126. sscanf(message, "\"%99[^\"]\" %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1127. sscanf(message, "%99s %11d %11d %11d %11d %11d %11d %11d %11d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1128. )) {
  1129. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1130. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1131. return -1;
  1132. }
  1133. if (number <= 0)
  1134. number = 1;
  1135. item_id = 0;
  1136. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1137. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1138. item_id = item_data->nameid;
  1139. if (item_id > 500) {
  1140. int loop, get_count, i;
  1141. char flag = 0;
  1142. loop = 1;
  1143. get_count = number;
  1144. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1145. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1146. loop = number;
  1147. get_count = 1;
  1148. if (item_data->type == IT_PETEGG) {
  1149. identify = 1;
  1150. refine = 0;
  1151. }
  1152. if (item_data->type == IT_PETARMOR)
  1153. refine = 0;
  1154. if (refine > MAX_REFINE)
  1155. refine = MAX_REFINE;
  1156. } else {
  1157. identify = 1;
  1158. refine = attr = 0;
  1159. }
  1160. for (i = 0; i < loop; i++) {
  1161. memset(&item_tmp, 0, sizeof(item_tmp));
  1162. item_tmp.nameid = item_id;
  1163. item_tmp.identify = identify;
  1164. item_tmp.refine = refine;
  1165. item_tmp.attribute = attr;
  1166. item_tmp.card[0] = c1;
  1167. item_tmp.card[1] = c2;
  1168. item_tmp.card[2] = c3;
  1169. item_tmp.card[3] = c4;
  1170. item_tmp.bound = bound;
  1171. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1172. clif_additem(sd, 0, 0, flag);
  1173. }
  1174. if (flag == 0)
  1175. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1176. } else {
  1177. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1178. return -1;
  1179. }
  1180. return 0;
  1181. }
  1182. /*==========================================
  1183. *
  1184. *------------------------------------------*/
  1185. ACMD_FUNC(itemreset)
  1186. {
  1187. int i;
  1188. nullpo_retr(-1, sd);
  1189. for (i = 0; i < MAX_INVENTORY; i++) {
  1190. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1191. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1192. }
  1193. }
  1194. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1195. return 0;
  1196. }
  1197. /*==========================================
  1198. * Atcommand @lvlup
  1199. *------------------------------------------*/
  1200. ACMD_FUNC(baselevelup)
  1201. {
  1202. int level=0, i=0, status_point=0;
  1203. nullpo_retr(-1, sd);
  1204. level = atoi(message);
  1205. if (!message || !*message || !level) {
  1206. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1207. return -1;
  1208. }
  1209. if (level > 0) {
  1210. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1211. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1212. return -1;
  1213. } // End Addition
  1214. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
  1215. level = pc_maxbaselv(sd) - sd->status.base_level;
  1216. for (i = 0; i < level; i++)
  1217. status_point += pc_gets_status_point(sd->status.base_level + i);
  1218. sd->status.status_point += status_point;
  1219. sd->status.base_level += (unsigned int)level;
  1220. status_calc_pc(sd, SCO_FORCE);
  1221. status_percent_heal(&sd->bl, 100, 100);
  1222. clif_misceffect(&sd->bl, 0);
  1223. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1224. } else {
  1225. if (sd->status.base_level == 1) {
  1226. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1227. return -1;
  1228. }
  1229. level*=-1;
  1230. if ((unsigned int)level >= sd->status.base_level)
  1231. level = sd->status.base_level-1;
  1232. for (i = 0; i > -level; i--)
  1233. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1234. if (sd->status.status_point < status_point)
  1235. pc_resetstate(sd);
  1236. if (sd->status.status_point < status_point)
  1237. sd->status.status_point = 0;
  1238. else
  1239. sd->status.status_point -= status_point;
  1240. sd->status.base_level -= (unsigned int)level;
  1241. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1242. status_calc_pc(sd, SCO_FORCE);
  1243. }
  1244. sd->status.base_exp = 0;
  1245. clif_updatestatus(sd, SP_STATUSPOINT);
  1246. clif_updatestatus(sd, SP_BASELEVEL);
  1247. clif_updatestatus(sd, SP_BASEEXP);
  1248. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1249. pc_baselevelchanged(sd);
  1250. if(sd->status.party_id)
  1251. party_send_levelup(sd);
  1252. return 0;
  1253. }
  1254. /*==========================================
  1255. *
  1256. *------------------------------------------*/
  1257. ACMD_FUNC(joblevelup)
  1258. {
  1259. int level=0;
  1260. nullpo_retr(-1, sd);
  1261. level = atoi(message);
  1262. if (!message || !*message || !level) {
  1263. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1264. return -1;
  1265. }
  1266. if (level > 0) {
  1267. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1268. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1269. return -1;
  1270. }
  1271. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
  1272. level = pc_maxjoblv(sd) - sd->status.job_level;
  1273. sd->status.job_level += (unsigned int)level;
  1274. sd->status.skill_point += level;
  1275. clif_misceffect(&sd->bl, 1);
  1276. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1277. } else {
  1278. if (sd->status.job_level == 1) {
  1279. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1280. return -1;
  1281. }
  1282. level *=-1;
  1283. if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
  1284. level = sd->status.job_level-1;
  1285. sd->status.job_level -= (unsigned int)level;
  1286. if (sd->status.skill_point < level)
  1287. pc_resetskill(sd,0); //Reset skills since we need to subtract more points.
  1288. if (sd->status.skill_point < level)
  1289. sd->status.skill_point = 0;
  1290. else
  1291. sd->status.skill_point -= level;
  1292. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1293. }
  1294. sd->status.job_exp = 0;
  1295. clif_updatestatus(sd, SP_JOBLEVEL);
  1296. clif_updatestatus(sd, SP_JOBEXP);
  1297. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1298. clif_updatestatus(sd, SP_SKILLPOINT);
  1299. status_calc_pc(sd, SCO_FORCE);
  1300. return 0;
  1301. }
  1302. /*==========================================
  1303. * @help
  1304. *------------------------------------------*/
  1305. ACMD_FUNC(help)
  1306. {
  1307. config_setting_t *help;
  1308. const char *text = NULL;
  1309. const char *command_name = NULL;
  1310. char *default_command = "help";
  1311. nullpo_retr(-1, sd);
  1312. help = config_lookup(&atcommand_config, "help");
  1313. if (help == NULL) {
  1314. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1315. return -1;
  1316. }
  1317. if (!message || !*message) {
  1318. command_name = default_command; // If no command_name specified, display help for @help.
  1319. } else {
  1320. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1321. ++message;
  1322. command_name = atcommand_checkalias(message);
  1323. }
  1324. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1325. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1326. clif_displaymessage(fd, atcmd_output);
  1327. atcommand_get_suggestions(sd, command_name, true);
  1328. return -1;
  1329. }
  1330. if (!config_setting_lookup_string(help, command_name, &text)) {
  1331. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1332. clif_displaymessage(fd, atcmd_output);
  1333. atcommand_get_suggestions(sd, command_name, true);
  1334. return -1;
  1335. }
  1336. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1337. clif_displaymessage(fd, atcmd_output);
  1338. { // Display aliases
  1339. DBIterator* iter;
  1340. AtCommandInfo *command_info;
  1341. AliasInfo *alias_info = NULL;
  1342. StringBuf buf;
  1343. bool has_aliases = false;
  1344. StringBuf_Init(&buf);
  1345. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1346. command_info = get_atcommandinfo_byname(command_name);
  1347. iter = db_iterator(atcommand_alias_db);
  1348. for (alias_info = (AliasInfo *)dbi_first(iter); dbi_exists(iter); alias_info = (AliasInfo *)dbi_next(iter)) {
  1349. if (alias_info->command == command_info) {
  1350. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1351. has_aliases = true;
  1352. }
  1353. }
  1354. dbi_destroy(iter);
  1355. if (has_aliases)
  1356. clif_displaymessage(fd, StringBuf_Value(&buf));
  1357. StringBuf_Destroy(&buf);
  1358. }
  1359. // Display help contents
  1360. clif_displaymessage(fd, text);
  1361. return 0;
  1362. }
  1363. // helper function, used in foreach calls to stop auto-attack timers
  1364. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1365. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1366. {
  1367. struct unit_data *ud = unit_bl2ud(bl);
  1368. int id = va_arg(ap, int);
  1369. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1370. {
  1371. unit_stop_attack(bl);
  1372. return 1;
  1373. }
  1374. return 0;
  1375. }
  1376. /*==========================================
  1377. *
  1378. *------------------------------------------*/
  1379. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1380. {
  1381. TBL_PC* sd = (TBL_PC*)bl;
  1382. clif_pvpset(sd, 0, 0, 2);
  1383. if (sd->pvp_timer != INVALID_TIMER) {
  1384. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1385. sd->pvp_timer = INVALID_TIMER;
  1386. }
  1387. return 0;
  1388. }
  1389. ACMD_FUNC(pvpoff)
  1390. {
  1391. nullpo_retr(-1, sd);
  1392. if (!map[sd->bl.m].flag.pvp) {
  1393. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1394. return -1;
  1395. }
  1396. map[sd->bl.m].flag.pvp = 0;
  1397. if (!battle_config.pk_mode){
  1398. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1399. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1400. }
  1401. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1402. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1403. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1404. return 0;
  1405. }
  1406. /*==========================================
  1407. *
  1408. *------------------------------------------*/
  1409. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1410. {
  1411. TBL_PC* sd = (TBL_PC*)bl;
  1412. if (sd->pvp_timer == INVALID_TIMER) {
  1413. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1414. sd->pvp_rank = 0;
  1415. sd->pvp_lastusers = 0;
  1416. sd->pvp_point = 5;
  1417. sd->pvp_won = 0;
  1418. sd->pvp_lost = 0;
  1419. }
  1420. return 0;
  1421. }
  1422. ACMD_FUNC(pvpon)
  1423. {
  1424. nullpo_retr(-1, sd);
  1425. if (map[sd->bl.m].flag.pvp) {
  1426. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1427. return -1;
  1428. }
  1429. map[sd->bl.m].flag.pvp = 1;
  1430. if (!battle_config.pk_mode) {// display pvp circle and rank
  1431. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1432. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1433. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1434. }
  1435. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1436. return 0;
  1437. }
  1438. /*==========================================
  1439. *
  1440. *------------------------------------------*/
  1441. ACMD_FUNC(gvgoff)
  1442. {
  1443. nullpo_retr(-1, sd);
  1444. if (!map[sd->bl.m].flag.gvg) {
  1445. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1446. return -1;
  1447. }
  1448. map[sd->bl.m].flag.gvg = 0;
  1449. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1450. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1451. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1452. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1453. return 0;
  1454. }
  1455. /*==========================================
  1456. *
  1457. *------------------------------------------*/
  1458. ACMD_FUNC(gvgon)
  1459. {
  1460. nullpo_retr(-1, sd);
  1461. if (map[sd->bl.m].flag.gvg) {
  1462. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1463. return -1;
  1464. }
  1465. map[sd->bl.m].flag.gvg = 1;
  1466. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1467. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1468. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1469. return 0;
  1470. }
  1471. /*==========================================
  1472. *
  1473. *------------------------------------------*/
  1474. ACMD_FUNC(model)
  1475. {
  1476. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1477. nullpo_retr(-1, sd);
  1478. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1479. if (!message || !*message || sscanf(message, "%11d %11d %11d", &hair_style, &hair_color, &cloth_color) < 1) {
  1480. 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>).
  1481. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1482. clif_displaymessage(fd, atcmd_output);
  1483. return -1;
  1484. }
  1485. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1486. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1487. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1488. pc_changelook(sd, LOOK_HAIR, hair_style);
  1489. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1490. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1491. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1492. } else {
  1493. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1494. return -1;
  1495. }
  1496. return 0;
  1497. }
  1498. /*==========================================
  1499. * @dye && @ccolor
  1500. *------------------------------------------*/
  1501. ACMD_FUNC(dye)
  1502. {
  1503. int cloth_color = 0;
  1504. nullpo_retr(-1, sd);
  1505. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1506. if (!message || !*message || sscanf(message, "%11d", &cloth_color) < 1) {
  1507. 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>).
  1508. clif_displaymessage(fd, atcmd_output);
  1509. return -1;
  1510. }
  1511. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1512. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1513. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1514. } else {
  1515. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1516. return -1;
  1517. }
  1518. return 0;
  1519. }
  1520. /*==========================================
  1521. * @hairstyle && @hstyle
  1522. *------------------------------------------*/
  1523. ACMD_FUNC(hair_style)
  1524. {
  1525. int hair_style = 0;
  1526. nullpo_retr(-1, sd);
  1527. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1528. if (!message || !*message || sscanf(message, "%11d", &hair_style) < 1) {
  1529. 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>).
  1530. clif_displaymessage(fd, atcmd_output);
  1531. return -1;
  1532. }
  1533. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1534. pc_changelook(sd, LOOK_HAIR, hair_style);
  1535. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1536. } else {
  1537. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1538. return -1;
  1539. }
  1540. return 0;
  1541. }
  1542. /*==========================================
  1543. * @haircolor && @hcolor
  1544. *------------------------------------------*/
  1545. ACMD_FUNC(hair_color)
  1546. {
  1547. int hair_color = 0;
  1548. nullpo_retr(-1, sd);
  1549. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1550. if (!message || !*message || sscanf(message, "%11d", &hair_color) < 1) {
  1551. 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>).
  1552. clif_displaymessage(fd, atcmd_output);
  1553. return -1;
  1554. }
  1555. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1556. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1557. clif_displaymessage(fd, msg_txt(sd,36)); // Appearance changed.
  1558. } else {
  1559. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1560. return -1;
  1561. }
  1562. return 0;
  1563. }
  1564. /*==========================================
  1565. * @go [city_number or city_name] - Updated by Harbin
  1566. *------------------------------------------*/
  1567. ACMD_FUNC(go)
  1568. {
  1569. int i;
  1570. int town;
  1571. char map_name[MAP_NAME_LENGTH];
  1572. const struct {
  1573. char map[MAP_NAME_LENGTH];
  1574. int x, y;
  1575. } data[] = {
  1576. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1577. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1578. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1579. { MAP_PAYON, 162, 233 }, // 3=Payon
  1580. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1581. #ifdef RENEWAL
  1582. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1583. #else
  1584. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1585. #endif
  1586. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1587. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1588. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1589. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1590. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1591. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1592. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1593. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1594. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1595. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1596. { MAP_JAIL, 23, 61 }, // 16=Prison
  1597. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1598. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1599. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1600. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1601. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1602. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1603. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1604. { MAP_VEINS, 216, 123 }, // 24=Veins
  1605. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1606. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1607. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1608. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1609. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1610. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1611. { MAP_MORA, 44, 151 }, // 31=Mora
  1612. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1613. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1614. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1615. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1616. };
  1617. nullpo_retr(-1, sd);
  1618. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1619. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1620. return 0;
  1621. }
  1622. memset(map_name, '\0', sizeof(map_name));
  1623. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1624. // get the number
  1625. town = atoi(message);
  1626. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1627. {// no value matched so send the list of locations
  1628. const char* text;
  1629. // attempt to find the text help string
  1630. text = atcommand_help_string( command );
  1631. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1632. if( text )
  1633. {// send the text to the client
  1634. clif_displaymessage( fd, text );
  1635. }
  1636. return -1;
  1637. }
  1638. // get possible name of the city
  1639. map_name[MAP_NAME_LENGTH-1] = '\0';
  1640. for (i = 0; map_name[i]; i++)
  1641. map_name[i] = TOLOWER(map_name[i]);
  1642. // try to identify the map name
  1643. if (strncmp(map_name, "prontera", 3) == 0) {
  1644. town = 0;
  1645. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1646. strncmp(map_name, "morroc", 4) == 0) {
  1647. town = 1;
  1648. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1649. town = 2;
  1650. } else if (strncmp(map_name, "payon", 3) == 0) {
  1651. town = 3;
  1652. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1653. town = 4;
  1654. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1655. town = 5;
  1656. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1657. town = 6;
  1658. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1659. strcmp(map_name, "christmas") == 0 ||
  1660. strncmp(map_name, "xmas", 3) == 0 ||
  1661. strncmp(map_name, "x-mas", 3) == 0) {
  1662. town = 7;
  1663. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1664. town = 8;
  1665. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1666. strncmp(map_name, "yuno", 3) == 0) {
  1667. town = 9;
  1668. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1669. town = 10;
  1670. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1671. strncmp(map_name, "gonryun", 3) == 0) {
  1672. town = 11;
  1673. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1674. town = 12;
  1675. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1676. town = 13;
  1677. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1678. town = 14;
  1679. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1680. strncmp(map_name, "startpoint", 3) == 0 ||
  1681. strncmp(map_name, "beginning", 3) == 0) {
  1682. town = 15;
  1683. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1684. strncmp(map_name, "prison", 3) == 0 ||
  1685. strncmp(map_name, "jail", 3) == 0) {
  1686. town = 16;
  1687. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1688. town = 17;
  1689. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1690. town = 18;
  1691. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1692. town = 19;
  1693. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1694. town = 20;
  1695. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1696. town = 21;
  1697. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1698. town = 22;
  1699. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1700. town = 23;
  1701. } else if (strncmp(map_name, "veins", 3) == 0) {
  1702. town = 24;
  1703. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1704. town = 25;
  1705. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1706. town = 26;
  1707. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1708. town = 27;
  1709. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1710. town = 28;
  1711. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1712. town = 29;
  1713. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1714. town = 30;
  1715. } else if (strcmp(map_name, "mora") == 0) {
  1716. town = 31;
  1717. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1718. town = 32;
  1719. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1720. town = 33;
  1721. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1722. town = 34;
  1723. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1724. town = 35;
  1725. }
  1726. if (town >= 0 && town < ARRAYLENGTH(data))
  1727. {
  1728. int16 m = map_mapname2mapid(data[town].map);
  1729. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1730. clif_displaymessage(fd, msg_txt(sd,247));
  1731. return -1;
  1732. }
  1733. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1734. clif_displaymessage(fd, msg_txt(sd,248));
  1735. return -1;
  1736. }
  1737. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1738. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1739. } else {
  1740. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1741. return -1;
  1742. }
  1743. } else { // if you arrive here, you have an error in town variable when reading of names
  1744. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1745. return -1;
  1746. }
  1747. return 0;
  1748. }
  1749. /*==========================================
  1750. *
  1751. *------------------------------------------*/
  1752. ACMD_FUNC(monster)
  1753. {
  1754. char name[NAME_LENGTH];
  1755. char monster[NAME_LENGTH];
  1756. char eventname[EVENT_NAME_LENGTH] = "";
  1757. int mob_id;
  1758. int number = 0;
  1759. int count;
  1760. int i, range;
  1761. short mx, my;
  1762. unsigned int size;
  1763. nullpo_retr(-1, sd);
  1764. memset(name, '\0', sizeof(name));
  1765. memset(monster, '\0', sizeof(monster));
  1766. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1767. if (!message || !*message) {
  1768. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1769. return -1;
  1770. }
  1771. if (sscanf(message, "\"%23[^\"]\" %23s %11d", name, monster, &number) > 1 ||
  1772. sscanf(message, "%23s \"%23[^\"]\" %11d", monster, name, &number) > 1) {
  1773. //All data can be left as it is.
  1774. } else if ((count=sscanf(message, "%23s %11d %23s", monster, &number, name)) > 1) {
  1775. //Here, it is possible name was not given and we are using monster for it.
  1776. if (count < 3) //Blank mob's name.
  1777. name[0] = '\0';
  1778. } else if (sscanf(message, "%23s %23s %11d", name, monster, &number) > 1) {
  1779. //All data can be left as it is.
  1780. } else if (sscanf(message, "%23s", monster) > 0) {
  1781. //As before, name may be already filled.
  1782. name[0] = '\0';
  1783. } else {
  1784. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1785. return -1;
  1786. }
  1787. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1788. mob_id = mobdb_checkid(atoi(monster));
  1789. if (mob_id == 0) {
  1790. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1791. return -1;
  1792. }
  1793. if (mob_id == MOBID_EMPERIUM) {
  1794. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1795. return -1;
  1796. }
  1797. if (number <= 0)
  1798. number = 1;
  1799. if( !name[0] )
  1800. strcpy(name, "--ja--");
  1801. // 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
  1802. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1803. number = battle_config.atc_spawn_quantity_limit;
  1804. parent_cmd = atcommand_checkalias(command+1);
  1805. if (strcmp(parent_cmd, "monstersmall") == 0)
  1806. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1807. else if (strcmp(parent_cmd, "monsterbig") == 0)
  1808. size = SZ_BIG;
  1809. else
  1810. size = SZ_SMALL;
  1811. if (battle_config.etc_log)
  1812. 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);
  1813. count = 0;
  1814. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1815. for (i = 0; i < number; i++) {
  1816. int k;
  1817. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1818. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1819. if(k) {
  1820. //mapreg_setreg(reference_uid(add_str("$@mobid"), i),k); //retain created mobid in array uncomment if needed
  1821. count ++;
  1822. }
  1823. }
  1824. if (count != 0)
  1825. if (number == count)
  1826. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1827. else {
  1828. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1829. clif_displaymessage(fd, atcmd_output);
  1830. }
  1831. else {
  1832. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1833. return -1;
  1834. }
  1835. return 0;
  1836. }
  1837. /*==========================================
  1838. *
  1839. *------------------------------------------*/
  1840. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1841. {
  1842. struct mob_data *md;
  1843. int flag;
  1844. nullpo_ret(md=(struct mob_data *)bl);
  1845. flag = va_arg(ap, int);
  1846. if (md->guardian_data)
  1847. return 0; //Do not touch WoE mobs!
  1848. if (flag)
  1849. status_zap(bl,md->status.hp, 0);
  1850. else
  1851. status_kill(bl);
  1852. return 1;
  1853. }
  1854. ACMD_FUNC(killmonster)
  1855. {
  1856. int map_id, drop_flag;
  1857. char map_name[MAP_NAME_LENGTH_EXT];
  1858. nullpo_retr(-1, sd);
  1859. memset(map_name, '\0', sizeof(map_name));
  1860. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1861. map_id = sd->bl.m;
  1862. else {
  1863. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1864. map_id = sd->bl.m;
  1865. }
  1866. parent_cmd = atcommand_checkalias(command+1);
  1867. drop_flag = strcmp(parent_cmd, "killmonster2");
  1868. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1869. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1870. return 0;
  1871. }
  1872. /*==========================================
  1873. *
  1874. *------------------------------------------*/
  1875. ACMD_FUNC(refine)
  1876. {
  1877. int j, position = 0, refine = 0, current_position, final_refine;
  1878. int count;
  1879. nullpo_retr(-1, sd);
  1880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1881. if (!message || !*message || sscanf(message, "%11d %11d", &position, &refine) < 2) {
  1882. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1883. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1884. clif_displaymessage(fd, atcmd_output);
  1885. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1886. clif_displaymessage(fd, atcmd_output);
  1887. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1888. clif_displaymessage(fd, atcmd_output);
  1889. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1890. clif_displaymessage(fd, atcmd_output);
  1891. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1892. clif_displaymessage(fd, atcmd_output);
  1893. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1894. clif_displaymessage(fd, atcmd_output);
  1895. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1896. clif_displaymessage(fd, atcmd_output);
  1897. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1898. clif_displaymessage(fd, atcmd_output);
  1899. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1900. clif_displaymessage(fd, atcmd_output);
  1901. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1902. clif_displaymessage(fd, atcmd_output);
  1903. return -1;
  1904. }
  1905. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1906. count = 0;
  1907. for (j = 0; j < EQI_MAX; j++) {
  1908. int i;
  1909. if ((i = sd->equip_index[j]) < 0)
  1910. continue;
  1911. if(j == EQI_AMMO)
  1912. continue;
  1913. if (pc_is_same_equip_index((enum equip_index)j, sd->equip_index, i))
  1914. continue;
  1915. if(position && !(sd->status.inventory[i].equip & position))
  1916. continue;
  1917. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1918. if (sd->status.inventory[i].refine != final_refine) {
  1919. sd->status.inventory[i].refine = final_refine;
  1920. current_position = sd->status.inventory[i].equip;
  1921. pc_unequipitem(sd, i, 3);
  1922. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1923. clif_delitem(sd, i, 1, 3);
  1924. clif_additem(sd, i, 1, 0);
  1925. pc_equipitem(sd, i, current_position);
  1926. clif_misceffect(&sd->bl, 3);
  1927. count++;
  1928. }
  1929. }
  1930. if (count == 0)
  1931. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1932. else if (count == 1)
  1933. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1934. else {
  1935. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1936. clif_displaymessage(fd, atcmd_output);
  1937. }
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. *
  1942. *------------------------------------------*/
  1943. ACMD_FUNC(produce)
  1944. {
  1945. char item_name[100];
  1946. unsigned short item_id;
  1947. int attribute = 0, star = 0;
  1948. struct item_data *item_data;
  1949. struct item tmp_item;
  1950. nullpo_retr(-1, sd);
  1951. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1952. memset(item_name, '\0', sizeof(item_name));
  1953. if (!message || !*message || (
  1954. sscanf(message, "\"%99[^\"]\" %11d %11d", item_name, &attribute, &star) < 1 &&
  1955. sscanf(message, "%99s %11d %11d", item_name, &attribute, &star) < 1
  1956. )) {
  1957. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1958. return -1;
  1959. }
  1960. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1961. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1962. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1963. return -1;
  1964. }
  1965. item_id = item_data->nameid;
  1966. if (itemdb_isequip2(item_data)) {
  1967. char flag = 0;
  1968. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1969. attribute = ATTRIBUTE_NORMAL;
  1970. if (star < MIN_STAR || star > MAX_STAR)
  1971. star = 0;
  1972. memset(&tmp_item, 0, sizeof tmp_item);
  1973. tmp_item.nameid = item_id;
  1974. tmp_item.amount = 1;
  1975. tmp_item.identify = 1;
  1976. tmp_item.card[0] = CARD0_FORGE;
  1977. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1978. ((star*5) << 8) + attribute:0;
  1979. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1980. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1981. clif_produceeffect(sd, 0, item_id);
  1982. clif_misceffect(&sd->bl, 3);
  1983. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1984. clif_additem(sd, 0, 0, flag);
  1985. } else {
  1986. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%hu: '%s') is not equipable.
  1987. clif_displaymessage(fd, atcmd_output);
  1988. return -1;
  1989. }
  1990. return 0;
  1991. }
  1992. /*==========================================
  1993. *
  1994. *------------------------------------------*/
  1995. ACMD_FUNC(memo)
  1996. {
  1997. int position = 0;
  1998. nullpo_retr(-1, sd);
  1999. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2000. if( !message || !*message || sscanf(message, "%11d", &position) < 1 )
  2001. {
  2002. int i;
  2003. clif_displaymessage(sd->fd, msg_txt(sd,668));
  2004. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  2005. {
  2006. if( sd->status.memo_point[i].map )
  2007. 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);
  2008. else
  2009. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  2010. clif_displaymessage(sd->fd, atcmd_output);
  2011. }
  2012. return 0;
  2013. }
  2014. if( position < 0 || position >= MAX_MEMOPOINTS )
  2015. {
  2016. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  2017. clif_displaymessage(fd, atcmd_output);
  2018. return -1;
  2019. }
  2020. return !pc_memo( sd, position );
  2021. }
  2022. /*==========================================
  2023. *
  2024. *------------------------------------------*/
  2025. ACMD_FUNC(gat)
  2026. {
  2027. int y;
  2028. nullpo_retr(-1, sd);
  2029. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2030. for (y = 2; y >= -2; y--) {
  2031. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  2032. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  2033. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  2034. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  2035. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  2036. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  2037. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  2038. clif_displaymessage(fd, atcmd_output);
  2039. }
  2040. return 0;
  2041. }
  2042. /*==========================================
  2043. *
  2044. *------------------------------------------*/
  2045. ACMD_FUNC(displaystatus)
  2046. {
  2047. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  2048. nullpo_retr(-1, sd);
  2049. if (!message || !*message || (i = sscanf(message, "%11d %11d %11d %11d %11d %11d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  2050. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  2051. return -1;
  2052. }
  2053. if (i < 2) flag = 1;
  2054. if (i < 3) tick = 0;
  2055. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  2056. return 0;
  2057. }
  2058. /*==========================================
  2059. * @stpoint (Rewritten by [Yor])
  2060. *------------------------------------------*/
  2061. ACMD_FUNC(statuspoint)
  2062. {
  2063. int point;
  2064. unsigned int new_status_point;
  2065. if (!message || !*message || (point = atoi(message)) == 0) {
  2066. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  2067. return -1;
  2068. }
  2069. if(point < 0)
  2070. {
  2071. if(sd->status.status_point < (unsigned int)(-point))
  2072. {
  2073. new_status_point = 0;
  2074. }
  2075. else
  2076. {
  2077. new_status_point = sd->status.status_point + point;
  2078. }
  2079. }
  2080. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  2081. {
  2082. new_status_point = UINT_MAX;
  2083. }
  2084. else
  2085. {
  2086. new_status_point = sd->status.status_point + point;
  2087. }
  2088. if (new_status_point != sd->status.status_point) {
  2089. sd->status.status_point = new_status_point;
  2090. clif_updatestatus(sd, SP_STATUSPOINT);
  2091. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2092. } else {
  2093. if (point < 0)
  2094. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2095. else
  2096. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2097. return -1;
  2098. }
  2099. return 0;
  2100. }
  2101. /*==========================================
  2102. * @skpoint (Rewritten by [Yor])
  2103. *------------------------------------------*/
  2104. ACMD_FUNC(skillpoint)
  2105. {
  2106. int point;
  2107. unsigned int new_skill_point;
  2108. nullpo_retr(-1, sd);
  2109. if (!message || !*message || (point = atoi(message)) == 0) {
  2110. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2111. return -1;
  2112. }
  2113. if(point < 0)
  2114. {
  2115. if(sd->status.skill_point < (unsigned int)(-point))
  2116. {
  2117. new_skill_point = 0;
  2118. }
  2119. else
  2120. {
  2121. new_skill_point = sd->status.skill_point + point;
  2122. }
  2123. }
  2124. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2125. {
  2126. new_skill_point = UINT_MAX;
  2127. }
  2128. else
  2129. {
  2130. new_skill_point = sd->status.skill_point + point;
  2131. }
  2132. if (new_skill_point != sd->status.skill_point) {
  2133. sd->status.skill_point = new_skill_point;
  2134. clif_updatestatus(sd, SP_SKILLPOINT);
  2135. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2136. } else {
  2137. if (point < 0)
  2138. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2139. else
  2140. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2141. return -1;
  2142. }
  2143. return 0;
  2144. }
  2145. /*==========================================
  2146. * @zeny
  2147. *------------------------------------------*/
  2148. ACMD_FUNC(zeny)
  2149. {
  2150. int zeny=0, ret=-1;
  2151. nullpo_retr(-1, sd);
  2152. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2153. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2154. return -1;
  2155. }
  2156. if(zeny > 0){
  2157. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2158. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2159. }
  2160. else {
  2161. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2162. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2163. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2164. }
  2165. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2166. return 0;
  2167. }
  2168. /*==========================================
  2169. *
  2170. *------------------------------------------*/
  2171. ACMD_FUNC(param)
  2172. {
  2173. uint8 i;
  2174. int value = 0;
  2175. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2176. unsigned short new_value, *status[6], max_status[6];
  2177. //we don't use direct initialization because it isn't part of the c standard.
  2178. nullpo_retr(-1, sd);
  2179. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2180. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2181. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2182. return -1;
  2183. }
  2184. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2185. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2186. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2187. return -1;
  2188. }
  2189. status[0] = &sd->status.str;
  2190. status[1] = &sd->status.agi;
  2191. status[2] = &sd->status.vit;
  2192. status[3] = &sd->status.int_;
  2193. status[4] = &sd->status.dex;
  2194. status[5] = &sd->status.luk;
  2195. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2196. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2197. else {
  2198. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2199. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2200. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2201. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2202. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2203. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2204. }
  2205. if(value > 0 && *status[i] + value >= max_status[i])
  2206. new_value = max_status[i];
  2207. else if(value < 0 && *status[i] <= -value)
  2208. new_value = 1;
  2209. else
  2210. new_value = *status[i] + value;
  2211. if (new_value != *status[i]) {
  2212. *status[i] = new_value;
  2213. clif_updatestatus(sd, SP_STR + i);
  2214. clif_updatestatus(sd, SP_USTR + i);
  2215. status_calc_pc(sd, SCO_FORCE);
  2216. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2217. } else {
  2218. if (value < 0)
  2219. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2220. else
  2221. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2222. return -1;
  2223. }
  2224. return 0;
  2225. }
  2226. /*==========================================
  2227. * Stat all by fritz (rewritten by [Yor])
  2228. *------------------------------------------*/
  2229. ACMD_FUNC(stat_all)
  2230. {
  2231. int value = 0;
  2232. uint8 count, i;
  2233. unsigned short *status[PARAM_MAX], max_status[PARAM_MAX];
  2234. //we don't use direct initialization because it isn't part of the c standard.
  2235. nullpo_retr(-1, sd);
  2236. status[0] = &sd->status.str;
  2237. status[1] = &sd->status.agi;
  2238. status[2] = &sd->status.vit;
  2239. status[3] = &sd->status.int_;
  2240. status[4] = &sd->status.dex;
  2241. status[5] = &sd->status.luk;
  2242. if (!message || !*message || sscanf(message, "%11d", &value) < 1 || value == 0) {
  2243. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2244. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2245. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2246. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2247. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2248. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2249. value = SHRT_MAX;
  2250. } else {
  2251. if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
  2252. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2253. else {
  2254. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2255. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2256. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2257. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2258. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2259. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2260. }
  2261. }
  2262. count = 0;
  2263. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2264. short new_value;
  2265. if (value > 0 && *status[i] + value >= max_status[i])
  2266. new_value = max_status[i];
  2267. else if (value < 0 && *status[i] <= -value)
  2268. new_value = 1;
  2269. else
  2270. new_value = *status[i] + value;
  2271. if (new_value != *status[i]) {
  2272. *status[i] = new_value;
  2273. clif_updatestatus(sd, SP_STR + i);
  2274. clif_updatestatus(sd, SP_USTR + i);
  2275. count++;
  2276. }
  2277. }
  2278. if (count > 0) { // if at least 1 stat modified
  2279. status_calc_pc(sd, SCO_FORCE);
  2280. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2281. } else {
  2282. if (value < 0)
  2283. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2284. else
  2285. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2286. return -1;
  2287. }
  2288. return 0;
  2289. }
  2290. /*==========================================
  2291. *
  2292. *------------------------------------------*/
  2293. ACMD_FUNC(guildlevelup) {
  2294. int level = 0;
  2295. short added_level;
  2296. struct guild *guild_info;
  2297. nullpo_retr(-1, sd);
  2298. if (!message || !*message || sscanf(message, "%11d", &level) < 1 || level == 0) {
  2299. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2300. return -1;
  2301. }
  2302. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2303. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2304. return -1;
  2305. }
  2306. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2307. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2308. // return -1;
  2309. //}
  2310. added_level = (short)level;
  2311. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positive overflow
  2312. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2313. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negative overflow
  2314. added_level = 1 - guild_info->guild_lv;
  2315. if (added_level != 0) {
  2316. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2317. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2318. } else {
  2319. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2320. return -1;
  2321. }
  2322. return 0;
  2323. }
  2324. /*==========================================
  2325. *
  2326. *------------------------------------------*/
  2327. ACMD_FUNC(makeegg) {
  2328. struct item_data *item_data;
  2329. int id, pet_id;
  2330. nullpo_retr(-1, sd);
  2331. if (!message || !*message) {
  2332. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2333. return -1;
  2334. }
  2335. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2336. id = item_data->nameid;
  2337. else
  2338. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2339. ;
  2340. else
  2341. id = atoi(message);
  2342. pet_id = search_petDB_index(id, PET_CLASS);
  2343. if (pet_id < 0)
  2344. pet_id = search_petDB_index(id, PET_EGG);
  2345. if (pet_id >= 0) {
  2346. sd->catch_target_class = pet_db[pet_id].class_;
  2347. intif_create_pet(
  2348. sd->status.account_id, sd->status.char_id,
  2349. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2350. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2351. 100, 0, 1, pet_db[pet_id].jname);
  2352. } else {
  2353. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2354. return -1;
  2355. }
  2356. return 0;
  2357. }
  2358. /*==========================================
  2359. *
  2360. *------------------------------------------*/
  2361. ACMD_FUNC(hatch) {
  2362. nullpo_retr(-1, sd);
  2363. if (sd->status.pet_id <= 0)
  2364. clif_sendegg(sd);
  2365. else {
  2366. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2367. return -1;
  2368. }
  2369. return 0;
  2370. }
  2371. /*==========================================
  2372. *
  2373. *------------------------------------------*/
  2374. ACMD_FUNC(petfriendly) {
  2375. int friendly;
  2376. struct pet_data *pd;
  2377. nullpo_retr(-1, sd);
  2378. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2379. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2380. return -1;
  2381. }
  2382. pd = sd->pd;
  2383. if (!pd) {
  2384. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2385. return -1;
  2386. }
  2387. if (friendly < 0 || friendly > 1000)
  2388. {
  2389. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2390. return -1;
  2391. }
  2392. if (friendly == pd->pet.intimate) {
  2393. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2394. return -1;
  2395. }
  2396. pet_set_intimate(pd, friendly);
  2397. clif_send_petstatus(sd);
  2398. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2399. return 0;
  2400. }
  2401. /*==========================================
  2402. *
  2403. *------------------------------------------*/
  2404. ACMD_FUNC(pethungry)
  2405. {
  2406. int hungry;
  2407. struct pet_data *pd;
  2408. nullpo_retr(-1, sd);
  2409. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2410. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2411. return -1;
  2412. }
  2413. pd = sd->pd;
  2414. if (!sd->status.pet_id || !pd) {
  2415. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2416. return -1;
  2417. }
  2418. if (hungry < 0 || hungry > 100) {
  2419. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2420. return -1;
  2421. }
  2422. if (hungry == pd->pet.hungry) {
  2423. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2424. return -1;
  2425. }
  2426. pd->pet.hungry = hungry;
  2427. clif_send_petstatus(sd);
  2428. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2429. return 0;
  2430. }
  2431. /*==========================================
  2432. *
  2433. *------------------------------------------*/
  2434. ACMD_FUNC(petrename)
  2435. {
  2436. struct pet_data *pd;
  2437. nullpo_retr(-1, sd);
  2438. if (!sd->status.pet_id || !sd->pd) {
  2439. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2440. return -1;
  2441. }
  2442. pd = sd->pd;
  2443. if (!pd->pet.rename_flag) {
  2444. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2445. return -1;
  2446. }
  2447. pd->pet.rename_flag = 0;
  2448. intif_save_petdata(sd->status.account_id, &pd->pet);
  2449. clif_send_petstatus(sd);
  2450. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2451. return 0;
  2452. }
  2453. /*==========================================
  2454. *
  2455. *------------------------------------------*/
  2456. ACMD_FUNC(recall) {
  2457. struct map_session_data *pl_sd = NULL;
  2458. nullpo_retr(-1, sd);
  2459. if (!message || !*message) {
  2460. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2461. return -1;
  2462. }
  2463. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2464. {
  2465. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2466. return -1;
  2467. }
  2468. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2469. {
  2470. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2471. return -1;
  2472. }
  2473. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2474. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2475. return -1;
  2476. }
  2477. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2478. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2479. return -1;
  2480. }
  2481. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2482. return -1;
  2483. }
  2484. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2485. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2486. clif_displaymessage(fd, atcmd_output);
  2487. return 0;
  2488. }
  2489. /*==========================================
  2490. * charblock command (usage: charblock <player_name>)
  2491. * This command do a definitiv ban on a player
  2492. *------------------------------------------*/
  2493. ACMD_FUNC(char_block)
  2494. {
  2495. nullpo_retr(-1, sd);
  2496. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2497. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2498. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2499. clif_displaymessage(fd, atcmd_output);
  2500. return -1;
  2501. }
  2502. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0);
  2503. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2504. clif_displaymessage(fd, atcmd_output);
  2505. return 0;
  2506. }
  2507. /*==========================================
  2508. * accountban command (usage: ban <%time> <player_name>)
  2509. * charban command (usage: charban <%time> <player_name>)
  2510. * %time see common/timer.c::solve_time()
  2511. *------------------------------------------*/
  2512. ACMD_FUNC(char_ban)
  2513. {
  2514. char *modif_p, output[CHAT_SIZE_MAX];
  2515. int32 timediff = 0; //don't set this as uint as we may want to decrease banned time
  2516. int bantype = 0;
  2517. nullpo_retr(-1, sd);
  2518. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2519. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2520. parent_cmd = atcommand_checkalias(command+1);
  2521. if (strcmpi(parent_cmd,"charban") == 0)
  2522. bantype = CHRIF_OP_BAN;
  2523. else if (strcmpi(parent_cmd,"ban") == 0)
  2524. bantype = CHRIF_OP_LOGIN_BAN;
  2525. else
  2526. return -1;
  2527. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2528. sprintf(output, msg_txt(sd,1022), command); // Please enter ban time and a player name (usage: %s <time> <char name>).
  2529. clif_displaymessage(fd, output);
  2530. return -1;
  2531. }
  2532. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2533. modif_p = atcmd_output;
  2534. timediff = (int32)solve_time(modif_p); //discard seconds
  2535. if (timediff == 0) { //allow negative ?
  2536. safesnprintf(output, sizeof(output), msg_txt(sd,85), command, timediff); // Invalid time for %s command (time=%d)
  2537. clif_displaymessage(fd, output);
  2538. 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.
  2539. return -1;
  2540. }
  2541. if( timediff < 0 && (
  2542. (bantype == CHRIF_OP_LOGIN_BAN && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND))
  2543. || (bantype == CHRIF_OP_BAN && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND))
  2544. ))
  2545. {
  2546. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2547. return -1;
  2548. }
  2549. if (bantype == CHRIF_OP_BAN)
  2550. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2551. else
  2552. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, bantype, timediff, 0, 0);
  2553. safesnprintf(output, sizeof(output), msg_txt(sd,88), bantype == CHRIF_OP_BAN ? "char" : "login"); // Sending request to %s server...
  2554. clif_displaymessage(fd, output);
  2555. return 0;
  2556. }
  2557. /*==========================================
  2558. * charunblock command (usage: charunblock <player_name>)
  2559. *------------------------------------------*/
  2560. ACMD_FUNC(char_unblock)
  2561. {
  2562. nullpo_retr(-1, sd);
  2563. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2564. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2565. sprintf(atcmd_output, msg_txt(sd, 1021), command); // Please enter a player name (usage: %s <char name>).
  2566. clif_displaymessage(fd, atcmd_output);
  2567. return -1;
  2568. }
  2569. // send answer to login server via char-server
  2570. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, CHRIF_OP_LOGIN_UNBLOCK, 0, 0, 0);
  2571. sprintf(atcmd_output, msg_txt(sd,88), "login"); // Sending request to %s server...
  2572. clif_displaymessage(fd, atcmd_output);
  2573. return 0;
  2574. }
  2575. /*==========================================
  2576. * acc unban command (usage: unban <player_name>)
  2577. * char unban command (usage: charunban <player_name>)
  2578. *------------------------------------------*/
  2579. ACMD_FUNC(char_unban){
  2580. int unbantype = 0;
  2581. nullpo_retr(-1, sd);
  2582. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2583. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2584. parent_cmd = atcommand_checkalias(command+1);
  2585. if (strcmpi(parent_cmd,"charunban") == 0)
  2586. unbantype = CHRIF_OP_UNBAN;
  2587. else if (strcmpi(parent_cmd,"unban") == 0)
  2588. unbantype = CHRIF_OP_LOGIN_UNBAN;
  2589. else
  2590. return -1;
  2591. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2592. sprintf(atcmd_output, msg_txt(sd,435), command); // Please enter a player name (usage: %s <char name>).
  2593. clif_displaymessage(fd, atcmd_output);
  2594. return -1;
  2595. }
  2596. if (unbantype == CHRIF_OP_UNBAN)
  2597. chrif_req_charunban(sd->status.account_id,atcmd_player_name);
  2598. else
  2599. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, unbantype, 0, 0, 0);
  2600. sprintf(atcmd_output, msg_txt(sd,88), unbantype == CHRIF_OP_UNBAN ? "char":"login"); // Sending request to %s server...
  2601. clif_displaymessage(fd, atcmd_output);
  2602. return 0;
  2603. }
  2604. /*==========================================
  2605. *
  2606. *------------------------------------------*/
  2607. ACMD_FUNC(night)
  2608. {
  2609. nullpo_retr(-1, sd);
  2610. if (night_flag != 1) {
  2611. map_night_timer(night_timer_tid, 0, 0, 1);
  2612. } else {
  2613. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2614. return -1;
  2615. }
  2616. return 0;
  2617. }
  2618. /*==========================================
  2619. *
  2620. *------------------------------------------*/
  2621. ACMD_FUNC(day)
  2622. {
  2623. nullpo_retr(-1, sd);
  2624. if (night_flag != 0) {
  2625. map_day_timer(day_timer_tid, 0, 0, 1);
  2626. } else {
  2627. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2628. return -1;
  2629. }
  2630. return 0;
  2631. }
  2632. /*==========================================
  2633. *
  2634. *------------------------------------------*/
  2635. ACMD_FUNC(doom)
  2636. {
  2637. struct map_session_data* pl_sd;
  2638. struct s_mapiterator* iter;
  2639. nullpo_retr(-1, sd);
  2640. iter = mapit_getallusers();
  2641. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2642. {
  2643. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2644. {
  2645. status_kill(&pl_sd->bl);
  2646. clif_specialeffect(&pl_sd->bl,450,AREA);
  2647. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2648. }
  2649. }
  2650. mapit_free(iter);
  2651. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2652. return 0;
  2653. }
  2654. /*==========================================
  2655. *
  2656. *------------------------------------------*/
  2657. ACMD_FUNC(doommap)
  2658. {
  2659. struct map_session_data* pl_sd;
  2660. struct s_mapiterator* iter;
  2661. nullpo_retr(-1, sd);
  2662. iter = mapit_getallusers();
  2663. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2664. {
  2665. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2666. {
  2667. status_kill(&pl_sd->bl);
  2668. clif_specialeffect(&pl_sd->bl,450,AREA);
  2669. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2670. }
  2671. }
  2672. mapit_free(iter);
  2673. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2674. return 0;
  2675. }
  2676. /*==========================================
  2677. *
  2678. *------------------------------------------*/
  2679. static void atcommand_raise_sub(struct map_session_data* sd) {
  2680. status_revive(&sd->bl, 100, 100);
  2681. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2682. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2683. }
  2684. /*==========================================
  2685. *
  2686. *------------------------------------------*/
  2687. ACMD_FUNC(raise)
  2688. {
  2689. struct map_session_data* pl_sd;
  2690. struct s_mapiterator* iter;
  2691. nullpo_retr(-1, sd);
  2692. iter = mapit_getallusers();
  2693. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2694. if( pc_isdead(pl_sd) )
  2695. atcommand_raise_sub(pl_sd);
  2696. mapit_free(iter);
  2697. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2698. return 0;
  2699. }
  2700. /*==========================================
  2701. *
  2702. *------------------------------------------*/
  2703. ACMD_FUNC(raisemap)
  2704. {
  2705. struct map_session_data* pl_sd;
  2706. struct s_mapiterator* iter;
  2707. nullpo_retr(-1, sd);
  2708. iter = mapit_getallusers();
  2709. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2710. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2711. atcommand_raise_sub(pl_sd);
  2712. mapit_free(iter);
  2713. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2714. return 0;
  2715. }
  2716. /*==========================================
  2717. *
  2718. *------------------------------------------*/
  2719. ACMD_FUNC(kick)
  2720. {
  2721. struct map_session_data *pl_sd;
  2722. nullpo_retr(-1, sd);
  2723. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2724. if (!message || !*message) {
  2725. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2726. return -1;
  2727. }
  2728. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2729. {
  2730. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2731. return -1;
  2732. }
  2733. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2734. {
  2735. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2736. return -1;
  2737. }
  2738. clif_GM_kick(sd, pl_sd);
  2739. return 0;
  2740. }
  2741. /*==========================================
  2742. *
  2743. *------------------------------------------*/
  2744. ACMD_FUNC(kickall)
  2745. {
  2746. struct map_session_data* pl_sd;
  2747. struct s_mapiterator* iter;
  2748. nullpo_retr(-1, sd);
  2749. iter = mapit_getallusers();
  2750. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2751. {
  2752. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2753. if (sd->status.account_id != pl_sd->status.account_id)
  2754. clif_GM_kick(NULL, pl_sd);
  2755. }
  2756. }
  2757. mapit_free(iter);
  2758. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2759. return 0;
  2760. }
  2761. /*==========================================
  2762. *
  2763. *------------------------------------------*/
  2764. ACMD_FUNC(allskill)
  2765. {
  2766. nullpo_retr(-1, sd);
  2767. pc_allskillup(sd); // all skills
  2768. sd->status.skill_point = 0; // 0 skill points
  2769. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2770. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2771. return 0;
  2772. }
  2773. /*==========================================
  2774. *
  2775. *------------------------------------------*/
  2776. ACMD_FUNC(questskill)
  2777. {
  2778. uint16 skill_id;
  2779. nullpo_retr(-1, sd);
  2780. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2781. {// also send a list of skills applicable to this command
  2782. const char* text;
  2783. // attempt to find the text corresponding to this command
  2784. text = atcommand_help_string( command );
  2785. // send the error message as always
  2786. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2787. if( text )
  2788. {// send the skill ID list associated with this command
  2789. clif_displaymessage( fd, text );
  2790. }
  2791. return -1;
  2792. }
  2793. if (skill_id >= MAX_SKILL_ID) {
  2794. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2795. return -1;
  2796. }
  2797. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2798. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2799. return -1;
  2800. }
  2801. if (pc_checkskill(sd, skill_id) > 0) {
  2802. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2803. return -1;
  2804. }
  2805. pc_skill(sd, skill_id, 1, ADDSKILL_PERMANENT);
  2806. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2807. return 0;
  2808. }
  2809. /*==========================================
  2810. *
  2811. *------------------------------------------*/
  2812. ACMD_FUNC(lostskill)
  2813. {
  2814. uint16 skill_id = 0, sk_idx = 0;
  2815. nullpo_retr(-1, sd);
  2816. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2817. {// also send a list of skills applicable to this command
  2818. const char* text;
  2819. // attempt to find the text corresponding to this command
  2820. text = atcommand_help_string( command );
  2821. // send the error message as always
  2822. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2823. if( text )
  2824. {// send the skill ID list associated with this command
  2825. clif_displaymessage( fd, text );
  2826. }
  2827. return -1;
  2828. }
  2829. if (!(sk_idx = skill_get_index(skill_id))) {
  2830. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2831. return -1;
  2832. }
  2833. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2834. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2835. return -1;
  2836. }
  2837. if (pc_checkskill(sd, skill_id) == 0) {
  2838. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2839. return -1;
  2840. }
  2841. sd->status.skill[sk_idx].lv = 0;
  2842. sd->status.skill[sk_idx].flag = SKILL_FLAG_PERMANENT;
  2843. clif_deleteskill(sd,skill_id);
  2844. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2845. return 0;
  2846. }
  2847. /*==========================================
  2848. *
  2849. *------------------------------------------*/
  2850. ACMD_FUNC(spiritball)
  2851. {
  2852. uint32 max_spiritballs;
  2853. int number;
  2854. nullpo_retr(-1, sd);
  2855. max_spiritballs = zmin(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2856. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2857. {
  2858. char msg[CHAT_SIZE_MAX];
  2859. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2860. clif_displaymessage(fd, msg);
  2861. return -1;
  2862. }
  2863. if( sd->spiritball > 0 )
  2864. pc_delspiritball(sd, sd->spiritball, 1);
  2865. sd->spiritball = number;
  2866. clif_spiritball(&sd->bl);
  2867. // no message, player can look the difference
  2868. return 0;
  2869. }
  2870. /*==========================================
  2871. *
  2872. *------------------------------------------*/
  2873. ACMD_FUNC(party)
  2874. {
  2875. char party[NAME_LENGTH];
  2876. nullpo_retr(-1, sd);
  2877. memset(party, '\0', sizeof(party));
  2878. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2879. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2880. return -1;
  2881. }
  2882. party_create(sd, party, 0, 0);
  2883. return 0;
  2884. }
  2885. /*==========================================
  2886. *
  2887. *------------------------------------------*/
  2888. ACMD_FUNC(guild)
  2889. {
  2890. char guild[NAME_LENGTH];
  2891. int prev;
  2892. nullpo_retr(-1, sd);
  2893. memset(guild, '\0', sizeof(guild));
  2894. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2895. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2896. return -1;
  2897. }
  2898. prev = battle_config.guild_emperium_check;
  2899. battle_config.guild_emperium_check = 0;
  2900. guild_create(sd, guild);
  2901. battle_config.guild_emperium_check = prev;
  2902. return 0;
  2903. }
  2904. ACMD_FUNC(breakguild)
  2905. {
  2906. nullpo_retr(-1, sd);
  2907. if (sd->status.guild_id) { // Check if the player has a guild
  2908. struct guild *g;
  2909. g = sd->guild; // Search the guild
  2910. if (g) { // Check if guild was found
  2911. if (sd->state.gmaster_flag) { // Check if player is guild master
  2912. int ret = 0;
  2913. ret = guild_break(sd, g->name); // Break guild
  2914. if (ret) { // Check if anything went wrong
  2915. return 0; // Guild was broken
  2916. } else {
  2917. return -1; // Something went wrong
  2918. }
  2919. } else { // Not guild master
  2920. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2921. return -1;
  2922. }
  2923. } else { // Guild was not found. HOW?
  2924. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2925. return -1;
  2926. }
  2927. } else { // Player does not have a guild
  2928. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2929. return -1;
  2930. }
  2931. return 0;
  2932. }
  2933. /*==========================================
  2934. *
  2935. *------------------------------------------*/
  2936. ACMD_FUNC(agitstart)
  2937. {
  2938. nullpo_retr(-1, sd);
  2939. if (agit_flag == 1) {
  2940. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2941. return -1;
  2942. }
  2943. agit_flag = 1;
  2944. guild_agit_start();
  2945. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2946. return 0;
  2947. }
  2948. /*==========================================
  2949. *
  2950. *------------------------------------------*/
  2951. ACMD_FUNC(agitstart2)
  2952. {
  2953. nullpo_retr(-1, sd);
  2954. if (agit2_flag == 1) {
  2955. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2956. return -1;
  2957. }
  2958. agit2_flag = 1;
  2959. guild_agit2_start();
  2960. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2961. return 0;
  2962. }
  2963. /*==========================================
  2964. *
  2965. *------------------------------------------*/
  2966. ACMD_FUNC(agitend)
  2967. {
  2968. nullpo_retr(-1, sd);
  2969. if (agit_flag == 0) {
  2970. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2971. return -1;
  2972. }
  2973. agit_flag = 0;
  2974. guild_agit_end();
  2975. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2976. return 0;
  2977. }
  2978. /*==========================================
  2979. *
  2980. *------------------------------------------*/
  2981. ACMD_FUNC(agitend2)
  2982. {
  2983. nullpo_retr(-1, sd);
  2984. if (agit2_flag == 0) {
  2985. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2986. return -1;
  2987. }
  2988. agit2_flag = 0;
  2989. guild_agit2_end();
  2990. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2991. return 0;
  2992. }
  2993. /*==========================================
  2994. * @mapexit - shuts down the map server
  2995. *------------------------------------------*/
  2996. ACMD_FUNC(mapexit)
  2997. {
  2998. nullpo_retr(-1, sd);
  2999. do_shutdown();
  3000. return 0;
  3001. }
  3002. /*==========================================
  3003. * idsearch <part_of_name>: revrited by [Yor]
  3004. *------------------------------------------*/
  3005. ACMD_FUNC(idsearch)
  3006. {
  3007. char item_name[100];
  3008. unsigned int i, match;
  3009. struct item_data *item_array[MAX_SEARCH];
  3010. nullpo_retr(-1, sd);
  3011. memset(item_name, '\0', sizeof(item_name));
  3012. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3013. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  3014. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  3015. return -1;
  3016. }
  3017. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  3018. clif_displaymessage(fd, atcmd_output);
  3019. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  3020. if (match > MAX_SEARCH) {
  3021. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  3022. clif_displaymessage(fd, atcmd_output);
  3023. match = MAX_SEARCH;
  3024. }
  3025. for(i = 0; i < match; i++) {
  3026. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  3027. clif_displaymessage(fd, atcmd_output);
  3028. }
  3029. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  3030. clif_displaymessage(fd, atcmd_output);
  3031. return 0;
  3032. }
  3033. /*==========================================
  3034. * Recall All Characters Online To Your Location
  3035. *------------------------------------------*/
  3036. ACMD_FUNC(recallall)
  3037. {
  3038. struct map_session_data* pl_sd;
  3039. struct s_mapiterator* iter;
  3040. int count;
  3041. nullpo_retr(-1, sd);
  3042. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3043. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3044. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3045. return -1;
  3046. }
  3047. count = 0;
  3048. iter = mapit_getallusers();
  3049. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3050. {
  3051. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  3052. {
  3053. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  3054. continue; // Don't waste time warping the character to the same place.
  3055. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3056. count++;
  3057. else {
  3058. if (pc_isdead(pl_sd)) { //Wake them up
  3059. pc_setstand(pl_sd, true);
  3060. pc_setrestartvalue(pl_sd,1);
  3061. }
  3062. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3063. }
  3064. }
  3065. }
  3066. mapit_free(iter);
  3067. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  3068. if (count) {
  3069. 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.
  3070. clif_displaymessage(fd, atcmd_output);
  3071. }
  3072. return 0;
  3073. }
  3074. /*==========================================
  3075. * Recall online characters of a guild to your location
  3076. *------------------------------------------*/
  3077. ACMD_FUNC(guildrecall)
  3078. {
  3079. struct map_session_data* pl_sd;
  3080. struct s_mapiterator* iter;
  3081. int count;
  3082. char guild_name[NAME_LENGTH];
  3083. struct guild *g;
  3084. nullpo_retr(-1, sd);
  3085. memset(guild_name, '\0', sizeof(guild_name));
  3086. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3087. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3088. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  3089. return -1;
  3090. }
  3091. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3092. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3093. return -1;
  3094. }
  3095. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  3096. (g = guild_search(atoi(message))) == NULL)
  3097. {
  3098. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  3099. return -1;
  3100. }
  3101. count = 0;
  3102. iter = mapit_getallusers();
  3103. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3104. {
  3105. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3106. {
  3107. 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))
  3108. continue; // Skip GMs greater than you... or chars already on the cell
  3109. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3110. count++;
  3111. else
  3112. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3113. }
  3114. }
  3115. mapit_free(iter);
  3116. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3117. clif_displaymessage(fd, atcmd_output);
  3118. if (count) {
  3119. 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.
  3120. clif_displaymessage(fd, atcmd_output);
  3121. }
  3122. return 0;
  3123. }
  3124. /*==========================================
  3125. * Recall online characters of a party to your location
  3126. *------------------------------------------*/
  3127. ACMD_FUNC(partyrecall)
  3128. {
  3129. struct map_session_data* pl_sd;
  3130. struct s_mapiterator* iter;
  3131. char party_name[NAME_LENGTH];
  3132. struct party_data *p;
  3133. int count;
  3134. nullpo_retr(-1, sd);
  3135. memset(party_name, '\0', sizeof(party_name));
  3136. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3137. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3138. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3139. return -1;
  3140. }
  3141. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3142. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp someone to your current map.
  3143. return -1;
  3144. }
  3145. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3146. (p = party_search(atoi(message))) == NULL)
  3147. {
  3148. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3149. return -1;
  3150. }
  3151. count = 0;
  3152. iter = mapit_getallusers();
  3153. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3154. {
  3155. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3156. {
  3157. 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))
  3158. continue; // Skip GMs greater than you... or chars already on the cell
  3159. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3160. count++;
  3161. else
  3162. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3163. }
  3164. }
  3165. mapit_free(iter);
  3166. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3167. clif_displaymessage(fd, atcmd_output);
  3168. if (count) {
  3169. 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.
  3170. clif_displaymessage(fd, atcmd_output);
  3171. }
  3172. return 0;
  3173. }
  3174. /*==========================================
  3175. *
  3176. *------------------------------------------*/
  3177. void atcommand_doload();
  3178. ACMD_FUNC(reload) {
  3179. nullpo_retr(-1, sd);
  3180. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3181. const char* text;
  3182. text = atcommand_help_string( command );
  3183. if(text)
  3184. clif_displaymessage( fd, text );
  3185. return -1;
  3186. }
  3187. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3188. itemdb_reload();
  3189. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3190. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3191. mob_reload();
  3192. read_petdb();
  3193. hom_reload();
  3194. mercenary_readdb();
  3195. mercenary_read_skilldb();
  3196. reload_elementaldb();
  3197. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3198. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3199. skill_reload();
  3200. hom_reload_skill();
  3201. reload_elemental_skilldb();
  3202. mercenary_read_skilldb();
  3203. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3204. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3205. config_t run_test;
  3206. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3207. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3208. return -1;
  3209. }
  3210. config_destroy(&run_test);
  3211. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3212. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3213. return -1;
  3214. }
  3215. config_destroy(&run_test);
  3216. atcommand_doload();
  3217. pc_groups_reload();
  3218. clif_displaymessage(fd, msg_txt(sd,254));
  3219. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3220. struct Battle_Config prev_config;
  3221. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3222. battle_config_read(BATTLE_CONF_FILENAME);
  3223. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3224. || prev_config.item_rate_common != battle_config.item_rate_common
  3225. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3226. || prev_config.item_rate_card != battle_config.item_rate_card
  3227. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3228. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3229. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3230. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3231. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3232. || prev_config.item_rate_use != battle_config.item_rate_use
  3233. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3234. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3235. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3236. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3237. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3238. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3239. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3240. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3241. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3242. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3243. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3244. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3245. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3246. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3247. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3248. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3249. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3250. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3251. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3252. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3253. )
  3254. { // Exp or Drop rates changed.
  3255. mob_reload(); //Needed as well so rate changes take effect.
  3256. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3257. }
  3258. clif_displaymessage(fd, msg_txt(sd,255));
  3259. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3260. status_readdb();
  3261. clif_displaymessage(fd, msg_txt(sd,256));
  3262. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3263. pc_readdb();
  3264. clif_displaymessage(fd, msg_txt(sd,257));
  3265. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3266. pc_read_motd();
  3267. clif_displaymessage(fd, msg_txt(sd,268));
  3268. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3269. struct s_mapiterator* iter;
  3270. struct map_session_data* pl_sd;
  3271. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3272. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3273. iter = mapit_getallusers();
  3274. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3275. pc_close_npc(pl_sd,2);
  3276. mapit_free(iter);
  3277. flush_fifos();
  3278. map_reloadnpc(true); // reload config files seeking for npcs
  3279. script_reload();
  3280. npc_reload();
  3281. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3282. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3283. map_msg_reload();
  3284. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3285. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3286. do_reload_quest();
  3287. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3288. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3289. packetdb_readdb(true);
  3290. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3291. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3292. instance_reload();
  3293. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3294. }
  3295. return 0;
  3296. }
  3297. /*==========================================
  3298. * @partysharelvl <share_range> [Akinari]
  3299. * Updates char server party share level range in runtime
  3300. * Temporary - Permanent update in inter_athena.conf
  3301. *------------------------------------------*/
  3302. ACMD_FUNC(partysharelvl) {
  3303. unsigned int share_lvl;
  3304. nullpo_retr(-1, sd);
  3305. if(!message || !*message) {
  3306. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3307. return -1;
  3308. } else {
  3309. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3310. }
  3311. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3312. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3313. else //Char server offline
  3314. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3315. return 0;
  3316. }
  3317. /*==========================================
  3318. * @mapinfo [0-3] <map name> by MC_Cameri
  3319. * => Shows information about the map [map name]
  3320. * 0 = no additional information
  3321. * 1 = Show users in that map and their location
  3322. * 2 = Shows NPCs in that map
  3323. * 3 = Shows the chats in that map
  3324. *------------------------------------------*/
  3325. ACMD_FUNC(mapinfo) {
  3326. struct map_session_data* pl_sd;
  3327. struct s_mapiterator* iter;
  3328. struct chat_data *cd = NULL;
  3329. char direction[12];
  3330. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3331. unsigned short m_index;
  3332. char mapname[24];
  3333. nullpo_retr(-1, sd);
  3334. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3335. memset(mapname, '\0', sizeof(mapname));
  3336. memset(direction, '\0', sizeof(direction));
  3337. sscanf(message, "%11d %23[^\n]", &list, mapname);
  3338. if (list < 0 || list > 3) {
  3339. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3340. return -1;
  3341. }
  3342. if (mapname[0] == '\0') {
  3343. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3344. m_id = map_mapindex2mapid(sd->mapindex);
  3345. } else {
  3346. m_id = map_mapname2mapid(mapname);
  3347. }
  3348. if (m_id < 0) {
  3349. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3350. return -1;
  3351. }
  3352. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3353. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3354. // count chats (for initial message)
  3355. chat_num = 0;
  3356. iter = mapit_getallusers();
  3357. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3358. if( pl_sd->mapindex == m_index ) {
  3359. if( pl_sd->state.vending )
  3360. vend_num++;
  3361. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3362. chat_num++;
  3363. }
  3364. }
  3365. mapit_free(iter);
  3366. 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
  3367. clif_displaymessage(fd, atcmd_output);
  3368. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3369. if (map[m_id].flag.town)
  3370. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3371. if (map[m_id].flag.restricted){
  3372. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3373. clif_displaymessage(fd, atcmd_output);
  3374. }
  3375. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3376. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3377. else
  3378. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3379. if (map[m_id].flag.battleground){
  3380. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3381. clif_displaymessage(fd, atcmd_output);
  3382. }
  3383. /* Skill damage adjustment info [Cydh] */
  3384. #ifdef ADJUST_SKILL_DAMAGE
  3385. if (map[m_id].flag.skill_damage) {
  3386. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3387. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3388. ,map[m_id].adjust.damage.pc
  3389. ,map[m_id].adjust.damage.mob
  3390. ,map[m_id].adjust.damage.boss
  3391. ,map[m_id].adjust.damage.other
  3392. ,map[m_id].adjust.damage.caster);
  3393. clif_displaymessage(fd, atcmd_output);
  3394. if (map[m_id].skill_damage.count) {
  3395. uint8 j;
  3396. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3397. for (j = 0; j < map[m_id].skill_damage.count; j++) {
  3398. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3399. ,j+1
  3400. ,skill_get_name(map[m_id].skill_damage.entries[j]->skill_id)
  3401. ,map[m_id].skill_damage.entries[j]->pc
  3402. ,map[m_id].skill_damage.entries[j]->mob
  3403. ,map[m_id].skill_damage.entries[j]->boss
  3404. ,map[m_id].skill_damage.entries[j]->other
  3405. ,map[m_id].skill_damage.entries[j]->caster);
  3406. clif_displaymessage(fd,atcmd_output);
  3407. }
  3408. }
  3409. }
  3410. #endif
  3411. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3412. if (map[m_id].flag.pvp)
  3413. strcat(atcmd_output, " Pvp ON |");
  3414. if (map[m_id].flag.pvp_noguild)
  3415. strcat(atcmd_output, " NoGuild |");
  3416. if (map[m_id].flag.pvp_noparty)
  3417. strcat(atcmd_output, " NoParty |");
  3418. if (map[m_id].flag.pvp_nightmaredrop)
  3419. strcat(atcmd_output, " NightmareDrop |");
  3420. if (map[m_id].flag.pvp_nocalcrank)
  3421. strcat(atcmd_output, " NoCalcRank |");
  3422. clif_displaymessage(fd, atcmd_output);
  3423. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3424. if (map[m_id].flag.gvg)
  3425. strcat(atcmd_output, " GvG ON |");
  3426. if (map[m_id].flag.gvg_dungeon)
  3427. strcat(atcmd_output, " GvG Dungeon |");
  3428. if (map[m_id].flag.gvg_castle)
  3429. strcat(atcmd_output, " GvG Castle |");
  3430. if (map[m_id].flag.gvg_noparty)
  3431. strcat(atcmd_output, " NoParty |");
  3432. clif_displaymessage(fd, atcmd_output);
  3433. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3434. if (map[m_id].flag.noteleport)
  3435. strcat(atcmd_output, " NoTeleport |");
  3436. if (map[m_id].flag.monster_noteleport)
  3437. strcat(atcmd_output, " Monster NoTeleport |");
  3438. if (map[m_id].flag.nowarp)
  3439. strcat(atcmd_output, " NoWarp |");
  3440. if (map[m_id].flag.nowarpto)
  3441. strcat(atcmd_output, " NoWarpTo |");
  3442. if (map[m_id].flag.noreturn)
  3443. strcat(atcmd_output, " NoReturn |");
  3444. if (map[m_id].flag.nogo)
  3445. strcat(atcmd_output, " NoGo |"); //
  3446. if (map[m_id].flag.nomemo)
  3447. strcat(atcmd_output, " NoMemo |");
  3448. clif_displaymessage(fd, atcmd_output);
  3449. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3450. (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
  3451. clif_displaymessage(fd, atcmd_output);
  3452. if (map[m_id].flag.nosave) {
  3453. if (!map[m_id].save.map)
  3454. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3455. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3456. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3457. clif_displaymessage(fd, atcmd_output);
  3458. }
  3459. else {
  3460. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3461. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3462. clif_displaymessage(fd, atcmd_output);
  3463. }
  3464. }
  3465. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3466. if (map[m_id].flag.snow)
  3467. strcat(atcmd_output, " Snow |");
  3468. if (map[m_id].flag.fog)
  3469. strcat(atcmd_output, " Fog |");
  3470. if (map[m_id].flag.sakura)
  3471. strcat(atcmd_output, " Sakura |");
  3472. if (map[m_id].flag.clouds)
  3473. strcat(atcmd_output, " Clouds |");
  3474. if (map[m_id].flag.clouds2)
  3475. strcat(atcmd_output, " Clouds2 |");
  3476. if (map[m_id].flag.fireworks)
  3477. strcat(atcmd_output, " Fireworks |");
  3478. if (map[m_id].flag.leaves)
  3479. strcat(atcmd_output, " Leaves |");
  3480. if (map[m_id].flag.nightenabled)
  3481. strcat(atcmd_output, " Displays Night |");
  3482. clif_displaymessage(fd, atcmd_output);
  3483. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3484. if (map[m_id].flag.nobranch)
  3485. strcat(atcmd_output, " NoBranch |");
  3486. if (map[m_id].flag.notrade)
  3487. strcat(atcmd_output, " NoTrade |");
  3488. if (map[m_id].flag.novending)
  3489. strcat(atcmd_output, " NoVending |");
  3490. if (map[m_id].flag.nodrop)
  3491. strcat(atcmd_output, " NoDrop |");
  3492. if (map[m_id].flag.noskill)
  3493. strcat(atcmd_output, " NoSkill |");
  3494. if (map[m_id].flag.noicewall)
  3495. strcat(atcmd_output, " NoIcewall |");
  3496. if (map[m_id].flag.allowks)
  3497. strcat(atcmd_output, " AllowKS |");
  3498. if (map[m_id].flag.reset)
  3499. strcat(atcmd_output, " Reset |");
  3500. clif_displaymessage(fd, atcmd_output);
  3501. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3502. if (map[m_id].nocommand)
  3503. strcat(atcmd_output, " NoCommand |");
  3504. if (map[m_id].flag.nobaseexp)
  3505. strcat(atcmd_output, " NoBaseEXP |");
  3506. if (map[m_id].flag.nojobexp)
  3507. strcat(atcmd_output, " NoJobEXP |");
  3508. if (map[m_id].flag.nomobloot)
  3509. strcat(atcmd_output, " NoMobLoot |");
  3510. if (map[m_id].flag.nomvploot)
  3511. strcat(atcmd_output, " NoMVPLoot |");
  3512. if (map[m_id].flag.partylock)
  3513. strcat(atcmd_output, " PartyLock |");
  3514. if (map[m_id].flag.guildlock)
  3515. strcat(atcmd_output, " GuildLock |");
  3516. if (map[m_id].flag.loadevent)
  3517. strcat(atcmd_output, " Loadevent |");
  3518. if (map[m_id].flag.chmautojoin)
  3519. strcat(atcmd_output, " Chmautojoin |");
  3520. if (map[m_id].flag.nousecart)
  3521. strcat(atcmd_output, " NoUsecart |");
  3522. if (map[m_id].flag.noitemconsumption)
  3523. strcat(atcmd_output, " NoItemConsumption |");
  3524. if (map[m_id].flag.nosumstarmiracle)
  3525. strcat(atcmd_output, " NoSumStarMiracle |");
  3526. if (map[m_id].flag.nomineeffect)
  3527. strcat(atcmd_output, " NoMineEffect |");
  3528. if (map[m_id].flag.nolockon)
  3529. strcat(atcmd_output, " NoLockOn |");
  3530. if (map[m_id].flag.notomb)
  3531. strcat(atcmd_output, " NoTomb |");
  3532. clif_displaymessage(fd, atcmd_output);
  3533. switch (list) {
  3534. case 0:
  3535. // Do nothing. It's list 0, no additional display.
  3536. break;
  3537. case 1:
  3538. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3539. iter = mapit_getallusers();
  3540. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3541. {
  3542. if (pl_sd->mapindex == m_index) {
  3543. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3544. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3545. clif_displaymessage(fd, atcmd_output);
  3546. }
  3547. }
  3548. mapit_free(iter);
  3549. break;
  3550. case 2:
  3551. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3552. for (i = 0; i < map[m_id].npc_num;)
  3553. {
  3554. struct npc_data *nd = map[m_id].npc[i];
  3555. switch(nd->ud.dir) {
  3556. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3557. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3558. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3559. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3560. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3561. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3562. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3563. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3564. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3565. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3566. }
  3567. if(strcmp(nd->name,nd->exname) == 0)
  3568. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3569. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3570. else
  3571. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3572. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3573. clif_displaymessage(fd, atcmd_output);
  3574. }
  3575. break;
  3576. case 3:
  3577. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3578. iter = mapit_getallusers();
  3579. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3580. {
  3581. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3582. pl_sd->mapindex == m_index &&
  3583. cd->usersd[0] == pl_sd)
  3584. {
  3585. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3586. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3587. clif_displaymessage(fd, atcmd_output);
  3588. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3589. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3590. clif_displaymessage(fd, atcmd_output);
  3591. }
  3592. }
  3593. mapit_free(iter);
  3594. break;
  3595. default: // normally impossible to arrive here
  3596. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3597. return -1;
  3598. break;
  3599. }
  3600. return 0;
  3601. }
  3602. /*==========================================
  3603. *
  3604. *------------------------------------------*/
  3605. ACMD_FUNC(mount_peco)
  3606. {
  3607. nullpo_retr(-1, sd);
  3608. if (sd->disguise) {
  3609. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3610. return -1;
  3611. }
  3612. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3613. if( !(sd->sc.option&OPTION_DRAGON) ) {
  3614. unsigned int option = OPTION_DRAGON1;
  3615. if( message[0] ) {
  3616. int color = atoi(message);
  3617. option = ( color == 2 ? OPTION_DRAGON2 :
  3618. color == 3 ? OPTION_DRAGON3 :
  3619. color == 4 ? OPTION_DRAGON4 :
  3620. color == 5 ? OPTION_DRAGON5 :
  3621. OPTION_DRAGON1 );
  3622. }
  3623. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3624. pc_setoption(sd, sd->sc.option|option);
  3625. } else {
  3626. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3627. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
  3628. }
  3629. return 0;
  3630. }
  3631. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 && (!pc_isfalcon(sd) || battle_config.warg_can_falcon) ) {
  3632. if( !pc_isridingwug(sd) ) {
  3633. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3634. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3635. } else {
  3636. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3637. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3638. }
  3639. return 0;
  3640. }
  3641. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3642. if( !pc_ismadogear(sd) ) {
  3643. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3644. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3645. } else {
  3646. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3647. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3648. }
  3649. return 0;
  3650. }
  3651. if (!pc_isriding(sd)) { // if actually no peco
  3652. if (!pc_checkskill(sd, KN_RIDING)) {
  3653. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3654. return -1;
  3655. }
  3656. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3657. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3658. } else {//Dismount
  3659. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3660. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3661. }
  3662. return 0;
  3663. }
  3664. /*==========================================
  3665. *Spy Commands by Syrus22
  3666. *------------------------------------------*/
  3667. ACMD_FUNC(guildspy)
  3668. {
  3669. char guild_name[NAME_LENGTH];
  3670. struct guild *g;
  3671. nullpo_retr(-1, sd);
  3672. memset(guild_name, '\0', sizeof(guild_name));
  3673. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3674. if (!enable_spy)
  3675. {
  3676. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3677. return -1;
  3678. }
  3679. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3680. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3681. return -1;
  3682. }
  3683. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3684. (g = guild_search(atoi(message))) != NULL) {
  3685. if (sd->guildspy == g->guild_id) {
  3686. sd->guildspy = 0;
  3687. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3688. clif_displaymessage(fd, atcmd_output);
  3689. } else {
  3690. sd->guildspy = g->guild_id;
  3691. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3692. clif_displaymessage(fd, atcmd_output);
  3693. }
  3694. } else {
  3695. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3696. return -1;
  3697. }
  3698. return 0;
  3699. }
  3700. /*==========================================
  3701. *
  3702. *------------------------------------------*/
  3703. ACMD_FUNC(partyspy)
  3704. {
  3705. char party_name[NAME_LENGTH];
  3706. struct party_data *p;
  3707. nullpo_retr(-1, sd);
  3708. memset(party_name, '\0', sizeof(party_name));
  3709. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3710. if (!enable_spy)
  3711. {
  3712. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3713. return -1;
  3714. }
  3715. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3716. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3717. return -1;
  3718. }
  3719. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3720. (p = party_search(atoi(message))) != NULL) {
  3721. if (sd->partyspy == p->party.party_id) {
  3722. sd->partyspy = 0;
  3723. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3724. clif_displaymessage(fd, atcmd_output);
  3725. } else {
  3726. sd->partyspy = p->party.party_id;
  3727. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3728. clif_displaymessage(fd, atcmd_output);
  3729. }
  3730. } else {
  3731. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3732. return -1;
  3733. }
  3734. return 0;
  3735. }
  3736. /*==========================================
  3737. * @repairall [Valaris]
  3738. *------------------------------------------*/
  3739. ACMD_FUNC(repairall)
  3740. {
  3741. int count, i;
  3742. nullpo_retr(-1, sd);
  3743. count = 0;
  3744. for (i = 0; i < MAX_INVENTORY; i++) {
  3745. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3746. sd->status.inventory[i].attribute = 0;
  3747. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3748. count++;
  3749. }
  3750. }
  3751. if (count > 0) {
  3752. clif_misceffect(&sd->bl, 3);
  3753. clif_equiplist(sd);
  3754. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3755. } else {
  3756. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3757. return -1;
  3758. }
  3759. return 0;
  3760. }
  3761. /*==========================================
  3762. * @nuke [Valaris]
  3763. *------------------------------------------*/
  3764. ACMD_FUNC(nuke)
  3765. {
  3766. struct map_session_data *pl_sd;
  3767. nullpo_retr(-1, sd);
  3768. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3769. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3770. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3771. return -1;
  3772. }
  3773. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3774. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3775. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3776. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3777. } else {
  3778. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3779. return -1;
  3780. }
  3781. } else {
  3782. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3783. return -1;
  3784. }
  3785. return 0;
  3786. }
  3787. /*==========================================
  3788. * @tonpc
  3789. *------------------------------------------*/
  3790. ACMD_FUNC(tonpc)
  3791. {
  3792. char npcname[NAME_LENGTH+1];
  3793. struct npc_data *nd;
  3794. nullpo_retr(-1, sd);
  3795. memset(npcname, 0, sizeof(npcname));
  3796. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3797. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3798. return -1;
  3799. }
  3800. if ((nd = npc_name2id(npcname)) != NULL) {
  3801. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3802. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3803. else
  3804. return -1;
  3805. } else {
  3806. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3807. return -1;
  3808. }
  3809. return 0;
  3810. }
  3811. /*==========================================
  3812. *
  3813. *------------------------------------------*/
  3814. ACMD_FUNC(shownpc)
  3815. {
  3816. char NPCname[NAME_LENGTH+1];
  3817. nullpo_retr(-1, sd);
  3818. memset(NPCname, '\0', sizeof(NPCname));
  3819. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3820. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3821. return -1;
  3822. }
  3823. if (npc_name2id(NPCname) != NULL) {
  3824. npc_enable(NPCname, 1);
  3825. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3826. } else {
  3827. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3828. return -1;
  3829. }
  3830. return 0;
  3831. }
  3832. /*==========================================
  3833. *
  3834. *------------------------------------------*/
  3835. ACMD_FUNC(hidenpc)
  3836. {
  3837. char NPCname[NAME_LENGTH+1];
  3838. nullpo_retr(-1, sd);
  3839. memset(NPCname, '\0', sizeof(NPCname));
  3840. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3841. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3842. return -1;
  3843. }
  3844. if (npc_name2id(NPCname) == NULL) {
  3845. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3846. return -1;
  3847. }
  3848. npc_enable(NPCname, 0);
  3849. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3850. return 0;
  3851. }
  3852. ACMD_FUNC(loadnpc)
  3853. {
  3854. if (!message || !*message) {
  3855. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3856. return -1;
  3857. }
  3858. // add to list of script sources and run it
  3859. if( !npc_addsrcfile(message) //try to read file
  3860. || !npc_parsesrcfile(message,true)
  3861. ){
  3862. clif_displaymessage(fd, msg_txt(sd,261));
  3863. return -1;
  3864. }
  3865. npc_read_event_script();
  3866. clif_displaymessage(fd, msg_txt(sd,262));
  3867. return 0;
  3868. }
  3869. ACMD_FUNC(unloadnpc)
  3870. {
  3871. struct npc_data *nd;
  3872. char NPCname[NAME_LENGTH];
  3873. nullpo_retr(-1, sd);
  3874. memset(NPCname, '\0', sizeof(NPCname));
  3875. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3876. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3877. return -1;
  3878. }
  3879. if ((nd = npc_name2id(NPCname)) == NULL) {
  3880. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3881. return -1;
  3882. }
  3883. npc_unload_duplicates(nd);
  3884. npc_unload(nd,true);
  3885. npc_read_event_script();
  3886. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3887. return 0;
  3888. }
  3889. /*==========================================
  3890. * time in txt for time command (by [Yor])
  3891. *------------------------------------------*/
  3892. char* txt_time(unsigned int duration)
  3893. {
  3894. int days, hours, minutes, seconds;
  3895. char temp[CHAT_SIZE_MAX];
  3896. static char temp1[CHAT_SIZE_MAX];
  3897. memset(temp, '\0', sizeof(temp));
  3898. memset(temp1, '\0', sizeof(temp1));
  3899. days = duration / (60 * 60 * 24);
  3900. duration = duration - (60 * 60 * 24 * days);
  3901. hours = duration / (60 * 60);
  3902. duration = duration - (60 * 60 * hours);
  3903. minutes = duration / 60;
  3904. seconds = duration - (60 * minutes);
  3905. if (days == 1)
  3906. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3907. else if (days > 1)
  3908. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3909. if (hours == 1)
  3910. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3911. else if (hours > 1)
  3912. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3913. if (minutes < 2)
  3914. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3915. else
  3916. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3917. if (seconds == 1)
  3918. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3919. else if (seconds > 1)
  3920. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3921. return temp1;
  3922. }
  3923. /*==========================================
  3924. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3925. * Calculation management of GM modification (@day/@night GM commands) is done
  3926. *------------------------------------------*/
  3927. ACMD_FUNC(servertime)
  3928. {
  3929. const struct TimerData * timer_data;
  3930. time_t time_server; // variable for number of seconds (used with time() function)
  3931. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3932. char temp[CHAT_SIZE_MAX];
  3933. nullpo_retr(-1, sd);
  3934. memset(temp, '\0', sizeof(temp));
  3935. time(&time_server); // get time in seconds since 1/1/1970
  3936. datetime = localtime(&time_server); // convert seconds in structure
  3937. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3938. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3939. clif_displaymessage(fd, temp);
  3940. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3941. if (night_flag == 0)
  3942. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3943. else
  3944. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3945. } else if (battle_config.night_duration == 0)
  3946. if (night_flag == 1) { // we start with night
  3947. timer_data = get_timer(day_timer_tid);
  3948. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in night for %s.
  3949. clif_displaymessage(fd, temp);
  3950. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3951. } else
  3952. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3953. else if (battle_config.day_duration == 0)
  3954. if (night_flag == 0) { // we start with day
  3955. timer_data = get_timer(night_timer_tid);
  3956. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3957. clif_displaymessage(fd, temp);
  3958. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3959. } else
  3960. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3961. else {
  3962. const struct TimerData * timer_data2;
  3963. if (night_flag == 0) {
  3964. timer_data = get_timer(night_timer_tid);
  3965. timer_data2 = get_timer(day_timer_tid);
  3966. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is in daylight for %s.
  3967. clif_displaymessage(fd, temp);
  3968. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3969. 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.
  3970. else
  3971. 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.
  3972. clif_displaymessage(fd, temp);
  3973. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3974. clif_displaymessage(fd, temp);
  3975. } else {
  3976. timer_data = get_timer(day_timer_tid);
  3977. timer_data2 = get_timer(night_timer_tid);
  3978. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is in night for %s.
  3979. clif_displaymessage(fd, temp);
  3980. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3981. 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.
  3982. else
  3983. 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.
  3984. clif_displaymessage(fd, temp);
  3985. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3986. clif_displaymessage(fd, temp);
  3987. }
  3988. }
  3989. return 0;
  3990. }
  3991. /*==========================================
  3992. * @jail <char_name> by [Yor]
  3993. * Special warp! No check with nowarp and nowarpto flag
  3994. *------------------------------------------*/
  3995. ACMD_FUNC(jail)
  3996. {
  3997. struct map_session_data *pl_sd;
  3998. int x, y;
  3999. unsigned short m_index;
  4000. nullpo_retr(-1, sd);
  4001. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4002. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4003. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  4004. return -1;
  4005. }
  4006. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4007. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4008. return -1;
  4009. }
  4010. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4011. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4012. return -1;
  4013. }
  4014. if (pl_sd->sc.data[SC_JAILED]) {
  4015. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4016. return -1;
  4017. }
  4018. switch(rnd() % 2) { //Jail Locations
  4019. case 0:
  4020. m_index = mapindex_name2id(MAP_JAIL);
  4021. x = 24;
  4022. y = 75;
  4023. break;
  4024. default:
  4025. m_index = mapindex_name2id(MAP_JAIL);
  4026. x = 49;
  4027. y = 75;
  4028. break;
  4029. }
  4030. //Duration of INT_MAX to specify infinity.
  4031. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  4032. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  4033. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  4034. return 0;
  4035. }
  4036. /*==========================================
  4037. * @unjail/@discharge <char_name> by [Yor]
  4038. * Special warp! No check with nowarp and nowarpto flag
  4039. *------------------------------------------*/
  4040. ACMD_FUNC(unjail)
  4041. {
  4042. struct map_session_data *pl_sd;
  4043. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  4044. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  4045. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  4046. return -1;
  4047. }
  4048. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4049. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4050. return -1;
  4051. }
  4052. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  4053. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4054. return -1;
  4055. }
  4056. if (!pl_sd->sc.data[SC_JAILED]) {
  4057. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  4058. return -1;
  4059. }
  4060. //Reset jail time to 1 sec.
  4061. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  4062. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  4063. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  4064. return 0;
  4065. }
  4066. ACMD_FUNC(jailfor) {
  4067. struct map_session_data *pl_sd = NULL;
  4068. char * modif_p;
  4069. int jailtime = 0,x,y;
  4070. short m_index = 0;
  4071. nullpo_retr(-1, sd);
  4072. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4073. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  4074. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  4075. return -1;
  4076. }
  4077. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  4078. modif_p = atcmd_output;
  4079. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  4080. if (jailtime == 0) {
  4081. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  4082. 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.
  4083. return -1;
  4084. }
  4085. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  4086. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4087. return -1;
  4088. }
  4089. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  4090. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4091. return -1;
  4092. }
  4093. // Added by Coltaro
  4094. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  4095. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  4096. if (jailtime <= 0) {
  4097. jailtime = 0;
  4098. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  4099. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  4100. } else {
  4101. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  4102. char timestr[21];
  4103. time_t now=time(NULL);
  4104. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4105. 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
  4106. clif_displaymessage(pl_sd->fd, atcmd_output);
  4107. 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
  4108. clif_displaymessage(fd, atcmd_output);
  4109. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4110. sprintf(atcmd_output,"Release date is: %s",timestr);
  4111. clif_displaymessage(pl_sd->fd, atcmd_output);
  4112. clif_displaymessage(fd, atcmd_output);
  4113. }
  4114. } else if (jailtime < 0) {
  4115. clif_displaymessage(fd, msg_txt(sd,1136));
  4116. return -1;
  4117. }
  4118. // Jail locations, add more as you wish.
  4119. switch(rnd()%2) {
  4120. case 1: // Jail #1
  4121. m_index = mapindex_name2id(MAP_JAIL);
  4122. x = 49; y = 75;
  4123. break;
  4124. default: // Default Jail
  4125. m_index = mapindex_name2id(MAP_JAIL);
  4126. x = 24; y = 75;
  4127. break;
  4128. }
  4129. 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).
  4130. return 0;
  4131. }
  4132. //By Coltaro
  4133. ACMD_FUNC(jailtime){
  4134. int year, month, day, hour, minute, second;
  4135. char timestr[21];
  4136. time_t now = time(NULL);
  4137. nullpo_retr(-1, sd);
  4138. if (!sd->sc.data[SC_JAILED]) {
  4139. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4140. return -1;
  4141. }
  4142. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4143. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4144. return 0;
  4145. }
  4146. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4147. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4148. return -1;
  4149. }
  4150. // Get remaining jail time
  4151. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4152. 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
  4153. clif_displaymessage(fd, atcmd_output);
  4154. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4155. sprintf(atcmd_output,"Release date is: %s",timestr);
  4156. clif_displaymessage(fd, atcmd_output);
  4157. return 0;
  4158. }
  4159. /*==========================================
  4160. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4161. *------------------------------------------*/
  4162. ACMD_FUNC(disguise)
  4163. {
  4164. int id = 0;
  4165. nullpo_retr(-1, sd);
  4166. if (!message || !*message) {
  4167. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4168. return -1;
  4169. }
  4170. if ((id = atoi(message)) > 0)
  4171. { //Acquired an ID
  4172. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4173. id = 0; //Invalid id for either mobs or npcs.
  4174. } else { //Acquired a Name
  4175. if ((id = mobdb_searchname(message)) == 0)
  4176. {
  4177. struct npc_data* nd = npc_name2id(message);
  4178. if (nd != NULL)
  4179. id = nd->class_;
  4180. }
  4181. }
  4182. if (id == 0)
  4183. {
  4184. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4185. return -1;
  4186. }
  4187. if(pc_isriding(sd))
  4188. {
  4189. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4190. return -1;
  4191. }
  4192. if (sd->sc.data[SC_MONSTER_TRANSFORM]) {
  4193. clif_displaymessage(fd, msg_txt(sd,730)); // Character cannot be disguised while in monster transform.
  4194. return -1;
  4195. }
  4196. pc_disguise(sd, id);
  4197. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4198. return 0;
  4199. }
  4200. /*==========================================
  4201. * DisguiseAll
  4202. *------------------------------------------*/
  4203. ACMD_FUNC(disguiseall)
  4204. {
  4205. int mob_id=0;
  4206. struct map_session_data *pl_sd;
  4207. struct s_mapiterator* iter;
  4208. nullpo_retr(-1, sd);
  4209. if (!message || !*message) {
  4210. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4211. return -1;
  4212. }
  4213. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name beginning by a number)
  4214. mob_id = atoi(message);
  4215. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4216. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4217. return -1;
  4218. }
  4219. iter = mapit_getallusers();
  4220. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4221. pc_disguise(pl_sd, mob_id);
  4222. mapit_free(iter);
  4223. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4224. return 0;
  4225. }
  4226. /*==========================================
  4227. * DisguiseGuild
  4228. *------------------------------------------*/
  4229. ACMD_FUNC(disguiseguild)
  4230. {
  4231. int id = 0, i;
  4232. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4233. struct guild *g;
  4234. memset(monster, '\0', sizeof(monster));
  4235. memset(guild, '\0', sizeof(guild));
  4236. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4237. 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>).
  4238. return -1;
  4239. }
  4240. if( (id = atoi(monster)) > 0 ) {
  4241. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4242. id = 0;
  4243. } else {
  4244. if( (id = mobdb_searchname(monster)) == 0 ) {
  4245. struct npc_data* nd = npc_name2id(monster);
  4246. if( nd != NULL )
  4247. id = nd->class_;
  4248. }
  4249. }
  4250. if( id == 0 ) {
  4251. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4252. return -1;
  4253. }
  4254. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4255. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4256. return -1;
  4257. }
  4258. for( i = 0; i < g->max_member; i++ ){
  4259. struct map_session_data *pl_sd;
  4260. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4261. pc_disguise(pl_sd, id);
  4262. }
  4263. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4264. return 0;
  4265. }
  4266. /*==========================================
  4267. * @undisguise by [Yor]
  4268. *------------------------------------------*/
  4269. ACMD_FUNC(undisguise)
  4270. {
  4271. nullpo_retr(-1, sd);
  4272. if (sd->disguise) {
  4273. pc_disguise(sd, 0);
  4274. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4275. } else {
  4276. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4277. return -1;
  4278. }
  4279. return 0;
  4280. }
  4281. /*==========================================
  4282. * UndisguiseAll
  4283. *------------------------------------------*/
  4284. ACMD_FUNC(undisguiseall)
  4285. {
  4286. struct map_session_data *pl_sd;
  4287. struct s_mapiterator* iter;
  4288. nullpo_retr(-1, sd);
  4289. iter = mapit_getallusers();
  4290. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4291. if( pl_sd->disguise )
  4292. pc_disguise(pl_sd, 0);
  4293. mapit_free(iter);
  4294. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4295. return 0;
  4296. }
  4297. /*==========================================
  4298. * UndisguiseGuild
  4299. *------------------------------------------*/
  4300. ACMD_FUNC(undisguiseguild)
  4301. {
  4302. char guild_name[NAME_LENGTH];
  4303. struct guild *g;
  4304. int i;
  4305. nullpo_retr(-1, sd);
  4306. memset(guild_name, '\0', sizeof(guild_name));
  4307. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4308. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4309. return -1;
  4310. }
  4311. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4312. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4313. return -1;
  4314. }
  4315. for(i = 0; i < g->max_member; i++){
  4316. struct map_session_data *pl_sd;
  4317. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4318. pc_disguise(pl_sd, 0);
  4319. }
  4320. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4321. return 0;
  4322. }
  4323. /*==========================================
  4324. * @exp by [Skotlex]
  4325. *------------------------------------------*/
  4326. ACMD_FUNC(exp)
  4327. {
  4328. char output[CHAT_SIZE_MAX];
  4329. double nextb, nextj;
  4330. nullpo_retr(-1, sd);
  4331. memset(output, '\0', sizeof(output));
  4332. nextb = pc_nextbaseexp(sd);
  4333. if (nextb)
  4334. nextb = sd->status.base_exp*100.0/nextb;
  4335. nextj = pc_nextjobexp(sd);
  4336. if (nextj)
  4337. nextj = sd->status.job_exp*100.0/nextj;
  4338. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4339. clif_displaymessage(fd, output);
  4340. return 0;
  4341. }
  4342. /*==========================================
  4343. * @broadcast by [Valaris]
  4344. *------------------------------------------*/
  4345. ACMD_FUNC(broadcast)
  4346. {
  4347. nullpo_retr(-1, sd);
  4348. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4349. if (!message || !*message) {
  4350. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4351. return -1;
  4352. }
  4353. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4354. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT);
  4355. return 0;
  4356. }
  4357. /*==========================================
  4358. * @localbroadcast by [Valaris]
  4359. *------------------------------------------*/
  4360. ACMD_FUNC(localbroadcast)
  4361. {
  4362. nullpo_retr(-1, sd);
  4363. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4364. if (!message || !*message) {
  4365. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4366. return -1;
  4367. }
  4368. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4369. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
  4370. return 0;
  4371. }
  4372. /*==========================================
  4373. * @email <actual@email> <new@email> by [Yor]
  4374. *------------------------------------------*/
  4375. ACMD_FUNC(email)
  4376. {
  4377. char actual_email[100];
  4378. char new_email[100];
  4379. nullpo_retr(-1, sd);
  4380. memset(actual_email, '\0', sizeof(actual_email));
  4381. memset(new_email, '\0', sizeof(new_email));
  4382. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4383. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4384. return -1;
  4385. }
  4386. if (e_mail_check(actual_email) == 0) {
  4387. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4388. return -1;
  4389. } else if (e_mail_check(new_email) == 0) {
  4390. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4391. return -1;
  4392. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4393. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4394. return -1;
  4395. } else if (strcmpi(actual_email, new_email) == 0) {
  4396. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4397. return -1;
  4398. }
  4399. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4400. clif_displaymessage(fd, msg_txt(sd,148)); // Information sent to login-server via char-server.
  4401. return 0;
  4402. }
  4403. /*==========================================
  4404. *@effect
  4405. *------------------------------------------*/
  4406. ACMD_FUNC(effect)
  4407. {
  4408. int type = 0, flag = 0;
  4409. nullpo_retr(-1, sd);
  4410. if (!message || !*message || sscanf(message, "%11d", &type) < 1) {
  4411. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4412. return -1;
  4413. }
  4414. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4415. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4416. return 0;
  4417. }
  4418. /*==========================================
  4419. * @killer by MouseJstr
  4420. * enable killing players even when not in pvp
  4421. *------------------------------------------*/
  4422. ACMD_FUNC(killer)
  4423. {
  4424. nullpo_retr(-1, sd);
  4425. sd->state.killer = !sd->state.killer;
  4426. if(sd->state.killer)
  4427. clif_displaymessage(fd, msg_txt(sd,241));
  4428. else {
  4429. clif_displaymessage(fd, msg_txt(sd,292));
  4430. pc_stop_attack(sd);
  4431. }
  4432. return 0;
  4433. }
  4434. /*==========================================
  4435. * @killable by MouseJstr
  4436. * enable other people killing you
  4437. *------------------------------------------*/
  4438. ACMD_FUNC(killable)
  4439. {
  4440. nullpo_retr(-1, sd);
  4441. sd->state.killable = !sd->state.killable;
  4442. if(sd->state.killable)
  4443. clif_displaymessage(fd, msg_txt(sd,242));
  4444. else {
  4445. clif_displaymessage(fd, msg_txt(sd,288));
  4446. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4447. }
  4448. return 0;
  4449. }
  4450. /*==========================================
  4451. * @skillon by MouseJstr
  4452. * turn skills on for the map
  4453. *------------------------------------------*/
  4454. ACMD_FUNC(skillon)
  4455. {
  4456. nullpo_retr(-1, sd);
  4457. map[sd->bl.m].flag.noskill = 0;
  4458. clif_displaymessage(fd, msg_txt(sd,244));
  4459. return 0;
  4460. }
  4461. /*==========================================
  4462. * @skilloff by MouseJstr
  4463. * Turn skills off on the map
  4464. *------------------------------------------*/
  4465. ACMD_FUNC(skilloff)
  4466. {
  4467. nullpo_retr(-1, sd);
  4468. map[sd->bl.m].flag.noskill = 1;
  4469. clif_displaymessage(fd, msg_txt(sd,243));
  4470. return 0;
  4471. }
  4472. /*==========================================
  4473. * @npcmove by MouseJstr
  4474. * move a npc
  4475. *------------------------------------------*/
  4476. ACMD_FUNC(npcmove)
  4477. {
  4478. short x = 0, y = 0, m;
  4479. struct npc_data *nd = 0;
  4480. nullpo_retr(-1, sd);
  4481. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4482. if (!message || !*message || sscanf(message, "%6hd %6hd %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4483. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4484. return -1;
  4485. }
  4486. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4487. {
  4488. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4489. return -1;
  4490. }
  4491. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4492. {
  4493. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4494. return -1; //Not on a map.
  4495. }
  4496. x = cap_value(x, 0, map[m].xs-1);
  4497. y = cap_value(y, 0, map[m].ys-1);
  4498. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4499. map_moveblock(&nd->bl, x, y, gettick());
  4500. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4501. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4502. return 0;
  4503. }
  4504. /*==========================================
  4505. * @addwarp by MouseJstr
  4506. * Create a new static warp point.
  4507. *------------------------------------------*/
  4508. ACMD_FUNC(addwarp)
  4509. {
  4510. char mapname[32], warpname[MAP_NAME_LENGTH_EXT];
  4511. short x,y;
  4512. unsigned short m;
  4513. struct npc_data* nd;
  4514. nullpo_retr(-1, sd);
  4515. memset(warpname, '\0', sizeof(warpname));
  4516. if (!message || !*message || sscanf(message, "%31s %6hd %6hd %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4517. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4518. return -1;
  4519. }
  4520. m = mapindex_name2id(mapname);
  4521. if( m == 0 )
  4522. {
  4523. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4524. clif_displaymessage(fd, atcmd_output);
  4525. return -1;
  4526. }
  4527. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4528. if( nd == NULL )
  4529. return -1;
  4530. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4531. clif_displaymessage(fd, atcmd_output);
  4532. return 0;
  4533. }
  4534. /*==========================================
  4535. * @follow by [MouseJstr]
  4536. * Follow a player .. staying no more then 5 spaces away
  4537. *------------------------------------------*/
  4538. ACMD_FUNC(follow)
  4539. {
  4540. struct map_session_data *pl_sd = NULL;
  4541. nullpo_retr(-1, sd);
  4542. if (!message || !*message) {
  4543. if (sd->followtarget == -1)
  4544. return -1;
  4545. pc_stop_following (sd);
  4546. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4547. return 0;
  4548. }
  4549. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4550. {
  4551. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4552. return -1;
  4553. }
  4554. if (sd->followtarget == pl_sd->bl.id) {
  4555. pc_stop_following (sd);
  4556. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4557. } else {
  4558. pc_follow(sd, pl_sd->bl.id);
  4559. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4560. }
  4561. return 0;
  4562. }
  4563. /*==========================================
  4564. * @dropall by [MouseJstr] and [Xantara]
  4565. * Drops all your possession on the ground based on item type
  4566. *------------------------------------------*/
  4567. ACMD_FUNC(dropall)
  4568. {
  4569. int8 type = -1;
  4570. uint16 i, count = 0, count2 = 0;
  4571. struct item_data *item_data = NULL;
  4572. nullpo_retr(-1, sd);
  4573. if( message[0] ) {
  4574. type = atoi(message);
  4575. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4576. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4577. {
  4578. clif_displaymessage(fd, msg_txt(sd,1492));
  4579. clif_displaymessage(fd, msg_txt(sd,1493));
  4580. return -1;
  4581. }
  4582. }
  4583. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4584. if( sd->status.inventory[i].amount ) {
  4585. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4586. 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);
  4587. continue;
  4588. }
  4589. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4590. continue;
  4591. if( type == -1 || type == (uint8)item_data->type ) {
  4592. if( sd->status.inventory[i].equip != 0 )
  4593. pc_unequipitem(sd, i, 3);
  4594. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4595. count += sd->status.inventory[i].amount;
  4596. else count2 += sd->status.inventory[i].amount;
  4597. }
  4598. }
  4599. }
  4600. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4601. clif_displaymessage(fd, atcmd_output);
  4602. return 0;
  4603. }
  4604. /*==========================================
  4605. * @storeall by [MouseJstr]
  4606. * Put everything into storage
  4607. *------------------------------------------*/
  4608. ACMD_FUNC(storeall)
  4609. {
  4610. int i;
  4611. nullpo_retr(-1, sd);
  4612. if (sd->state.storage_flag != 1)
  4613. { //Open storage.
  4614. if( storage_storageopen(sd) == 1 ) {
  4615. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4616. return -1;
  4617. }
  4618. }
  4619. for (i = 0; i < MAX_INVENTORY; i++) {
  4620. if (sd->status.inventory[i].amount) {
  4621. if(sd->status.inventory[i].equip != 0)
  4622. pc_unequipitem(sd, i, 3);
  4623. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4624. }
  4625. }
  4626. storage_storageclose(sd);
  4627. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4628. return 0;
  4629. }
  4630. ACMD_FUNC(clearstorage)
  4631. {
  4632. int i, j;
  4633. nullpo_retr(-1, sd);
  4634. if (sd->state.storage_flag == 1) {
  4635. clif_displaymessage(fd, msg_txt(sd,250));
  4636. return -1;
  4637. }
  4638. j = sd->status.storage.storage_amount;
  4639. for (i = 0; i < j; ++i) {
  4640. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4641. }
  4642. storage_storageclose(sd);
  4643. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4644. return 0;
  4645. }
  4646. ACMD_FUNC(cleargstorage)
  4647. {
  4648. int i, j;
  4649. struct guild *g;
  4650. struct guild_storage *gstorage;
  4651. nullpo_retr(-1, sd);
  4652. g = sd->guild;
  4653. if (g == NULL) {
  4654. clif_displaymessage(fd, msg_txt(sd,43));
  4655. return -1;
  4656. }
  4657. if (sd->state.storage_flag == 1) {
  4658. clif_displaymessage(fd, msg_txt(sd,250));
  4659. return -1;
  4660. }
  4661. if (sd->state.storage_flag == 2) {
  4662. clif_displaymessage(fd, msg_txt(sd,251));
  4663. return -1;
  4664. }
  4665. gstorage = gstorage_get_storage(sd->status.guild_id);
  4666. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4667. return -1;
  4668. }
  4669. if (gstorage->opened) {
  4670. struct map_session_data *tsd = map_charid2sd(gstorage->opened);
  4671. if (tsd)
  4672. gstorage_storageclose(tsd);
  4673. }
  4674. j = gstorage->storage_amount;
  4675. gstorage->locked = true; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4676. for (i = 0; i < j; ++i) {
  4677. gstorage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4678. }
  4679. gstorage_storageclose(sd);
  4680. gstorage->locked = false; // Cleaning done, release lock
  4681. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4682. return 0;
  4683. }
  4684. ACMD_FUNC(clearcart)
  4685. {
  4686. int i;
  4687. nullpo_retr(-1, sd);
  4688. if (pc_iscarton(sd) == 0) {
  4689. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4690. return -1;
  4691. }
  4692. if (sd->state.vending == 1) { //Somehow...
  4693. return -1;
  4694. }
  4695. for( i = 0; i < MAX_CART; i++ )
  4696. if(sd->status.cart[i].nameid > 0)
  4697. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4698. clif_clearcart(fd);
  4699. clif_updatestatus(sd,SP_CARTINFO);
  4700. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4701. return 0;
  4702. }
  4703. /*==========================================
  4704. * @skillid by [MouseJstr]
  4705. * lookup a skill by name
  4706. *------------------------------------------*/
  4707. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4708. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4709. ACMD_FUNC(skillid) {
  4710. int skillen, i, found = 0;
  4711. DBIterator* iter;
  4712. DBKey key;
  4713. DBData *data;
  4714. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4715. nullpo_retr(-1, sd);
  4716. if (!message || !*message) {
  4717. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4718. return -1;
  4719. }
  4720. skillen = strlen(message);
  4721. iter = db_iterator(skilldb_name2id);
  4722. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4723. int idx = skill_get_index(db_data2i(data));
  4724. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx]->desc, message, skillen) == 0) {
  4725. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str); // skill %d: %s (%s)
  4726. clif_displaymessage(fd, atcmd_output);
  4727. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx]->desc,message) ) ) {
  4728. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx]->desc, key.str);
  4729. }
  4730. }
  4731. dbi_destroy(iter);
  4732. if( found ) {
  4733. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4734. clif_displaymessage(fd, atcmd_output);
  4735. }
  4736. for(i = 0; i < found; i++) { /* partials */
  4737. clif_displaymessage(fd, partials[i]);
  4738. }
  4739. return 0;
  4740. }
  4741. /*==========================================
  4742. * @useskill by [MouseJstr]
  4743. * A way of using skills without having to find them in the skills menu
  4744. *------------------------------------------*/
  4745. ACMD_FUNC(useskill)
  4746. {
  4747. struct map_session_data *pl_sd = NULL;
  4748. struct block_list *bl;
  4749. uint16 skill_id;
  4750. uint16 skill_lv;
  4751. char target[100];
  4752. nullpo_retr(-1, sd);
  4753. if(!message || !*message || sscanf(message, "%6hu %6hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4754. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4755. return -1;
  4756. }
  4757. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4758. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4759. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4760. return -1;
  4761. }
  4762. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4763. {
  4764. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4765. return -1;
  4766. }
  4767. if (SKILL_CHK_HOMUN(skill_id)
  4768. && sd->hd && hom_is_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4769. bl = &sd->hd->bl;
  4770. else
  4771. bl = &sd->bl;
  4772. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4773. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4774. else
  4775. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4776. return 0;
  4777. }
  4778. /*==========================================
  4779. * @displayskill by [Skotlex]
  4780. * Debug command to locate new skill IDs. It sends the
  4781. * three possible skill-effect packets to the area.
  4782. *------------------------------------------*/
  4783. ACMD_FUNC(displayskill)
  4784. {
  4785. struct status_data * status;
  4786. unsigned int tick;
  4787. uint16 skill_id;
  4788. uint16 skill_lv = 1;
  4789. nullpo_retr(-1, sd);
  4790. if (!message || !*message || sscanf(message, "%6hu %6hu", &skill_id, &skill_lv) < 1)
  4791. {
  4792. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4793. return -1;
  4794. }
  4795. status = status_get_status_data(&sd->bl);
  4796. tick = gettick();
  4797. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4798. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4799. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4800. return 0;
  4801. }
  4802. /*==========================================
  4803. * @skilltree by [MouseJstr]
  4804. * prints the skill tree for a player required to get to a skill
  4805. *------------------------------------------*/
  4806. ACMD_FUNC(skilltree)
  4807. {
  4808. struct map_session_data *pl_sd = NULL;
  4809. uint16 skill_id;
  4810. int meets, j, c=0;
  4811. char target[NAME_LENGTH];
  4812. struct skill_tree_entry *ent;
  4813. nullpo_retr(-1, sd);
  4814. if(!message || !*message || sscanf(message, "%6hu %23[^\r\n]", &skill_id, target) != 2) {
  4815. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4816. return -1;
  4817. }
  4818. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4819. {
  4820. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4821. return -1;
  4822. }
  4823. c = pc_calc_skilltree_normalize_job(pl_sd);
  4824. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4825. 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).
  4826. clif_displaymessage(fd, atcmd_output);
  4827. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4828. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4829. {
  4830. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4831. return 0;
  4832. }
  4833. ent = &skill_tree[c][j];
  4834. meets = 1;
  4835. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4836. {
  4837. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4838. {
  4839. 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.
  4840. clif_displaymessage(fd, atcmd_output);
  4841. meets = 0;
  4842. }
  4843. }
  4844. if (meets == 1) {
  4845. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4846. }
  4847. return 0;
  4848. }
  4849. // Hand a ring with partners name on it to this char
  4850. void getring (struct map_session_data* sd)
  4851. {
  4852. char flag = 0;
  4853. unsigned short item_id;
  4854. struct item item_tmp;
  4855. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4856. memset(&item_tmp, 0, sizeof(item_tmp));
  4857. item_tmp.nameid = item_id;
  4858. item_tmp.identify = 1;
  4859. item_tmp.card[0] = 255;
  4860. item_tmp.card[2] = sd->status.partner_id;
  4861. item_tmp.card[3] = sd->status.partner_id >> 16;
  4862. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4863. clif_additem(sd,0,0,flag);
  4864. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4,0);
  4865. }
  4866. }
  4867. /*==========================================
  4868. * @marry by [MouseJstr], fixed by Lupus
  4869. * Marry two players
  4870. *------------------------------------------*/
  4871. ACMD_FUNC(marry)
  4872. {
  4873. struct map_session_data *pl_sd = NULL;
  4874. char player_name[NAME_LENGTH] = "";
  4875. nullpo_retr(-1, sd);
  4876. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4877. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4878. return -1;
  4879. }
  4880. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4881. clif_displaymessage(fd, msg_txt(sd,3));
  4882. return -1;
  4883. }
  4884. if (pc_marriage(sd, pl_sd)) {
  4885. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4886. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4887. getring(sd); // Auto-give named rings (Aru)
  4888. getring(pl_sd);
  4889. return 0;
  4890. }
  4891. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4892. return -1;
  4893. }
  4894. /*==========================================
  4895. * @divorce by [MouseJstr], fixed by [Lupus]
  4896. * divorce two players
  4897. *------------------------------------------*/
  4898. ACMD_FUNC(divorce)
  4899. {
  4900. nullpo_retr(-1, sd);
  4901. if (!pc_divorce(sd)) {
  4902. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4903. clif_displaymessage(fd, atcmd_output);
  4904. return -1;
  4905. }
  4906. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4907. clif_displaymessage(fd, atcmd_output);
  4908. return 0;
  4909. }
  4910. /*==========================================
  4911. * @changelook by [Celest]
  4912. *------------------------------------------*/
  4913. ACMD_FUNC(changelook)
  4914. {
  4915. int i, j = 0, k = 0;
  4916. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4917. if((i = sscanf(message, "%11d %11d", &j, &k)) < 1) {
  4918. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4919. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4920. return -1;
  4921. } else if ( i == 2 ) {
  4922. if (j < 1 || j > 7)
  4923. j = 1;
  4924. j = pos[j - 1];
  4925. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4926. k = j; // swap
  4927. j = LOOK_HEAD_TOP;
  4928. }
  4929. clif_changelook(&sd->bl,j,k);
  4930. return 0;
  4931. }
  4932. /*==========================================
  4933. * @autotrade by durf [Lupus] [Paradox924X]
  4934. * Turns on/off Autotrade for a specific player
  4935. *------------------------------------------*/
  4936. ACMD_FUNC(autotrade) {
  4937. nullpo_retr(-1, sd);
  4938. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4939. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4940. return -1;
  4941. }
  4942. if( pc_isdead(sd) ) {
  4943. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4944. return -1;
  4945. }
  4946. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4947. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4948. return -1;
  4949. }
  4950. sd->state.autotrade = 1;
  4951. if (battle_config.autotrade_monsterignore)
  4952. sd->state.monster_ignore = 1;
  4953. if( sd->state.vending ){
  4954. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_db, sd->vender_id ) != SQL_SUCCESS ){
  4955. Sql_ShowDebug( mmysql_handle );
  4956. }
  4957. }else if( sd->state.buyingstore ){
  4958. if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", buyingstores_db, sd->buyer_id ) != SQL_SUCCESS ){
  4959. Sql_ShowDebug( mmysql_handle );
  4960. }
  4961. }
  4962. if( battle_config.at_timeout ) {
  4963. int timeout = atoi(message);
  4964. 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);
  4965. }
  4966. channel_pcquit(sd,0xF); //leave all chan
  4967. clif_authfail_fd(sd->fd, 15);
  4968. chrif_save(sd,3);
  4969. return 0;
  4970. }
  4971. /*==========================================
  4972. * @changegm by durf (changed by Lupus)
  4973. * Changes Master of your Guild to a specified guild member
  4974. *------------------------------------------*/
  4975. ACMD_FUNC(changegm)
  4976. {
  4977. struct guild *g;
  4978. struct map_session_data *pl_sd;
  4979. nullpo_retr(-1, sd);
  4980. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4981. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4982. return -1;
  4983. }
  4984. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4985. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4986. return -1;
  4987. }
  4988. if( !message[0] ) {
  4989. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4990. return -1;
  4991. }
  4992. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4993. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4994. return -1;
  4995. }
  4996. guild_gm_change(sd->status.guild_id, pl_sd);
  4997. return 0;
  4998. }
  4999. /*==========================================
  5000. * @changeleader by Skotlex
  5001. * Changes the leader of a party.
  5002. *------------------------------------------*/
  5003. ACMD_FUNC(changeleader)
  5004. {
  5005. nullpo_retr(-1, sd);
  5006. if( !message[0] )
  5007. {
  5008. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  5009. return -1;
  5010. }
  5011. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  5012. return 0;
  5013. return -1;
  5014. }
  5015. /*==========================================
  5016. * @partyoption by Skotlex
  5017. * Used to change the item share setting of a party.
  5018. *------------------------------------------*/
  5019. ACMD_FUNC(partyoption)
  5020. {
  5021. struct party_data *p;
  5022. int mi, option;
  5023. char w1[16], w2[16];
  5024. nullpo_retr(-1, sd);
  5025. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  5026. {
  5027. clif_displaymessage(fd, msg_txt(sd,282));
  5028. return -1;
  5029. }
  5030. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  5031. if (mi == MAX_PARTY)
  5032. return -1; //Shouldn't happen
  5033. if (!p->party.member[mi].leader)
  5034. {
  5035. clif_displaymessage(fd, msg_txt(sd,282));
  5036. return -1;
  5037. }
  5038. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  5039. {
  5040. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  5041. return -1;
  5042. }
  5043. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  5044. //Change item share type.
  5045. if (option != p->party.item)
  5046. party_changeoption(sd, p->party.exp, option);
  5047. else
  5048. clif_displaymessage(fd, msg_txt(sd,286));
  5049. return 0;
  5050. }
  5051. /*==========================================
  5052. * @autoloot by Upa-Kun
  5053. * Turns on/off AutoLoot for a specific player
  5054. *------------------------------------------*/
  5055. ACMD_FUNC(autoloot)
  5056. {
  5057. int rate;
  5058. nullpo_retr(-1, sd);
  5059. // autoloot command without value
  5060. if(!message || !*message)
  5061. {
  5062. if (sd->state.autoloot)
  5063. rate = 0;
  5064. else
  5065. rate = 10000;
  5066. } else {
  5067. double drate;
  5068. drate = atof(message);
  5069. rate = (int)(drate*100);
  5070. }
  5071. if (rate < 0) rate = 0;
  5072. if (rate > 10000) rate = 10000;
  5073. sd->state.autoloot = rate;
  5074. if (sd->state.autoloot) {
  5075. 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.
  5076. clif_displaymessage(fd, atcmd_output);
  5077. }else
  5078. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  5079. return 0;
  5080. }
  5081. /*==========================================
  5082. * @alootid
  5083. *------------------------------------------*/
  5084. ACMD_FUNC(autolootitem)
  5085. {
  5086. struct item_data *item_data = NULL;
  5087. int i;
  5088. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5089. nullpo_retr(-1, sd);
  5090. if (message && *message) {
  5091. if (message[0] == '+') {
  5092. message++;
  5093. action = 1;
  5094. }
  5095. else if (message[0] == '-') {
  5096. message++;
  5097. action = 2;
  5098. }
  5099. else if (!strcmp(message,"reset"))
  5100. action = 4;
  5101. }
  5102. if (action < 3) // add or remove
  5103. {
  5104. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  5105. item_data = itemdb_searchname(message);
  5106. if (!item_data) {
  5107. // No items founds in the DB with Id or Name
  5108. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  5109. return -1;
  5110. }
  5111. }
  5112. switch(action) {
  5113. case 1:
  5114. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5115. if (i != AUTOLOOTITEM_SIZE) {
  5116. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  5117. return -1;
  5118. }
  5119. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  5120. if (i == AUTOLOOTITEM_SIZE) {
  5121. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  5122. return -1;
  5123. }
  5124. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5125. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5126. clif_displaymessage(fd, atcmd_output);
  5127. sd->state.autolooting = 1;
  5128. break;
  5129. case 2:
  5130. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5131. if (i == AUTOLOOTITEM_SIZE) {
  5132. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5133. return -1;
  5134. }
  5135. sd->state.autolootid[i] = 0;
  5136. 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.
  5137. clif_displaymessage(fd, atcmd_output);
  5138. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5139. if (i == AUTOLOOTITEM_SIZE) {
  5140. sd->state.autolooting = 0;
  5141. }
  5142. break;
  5143. case 3:
  5144. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5145. clif_displaymessage(fd, atcmd_output);
  5146. 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>".
  5147. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5148. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5149. if (i == AUTOLOOTITEM_SIZE) {
  5150. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5151. } else {
  5152. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5153. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5154. {
  5155. if (sd->state.autolootid[i] == 0)
  5156. continue;
  5157. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5158. 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);
  5159. continue;
  5160. }
  5161. sprintf(atcmd_output, "'%s'/'%s' {%hu}", item_data->name, item_data->jname, item_data->nameid);
  5162. clif_displaymessage(fd, atcmd_output);
  5163. }
  5164. }
  5165. break;
  5166. case 4:
  5167. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5168. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5169. sd->state.autolooting = 0;
  5170. break;
  5171. }
  5172. return 0;
  5173. }
  5174. /*==========================================
  5175. * @autoloottype
  5176. * Flags:
  5177. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5178. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5179. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5180. * 262144: IT_CASH
  5181. *------------------------------------------
  5182. * Credits:
  5183. * chriser
  5184. * Aleos
  5185. *------------------------------------------*/
  5186. ACMD_FUNC(autoloottype)
  5187. {
  5188. uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5189. enum item_types type = -1;
  5190. int ITEM_MAX = 1533;
  5191. nullpo_retr(-1, sd);
  5192. if (message && *message) {
  5193. if (message[0] == '+') {
  5194. message++;
  5195. action = 1;
  5196. }
  5197. else if (message[0] == '-') {
  5198. message++;
  5199. action = 2;
  5200. }
  5201. else if (!strcmp(message,"reset"))
  5202. action = 4;
  5203. }
  5204. if (action < 3) { // add or remove
  5205. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5206. type = IT_HEALING;
  5207. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5208. type = IT_USABLE;
  5209. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5210. type = IT_ETC;
  5211. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5212. type = IT_ARMOR;
  5213. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5214. type = IT_WEAPON;
  5215. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5216. type = IT_CARD;
  5217. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5218. type = IT_PETEGG;
  5219. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5220. type = IT_PETARMOR;
  5221. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5222. type = IT_AMMO;
  5223. else {
  5224. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5225. return -1;
  5226. }
  5227. }
  5228. switch (action) {
  5229. case 1:
  5230. if (sd->state.autoloottype&(1<<type)) {
  5231. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5232. return -1;
  5233. }
  5234. if (sd->state.autoloottype == ITEM_MAX) {
  5235. 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>.
  5236. return -1;
  5237. }
  5238. sd->state.autoloottype |= (1<<type); // Stores the type
  5239. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5240. clif_displaymessage(fd, atcmd_output);
  5241. break;
  5242. case 2:
  5243. if (!(sd->state.autoloottype&(1<<type))) {
  5244. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5245. return -1;
  5246. }
  5247. sd->state.autoloottype &= ~(1<<type);
  5248. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5249. clif_displaymessage(fd, atcmd_output);
  5250. break;
  5251. case 3:
  5252. 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>".
  5253. 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
  5254. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5255. if (sd->state.autoloottype == 0)
  5256. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5257. else {
  5258. uint8 i = 0;
  5259. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5260. while (i < IT_MAX) {
  5261. if (sd->state.autoloottype&(1<<i)) {
  5262. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5263. clif_displaymessage(fd, atcmd_output);
  5264. }
  5265. i++;
  5266. }
  5267. }
  5268. break;
  5269. case 4:
  5270. sd->state.autoloottype = 0;
  5271. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5272. break;
  5273. }
  5274. return 0;
  5275. }
  5276. /**
  5277. * No longer available, keeping here just in case it's back someday. [Ind]
  5278. **/
  5279. /*==========================================
  5280. * It is made to rain.
  5281. *------------------------------------------*/
  5282. //ACMD_FUNC(rain)
  5283. //{
  5284. // nullpo_retr(-1, sd);
  5285. // if (map[sd->bl.m].flag.rain) {
  5286. // map[sd->bl.m].flag.rain=0;
  5287. // clif_weather(sd->bl.m);
  5288. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5289. // } else {
  5290. // map[sd->bl.m].flag.rain=1;
  5291. // clif_weather(sd->bl.m);
  5292. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5293. // }
  5294. // return 0;
  5295. //}
  5296. /*==========================================
  5297. * It is made to snow.
  5298. *------------------------------------------*/
  5299. ACMD_FUNC(snow)
  5300. {
  5301. nullpo_retr(-1, sd);
  5302. if (map[sd->bl.m].flag.snow) {
  5303. map[sd->bl.m].flag.snow=0;
  5304. clif_weather(sd->bl.m);
  5305. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5306. } else {
  5307. map[sd->bl.m].flag.snow=1;
  5308. clif_weather(sd->bl.m);
  5309. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5310. }
  5311. return 0;
  5312. }
  5313. /*==========================================
  5314. * Cherry tree snowstorm is made to fall. (Sakura)
  5315. *------------------------------------------*/
  5316. ACMD_FUNC(sakura)
  5317. {
  5318. nullpo_retr(-1, sd);
  5319. if (map[sd->bl.m].flag.sakura) {
  5320. map[sd->bl.m].flag.sakura=0;
  5321. clif_weather(sd->bl.m);
  5322. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5323. } else {
  5324. map[sd->bl.m].flag.sakura=1;
  5325. clif_weather(sd->bl.m);
  5326. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5327. }
  5328. return 0;
  5329. }
  5330. /*==========================================
  5331. * Clouds appear.
  5332. *------------------------------------------*/
  5333. ACMD_FUNC(clouds)
  5334. {
  5335. nullpo_retr(-1, sd);
  5336. if (map[sd->bl.m].flag.clouds) {
  5337. map[sd->bl.m].flag.clouds=0;
  5338. clif_weather(sd->bl.m);
  5339. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5340. } else {
  5341. map[sd->bl.m].flag.clouds=1;
  5342. clif_weather(sd->bl.m);
  5343. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5344. }
  5345. return 0;
  5346. }
  5347. /*==========================================
  5348. * Different type of clouds using effect 516
  5349. *------------------------------------------*/
  5350. ACMD_FUNC(clouds2)
  5351. {
  5352. nullpo_retr(-1, sd);
  5353. if (map[sd->bl.m].flag.clouds2) {
  5354. map[sd->bl.m].flag.clouds2=0;
  5355. clif_weather(sd->bl.m);
  5356. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5357. } else {
  5358. map[sd->bl.m].flag.clouds2=1;
  5359. clif_weather(sd->bl.m);
  5360. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5361. }
  5362. return 0;
  5363. }
  5364. /*==========================================
  5365. * Fog hangs over.
  5366. *------------------------------------------*/
  5367. ACMD_FUNC(fog)
  5368. {
  5369. nullpo_retr(-1, sd);
  5370. if (map[sd->bl.m].flag.fog) {
  5371. map[sd->bl.m].flag.fog=0;
  5372. clif_weather(sd->bl.m);
  5373. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5374. } else {
  5375. map[sd->bl.m].flag.fog=1;
  5376. clif_weather(sd->bl.m);
  5377. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5378. }
  5379. return 0;
  5380. }
  5381. /*==========================================
  5382. * Fallen leaves fall.
  5383. *------------------------------------------*/
  5384. ACMD_FUNC(leaves)
  5385. {
  5386. nullpo_retr(-1, sd);
  5387. if (map[sd->bl.m].flag.leaves) {
  5388. map[sd->bl.m].flag.leaves=0;
  5389. clif_weather(sd->bl.m);
  5390. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5391. } else {
  5392. map[sd->bl.m].flag.leaves=1;
  5393. clif_weather(sd->bl.m);
  5394. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5395. }
  5396. return 0;
  5397. }
  5398. /*==========================================
  5399. * Fireworks appear.
  5400. *------------------------------------------*/
  5401. ACMD_FUNC(fireworks)
  5402. {
  5403. nullpo_retr(-1, sd);
  5404. if (map[sd->bl.m].flag.fireworks) {
  5405. map[sd->bl.m].flag.fireworks=0;
  5406. clif_weather(sd->bl.m);
  5407. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5408. } else {
  5409. map[sd->bl.m].flag.fireworks=1;
  5410. clif_weather(sd->bl.m);
  5411. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5412. }
  5413. return 0;
  5414. }
  5415. /*==========================================
  5416. * Clearing Weather Effects by Dexity
  5417. *------------------------------------------*/
  5418. ACMD_FUNC(clearweather)
  5419. {
  5420. nullpo_retr(-1, sd);
  5421. /**
  5422. * No longer available, keeping here just in case it's back someday. [Ind]
  5423. **/
  5424. //map[sd->bl.m].flag.rain=0;
  5425. map[sd->bl.m].flag.snow=0;
  5426. map[sd->bl.m].flag.sakura=0;
  5427. map[sd->bl.m].flag.clouds=0;
  5428. map[sd->bl.m].flag.clouds2=0;
  5429. map[sd->bl.m].flag.fog=0;
  5430. map[sd->bl.m].flag.fireworks=0;
  5431. map[sd->bl.m].flag.leaves=0;
  5432. clif_weather(sd->bl.m);
  5433. clif_displaymessage(fd, msg_txt(sd,291));
  5434. return 0;
  5435. }
  5436. /*===============================================================
  5437. * Sound Command - plays a sound for everyone around! [Codemaster]
  5438. *---------------------------------------------------------------*/
  5439. ACMD_FUNC(sound)
  5440. {
  5441. char sound_file[100];
  5442. memset(sound_file, '\0', sizeof(sound_file));
  5443. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5444. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5445. return -1;
  5446. }
  5447. if(strstr(sound_file, ".wav") == NULL)
  5448. strcat(sound_file, ".wav");
  5449. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5450. return 0;
  5451. }
  5452. /*==========================================
  5453. * MOB Search
  5454. *------------------------------------------*/
  5455. ACMD_FUNC(mobsearch)
  5456. {
  5457. char mob_name[100];
  5458. int mob_id;
  5459. int number = 0;
  5460. struct s_mapiterator* it;
  5461. nullpo_retr(-1, sd);
  5462. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5463. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5464. return -1;
  5465. }
  5466. if ((mob_id = atoi(mob_name)) == 0)
  5467. mob_id = mobdb_searchname(mob_name);
  5468. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5469. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5470. clif_displaymessage(fd, atcmd_output);
  5471. return -1;
  5472. }
  5473. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5474. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5475. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5476. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5477. clif_displaymessage(fd, atcmd_output);
  5478. it = mapit_geteachmob();
  5479. for(;;)
  5480. {
  5481. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5482. if( md == NULL )
  5483. break;// no more mobs
  5484. if( md->bl.m != sd->bl.m )
  5485. continue;
  5486. if( mob_id != -1 && md->mob_id != mob_id )
  5487. continue;
  5488. ++number;
  5489. if( md->spawn_timer == INVALID_TIMER )
  5490. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5491. else
  5492. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5493. clif_displaymessage(fd, atcmd_output);
  5494. }
  5495. mapit_free(it);
  5496. return 0;
  5497. }
  5498. /*==========================================
  5499. * @cleanmap - cleans items on the ground
  5500. * @cleanarea - cleans items on the ground within an specified area
  5501. *------------------------------------------*/
  5502. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5503. {
  5504. nullpo_ret(bl);
  5505. map_clearflooritem(bl);
  5506. return 0;
  5507. }
  5508. ACMD_FUNC(cleanmap)
  5509. {
  5510. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5511. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5512. return 0;
  5513. }
  5514. ACMD_FUNC(cleanarea)
  5515. {
  5516. short x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5517. if (!message || !*message || sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) < 1) {
  5518. 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);
  5519. }
  5520. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 1) {
  5521. 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);
  5522. }
  5523. else if (sscanf(message, "%6hd %6hd %6hd %6hd", &x0, &y0, &x1, &y1) == 4) {
  5524. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5525. }
  5526. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5527. return 0;
  5528. }
  5529. /*==========================================
  5530. * make a NPC/PET talk
  5531. * @npctalkc [SnakeDrak]
  5532. *------------------------------------------*/
  5533. ACMD_FUNC(npctalk)
  5534. {
  5535. char name[NAME_LENGTH],mes[100],temp[100];
  5536. struct npc_data *nd;
  5537. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5538. unsigned long color=0;
  5539. if (sd->sc.cant.chat)
  5540. return -1; //no "chatting" while muted.
  5541. if(!ifcolor) {
  5542. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5543. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5544. return -1;
  5545. }
  5546. }
  5547. else {
  5548. if (!message || !*message || sscanf(message, "%16lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5549. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5550. return -1;
  5551. }
  5552. }
  5553. if (!(nd = npc_name2id(name))) {
  5554. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5555. return -1;
  5556. }
  5557. strtok(name, "#"); // discard extra name identifier if present
  5558. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5559. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5560. else clif_disp_overhead(&nd->bl, temp);
  5561. return 0;
  5562. }
  5563. ACMD_FUNC(pettalk)
  5564. {
  5565. char mes[100],temp[100];
  5566. struct pet_data *pd;
  5567. nullpo_retr(-1, sd);
  5568. if ( battle_config.min_chat_delay ) {
  5569. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5570. return 0;
  5571. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5572. }
  5573. if(!sd->status.pet_id || !(pd=sd->pd))
  5574. {
  5575. clif_displaymessage(fd, msg_txt(sd,184));
  5576. return -1;
  5577. }
  5578. if (sd->sc.cant.chat)
  5579. return -1; //no "chatting" while muted.
  5580. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5581. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5582. return -1;
  5583. }
  5584. if (message[0] == '/')
  5585. {// pet emotion processing
  5586. const char* emo[] = {
  5587. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5588. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5589. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5590. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5591. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5592. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5593. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5594. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5595. "/whisp"
  5596. };
  5597. int i;
  5598. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5599. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5600. if( i < ARRAYLENGTH(emo) )
  5601. {
  5602. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5603. sd->emotionlasttime = time(NULL);
  5604. return 0;
  5605. }
  5606. sd->emotionlasttime = time(NULL);
  5607. clif_emotion(&pd->bl, i);
  5608. return 0;
  5609. }
  5610. }
  5611. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5612. clif_disp_overhead(&pd->bl, temp);
  5613. return 0;
  5614. }
  5615. /// @users - displays the number of players present on each map (and percentage)
  5616. /// #users displays on the target user instead of self
  5617. ACMD_FUNC(users)
  5618. {
  5619. char buf[CHAT_SIZE_MAX];
  5620. int i;
  5621. int users[MAX_MAPINDEX];
  5622. int users_all;
  5623. struct s_mapiterator* iter;
  5624. memset(users, 0, sizeof(users));
  5625. users_all = 0;
  5626. // count users on each map
  5627. iter = mapit_getallusers();
  5628. for(;;)
  5629. {
  5630. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5631. if( sd2 == NULL )
  5632. break;// no more users
  5633. if( sd2->mapindex >= MAX_MAPINDEX )
  5634. continue;// invalid mapindex
  5635. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5636. if( users_all < INT_MAX ) ++users_all;
  5637. }
  5638. mapit_free(iter);
  5639. // display results for each map
  5640. for( i = 0; i < MAX_MAPINDEX; ++i )
  5641. {
  5642. if( users[i] == 0 )
  5643. continue;// empty
  5644. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5645. clif_displaymessage(sd->fd, buf);
  5646. }
  5647. // display overall count
  5648. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5649. clif_displaymessage(sd->fd, buf);
  5650. return 0;
  5651. }
  5652. /*==========================================
  5653. *
  5654. *------------------------------------------*/
  5655. ACMD_FUNC(reset)
  5656. {
  5657. pc_resetstate(sd);
  5658. pc_resetskill(sd,1);
  5659. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5660. clif_displaymessage(fd, atcmd_output);
  5661. return 0;
  5662. }
  5663. /*==========================================
  5664. *
  5665. *------------------------------------------*/
  5666. ACMD_FUNC(summon)
  5667. {
  5668. char name[NAME_LENGTH];
  5669. int mob_id = 0;
  5670. int duration = 0;
  5671. struct mob_data *md;
  5672. unsigned int tick=gettick();
  5673. nullpo_retr(-1, sd);
  5674. if (!message || !*message || sscanf(message, "%23s %11d", name, &duration) < 1)
  5675. {
  5676. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5677. return -1;
  5678. }
  5679. if (duration < 1)
  5680. duration =1;
  5681. else if (duration > 60)
  5682. duration =60;
  5683. if ((mob_id = atoi(name)) == 0)
  5684. mob_id = mobdb_searchname(name);
  5685. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5686. {
  5687. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5688. return -1;
  5689. }
  5690. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5691. if(!md)
  5692. return -1;
  5693. md->master_id=sd->bl.id;
  5694. md->special_state.ai=AI_ATTACK;
  5695. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5696. clif_specialeffect(&md->bl,344,AREA);
  5697. mob_spawn(md);
  5698. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5699. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5700. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5701. return 0;
  5702. }
  5703. /*==========================================
  5704. * @adjgroup
  5705. * Temporarily move player to another group
  5706. * Useful during beta testing to allow players to use GM commands for short periods of time
  5707. *------------------------------------------*/
  5708. ACMD_FUNC(adjgroup)
  5709. {
  5710. int new_group = 0;
  5711. nullpo_retr(-1, sd);
  5712. if (!message || !*message || sscanf(message, "%11d", &new_group) != 1) {
  5713. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5714. return -1;
  5715. }
  5716. if (!pc_group_exists(new_group)) {
  5717. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5718. return -1;
  5719. }
  5720. sd->group_id = new_group;
  5721. pc_group_pc_load(sd);/* update cache */
  5722. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5723. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5724. return 0;
  5725. }
  5726. /*==========================================
  5727. * @trade by [MouseJstr]
  5728. * Open a trade window with a remote player
  5729. *------------------------------------------*/
  5730. ACMD_FUNC(trade)
  5731. {
  5732. struct map_session_data *pl_sd = NULL;
  5733. nullpo_retr(-1, sd);
  5734. if (!message || !*message) {
  5735. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5736. return -1;
  5737. }
  5738. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5739. {
  5740. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5741. return -1;
  5742. }
  5743. trade_traderequest(sd, pl_sd);
  5744. return 0;
  5745. }
  5746. /*==========================================
  5747. * @setbattleflag by [MouseJstr]
  5748. * set a battle_config flag without having to reboot
  5749. *------------------------------------------*/
  5750. ACMD_FUNC(setbattleflag)
  5751. {
  5752. char flag[128], value[128];
  5753. nullpo_retr(-1, sd);
  5754. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5755. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5756. return -1;
  5757. }
  5758. if (battle_set_value(flag, value) == 0)
  5759. {
  5760. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5761. return -1;
  5762. }
  5763. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5764. return 0;
  5765. }
  5766. /*==========================================
  5767. * @unmute [Valaris]
  5768. *------------------------------------------*/
  5769. ACMD_FUNC(unmute)
  5770. {
  5771. struct map_session_data *pl_sd = NULL;
  5772. nullpo_retr(-1, sd);
  5773. if (!message || !*message) {
  5774. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5775. return -1;
  5776. }
  5777. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5778. {
  5779. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5780. return -1;
  5781. }
  5782. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5783. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5784. return -1;
  5785. }
  5786. pl_sd->status.manner = 0;
  5787. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5788. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5789. return 0;
  5790. }
  5791. /*==========================================
  5792. * @uptime by MC Cameri
  5793. *------------------------------------------*/
  5794. ACMD_FUNC(uptime)
  5795. {
  5796. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5797. minute = 60, days = 0, hours = 0, minutes = 0;
  5798. nullpo_retr(-1, sd);
  5799. seconds = get_uptime();
  5800. days = seconds/day;
  5801. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5802. hours = seconds/hour;
  5803. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5804. minutes = seconds/minute;
  5805. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5806. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5807. clif_displaymessage(fd, atcmd_output);
  5808. return 0;
  5809. }
  5810. /*==========================================
  5811. * @changesex
  5812. * => Changes one's account sex. Switch from male to female or visversa
  5813. *------------------------------------------*/
  5814. ACMD_FUNC(changesex)
  5815. {
  5816. int i;
  5817. nullpo_retr(-1, sd);
  5818. pc_resetskill(sd,4);
  5819. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5820. for (i = 0; i < EQI_MAX; i++) {
  5821. if (sd->equip_index[i] >= 0)
  5822. pc_unequipitem(sd, sd->equip_index[i], 3);
  5823. }
  5824. chrif_changesex(sd, true);
  5825. return 0;
  5826. }
  5827. /*==========================================
  5828. * @changecharsex
  5829. * => Changes one's character sex. Switch from male to female or visversa.
  5830. *------------------------------------------*/
  5831. ACMD_FUNC(changecharsex)
  5832. {
  5833. int i;
  5834. nullpo_retr(-1, sd);
  5835. pc_resetskill(sd,4);
  5836. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5837. for (i = 0; i < EQI_MAX; i++) {
  5838. if (sd->equip_index[i] >= 0)
  5839. pc_unequipitem(sd, sd->equip_index[i], 3);
  5840. }
  5841. chrif_changesex(sd, false);
  5842. return 0;
  5843. }
  5844. /*================================================
  5845. * @mute - Mutes a player for a set amount of time
  5846. *------------------------------------------------*/
  5847. ACMD_FUNC(mute)
  5848. {
  5849. struct map_session_data *pl_sd = NULL;
  5850. int manner;
  5851. nullpo_retr(-1, sd);
  5852. if (!message || !*message || sscanf(message, "%11d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5853. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5854. return -1;
  5855. }
  5856. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5857. {
  5858. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5859. return -1;
  5860. }
  5861. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5862. {
  5863. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5864. return -1;
  5865. }
  5866. clif_manner_message(sd, 0);
  5867. clif_manner_message(pl_sd, 5);
  5868. if( pl_sd->status.manner < manner ) {
  5869. pl_sd->status.manner -= manner;
  5870. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5871. } else {
  5872. pl_sd->status.manner = 0;
  5873. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5874. }
  5875. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5876. return 0;
  5877. }
  5878. /*==========================================
  5879. * @refresh (like @jumpto <<yourself>>)
  5880. *------------------------------------------*/
  5881. ACMD_FUNC(refresh)
  5882. {
  5883. nullpo_retr(-1, sd);
  5884. clif_refresh(sd);
  5885. return 0;
  5886. }
  5887. ACMD_FUNC(refreshall)
  5888. {
  5889. struct map_session_data* iter_sd;
  5890. struct s_mapiterator* iter;
  5891. nullpo_retr(-1, sd);
  5892. iter = mapit_getallusers();
  5893. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5894. clif_refresh(iter_sd);
  5895. mapit_free(iter);
  5896. return 0;
  5897. }
  5898. /*==========================================
  5899. * @identify
  5900. * => GM's magnifier.
  5901. *------------------------------------------*/
  5902. ACMD_FUNC(identify)
  5903. {
  5904. int i,num;
  5905. nullpo_retr(-1, sd);
  5906. for(i=num=0;i<MAX_INVENTORY;i++){
  5907. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5908. num++;
  5909. }
  5910. }
  5911. if (num > 0) {
  5912. clif_item_identify_list(sd);
  5913. } else {
  5914. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5915. }
  5916. return 0;
  5917. }
  5918. /*===============================================
  5919. * @identifyall
  5920. * => Indentify all items in inventory - Akinari
  5921. *-----------------------------------------------*/
  5922. ACMD_FUNC(identifyall)
  5923. {
  5924. int i;
  5925. nullpo_retr(-1, sd);
  5926. for(i=0; i<MAX_INVENTORY; i++) {
  5927. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5928. sd->status.inventory[i].identify=1;
  5929. clif_item_identified(sd,i,0);
  5930. }
  5931. }
  5932. return 0;
  5933. }
  5934. /*==========================================
  5935. * @gmotd (Global MOTD)
  5936. * by davidsiaw :P
  5937. *------------------------------------------*/
  5938. ACMD_FUNC(gmotd)
  5939. {
  5940. FILE* fp;
  5941. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5942. {
  5943. char buf[CHAT_SIZE_MAX];
  5944. size_t len;
  5945. while( fgets(buf, sizeof(buf), fp) )
  5946. {
  5947. if( buf[0] == '/' && buf[1] == '/' )
  5948. {
  5949. continue;
  5950. }
  5951. len = strlen(buf);
  5952. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5953. {// strip trailing EOL characters
  5954. len--;
  5955. }
  5956. if( len )
  5957. {
  5958. buf[len] = 0;
  5959. intif_broadcast(buf, len+1, 0);
  5960. }
  5961. }
  5962. fclose(fp);
  5963. }
  5964. return 0;
  5965. }
  5966. ACMD_FUNC(misceffect)
  5967. {
  5968. int effect = 0;
  5969. nullpo_retr(-1, sd);
  5970. if (!message || !*message)
  5971. return -1;
  5972. if (sscanf(message, "%11d", &effect) < 1)
  5973. return -1;
  5974. clif_misceffect(&sd->bl,effect);
  5975. return 0;
  5976. }
  5977. /*==========================================
  5978. * MAIL SYSTEM
  5979. *------------------------------------------*/
  5980. ACMD_FUNC(mail)
  5981. {
  5982. nullpo_ret(sd);
  5983. mail_openmail(sd);
  5984. return 0;
  5985. }
  5986. /*==========================================
  5987. * Show Monster DB Info v 1.0
  5988. * originally by [Lupus]
  5989. *------------------------------------------*/
  5990. ACMD_FUNC(mobinfo)
  5991. {
  5992. unsigned char msize[SZ_ALL][7] = { "Small", "Medium", "Large" };
  5993. unsigned char mrace[RC_ALL][11] = { "Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Player" };
  5994. unsigned char melement[ELE_ALL][8] = { "Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead" };
  5995. char atcmd_output2[CHAT_SIZE_MAX];
  5996. struct item_data *item_data;
  5997. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5998. int count;
  5999. int i, k;
  6000. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6001. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  6002. if (!message || !*message) {
  6003. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  6004. return -1;
  6005. }
  6006. // If monster identifier/name argument is a name
  6007. if ((i = mobdb_checkid(atoi(message))))
  6008. {
  6009. mob_array[0] = mob_db(i);
  6010. count = 1;
  6011. } else
  6012. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6013. if (!count) {
  6014. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6015. return -1;
  6016. }
  6017. if (count > MAX_SEARCH) {
  6018. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6019. clif_displaymessage(fd, atcmd_output);
  6020. count = MAX_SEARCH;
  6021. }
  6022. for (k = 0; k < count; k++) {
  6023. unsigned int j,base_exp,job_exp;
  6024. mob = mob_array[k];
  6025. base_exp = mob->base_exp;
  6026. job_exp = mob->job_exp;
  6027. #ifdef RENEWAL_EXP
  6028. if( battle_config.atcommand_mobinfo_type ) {
  6029. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  6030. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 1) / 100;
  6031. }
  6032. #endif
  6033. #ifdef VIP_ENABLE
  6034. // Display EXP rate increase for VIP.
  6035. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase)) {
  6036. base_exp += battle_config.vip_base_exp_increase;
  6037. job_exp += battle_config.vip_job_exp_increase;
  6038. }
  6039. #endif
  6040. // stats
  6041. if (mob->mexp)
  6042. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  6043. else
  6044. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  6045. clif_displaymessage(fd, atcmd_output);
  6046. 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
  6047. clif_displaymessage(fd, atcmd_output);
  6048. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  6049. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  6050. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  6051. clif_displaymessage(fd, atcmd_output);
  6052. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  6053. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  6054. mob->range2 , mob->range3, msize[mob->status.size],
  6055. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  6056. clif_displaymessage(fd, atcmd_output);
  6057. // drops
  6058. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  6059. strcpy(atcmd_output, " ");
  6060. j = 0;
  6061. for (i = 0; i < MAX_MOB_DROP; i++) {
  6062. int droprate;
  6063. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  6064. continue;
  6065. droprate = mob->dropitem[i].p;
  6066. #ifdef RENEWAL_DROP
  6067. if( battle_config.atcommand_mobinfo_type ) {
  6068. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.class_, 2) / 100;
  6069. if (droprate <= 0 && !battle_config.drop_rate0item)
  6070. droprate = 1;
  6071. }
  6072. #endif
  6073. #ifdef VIP_ENABLE
  6074. // Display item rate increase for VIP.
  6075. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6076. droprate += battle_config.vip_drop_increase;
  6077. #endif
  6078. if (item_data->slot)
  6079. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  6080. else
  6081. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  6082. strcat(atcmd_output, atcmd_output2);
  6083. if (++j % 3 == 0) {
  6084. clif_displaymessage(fd, atcmd_output);
  6085. strcpy(atcmd_output, " ");
  6086. }
  6087. }
  6088. if (j == 0)
  6089. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  6090. else if (j % 3 != 0)
  6091. clif_displaymessage(fd, atcmd_output);
  6092. // mvp
  6093. if (mob->mexp) {
  6094. float mvppercent, mvpremain;
  6095. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  6096. clif_displaymessage(fd, atcmd_output);
  6097. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  6098. mvpremain = 100.0; //Remaining drop chance for official mvp drop mode
  6099. j = 0;
  6100. for (i = 0; i < MAX_MVP_DROP; i++) {
  6101. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  6102. continue;
  6103. //Because if there are 3 MVP drops at 50%, the first has a chance of 50%, the second 25% and the third 12.5%
  6104. mvppercent = (float)mob->mvpitem[i].p * mvpremain / 10000.0f;
  6105. if(battle_config.item_drop_mvp_mode == 0) {
  6106. mvpremain -= mvppercent;
  6107. }
  6108. if (mvppercent > 0) {
  6109. j++;
  6110. if (j == 1) {
  6111. if (item_data->slot)
  6112. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6113. else
  6114. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, mvppercent);
  6115. } else {
  6116. if (item_data->slot)
  6117. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, mvppercent);
  6118. else
  6119. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, mvppercent);
  6120. }
  6121. strcat(atcmd_output, atcmd_output2);
  6122. }
  6123. }
  6124. if (j == 0)
  6125. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  6126. else
  6127. clif_displaymessage(fd, atcmd_output);
  6128. }
  6129. }
  6130. return 0;
  6131. }
  6132. /*=========================================
  6133. * @showmobs by KarLaeda
  6134. * => For 15 sec displays the mobs on minimap
  6135. *------------------------------------------*/
  6136. ACMD_FUNC(showmobs)
  6137. {
  6138. char mob_name[100];
  6139. int mob_id;
  6140. int number = 0;
  6141. struct s_mapiterator* it;
  6142. nullpo_retr(-1, sd);
  6143. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  6144. return -1;
  6145. if((mob_id = atoi(mob_name)) == 0)
  6146. mob_id = mobdb_searchname(mob_name);
  6147. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  6148. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  6149. clif_displaymessage(fd, atcmd_output);
  6150. return 0;
  6151. }
  6152. 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.
  6153. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  6154. return 0;
  6155. }
  6156. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  6157. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  6158. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  6159. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6160. mob_name, mapindex_id2name(sd->mapindex));
  6161. clif_displaymessage(fd, atcmd_output);
  6162. it = mapit_geteachmob();
  6163. for(;;)
  6164. {
  6165. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6166. if( md == NULL )
  6167. break;// no more mobs
  6168. if( md->bl.m != sd->bl.m )
  6169. continue;
  6170. if( mob_id != -1 && md->mob_id != mob_id )
  6171. continue;
  6172. if( md->special_state.ai || md->master_id )
  6173. continue; // hide slaves and player summoned mobs
  6174. if( md->spawn_timer != INVALID_TIMER )
  6175. continue; // hide mobs waiting for respawn
  6176. ++number;
  6177. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6178. }
  6179. mapit_free(it);
  6180. return 0;
  6181. }
  6182. /*==========================================
  6183. * homunculus level up [orn]
  6184. *------------------------------------------*/
  6185. ACMD_FUNC(homlevel)
  6186. {
  6187. TBL_HOM * hd;
  6188. int level = 0, i = 0;
  6189. nullpo_retr(-1, sd);
  6190. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6191. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6192. return -1;
  6193. }
  6194. if ( !hom_is_active(sd->hd) ) {
  6195. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6196. return -1;
  6197. }
  6198. hd = sd->hd;
  6199. for (i = 1; i <= level && hd->exp_next; i++){
  6200. hd->homunculus.exp += hd->exp_next;
  6201. if( !hom_levelup(hd) )
  6202. break;
  6203. }
  6204. status_calc_homunculus(hd, SCO_NONE);
  6205. status_percent_heal(&hd->bl, 100, 100);
  6206. clif_specialeffect(&hd->bl,568,AREA);
  6207. return 0;
  6208. }
  6209. /*==========================================
  6210. * homunculus evolution H [orn]
  6211. *------------------------------------------*/
  6212. ACMD_FUNC(homevolution)
  6213. {
  6214. nullpo_retr(-1, sd);
  6215. if ( !hom_is_active(sd->hd) ) {
  6216. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6217. return -1;
  6218. }
  6219. if ( !hom_evolution(sd->hd) ) {
  6220. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6221. return -1;
  6222. }
  6223. clif_homskillinfoblock(sd);
  6224. return 0;
  6225. }
  6226. ACMD_FUNC(hommutate)
  6227. {
  6228. int homun_id, m_class = 0, m_id;
  6229. nullpo_retr(-1, sd);
  6230. if (!hom_is_active(sd->hd)) {
  6231. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6232. return -1;
  6233. }
  6234. if (!message || !*message) {
  6235. homun_id = 6048 + (rnd() % 4);
  6236. } else {
  6237. homun_id = atoi(message);
  6238. }
  6239. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6240. m_id = hom_class2mapid(homun_id);
  6241. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6242. hom_mutate(sd->hd, homun_id);
  6243. } else {
  6244. clif_emotion(&sd->hd->bl, E_SWT);
  6245. }
  6246. return 0;
  6247. }
  6248. /*==========================================
  6249. * call choosen homunculus [orn]
  6250. *------------------------------------------*/
  6251. ACMD_FUNC(makehomun)
  6252. {
  6253. int homunid;
  6254. nullpo_retr(-1, sd);
  6255. if ( sd->status.hom_id ) {
  6256. clif_displaymessage(fd, msg_txt(sd,450));
  6257. return -1;
  6258. }
  6259. if (!message || !*message) {
  6260. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6261. return -1;
  6262. }
  6263. homunid = atoi(message);
  6264. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6265. {
  6266. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6267. return -1;
  6268. }
  6269. hom_create_request(sd,homunid);
  6270. return 0;
  6271. }
  6272. /*==========================================
  6273. * modify homunculus intimacy [orn]
  6274. *------------------------------------------*/
  6275. ACMD_FUNC(homfriendly)
  6276. {
  6277. int friendly = 0;
  6278. nullpo_retr(-1, sd);
  6279. if ( !hom_is_active(sd->hd) ) {
  6280. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6281. return -1;
  6282. }
  6283. if (!message || !*message) {
  6284. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6285. return -1;
  6286. }
  6287. friendly = atoi(message);
  6288. friendly = cap_value(friendly, 0, 1000);
  6289. sd->hd->homunculus.intimacy = friendly * 100 ;
  6290. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6291. return 0;
  6292. }
  6293. /*==========================================
  6294. * modify homunculus hunger [orn]
  6295. *------------------------------------------*/
  6296. ACMD_FUNC(homhungry)
  6297. {
  6298. int hungry = 0;
  6299. nullpo_retr(-1, sd);
  6300. if ( !hom_is_active(sd->hd) ) {
  6301. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6302. return -1;
  6303. }
  6304. if (!message || !*message) {
  6305. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6306. return -1;
  6307. }
  6308. hungry = atoi(message);
  6309. hungry = cap_value(hungry, 0, 100);
  6310. sd->hd->homunculus.hunger = hungry;
  6311. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6312. return 0;
  6313. }
  6314. /*==========================================
  6315. * make the homunculus speak [orn]
  6316. *------------------------------------------*/
  6317. ACMD_FUNC(homtalk)
  6318. {
  6319. char mes[100],temp[100];
  6320. nullpo_retr(-1, sd);
  6321. if ( battle_config.min_chat_delay ) {
  6322. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6323. return 0;
  6324. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6325. }
  6326. if (sd->sc.cant.chat)
  6327. return -1; //no "chatting" while muted.
  6328. if ( !hom_is_active(sd->hd) ) {
  6329. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6330. return -1;
  6331. }
  6332. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6333. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6334. return -1;
  6335. }
  6336. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6337. clif_disp_overhead(&sd->hd->bl, temp);
  6338. return 0;
  6339. }
  6340. /*==========================================
  6341. * Show homunculus stats
  6342. *------------------------------------------*/
  6343. ACMD_FUNC(hominfo)
  6344. {
  6345. struct homun_data *hd;
  6346. struct status_data *status;
  6347. nullpo_retr(-1, sd);
  6348. if ( !hom_is_active(sd->hd) ) {
  6349. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6350. return -1;
  6351. }
  6352. hd = sd->hd;
  6353. status = status_get_status_data(&hd->bl);
  6354. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6355. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6356. status->hp, status->max_hp, status->sp, status->max_sp);
  6357. clif_displaymessage(fd, atcmd_output);
  6358. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6359. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6360. clif_displaymessage(fd, atcmd_output);
  6361. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6362. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6363. clif_displaymessage(fd, atcmd_output);
  6364. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6365. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6366. status->str, status->agi, status->vit,
  6367. status->int_, status->dex, status->luk);
  6368. clif_displaymessage(fd, atcmd_output);
  6369. return 0;
  6370. }
  6371. ACMD_FUNC(homstats)
  6372. {
  6373. struct homun_data *hd;
  6374. struct s_homunculus_db *db;
  6375. struct s_homunculus *hom;
  6376. int lv, min, max, evo;
  6377. nullpo_retr(-1, sd);
  6378. if ( !hom_is_active(sd->hd) ) {
  6379. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6380. return -1;
  6381. }
  6382. hd = sd->hd;
  6383. hom = &hd->homunculus;
  6384. db = hd->homunculusDB;
  6385. lv = hom->level;
  6386. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6387. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6388. clif_displaymessage(fd, atcmd_output);
  6389. lv--; //Since the first increase is at level 2.
  6390. evo = (hom->class_ == db->evo_class);
  6391. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6392. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6393. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6394. clif_displaymessage(fd, atcmd_output);
  6395. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6396. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6397. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6398. clif_displaymessage(fd, atcmd_output);
  6399. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6400. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6401. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6402. clif_displaymessage(fd, atcmd_output);
  6403. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6404. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6405. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6406. clif_displaymessage(fd, atcmd_output);
  6407. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6408. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6409. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6410. clif_displaymessage(fd, atcmd_output);
  6411. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6412. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6413. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6414. clif_displaymessage(fd, atcmd_output);
  6415. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6416. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6417. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6418. clif_displaymessage(fd, atcmd_output);
  6419. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6420. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6421. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6422. clif_displaymessage(fd, atcmd_output);
  6423. return 0;
  6424. }
  6425. ACMD_FUNC(homshuffle)
  6426. {
  6427. nullpo_retr(-1, sd);
  6428. if(!sd->hd)
  6429. return -1; // nothing to do
  6430. if(!hom_shuffle(sd->hd))
  6431. return -1;
  6432. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6433. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6434. return 0;
  6435. }
  6436. /*==========================================
  6437. * Show Items DB Info v 1.0
  6438. * originally by [Lupus]
  6439. *------------------------------------------*/
  6440. ACMD_FUNC(iteminfo)
  6441. {
  6442. struct item_data *item_array[MAX_SEARCH];
  6443. int i, count = 1;
  6444. if (!message || !*message) {
  6445. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6446. return -1;
  6447. }
  6448. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6449. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6450. if (!count) {
  6451. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6452. return -1;
  6453. }
  6454. if (count > MAX_SEARCH) {
  6455. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6456. clif_displaymessage(fd, atcmd_output);
  6457. count = MAX_SEARCH;
  6458. }
  6459. for (i = 0; i < count; i++) {
  6460. struct item_data * item_data = item_array[i];
  6461. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%hu) Type: %s | Extra Effect: %s
  6462. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6463. (item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((enum e_item_ammo)item_data->look),
  6464. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6465. );
  6466. clif_displaymessage(fd, atcmd_output);
  6467. 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
  6468. clif_displaymessage(fd, atcmd_output);
  6469. if (item_data->maxchance == -1)
  6470. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6471. else if (!battle_config.atcommand_mobinfo_type) {
  6472. if (item_data->maxchance)
  6473. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6474. else
  6475. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6476. }
  6477. clif_displaymessage(fd, atcmd_output);
  6478. }
  6479. return 0;
  6480. }
  6481. /*==========================================
  6482. * Show who drops the item.
  6483. *------------------------------------------*/
  6484. ACMD_FUNC(whodrops)
  6485. {
  6486. struct item_data *item_data, *item_array[MAX_SEARCH];
  6487. int i,j, count = 1;
  6488. if (!message || !*message) {
  6489. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6490. return -1;
  6491. }
  6492. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6493. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6494. if (!count) {
  6495. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6496. return -1;
  6497. }
  6498. if (count > MAX_SEARCH) {
  6499. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6500. clif_displaymessage(fd, atcmd_output);
  6501. count = MAX_SEARCH;
  6502. }
  6503. for (i = 0; i < count; i++) {
  6504. item_data = item_array[i];
  6505. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%hu)
  6506. clif_displaymessage(fd, atcmd_output);
  6507. if (item_data->mob[0].chance == 0) {
  6508. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6509. clif_displaymessage(fd, atcmd_output);
  6510. } else {
  6511. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6512. clif_displaymessage(fd, atcmd_output);
  6513. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6514. {
  6515. int dropchance = item_data->mob[j].chance;
  6516. #ifdef RENEWAL_DROP
  6517. if( battle_config.atcommand_mobinfo_type )
  6518. 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;
  6519. #endif
  6520. #ifdef VIP_ENABLE
  6521. // Display item rate increase for VIP.
  6522. if (pc_isvip(sd) && battle_config.vip_drop_increase)
  6523. dropchance += battle_config.vip_drop_increase;
  6524. #endif
  6525. sprintf(atcmd_output, "- %s (%d): %02.02f%%", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].id, dropchance/100.);
  6526. clif_displaymessage(fd, atcmd_output);
  6527. }
  6528. }
  6529. }
  6530. return 0;
  6531. }
  6532. ACMD_FUNC(whereis)
  6533. {
  6534. struct mob_db *mob_array[MAX_SEARCH];
  6535. int count;
  6536. int i, j, k;
  6537. if (!message || !*message) {
  6538. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6539. return -1;
  6540. }
  6541. // If monster identifier/name argument is a name
  6542. if ((i = mobdb_checkid(atoi(message))))
  6543. {
  6544. mob_array[0] = mob_db(i);
  6545. count = 1;
  6546. } else
  6547. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6548. if (!count) {
  6549. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6550. return -1;
  6551. }
  6552. if (count > MAX_SEARCH) {
  6553. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6554. clif_displaymessage(fd, atcmd_output);
  6555. count = MAX_SEARCH;
  6556. }
  6557. for (k = 0; k < count; k++) {
  6558. struct mob_db *mob = mob_array[k];
  6559. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6560. clif_displaymessage(fd, atcmd_output);
  6561. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6562. {
  6563. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6564. if (j < 0) continue;
  6565. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6566. clif_displaymessage(fd, atcmd_output);
  6567. }
  6568. if (i == 0)
  6569. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6570. }
  6571. return 0;
  6572. }
  6573. ACMD_FUNC(version)
  6574. {
  6575. pc_show_version(sd);
  6576. return 0;
  6577. }
  6578. /*==========================================
  6579. * @mutearea by MouseJstr
  6580. *------------------------------------------*/
  6581. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6582. {
  6583. int time, id;
  6584. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6585. if (pl_sd == NULL)
  6586. return 0;
  6587. id = va_arg(ap, int);
  6588. time = va_arg(ap, int);
  6589. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6590. pl_sd->status.manner -= time;
  6591. if (pl_sd->status.manner < 0)
  6592. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6593. else
  6594. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6595. }
  6596. return 0;
  6597. }
  6598. ACMD_FUNC(mutearea)
  6599. {
  6600. int time;
  6601. nullpo_ret(sd);
  6602. if (!message || !*message) {
  6603. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6604. return -1;
  6605. }
  6606. time = atoi(message);
  6607. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6608. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6609. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6610. return 0;
  6611. }
  6612. ACMD_FUNC(rates)
  6613. {
  6614. char buf[CHAT_SIZE_MAX];
  6615. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6616. nullpo_ret(sd);
  6617. memset(buf, '\0', sizeof(buf));
  6618. #ifdef VIP_ENABLE
  6619. // Display EXP and item rate increase for VIP.
  6620. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6621. base_exp_rate += battle_config.vip_base_exp_increase;
  6622. job_exp_rate += battle_config.vip_job_exp_increase;
  6623. item_rate += battle_config.vip_drop_increase;
  6624. }
  6625. #endif
  6626. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6627. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6628. clif_displaymessage(fd, buf);
  6629. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6630. (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.);
  6631. clif_displaymessage(fd, buf);
  6632. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6633. (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.);
  6634. clif_displaymessage(fd, buf);
  6635. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6636. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6637. clif_displaymessage(fd, buf);
  6638. return 0;
  6639. }
  6640. /*==========================================
  6641. * @me by lordalfa
  6642. * => Displays the OUTPUT string on top of the Visible players Heads.
  6643. *------------------------------------------*/
  6644. ACMD_FUNC(me)
  6645. {
  6646. char tempmes[CHAT_SIZE_MAX];
  6647. nullpo_retr(-1, sd);
  6648. memset(tempmes, '\0', sizeof(tempmes));
  6649. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6650. if (sd->sc.cant.chat)
  6651. return -1; //no "chatting" while muted.
  6652. if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
  6653. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6654. return -1;
  6655. }
  6656. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6657. clif_disp_overhead(&sd->bl, atcmd_output);
  6658. return 0;
  6659. }
  6660. /*==========================================
  6661. * @size
  6662. * => Resize your character sprite. [Valaris]
  6663. *------------------------------------------*/
  6664. ACMD_FUNC(size)
  6665. {
  6666. int size = 0;
  6667. nullpo_retr(-1, sd);
  6668. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6669. if(sd->state.size) {
  6670. sd->state.size = SZ_SMALL;
  6671. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6672. }
  6673. sd->state.size = size;
  6674. if( size == SZ_MEDIUM )
  6675. clif_specialeffect(&sd->bl,420,AREA);
  6676. else if( size == SZ_BIG )
  6677. clif_specialeffect(&sd->bl,422,AREA);
  6678. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6679. return 0;
  6680. }
  6681. ACMD_FUNC(sizeall)
  6682. {
  6683. int size;
  6684. struct map_session_data *pl_sd;
  6685. struct s_mapiterator* iter;
  6686. size = atoi(message);
  6687. size = cap_value(size,0,2);
  6688. iter = mapit_getallusers();
  6689. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6690. if( pl_sd->state.size != size ) {
  6691. if( pl_sd->state.size ) {
  6692. pl_sd->state.size = SZ_SMALL;
  6693. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6694. }
  6695. pl_sd->state.size = size;
  6696. if( size == SZ_MEDIUM )
  6697. clif_specialeffect(&pl_sd->bl,420,AREA);
  6698. else if( size == SZ_BIG )
  6699. clif_specialeffect(&pl_sd->bl,422,AREA);
  6700. }
  6701. }
  6702. mapit_free(iter);
  6703. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6704. return 0;
  6705. }
  6706. ACMD_FUNC(sizeguild)
  6707. {
  6708. int size = 0, i;
  6709. char guild[NAME_LENGTH];
  6710. struct map_session_data *pl_sd;
  6711. struct guild *g;
  6712. nullpo_retr(-1, sd);
  6713. memset(guild, '\0', sizeof(guild));
  6714. if( !message || !*message || sscanf(message, "%11d %23[^\n]", &size, guild) < 2 ) {
  6715. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6716. return -1;
  6717. }
  6718. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6719. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6720. return -1;
  6721. }
  6722. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6723. for( i = 0; i < g->max_member; i++ ) {
  6724. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6725. if( pl_sd->state.size ) {
  6726. pl_sd->state.size = SZ_SMALL;
  6727. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6728. }
  6729. pl_sd->state.size = size;
  6730. if( size == SZ_MEDIUM )
  6731. clif_specialeffect(&pl_sd->bl,420,AREA);
  6732. else if( size == SZ_BIG )
  6733. clif_specialeffect(&pl_sd->bl,422,AREA);
  6734. }
  6735. }
  6736. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6737. return 0;
  6738. }
  6739. /*==========================================
  6740. * @monsterignore
  6741. * => Makes monsters ignore you. [Valaris]
  6742. *------------------------------------------*/
  6743. ACMD_FUNC(monsterignore)
  6744. {
  6745. nullpo_retr(-1, sd);
  6746. if (!sd->state.monster_ignore) {
  6747. sd->state.monster_ignore = 1;
  6748. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6749. } else {
  6750. sd->state.monster_ignore = 0;
  6751. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6752. }
  6753. return 0;
  6754. }
  6755. /*==========================================
  6756. * @fakename
  6757. * => Gives your character a fake name. [Valaris]
  6758. *------------------------------------------*/
  6759. ACMD_FUNC(fakename)
  6760. {
  6761. nullpo_retr(-1, sd);
  6762. if( !message || !*message )
  6763. {
  6764. if( sd->fakename[0] )
  6765. {
  6766. sd->fakename[0] = '\0';
  6767. clif_charnameack(0, &sd->bl);
  6768. if (sd->disguise)
  6769. clif_charnameack(sd->fd, &sd->bl);
  6770. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6771. return 0;
  6772. }
  6773. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6774. return -1;
  6775. }
  6776. if( strlen(message) < 2 )
  6777. {
  6778. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6779. return -1;
  6780. }
  6781. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6782. clif_charnameack(0, &sd->bl);
  6783. if (sd->disguise) // Another packet should be sent so the client updates the name for sd
  6784. clif_charnameack(sd->fd, &sd->bl);
  6785. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6786. return 0;
  6787. }
  6788. /*==========================================
  6789. * Ragnarok Resources
  6790. *------------------------------------------*/
  6791. ACMD_FUNC(mapflag) {
  6792. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6793. #define setflag( cmd ) \
  6794. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6795. map[ sd->bl.m ].flag.cmd = flag;\
  6796. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6797. clif_displaymessage(sd->fd,atcmd_output);\
  6798. return 0;\
  6799. }
  6800. char flag_name[100];
  6801. short flag=0,i;
  6802. nullpo_retr(-1, sd);
  6803. memset(flag_name, '\0', sizeof(flag_name));
  6804. if (!message || !*message || (sscanf(message, "%99s %6hd", flag_name, &flag) < 1)) {
  6805. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6806. clif_displaymessage(sd->fd,"----------------------------------");
  6807. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6808. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6809. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6810. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6811. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6812. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6813. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6814. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6815. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6816. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6817. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6818. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6819. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6820. checkflag(nolockon); checkflag(notomb);
  6821. #ifdef ADJUST_SKILL_DAMAGE
  6822. checkflag(skill_damage);
  6823. #endif
  6824. clif_displaymessage(sd->fd," ");
  6825. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6826. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6827. return 1;
  6828. }
  6829. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6830. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6831. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6832. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6833. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6834. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6835. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6836. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6837. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6838. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6839. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6840. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6841. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6842. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6843. setflag(nolockon); setflag(notomb);
  6844. #ifdef ADJUST_SKILL_DAMAGE
  6845. setflag(skill_damage);
  6846. #endif
  6847. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6848. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6849. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6850. clif_displaymessage(sd->fd,"----------------------------------");
  6851. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6852. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6853. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6854. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6855. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6856. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6857. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6858. #ifdef ADJUST_SKILL_DAMAGE
  6859. clif_displaymessage(sd->fd,"skill_damage");
  6860. #endif
  6861. #undef checkflag
  6862. #undef setflag
  6863. return 0;
  6864. }
  6865. /*===================================
  6866. * Remove some messages
  6867. *-----------------------------------*/
  6868. ACMD_FUNC(showexp)
  6869. {
  6870. if (sd->state.showexp) {
  6871. sd->state.showexp = 0;
  6872. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6873. return 0;
  6874. }
  6875. sd->state.showexp = 1;
  6876. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6877. return 0;
  6878. }
  6879. ACMD_FUNC(showzeny)
  6880. {
  6881. if (sd->state.showzeny) {
  6882. sd->state.showzeny = 0;
  6883. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6884. return 0;
  6885. }
  6886. sd->state.showzeny = 1;
  6887. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6888. return 0;
  6889. }
  6890. ACMD_FUNC(showdelay)
  6891. {
  6892. if (sd->state.showdelay) {
  6893. sd->state.showdelay = 0;
  6894. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6895. return 0;
  6896. }
  6897. sd->state.showdelay = 1;
  6898. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6899. return 0;
  6900. }
  6901. /*==========================================
  6902. * Duel organizing functions [LuzZza]
  6903. *
  6904. * @duel [limit|nick] - create a duel
  6905. * @invite <nick> - invite player
  6906. * @accept - accept invitation
  6907. * @reject - reject invitation
  6908. * @leave - leave duel
  6909. *------------------------------------------*/
  6910. ACMD_FUNC(invite)
  6911. {
  6912. unsigned int did = sd->duel_group;
  6913. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6914. if(did == 0) {
  6915. // "Duel: @invite without @duel."
  6916. clif_displaymessage(fd, msg_txt(sd,350));
  6917. return 0;
  6918. }
  6919. if(duel_list[did].max_players_limit > 0 &&
  6920. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6921. // "Duel: Limit of players is reached."
  6922. clif_displaymessage(fd, msg_txt(sd,351));
  6923. return 0;
  6924. }
  6925. if(target_sd == NULL) {
  6926. // "Duel: Player not found."
  6927. clif_displaymessage(fd, msg_txt(sd,352));
  6928. return 0;
  6929. }
  6930. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6931. // "Duel: Player already in duel."
  6932. clif_displaymessage(fd, msg_txt(sd,353));
  6933. return 0;
  6934. }
  6935. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6936. {
  6937. sprintf(atcmd_output, msg_txt(sd,364), message);
  6938. clif_displaymessage(fd, atcmd_output);
  6939. return 0;
  6940. }
  6941. duel_invite(did, sd, target_sd);
  6942. // "Duel: Invitation has been sent."
  6943. clif_displaymessage(fd, msg_txt(sd,354));
  6944. return 0;
  6945. }
  6946. ACMD_FUNC(duel)
  6947. {
  6948. unsigned int maxpl = 0;
  6949. if(sd->duel_group > 0) {
  6950. duel_showinfo(sd->duel_group, sd);
  6951. return 0;
  6952. }
  6953. if(sd->duel_invite > 0) {
  6954. // "Duel: @duel without @reject."
  6955. clif_displaymessage(fd, msg_txt(sd,355));
  6956. return 0;
  6957. }
  6958. if(!duel_checktime(sd)) {
  6959. char output[CHAT_SIZE_MAX];
  6960. // "Duel: You can take part in duel only one time per %d minutes."
  6961. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6962. clif_displaymessage(fd, output);
  6963. return 0;
  6964. }
  6965. if( message[0] ) {
  6966. if(sscanf(message, "%11u", &maxpl) >= 1) {
  6967. if(maxpl < 2 || maxpl > 65535) {
  6968. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6969. return 0;
  6970. }
  6971. duel_create(sd, maxpl);
  6972. } else {
  6973. struct map_session_data *target_sd;
  6974. target_sd = map_nick2sd((char *)message);
  6975. if(target_sd != NULL) {
  6976. unsigned int newduel;
  6977. if((newduel = duel_create(sd, 2)) != -1) {
  6978. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6979. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6980. return 0;
  6981. }
  6982. duel_invite(newduel, sd, target_sd);
  6983. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6984. }
  6985. } else {
  6986. // "Duel: Player not found."
  6987. clif_displaymessage(fd, msg_txt(sd,352));
  6988. return 0;
  6989. }
  6990. }
  6991. } else
  6992. duel_create(sd, 0);
  6993. return 0;
  6994. }
  6995. ACMD_FUNC(leave)
  6996. {
  6997. if(sd->duel_group <= 0) {
  6998. // "Duel: @leave without @duel."
  6999. clif_displaymessage(fd, msg_txt(sd,358));
  7000. return 0;
  7001. }
  7002. duel_leave(sd->duel_group, sd);
  7003. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  7004. return 0;
  7005. }
  7006. ACMD_FUNC(accept)
  7007. {
  7008. if(!duel_checktime(sd)) {
  7009. char output[CHAT_SIZE_MAX];
  7010. // "Duel: You can take part in duel only one time per %d minutes."
  7011. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  7012. clif_displaymessage(fd, output);
  7013. return 0;
  7014. }
  7015. if(sd->duel_invite <= 0) {
  7016. // "Duel: @accept without invititation."
  7017. clif_displaymessage(fd, msg_txt(sd,360));
  7018. return 0;
  7019. }
  7020. 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 )
  7021. {
  7022. // "Duel: Limit of players is reached."
  7023. clif_displaymessage(fd, msg_txt(sd,351));
  7024. return 0;
  7025. }
  7026. duel_accept(sd->duel_invite, sd);
  7027. // "Duel: Invitation has been accepted."
  7028. clif_displaymessage(fd, msg_txt(sd,361));
  7029. return 0;
  7030. }
  7031. ACMD_FUNC(reject)
  7032. {
  7033. if(sd->duel_invite <= 0) {
  7034. // "Duel: @reject without invititation."
  7035. clif_displaymessage(fd, msg_txt(sd,362));
  7036. return 0;
  7037. }
  7038. duel_reject(sd->duel_invite, sd);
  7039. // "Duel: Invitation has been rejected."
  7040. clif_displaymessage(fd, msg_txt(sd,363));
  7041. return 0;
  7042. }
  7043. /*===================================
  7044. * Cash Points
  7045. *-----------------------------------*/
  7046. ACMD_FUNC(cash)
  7047. {
  7048. char output[128];
  7049. int value;
  7050. int ret=0;
  7051. nullpo_retr(-1, sd);
  7052. if( !message || !*message || (value = atoi(message)) == 0 ) {
  7053. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  7054. return -1;
  7055. }
  7056. parent_cmd = atcommand_checkalias(command+1);
  7057. if( !strcmpi(parent_cmd,"cash") )
  7058. {
  7059. if( value > 0 ) {
  7060. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  7061. // If this option is set, the message is already sent by pc function
  7062. if( !battle_config.cashshop_show_points ){
  7063. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  7064. clif_disp_onlyself(sd, output, strlen(output));
  7065. }
  7066. }
  7067. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7068. } else {
  7069. if (-value > sd->cashPoints) //By command, if cash < value, force it to remove all
  7070. value = -sd->cashPoints;
  7071. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  7072. // If this option is set, the message is already sent by pc function
  7073. if( !battle_config.cashshop_show_points ){
  7074. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  7075. clif_disp_onlyself(sd, output, strlen(output));
  7076. }
  7077. }
  7078. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7079. }
  7080. }
  7081. else
  7082. { // @points
  7083. if( value > 0 ) {
  7084. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  7085. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  7086. clif_disp_onlyself(sd, output, strlen(output));
  7087. }
  7088. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  7089. } else {
  7090. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  7091. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  7092. clif_disp_onlyself(sd, output, strlen(output));
  7093. }
  7094. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  7095. }
  7096. }
  7097. return 0;
  7098. }
  7099. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  7100. ACMD_FUNC(clone)
  7101. {
  7102. int x=0,y=0,flag=0,master=0,i=0;
  7103. struct map_session_data *pl_sd=NULL;
  7104. if (!message || !*message) {
  7105. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  7106. return 0;
  7107. }
  7108. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  7109. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7110. return 0;
  7111. }
  7112. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7113. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  7114. return 0;
  7115. }
  7116. parent_cmd = atcommand_checkalias(command+1);
  7117. if (strcmpi(parent_cmd, "clone") == 0)
  7118. flag = 1;
  7119. else if (strcmpi(parent_cmd, "slaveclone") == 0) {
  7120. flag = 2;
  7121. if(pc_isdead(sd)){
  7122. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  7123. return 0;
  7124. }
  7125. master = sd->bl.id;
  7126. if (battle_config.atc_slave_clone_limit
  7127. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  7128. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  7129. return 0;
  7130. }
  7131. }
  7132. do {
  7133. x = sd->bl.x + (rnd() % 10 - 5);
  7134. y = sd->bl.y + (rnd() % 10 - 5);
  7135. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  7136. if (i >= 10) {
  7137. x = sd->bl.x;
  7138. y = sd->bl.y;
  7139. }
  7140. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  7141. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  7142. return 0;
  7143. }
  7144. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  7145. return 0;
  7146. }
  7147. /*=====================================
  7148. * Autorejecting Invites/Deals [LuzZza]
  7149. * Usage: @noask
  7150. *-------------------------------------*/
  7151. ACMD_FUNC(noask)
  7152. {
  7153. if(sd->state.noask) {
  7154. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  7155. sd->state.noask = 0;
  7156. } else {
  7157. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  7158. sd->state.noask = 1;
  7159. }
  7160. return 0;
  7161. }
  7162. /*=====================================
  7163. * Send a @request message to all GMs of lowest_gm_level.
  7164. * Usage: @request <petition>
  7165. *-------------------------------------*/
  7166. ACMD_FUNC(request)
  7167. {
  7168. if (!message || !*message) {
  7169. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  7170. return -1;
  7171. }
  7172. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  7173. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  7174. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  7175. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7176. return 0;
  7177. }
  7178. /*==========================================
  7179. * Feel (SG save map) Reset [HiddenDragon]
  7180. *------------------------------------------*/
  7181. ACMD_FUNC(feelreset)
  7182. {
  7183. pc_resetfeel(sd);
  7184. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7185. return 0;
  7186. }
  7187. /*==========================================
  7188. * AUCTION SYSTEM
  7189. *------------------------------------------*/
  7190. ACMD_FUNC(auction)
  7191. {
  7192. nullpo_ret(sd);
  7193. if (!battle_config.feature_auction) {
  7194. clif_colormes(sd->fd, color_table[COLOR_RED], msg_txt(sd, 517));
  7195. return 0;
  7196. }
  7197. clif_Auction_openwindow(sd);
  7198. return 0;
  7199. }
  7200. /*==========================================
  7201. * Kill Steal Protection
  7202. *------------------------------------------*/
  7203. ACMD_FUNC(ksprotection)
  7204. {
  7205. nullpo_retr(-1,sd);
  7206. if( sd->state.noks ) {
  7207. sd->state.noks = 0;
  7208. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7209. }
  7210. else
  7211. {
  7212. if( !message || !*message || !strcmpi(message, "party") )
  7213. { // Default is Party
  7214. sd->state.noks = 2;
  7215. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7216. }
  7217. else if( !strcmpi(message, "self") )
  7218. {
  7219. sd->state.noks = 1;
  7220. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7221. }
  7222. else if( !strcmpi(message, "guild") )
  7223. {
  7224. sd->state.noks = 3;
  7225. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7226. }
  7227. else
  7228. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7229. }
  7230. return 0;
  7231. }
  7232. /*==========================================
  7233. * Map Kill Steal Protection Setting
  7234. *------------------------------------------*/
  7235. ACMD_FUNC(allowks)
  7236. {
  7237. nullpo_retr(-1,sd);
  7238. if( map[sd->bl.m].flag.allowks ) {
  7239. map[sd->bl.m].flag.allowks = 0;
  7240. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7241. } else {
  7242. map[sd->bl.m].flag.allowks = 1;
  7243. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7244. }
  7245. return 0;
  7246. }
  7247. ACMD_FUNC(resetstat)
  7248. {
  7249. nullpo_retr(-1, sd);
  7250. pc_resetstate(sd);
  7251. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7252. clif_displaymessage(fd, atcmd_output);
  7253. return 0;
  7254. }
  7255. ACMD_FUNC(resetskill)
  7256. {
  7257. nullpo_retr(-1,sd);
  7258. pc_resetskill(sd,1);
  7259. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7260. clif_displaymessage(fd, atcmd_output);
  7261. return 0;
  7262. }
  7263. /*==========================================
  7264. * #storagelist: Displays the items list of a player's storage.
  7265. * #cartlist: Displays contents of target's cart.
  7266. * #itemlist: Displays contents of target's inventory.
  7267. *------------------------------------------*/
  7268. ACMD_FUNC(itemlist)
  7269. {
  7270. int i, j, count, counter;
  7271. const char* location;
  7272. const struct item* items;
  7273. int size;
  7274. StringBuf buf;
  7275. nullpo_retr(-1, sd);
  7276. parent_cmd = atcommand_checkalias(command+1);
  7277. if( strcmp(parent_cmd, "storagelist") == 0 ) {
  7278. location = "storage";
  7279. items = sd->status.storage.items;
  7280. size = sd->storage_size;
  7281. } else if( strcmp(parent_cmd, "cartlist") == 0 ) {
  7282. location = "cart";
  7283. items = sd->status.cart;
  7284. size = MAX_CART;
  7285. } else if( strcmp(parent_cmd, "itemlist") == 0 ) {
  7286. location = "inventory";
  7287. items = sd->status.inventory;
  7288. size = MAX_INVENTORY;
  7289. } else
  7290. return 1;
  7291. StringBuf_Init(&buf);
  7292. count = 0; // total slots occupied
  7293. counter = 0; // total items found
  7294. for( i = 0; i < size; ++i ) {
  7295. const struct item* it = &items[i];
  7296. struct item_data* itd;
  7297. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7298. continue;
  7299. counter += it->amount;
  7300. count++;
  7301. if( count == 1 ) {
  7302. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7303. clif_displaymessage(fd, StringBuf_Value(&buf));
  7304. StringBuf_Clear(&buf);
  7305. }
  7306. if( it->refine )
  7307. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7308. else
  7309. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7310. if( it->equip ) {
  7311. char equipstr[CHAT_SIZE_MAX];
  7312. strcpy(equipstr, msg_txt(sd,1333)); // | Equipped:
  7313. if( it->equip&EQP_GARMENT )
  7314. strcat(equipstr, msg_txt(sd,1334)); // Robe,
  7315. if( it->equip&EQP_ACC_L )
  7316. strcat(equipstr, msg_txt(sd,1335)); // Left Accessory,
  7317. if( it->equip&EQP_ARMOR )
  7318. strcat(equipstr, msg_txt(sd,1336)); // Body/Armor,
  7319. if( (it->equip&EQP_ARMS) == EQP_HAND_R )
  7320. strcat(equipstr, msg_txt(sd,1337)); // Right Hand,
  7321. if( (it->equip&EQP_ARMS) == EQP_HAND_L )
  7322. strcat(equipstr, msg_txt(sd,1338)); // Left Hand,
  7323. if( (it->equip&EQP_ARMS) == EQP_ARMS )
  7324. strcat(equipstr, msg_txt(sd,1339)); // Both Hands,
  7325. if( it->equip&EQP_SHOES )
  7326. strcat(equipstr, msg_txt(sd,1340)); // Shoes,
  7327. if( it->equip&EQP_ACC_R )
  7328. strcat(equipstr, msg_txt(sd,1341)); // Right Accessory,
  7329. if( (it->equip&EQP_HELM) == EQP_HEAD_LOW )
  7330. strcat(equipstr, msg_txt(sd,1342)); // Lower Head,
  7331. if( (it->equip&EQP_HELM) == EQP_HEAD_TOP )
  7332. strcat(equipstr, msg_txt(sd,1343)); // Top Head,
  7333. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7334. strcat(equipstr, msg_txt(sd,1344)); // Top/Lower Head,
  7335. if( (it->equip&EQP_HELM) == EQP_HEAD_MID )
  7336. strcat(equipstr, msg_txt(sd,1345)); // Mid Head,
  7337. if( (it->equip&EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7338. strcat(equipstr, msg_txt(sd,1346)); // Mid/Lower Head,
  7339. if( (it->equip&EQP_HELM) == EQP_HELM )
  7340. strcat(equipstr, msg_txt(sd,1347)); // Top/Mid/Lower Head,
  7341. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_LOW )
  7342. strcat(equipstr, msg_txt(sd,518));
  7343. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_TOP )
  7344. strcat(equipstr, msg_txt(sd,519));
  7345. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_TOP) )
  7346. strcat(equipstr, msg_txt(sd,520));
  7347. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HEAD_MID )
  7348. strcat(equipstr, msg_txt(sd,521));
  7349. if( (it->equip&EQP_COSTUME_HELM) == (EQP_COSTUME_HEAD_LOW|EQP_COSTUME_HEAD_MID) )
  7350. strcat(equipstr, msg_txt(sd,522));
  7351. if( (it->equip&EQP_COSTUME_HELM) == EQP_COSTUME_HELM )
  7352. strcat(equipstr, msg_txt(sd,523));
  7353. if( it->equip&EQP_COSTUME_GARMENT )
  7354. strcat(equipstr, msg_txt(sd,524));
  7355. //if( it->equip&EQP_COSTUME_FLOOR )
  7356. //strcat(equipstr, msg_txt(sd,525));
  7357. if( it->equip&EQP_AMMO )
  7358. strcat(equipstr, msg_txt(sd,526));
  7359. if( it->equip&EQP_SHADOW_ARMOR )
  7360. strcat(equipstr, msg_txt(sd,527));
  7361. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_WEAPON )
  7362. strcat(equipstr, msg_txt(sd,528));
  7363. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_SHIELD )
  7364. strcat(equipstr, msg_txt(sd,529));
  7365. if( (it->equip&EQP_SHADOW_ARMS) == EQP_SHADOW_ARMS )
  7366. strcat(equipstr, msg_txt(sd,530));
  7367. if( it->equip&EQP_SHADOW_SHOES )
  7368. strcat(equipstr, msg_txt(sd,531));
  7369. if( it->equip&EQP_SHADOW_ACC_R )
  7370. strcat(equipstr, msg_txt(sd,532));
  7371. if( it->equip&EQP_SHADOW_ACC_L )
  7372. strcat(equipstr, msg_txt(sd,533));
  7373. // remove final ', '
  7374. equipstr[strlen(equipstr) - 2] = '\0';
  7375. StringBuf_AppendStr(&buf, equipstr);
  7376. }
  7377. clif_displaymessage(fd, StringBuf_Value(&buf));
  7378. StringBuf_Clear(&buf);
  7379. if( it->card[0] == CARD0_PET ) { // pet egg
  7380. if (it->card[3])
  7381. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7382. else
  7383. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7384. } else if(it->card[0] == CARD0_FORGE) { // forged item
  7385. 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)
  7386. } else if(it->card[0] == CARD0_CREATE) { // created item
  7387. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7388. } else { // normal item
  7389. int counter2 = 0;
  7390. for( j = 0; j < itd->slot; ++j ) {
  7391. struct item_data* card;
  7392. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7393. continue;
  7394. counter2++;
  7395. if( counter2 == 1 )
  7396. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7397. if( counter2 != 1 )
  7398. StringBuf_AppendStr(&buf, ", ");
  7399. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7400. }
  7401. if( counter2 > 0 )
  7402. StringBuf_AppendStr(&buf, ")");
  7403. }
  7404. if( StringBuf_Length(&buf) > 0 )
  7405. clif_displaymessage(fd, StringBuf_Value(&buf));
  7406. StringBuf_Clear(&buf);
  7407. }
  7408. if( count == 0 )
  7409. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7410. else
  7411. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7412. clif_displaymessage(fd, StringBuf_Value(&buf));
  7413. StringBuf_Destroy(&buf);
  7414. return 0;
  7415. }
  7416. ACMD_FUNC(stats)
  7417. {
  7418. char job_jobname[100];
  7419. char output[CHAT_SIZE_MAX];
  7420. int i;
  7421. struct {
  7422. const char* format;
  7423. int value;
  7424. } output_table[] = {
  7425. { "Base Level - %d", 0 },
  7426. { NULL, 0 },
  7427. { "Hp - %d", 0 },
  7428. { "MaxHp - %d", 0 },
  7429. { "Sp - %d", 0 },
  7430. { "MaxSp - %d", 0 },
  7431. { "Str - %3d", 0 },
  7432. { "Agi - %3d", 0 },
  7433. { "Vit - %3d", 0 },
  7434. { "Int - %3d", 0 },
  7435. { "Dex - %3d", 0 },
  7436. { "Luk - %3d", 0 },
  7437. { "Zeny - %d", 0 },
  7438. { "Free SK Points - %d", 0 },
  7439. { "JobChangeLvl (2nd) - %d", 0 },
  7440. { "JobChangeLvl (3rd) - %d", 0 },
  7441. { NULL, 0 }
  7442. };
  7443. memset(job_jobname, '\0', sizeof(job_jobname));
  7444. memset(output, '\0', sizeof(output));
  7445. //direct array initialization with variables is not standard C compliant.
  7446. output_table[0].value = sd->status.base_level;
  7447. output_table[1].format = job_jobname;
  7448. output_table[1].value = sd->status.job_level;
  7449. output_table[2].value = sd->status.hp;
  7450. output_table[3].value = sd->status.max_hp;
  7451. output_table[4].value = sd->status.sp;
  7452. output_table[5].value = sd->status.max_sp;
  7453. output_table[6].value = sd->status.str;
  7454. output_table[7].value = sd->status.agi;
  7455. output_table[8].value = sd->status.vit;
  7456. output_table[9].value = sd->status.int_;
  7457. output_table[10].value = sd->status.dex;
  7458. output_table[11].value = sd->status.luk;
  7459. output_table[12].value = sd->status.zeny;
  7460. output_table[13].value = sd->status.skill_point;
  7461. output_table[14].value = sd->change_level_2nd;
  7462. output_table[15].value = sd->change_level_3rd;
  7463. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7464. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7465. clif_displaymessage(fd, output);
  7466. for (i = 0; output_table[i].format != NULL; i++) {
  7467. sprintf(output, output_table[i].format, output_table[i].value);
  7468. clif_displaymessage(fd, output);
  7469. }
  7470. return 0;
  7471. }
  7472. ACMD_FUNC(delitem)
  7473. {
  7474. char item_name[100];
  7475. unsigned short nameid;
  7476. int amount = 0, total, idx;
  7477. struct item_data* id;
  7478. nullpo_retr(-1, sd);
  7479. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %11d", item_name, &amount) < 2 && sscanf(message, "%99s %11d", item_name, &amount) < 2 ) || amount < 1 )
  7480. {
  7481. 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>).
  7482. return -1;
  7483. }
  7484. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7485. {
  7486. nameid = id->nameid;
  7487. }
  7488. else
  7489. {
  7490. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7491. return -1;
  7492. }
  7493. total = amount;
  7494. // delete items
  7495. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7496. {
  7497. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7498. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7499. {// delete pet
  7500. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7501. }
  7502. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7503. amount-= delamount;
  7504. }
  7505. // notify target
  7506. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7507. clif_displaymessage(sd->fd, atcmd_output);
  7508. // notify source
  7509. if( amount == total )
  7510. {
  7511. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7512. }
  7513. else if( amount )
  7514. {
  7515. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7516. clif_displaymessage(fd, atcmd_output);
  7517. }
  7518. else
  7519. {
  7520. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7521. clif_displaymessage(fd, atcmd_output);
  7522. }
  7523. return 0;
  7524. }
  7525. /*==========================================
  7526. * Custom Fonts
  7527. *------------------------------------------*/
  7528. ACMD_FUNC(font)
  7529. {
  7530. int font_id;
  7531. nullpo_retr(-1,sd);
  7532. font_id = atoi(message);
  7533. if( font_id == 0 ) {
  7534. if( sd->status.font ) {
  7535. sd->status.font = 0;
  7536. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7537. clif_font(sd);
  7538. } else {
  7539. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7540. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7541. }
  7542. } else if( font_id < 0 || font_id > 9 )
  7543. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7544. else if( font_id != sd->status.font ) {
  7545. sd->status.font = font_id;
  7546. clif_font(sd);
  7547. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7548. } else
  7549. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7550. return 0;
  7551. }
  7552. /*==========================================
  7553. * type: 1 = commands (@), 2 = charcommands (#)
  7554. *------------------------------------------*/
  7555. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7556. {
  7557. char line_buff[CHATBOX_SIZE];
  7558. char* cur = line_buff;
  7559. AtCommandInfo* cmd;
  7560. DBIterator *iter = db_iterator(atcommand_db);
  7561. int count = 0;
  7562. memset(line_buff,' ',CHATBOX_SIZE);
  7563. line_buff[CHATBOX_SIZE-1] = 0;
  7564. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7565. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  7566. unsigned int slen = 0;
  7567. switch( type ) {
  7568. case COMMAND_CHARCOMMAND:
  7569. if( cmd->char_groups[sd->group_pos] == 0 )
  7570. continue;
  7571. break;
  7572. case COMMAND_ATCOMMAND:
  7573. if( cmd->at_groups[sd->group_pos] == 0 )
  7574. continue;
  7575. break;
  7576. default:
  7577. continue;
  7578. }
  7579. slen = strlen(cmd->command);
  7580. // flush the text buffer if this command won't fit into it
  7581. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7582. clif_displaymessage(fd,line_buff);
  7583. cur = line_buff;
  7584. memset(line_buff,' ',CHATBOX_SIZE);
  7585. line_buff[CHATBOX_SIZE-1] = 0;
  7586. }
  7587. memcpy(cur,cmd->command,slen);
  7588. cur += slen+(10-slen%10);
  7589. count++;
  7590. }
  7591. dbi_destroy(iter);
  7592. clif_displaymessage(fd,line_buff);
  7593. if ( atcmd_binding_count ) {
  7594. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7595. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7596. if ( gm_lvl >= ( (type - 1) ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7597. unsigned int slen = strlen(atcmd_binding[i]->command);
  7598. if ( count_bind == 0 ) {
  7599. cur = line_buff;
  7600. memset(line_buff,' ',CHATBOX_SIZE);
  7601. line_buff[CHATBOX_SIZE-1] = 0;
  7602. clif_displaymessage(fd, "-----------------");
  7603. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7604. }
  7605. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7606. clif_displaymessage(fd,line_buff);
  7607. cur = line_buff;
  7608. memset(line_buff,' ',CHATBOX_SIZE);
  7609. line_buff[CHATBOX_SIZE-1] = 0;
  7610. }
  7611. memcpy(cur,atcmd_binding[i]->command,slen);
  7612. cur += slen+(10-slen%10);
  7613. count_bind++;
  7614. }
  7615. }
  7616. if ( count_bind )
  7617. clif_displaymessage(fd,line_buff);// last one
  7618. count += count_bind;
  7619. }
  7620. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7621. clif_displaymessage(fd, atcmd_output);
  7622. return;
  7623. }
  7624. /*==========================================
  7625. * @commands Lists available @ commands to you
  7626. *------------------------------------------*/
  7627. ACMD_FUNC(commands)
  7628. {
  7629. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7630. return 0;
  7631. }
  7632. /*==========================================
  7633. * @charcommands Lists available # commands to you
  7634. *------------------------------------------*/
  7635. ACMD_FUNC(charcommands) {
  7636. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7637. return 0;
  7638. }
  7639. /* for new mounts */
  7640. ACMD_FUNC(mount2) {
  7641. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7642. if (!&sd->sc || !(sd->sc.data[SC_ALL_RIDING])) {
  7643. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7644. sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INVALID_TIMER);
  7645. } else {
  7646. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7647. if (&sd->sc)
  7648. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER);
  7649. }
  7650. return 0;
  7651. }
  7652. ACMD_FUNC(accinfo) {
  7653. char query[NAME_LENGTH];
  7654. char type = 0; // type = 1, get only account name
  7655. if (!message || !*message || strlen(message) > NAME_LENGTH
  7656. || ( sscanf(message, "%23s %c", query, &type) < 1))
  7657. {
  7658. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7659. 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".
  7660. return -1;
  7661. } else if (type != 0) {
  7662. type = type-'0'; //make it int
  7663. if (type != 1) {
  7664. clif_displaymessage(fd, "accinfo : Unknow type specified\n");
  7665. return -1;
  7666. }
  7667. }
  7668. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query, type);
  7669. return 0;
  7670. }
  7671. /* [Ind] */
  7672. ACMD_FUNC(set) {
  7673. char reg[32], val[128];
  7674. struct script_data* data;
  7675. int toset = 0, len;
  7676. bool is_str = false;
  7677. if( !message || !*message || (toset = sscanf(message, "%31s %127[^\n]s", reg, val)) < 1 ) {
  7678. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7679. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7680. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7681. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7682. return -1;
  7683. }
  7684. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7685. if( reg[0] == '.' ) {
  7686. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7687. return -1;
  7688. } else if( reg[0] == '\'' ) {
  7689. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7690. return -1;
  7691. }
  7692. is_str = ( reg[strlen(reg) - 1] == '$' );
  7693. if( ( len = strlen(val) ) > 1 ) {
  7694. if( val[0] == '"' && val[len-1] == '"') {
  7695. val[len-1] = '\0'; //Strip quotes.
  7696. memmove(val, val+1, len-1);
  7697. }
  7698. }
  7699. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7700. if( is_str )
  7701. set_var(sd, reg, (void*) val);
  7702. else
  7703. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7704. }
  7705. CREATE(data, struct script_data,1);
  7706. if( is_str ) {// string variable
  7707. switch( reg[0] ) {
  7708. case '@':
  7709. data->u.str = pc_readregstr(sd, add_str(reg));
  7710. break;
  7711. case '$':
  7712. data->u.str = mapreg_readregstr(add_str(reg));
  7713. break;
  7714. case '#':
  7715. if( reg[1] == '#' )
  7716. data->u.str = pc_readaccountreg2str(sd, add_str(reg));// global
  7717. else
  7718. data->u.str = pc_readaccountregstr(sd, add_str(reg));// local
  7719. break;
  7720. default:
  7721. data->u.str = pc_readglobalreg_str(sd, add_str(reg));
  7722. break;
  7723. }
  7724. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7725. data->type = C_CONSTSTR;
  7726. data->u.str = "";
  7727. } else {// duplicate string
  7728. data->type = C_STR;
  7729. data->u.str = aStrdup(data->u.str);
  7730. }
  7731. } else {// integer variable
  7732. data->type = C_INT;
  7733. switch( reg[0] ) {
  7734. case '@':
  7735. data->u.num = pc_readreg(sd, add_str(reg));
  7736. break;
  7737. case '$':
  7738. data->u.num = mapreg_readreg(add_str(reg));
  7739. break;
  7740. case '#':
  7741. if( reg[1] == '#' )
  7742. data->u.num = pc_readaccountreg2(sd, add_str(reg));// global
  7743. else
  7744. data->u.num = pc_readaccountreg(sd, add_str(reg));// local
  7745. break;
  7746. default:
  7747. data->u.num = pc_readglobalreg(sd, add_str(reg));
  7748. break;
  7749. }
  7750. }
  7751. switch( data->type ) {
  7752. case C_INT:
  7753. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7754. break;
  7755. case C_STR:
  7756. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7757. break;
  7758. case C_CONSTSTR:
  7759. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7760. break;
  7761. default:
  7762. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7763. break;
  7764. }
  7765. clif_displaymessage(fd, atcmd_output);
  7766. if (is_str && data->u.str)
  7767. aFree(data->u.str);
  7768. aFree(data);
  7769. return 0;
  7770. }
  7771. ACMD_FUNC(addperm) {
  7772. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7773. bool add;
  7774. int i;
  7775. parent_cmd = atcommand_checkalias(command+1);
  7776. add = (strcmpi(parent_cmd, "addperm") == 0);
  7777. if( !message || !*message ) {
  7778. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7779. clif_displaymessage(fd, atcmd_output);
  7780. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7781. for( i = 0; i < perm_size; i++ ) {
  7782. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7783. clif_displaymessage(fd, atcmd_output);
  7784. }
  7785. return -1;
  7786. }
  7787. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7788. if( i == perm_size ) {
  7789. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7790. clif_displaymessage(fd, atcmd_output);
  7791. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7792. for( i = 0; i < perm_size; i++ ) {
  7793. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7794. clif_displaymessage(fd, atcmd_output);
  7795. }
  7796. return -1;
  7797. }
  7798. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7799. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7800. clif_displaymessage(fd, atcmd_output);
  7801. return -1;
  7802. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7803. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7804. clif_displaymessage(fd, atcmd_output);
  7805. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7806. clif_displaymessage(fd, atcmd_output);
  7807. for( i = 0; i < perm_size; i++ ) {
  7808. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7809. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7810. clif_displaymessage(fd, atcmd_output);
  7811. }
  7812. }
  7813. return -1;
  7814. }
  7815. if( add )
  7816. sd->permissions |= pc_g_permission_name[i].permission;
  7817. else
  7818. sd->permissions &=~ pc_g_permission_name[i].permission;
  7819. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7820. clif_displaymessage(fd, atcmd_output);
  7821. return 0;
  7822. }
  7823. ACMD_FUNC(unloadnpcfile) {
  7824. if( !message || !*message ) {
  7825. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7826. return -1;
  7827. }
  7828. if( npc_unloadfile(message) )
  7829. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7830. else {
  7831. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7832. return -1;
  7833. }
  7834. return 0;
  7835. }
  7836. ACMD_FUNC(cart) {
  7837. #define MC_CART_MDFY(idx, x) \
  7838. sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
  7839. sd->status.skill[(idx)].lv = (x)?1:0; \
  7840. sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7841. int val = atoi(message);
  7842. bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);
  7843. uint16 sk_idx = 0;
  7844. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7845. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7846. clif_displaymessage(fd, atcmd_output);
  7847. return -1;
  7848. }
  7849. if( val == 0 && !pc_iscarton(sd) ) {
  7850. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7851. return -1;
  7852. }
  7853. if (!(sk_idx = skill_get_index(MC_PUSHCART)))
  7854. return -1;
  7855. if( need_skill ) {
  7856. MC_CART_MDFY(sk_idx,1);
  7857. }
  7858. if( !pc_setcart(sd, val) ) {
  7859. if( need_skill ) {
  7860. MC_CART_MDFY(sk_idx,0);
  7861. }
  7862. return -1;/* @cart failed */
  7863. }
  7864. if( need_skill ) {
  7865. MC_CART_MDFY(sk_idx,0);
  7866. }
  7867. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7868. return 0;
  7869. #undef MC_CART_MDFY
  7870. }
  7871. /* Channel System [Ind] */
  7872. ACMD_FUNC(join){
  7873. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7874. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7875. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7876. clif_displaymessage(fd, atcmd_output);
  7877. return -1;
  7878. }
  7879. return channel_pcjoin(sd, chname, pass);
  7880. }
  7881. /*
  7882. * Display available option for @channel command
  7883. * @command : the name of used command (for alias case)
  7884. */
  7885. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7886. {
  7887. int fd = sd->fd;
  7888. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7889. bool can_create = (can_delete || channel_config.user_chenable);
  7890. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7891. //option create
  7892. if( can_create ) {
  7893. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7894. clif_displaymessage(fd, atcmd_output);
  7895. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7896. }
  7897. //option delete
  7898. if(can_delete){
  7899. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7900. clif_displaymessage(fd, atcmd_output);
  7901. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7902. }
  7903. //option list
  7904. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7905. clif_displaymessage(fd, atcmd_output);
  7906. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7907. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7908. clif_displaymessage(fd, atcmd_output);
  7909. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7910. if( can_create ) {
  7911. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7912. clif_displaymessage(fd, atcmd_output);
  7913. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7914. }
  7915. //option setcolor
  7916. if(can_create){
  7917. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7918. clif_displaymessage(fd, atcmd_output);
  7919. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7920. }
  7921. //option join
  7922. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7923. clif_displaymessage(fd, atcmd_output);
  7924. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7925. //option leave
  7926. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7927. clif_displaymessage(fd, atcmd_output);
  7928. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7929. //option bindto
  7930. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7931. clif_displaymessage(fd, atcmd_output);
  7932. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7933. //option unbind
  7934. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7935. clif_displaymessage(fd, atcmd_output);
  7936. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7937. //option ban/unban/banlist
  7938. if( can_create ) {
  7939. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7940. clif_displaymessage(fd, atcmd_output);
  7941. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7942. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7943. clif_displaymessage(fd, atcmd_output);
  7944. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7945. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7946. clif_displaymessage(fd, atcmd_output);
  7947. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7948. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7949. clif_displaymessage(fd, atcmd_output);
  7950. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7951. }
  7952. //option setopt
  7953. if(can_create){
  7954. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7955. clif_displaymessage(fd, atcmd_output);
  7956. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7957. }
  7958. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7959. clif_displaymessage(fd, atcmd_output);
  7960. }
  7961. ACMD_FUNC(channel) {
  7962. char key[NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[64];
  7963. sub1[0] = sub2[0] = '\0';
  7964. if( !message || !*message || sscanf(message, "%23s %19s %63[^\n]", key, sub1, sub2) < 1 ) {
  7965. atcmd_channel_help(sd,command);
  7966. return 0;
  7967. }
  7968. if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7969. return channel_pcdelete(sd,sub1);
  7970. } else if ( strcmpi(key,"list") == 0 ) {
  7971. return channel_display_list(sd,sub1);
  7972. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7973. return channel_pccolor(sd, sub1, sub2);
  7974. } else if ( strcmpi(key,"join") == 0 ) {
  7975. return channel_pcjoin(sd, sub1, sub2);
  7976. }else if ( strcmpi(key,"leave") == 0 ) {
  7977. return channel_pcleave(sd, sub1);
  7978. } else if ( strcmpi(key,"bindto") == 0 ) {
  7979. return channel_pcbind(sd, sub1);
  7980. } else if ( strcmpi(key,"unbind") == 0 ) {
  7981. return channel_pcunbind(sd);
  7982. } else if ( strcmpi(key,"ban") == 0 ) {
  7983. return channel_pcban(sd,sub1,sub2,0);
  7984. } else if ( strcmpi(key,"banlist") == 0 ) {
  7985. return channel_pcban(sd,sub1,NULL,3);
  7986. } else if ( strcmpi(key,"unban") == 0 ) {
  7987. return channel_pcban(sd,sub1,sub2,1);
  7988. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7989. return channel_pcban(sd,sub1,NULL,2);
  7990. } else {
  7991. char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
  7992. sub3[0] = sub4[0] = '\0';
  7993. sscanf(sub2, "%19s %19s", sub3, sub4);
  7994. if( strcmpi(key,"create") == 0 && ( channel_config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7995. if (sub4[0] != '\0') {
  7996. clif_displaymessage(fd, msg_txt(sd, 1408)); // Channel password may not contain spaces.
  7997. return -1;
  7998. }
  7999. return channel_pccreate(sd,sub1,sub3);
  8000. } else if ( strcmpi(key,"setopt") == 0 ) {
  8001. return channel_pcsetopt(sd,sub1,sub3,sub4);
  8002. }
  8003. atcmd_channel_help(sd,command);
  8004. }
  8005. return 0;
  8006. }
  8007. ACMD_FUNC(fontcolor)
  8008. {
  8009. if( !message || !*message ) {
  8010. channel_display_list(sd,"colors");
  8011. return -1;
  8012. }
  8013. if( strcmpi(message,"Normal") == 0 ) {
  8014. sd->fontcolor = 0;
  8015. } else {
  8016. unsigned char k;
  8017. ARR_FIND(0,channel_config.colors_count,k,( strcmpi(message,channel_config.colors_name[k]) == 0 ));
  8018. if( k == channel_config.colors_count ) {
  8019. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  8020. clif_displaymessage(fd, atcmd_output);
  8021. return -1;
  8022. }
  8023. sd->fontcolor = k;
  8024. }
  8025. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  8026. clif_displaymessage(fd, atcmd_output);
  8027. return 0;
  8028. }
  8029. ACMD_FUNC(langtype)
  8030. {
  8031. char langstr[8];
  8032. int i=0, fail=0;
  8033. memset(langstr, '\0', sizeof(langstr));
  8034. if(sscanf(message, "%3s", langstr) >= 1){
  8035. int lang=0;
  8036. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  8037. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  8038. char output[100];
  8039. pc_setaccountreg(sd, add_str("#langtype"), lang); //For login/char
  8040. sd->langtype = lang;
  8041. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  8042. clif_displaymessage(fd,output);
  8043. return 0;
  8044. } else if (lang != -1) { //defined langage but failed check
  8045. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  8046. return -1;
  8047. }
  8048. }
  8049. //wrong or no entry
  8050. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  8051. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  8052. while(fail != -1){ //out of range
  8053. fail = msg_checklangtype(i,false);
  8054. if(fail == 1)
  8055. clif_displaymessage(fd,msg_langtype2langstr(i));
  8056. i++;
  8057. }
  8058. return -1;
  8059. }
  8060. #ifdef VIP_ENABLE
  8061. ACMD_FUNC(vip) {
  8062. struct map_session_data *pl_sd = NULL;
  8063. char * modif_p;
  8064. int32 vipdifftime = 0;
  8065. time_t now=time(NULL);
  8066. nullpo_retr(-1, sd);
  8067. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8068. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  8069. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  8070. return -1;
  8071. }
  8072. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  8073. modif_p = atcmd_output;
  8074. vipdifftime = (int32)solve_time(modif_p);
  8075. if (vipdifftime == 0) {
  8076. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  8077. 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.
  8078. return -1;
  8079. }
  8080. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  8081. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8082. return -1;
  8083. }
  8084. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  8085. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  8086. return -1;
  8087. }
  8088. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  8089. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  8090. if (pl_sd->vip.time <= now) {
  8091. pl_sd->vip.time = 0;
  8092. pl_sd->vip.enabled = 0;
  8093. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  8094. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  8095. } else {
  8096. int year,month,day,hour,minute,second;
  8097. char timestr[21];
  8098. split_time((int)(pl_sd->vip.time-now),&year,&month,&day,&hour,&minute,&second);
  8099. 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.
  8100. clif_displaymessage(pl_sd->fd,atcmd_output);
  8101. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  8102. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  8103. clif_displaymessage(pl_sd->fd,atcmd_output);
  8104. if (pl_sd != sd) {
  8105. 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.
  8106. clif_displaymessage(fd,atcmd_output);
  8107. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  8108. clif_displaymessage(fd,atcmd_output);
  8109. }
  8110. }
  8111. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, CHRIF_OP_LOGIN_VIP, vipdifftime, 7, 0);
  8112. return 0;
  8113. }
  8114. /** Enable/disable rate info */
  8115. ACMD_FUNC(showrate) {
  8116. nullpo_retr(-1,sd);
  8117. if (!sd->disableshowrate) {
  8118. sprintf(atcmd_output,msg_txt(sd,718)); //Personal rate information is not displayed now.
  8119. sd->disableshowrate = 1;
  8120. }
  8121. else {
  8122. sprintf(atcmd_output,msg_txt(sd,719)); //Personal rate information will be shown.
  8123. sd->disableshowrate = 0;
  8124. }
  8125. clif_displaymessage(fd,atcmd_output);
  8126. return 0;
  8127. }
  8128. #endif
  8129. ACMD_FUNC(fullstrip) {
  8130. int i;
  8131. TBL_PC *tsd;
  8132. nullpo_retr(-1,sd);
  8133. if (!message || !*message) {
  8134. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  8135. return -1;
  8136. }
  8137. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  8138. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  8139. return -1;
  8140. }
  8141. for( i = 0; i < EQI_MAX; i++ ) {
  8142. if( tsd->equip_index[ i ] >= 0 )
  8143. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  8144. }
  8145. return 0;
  8146. }
  8147. ACMD_FUNC(costume) {
  8148. const char* names[] = {
  8149. "Wedding",
  8150. "Xmas",
  8151. "Summer",
  8152. "Hanbok",
  8153. "Oktoberfest",
  8154. };
  8155. const int name2id[] = {
  8156. SC_WEDDING,
  8157. SC_XMAS,
  8158. SC_SUMMER,
  8159. SC_HANBOK,
  8160. SC_OKTOBERFEST
  8161. };
  8162. unsigned short k = 0, len = ARRAYLENGTH(names);
  8163. if( !message || !*message ) {
  8164. for( k = 0; k < len; k++ ) {
  8165. if( sd->sc.data[name2id[k]] ) {
  8166. sprintf(atcmd_output, msg_txt(sd, 727), names[k]); // '%s' Costume removed.
  8167. clif_displaymessage(sd->fd, atcmd_output);
  8168. status_change_end(&sd->bl, (sc_type)name2id[k], INVALID_TIMER);
  8169. return 0;
  8170. }
  8171. }
  8172. clif_displaymessage(sd->fd, msg_txt(sd, 726)); // Available Costumes
  8173. for( k = 0; k < len; k++ ) {
  8174. sprintf(atcmd_output, msg_txt(sd, 725), names[k]); // -- %s
  8175. clif_displaymessage(sd->fd, atcmd_output);
  8176. }
  8177. return -1;
  8178. }
  8179. for( k = 0; k < len; k++ ) {
  8180. if( sd->sc.data[name2id[k]] ) {
  8181. sprintf(atcmd_output, msg_txt(sd, 724), names[k]); // You're already wearing a(n) '%s' costume, type '@costume' to remove it.
  8182. clif_displaymessage(sd->fd, atcmd_output);
  8183. return -1;
  8184. }
  8185. }
  8186. for( k = 0; k < len; k++ )
  8187. if( strcmpi(message, names[k]) == 0 )
  8188. break;
  8189. if( k == len ) {
  8190. sprintf(atcmd_output, msg_txt(sd, 723), message); // '%s' is an unknown costume
  8191. clif_displaymessage(sd->fd, atcmd_output);
  8192. return -1;
  8193. }
  8194. sc_start(&sd->bl, &sd->bl, (sc_type)name2id[k], 100, 0, -1);
  8195. return 0;
  8196. }
  8197. /**
  8198. * Clone other player's equipments
  8199. * Usage: @cloneequip <char_id or "char name">
  8200. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8201. * @author [Cydh], [Antares]
  8202. */
  8203. ACMD_FUNC(cloneequip) {
  8204. struct map_session_data *pl_sd;
  8205. uint32 char_id = 0;
  8206. nullpo_retr(-1, sd);
  8207. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8208. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8209. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8210. return -1;
  8211. }
  8212. if (char_id)
  8213. pl_sd = map_charid2sd(char_id);
  8214. else
  8215. pl_sd = map_nick2sd(atcmd_output);
  8216. if (!pl_sd) {
  8217. clif_displaymessage(fd, msg_txt(sd, 3));
  8218. return -1;
  8219. }
  8220. if (sd == pl_sd) {
  8221. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8222. sprintf(atcmd_output, msg_txt(sd, 734), "equip"); // Cannot clone your own %.
  8223. clif_displaymessage(fd, atcmd_output);
  8224. return -1;
  8225. }
  8226. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8227. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8228. sprintf(atcmd_output, msg_txt(sd, 736), "equip"); // Cannot clone %s from this player.
  8229. clif_displaymessage(fd, atcmd_output);
  8230. return -1;
  8231. }
  8232. else {
  8233. int8 i;
  8234. for (i = 0; i < EQI_MAX; i++) {
  8235. short idx;
  8236. char flag = 0;
  8237. struct item tmp_item;
  8238. if ((idx = pl_sd->equip_index[i]) < 0)
  8239. continue;
  8240. if (i == EQI_AMMO)
  8241. continue;
  8242. if (pc_is_same_equip_index((enum equip_index) i, pl_sd->equip_index, idx))
  8243. continue;
  8244. tmp_item = pl_sd->status.inventory[idx];
  8245. if (itemdb_isspecial(tmp_item.card[0]))
  8246. memset(tmp_item.card, 0, sizeof(tmp_item.card));
  8247. tmp_item.bound = 0;
  8248. tmp_item.expire_time = 0;
  8249. tmp_item.unique_id = 0;
  8250. tmp_item.favorite = 0;
  8251. tmp_item.amount = 1;
  8252. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  8253. clif_additem(sd, 0, 0, flag);
  8254. else
  8255. pc_equipitem(sd, sd->last_addeditem_index, itemdb_equip(tmp_item.nameid));
  8256. }
  8257. }
  8258. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8259. sprintf(atcmd_output, msg_txt(sd, 738), "equip");
  8260. clif_displaymessage(fd, atcmd_output);
  8261. return 0;
  8262. }
  8263. /**
  8264. * Clone other player's statuses/parameters using method same like ACMD_FUNC(param), doesn't use stat point
  8265. * Usage: @clonestat <char_id or "char name">
  8266. * http://rathena.org/board/topic/95076-new-atcommands-suggestion/
  8267. * @author [Cydh], [Antares]
  8268. */
  8269. ACMD_FUNC(clonestat) {
  8270. struct map_session_data *pl_sd;
  8271. uint32 char_id = 0;
  8272. nullpo_retr(-1, sd);
  8273. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8274. if( !message || !*message || (sscanf(message, "%11d", &char_id) < 1 && sscanf(message, "\"%23[^\"]\"", atcmd_output) < 1) ) {
  8275. clif_displaymessage(fd, msg_txt(sd, 735)); // Please enter char_id or \"char name\".
  8276. return -1;
  8277. }
  8278. if (char_id)
  8279. pl_sd = map_charid2sd(char_id);
  8280. else
  8281. pl_sd = map_nick2sd(atcmd_output);
  8282. if (!pl_sd) {
  8283. clif_displaymessage(fd, msg_txt(sd, 3));
  8284. return -1;
  8285. }
  8286. if (sd == pl_sd) {
  8287. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8288. sprintf(atcmd_output, msg_txt(sd, 734), "status"); // Cannot clone your own %.
  8289. clif_displaymessage(fd, atcmd_output);
  8290. return -1;
  8291. }
  8292. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) {
  8293. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8294. sprintf(atcmd_output, msg_txt(sd, 736), "status"); // Cannot clone %s from this player.
  8295. clif_displaymessage(fd, atcmd_output);
  8296. return -1;
  8297. }
  8298. else {
  8299. uint8 i;
  8300. short max_status[6];
  8301. pc_resetstate(sd);
  8302. if (pc_has_permission(sd, PC_PERM_BYPASS_STAT_ONCLONE))
  8303. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  8304. else {
  8305. max_status[0] = pc_maxparameter(sd, PARAM_STR);
  8306. max_status[1] = pc_maxparameter(sd, PARAM_AGI);
  8307. max_status[2] = pc_maxparameter(sd, PARAM_VIT);
  8308. max_status[3] = pc_maxparameter(sd, PARAM_INT);
  8309. max_status[4] = pc_maxparameter(sd, PARAM_DEX);
  8310. max_status[5] = pc_maxparameter(sd, PARAM_LUK);
  8311. }
  8312. #define clonestat_check(cmd,stat)\
  8313. {\
  8314. memset(atcmd_output, '\0', sizeof(atcmd_output));\
  8315. if (pl_sd->status.cmd > max_status[(stat)]) {\
  8316. sprintf(atcmd_output, msg_txt(sd, 737), #cmd, pl_sd->status.cmd, max_status[(stat)]);\
  8317. clif_displaymessage(fd, atcmd_output);\
  8318. sd->status.cmd = max_status[(stat)];\
  8319. }\
  8320. else\
  8321. sd->status.cmd = pl_sd->status.cmd;\
  8322. }
  8323. clonestat_check(str, PARAM_STR);
  8324. clonestat_check(agi, PARAM_AGI);
  8325. clonestat_check(vit, PARAM_VIT);
  8326. clonestat_check(int_, PARAM_INT);
  8327. clonestat_check(dex, PARAM_DEX);
  8328. clonestat_check(luk, PARAM_LUK);
  8329. for (i = 0; i < PARAM_MAX; i++) {
  8330. clif_updatestatus(sd, SP_STR + i);
  8331. clif_updatestatus(sd, SP_USTR + i);
  8332. }
  8333. status_calc_pc(sd, SCO_FORCE);
  8334. }
  8335. memset(atcmd_output, '\0', sizeof(atcmd_output));
  8336. sprintf(atcmd_output, msg_txt(sd, 738), "status");
  8337. clif_displaymessage(fd, atcmd_output);
  8338. #undef clonestat_check
  8339. return 0;
  8340. }
  8341. #include "../custom/atcommand.inc"
  8342. /**
  8343. * Fills the reference of available commands in atcommand DBMap
  8344. **/
  8345. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  8346. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  8347. // Define with restriction
  8348. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  8349. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  8350. void atcommand_basecommands(void) {
  8351. /**
  8352. * Command reference list, place the base of your commands here
  8353. * TODO: List all commands that causing crash
  8354. **/
  8355. AtCommandInfo atcommand_base[] = {
  8356. #include "../custom/atcommand_def.inc"
  8357. ACMD_DEF2R("warp", mapmove, ATCMD_NOCONSOLE),
  8358. ACMD_DEF(where),
  8359. ACMD_DEF(jumpto),
  8360. ACMD_DEF(jump),
  8361. ACMD_DEF(who),
  8362. ACMD_DEF2("who2", who),
  8363. ACMD_DEF2("who3", who),
  8364. ACMD_DEF2("whomap", who),
  8365. ACMD_DEF2("whomap2", who),
  8366. ACMD_DEF2("whomap3", who),
  8367. ACMD_DEF(whogm),
  8368. ACMD_DEF(save),
  8369. ACMD_DEF(load),
  8370. ACMD_DEF(speed),
  8371. ACMD_DEF(storage),
  8372. ACMD_DEF(guildstorage),
  8373. ACMD_DEF(option),
  8374. ACMD_DEF(hide), // + /hide
  8375. ACMD_DEFR(jobchange, ATCMD_NOCONSOLE),
  8376. ACMD_DEF(kill),
  8377. ACMD_DEF(alive),
  8378. ACMD_DEF(kami),
  8379. ACMD_DEF2("kamib", kami),
  8380. ACMD_DEF2("kamic", kami),
  8381. ACMD_DEF2("lkami", kami),
  8382. ACMD_DEF(heal),
  8383. ACMD_DEF(item),
  8384. ACMD_DEF(item2),
  8385. ACMD_DEF2("itembound",item),
  8386. ACMD_DEF2("itembound2",item2),
  8387. ACMD_DEF(itemreset),
  8388. ACMD_DEF(clearstorage),
  8389. ACMD_DEF(cleargstorage),
  8390. ACMD_DEF(clearcart),
  8391. ACMD_DEF2R("blvl", baselevelup, ATCMD_NOCONSOLE),
  8392. ACMD_DEF2("jlvl", joblevelup),
  8393. ACMD_DEF(help),
  8394. ACMD_DEF(pvpoff),
  8395. ACMD_DEF(pvpon),
  8396. ACMD_DEF(gvgoff),
  8397. ACMD_DEF(gvgon),
  8398. ACMD_DEF(model),
  8399. ACMD_DEFR(go, ATCMD_NOCONSOLE),
  8400. ACMD_DEF(monster),
  8401. ACMD_DEF2("monstersmall", monster),
  8402. ACMD_DEF2("monsterbig", monster),
  8403. ACMD_DEF(killmonster),
  8404. ACMD_DEF2("killmonster2", killmonster),
  8405. ACMD_DEF(refine),
  8406. ACMD_DEF(produce),
  8407. ACMD_DEF(memo),
  8408. ACMD_DEF(gat),
  8409. ACMD_DEF(displaystatus),
  8410. ACMD_DEF2("stpoint", statuspoint),
  8411. ACMD_DEF2("skpoint", skillpoint),
  8412. ACMD_DEF(zeny),
  8413. ACMD_DEF2("str", param),
  8414. ACMD_DEF2("agi", param),
  8415. ACMD_DEF2("vit", param),
  8416. ACMD_DEF2("int", param),
  8417. ACMD_DEF2("dex", param),
  8418. ACMD_DEF2("luk", param),
  8419. ACMD_DEF2("glvl", guildlevelup),
  8420. ACMD_DEF(makeegg),
  8421. ACMD_DEF(hatch),
  8422. ACMD_DEF(petfriendly),
  8423. ACMD_DEF(pethungry),
  8424. ACMD_DEF(petrename),
  8425. ACMD_DEF(recall), // + /recall
  8426. ACMD_DEF(night),
  8427. ACMD_DEF(day),
  8428. ACMD_DEF(doom),
  8429. ACMD_DEF(doommap),
  8430. ACMD_DEF(raise),
  8431. ACMD_DEF(raisemap),
  8432. ACMD_DEFR(kick,ATCMD_NOAUTOTRADE), // + right click menu for GM "(name) force to quit"
  8433. ACMD_DEF(kickall),
  8434. ACMD_DEF(allskill),
  8435. ACMD_DEF(questskill),
  8436. ACMD_DEF(lostskill),
  8437. ACMD_DEF(spiritball),
  8438. ACMD_DEF(party),
  8439. ACMD_DEF(guild),
  8440. ACMD_DEF(breakguild),
  8441. ACMD_DEF(agitstart),
  8442. ACMD_DEF(agitend),
  8443. ACMD_DEF(mapexit),
  8444. ACMD_DEF(idsearch),
  8445. ACMD_DEF(broadcast), // + /b and /nb
  8446. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8447. ACMD_DEF(recallall),
  8448. ACMD_DEFR(reload,ATCMD_NOSCRIPT),
  8449. ACMD_DEF2("reloaditemdb", reload),
  8450. ACMD_DEF2("reloadmobdb", reload),
  8451. ACMD_DEF2("reloadskilldb", reload),
  8452. ACMD_DEF2R("reloadscript", reload, ATCMD_NOSCRIPT),
  8453. ACMD_DEF2("reloadatcommand", reload),
  8454. ACMD_DEF2("reloadbattleconf", reload),
  8455. ACMD_DEF2("reloadstatusdb", reload),
  8456. ACMD_DEF2("reloadpcdb", reload),
  8457. ACMD_DEF2("reloadmotd", reload),
  8458. ACMD_DEF2("reloadquestdb", reload),
  8459. ACMD_DEF2("reloadmsgconf", reload),
  8460. ACMD_DEF2("reloadpacketdb", reload),
  8461. ACMD_DEF2("reloadinstancedb", reload),
  8462. ACMD_DEF(partysharelvl),
  8463. ACMD_DEF(mapinfo),
  8464. ACMD_DEF(dye),
  8465. ACMD_DEF2("hairstyle", hair_style),
  8466. ACMD_DEF2("haircolor", hair_color),
  8467. ACMD_DEF2("allstats", stat_all),
  8468. ACMD_DEF2("block", char_block),
  8469. ACMD_DEF2("ban", char_ban),
  8470. ACMD_DEF2("unblock", char_unblock),
  8471. ACMD_DEF2("unban", char_unban),
  8472. ACMD_DEF2("charban", char_ban),
  8473. ACMD_DEF2("charunban", char_unban),
  8474. ACMD_DEF2("mount", mount_peco),
  8475. ACMD_DEF(guildspy),
  8476. ACMD_DEF(partyspy),
  8477. ACMD_DEF(repairall),
  8478. ACMD_DEF(guildrecall),
  8479. ACMD_DEF(partyrecall),
  8480. ACMD_DEF(nuke),
  8481. ACMD_DEF(shownpc),
  8482. ACMD_DEF(hidenpc),
  8483. ACMD_DEF(loadnpc),
  8484. ACMD_DEF(unloadnpc),
  8485. ACMD_DEF2("time", servertime),
  8486. ACMD_DEF(jail),
  8487. ACMD_DEF(unjail),
  8488. ACMD_DEF(jailfor),
  8489. ACMD_DEF(jailtime),
  8490. ACMD_DEF(disguise),
  8491. ACMD_DEF(undisguise),
  8492. ACMD_DEF(email),
  8493. ACMD_DEF(effect),
  8494. ACMD_DEF(follow),
  8495. ACMD_DEF(addwarp),
  8496. ACMD_DEF(skillon),
  8497. ACMD_DEF(skilloff),
  8498. ACMD_DEF(killer),
  8499. ACMD_DEF(npcmove),
  8500. ACMD_DEF(killable),
  8501. ACMD_DEF(dropall),
  8502. ACMD_DEF(storeall),
  8503. ACMD_DEF(skillid),
  8504. ACMD_DEF(useskill),
  8505. ACMD_DEF(displayskill),
  8506. ACMD_DEF(snow),
  8507. ACMD_DEF(sakura),
  8508. ACMD_DEF(clouds),
  8509. ACMD_DEF(clouds2),
  8510. ACMD_DEF(fog),
  8511. ACMD_DEF(fireworks),
  8512. ACMD_DEF(leaves),
  8513. ACMD_DEF(summon),
  8514. ACMD_DEF(adjgroup),
  8515. ACMD_DEF(trade),
  8516. ACMD_DEF(send),
  8517. ACMD_DEF(setbattleflag),
  8518. ACMD_DEF(unmute),
  8519. ACMD_DEF(clearweather),
  8520. ACMD_DEF(uptime),
  8521. ACMD_DEF(changesex),
  8522. ACMD_DEF(changecharsex),
  8523. ACMD_DEF(mute),
  8524. ACMD_DEF(refresh),
  8525. ACMD_DEF(refreshall),
  8526. ACMD_DEF(identify),
  8527. ACMD_DEF(identifyall),
  8528. ACMD_DEF(gmotd),
  8529. ACMD_DEF(misceffect),
  8530. ACMD_DEF(mobsearch),
  8531. ACMD_DEF(cleanmap),
  8532. ACMD_DEF(cleanarea),
  8533. ACMD_DEF(npctalk),
  8534. ACMD_DEF(pettalk),
  8535. ACMD_DEF(users),
  8536. ACMD_DEF(reset),
  8537. ACMD_DEF(skilltree),
  8538. ACMD_DEF(marry),
  8539. ACMD_DEF(divorce),
  8540. ACMD_DEF(sound),
  8541. ACMD_DEF(undisguiseall),
  8542. ACMD_DEF(disguiseall),
  8543. ACMD_DEF(changelook),
  8544. ACMD_DEF(autoloot),
  8545. ACMD_DEF2("alootid", autolootitem),
  8546. ACMD_DEF(autoloottype),
  8547. ACMD_DEF(mobinfo),
  8548. ACMD_DEF(exp),
  8549. ACMD_DEF(version),
  8550. ACMD_DEF(mutearea),
  8551. ACMD_DEF(rates),
  8552. ACMD_DEF(iteminfo),
  8553. ACMD_DEF(whodrops),
  8554. ACMD_DEF(whereis),
  8555. ACMD_DEF(mapflag),
  8556. ACMD_DEF(me),
  8557. ACMD_DEF(monsterignore),
  8558. ACMD_DEF(fakename),
  8559. ACMD_DEF(size),
  8560. ACMD_DEF(showexp),
  8561. ACMD_DEF(showzeny),
  8562. ACMD_DEF(showdelay),
  8563. ACMD_DEF(autotrade),
  8564. ACMD_DEF(changegm),
  8565. ACMD_DEF(changeleader),
  8566. ACMD_DEF(partyoption),
  8567. ACMD_DEF(invite),
  8568. ACMD_DEF(duel),
  8569. ACMD_DEF(leave),
  8570. ACMD_DEF(accept),
  8571. ACMD_DEF(reject),
  8572. ACMD_DEF(clone),
  8573. ACMD_DEF2("slaveclone", clone),
  8574. ACMD_DEF2("evilclone", clone),
  8575. ACMD_DEF(tonpc),
  8576. ACMD_DEF(commands),
  8577. ACMD_DEF(noask),
  8578. ACMD_DEF(request),
  8579. ACMD_DEF(homlevel),
  8580. ACMD_DEF(homevolution),
  8581. ACMD_DEF(hommutate),
  8582. ACMD_DEF(makehomun),
  8583. ACMD_DEF(homfriendly),
  8584. ACMD_DEF(homhungry),
  8585. ACMD_DEF(homtalk),
  8586. ACMD_DEF(hominfo),
  8587. ACMD_DEF(homstats),
  8588. ACMD_DEF(homshuffle),
  8589. ACMD_DEF(showmobs),
  8590. ACMD_DEF(feelreset),
  8591. ACMD_DEF(auction),
  8592. ACMD_DEF(mail),
  8593. ACMD_DEF2("noks", ksprotection),
  8594. ACMD_DEF(allowks),
  8595. ACMD_DEF(cash),
  8596. ACMD_DEF2("points", cash),
  8597. ACMD_DEF(agitstart2),
  8598. ACMD_DEF(agitend2),
  8599. ACMD_DEF(resetskill),
  8600. ACMD_DEF(resetstat),
  8601. ACMD_DEF2("storagelist", itemlist),
  8602. ACMD_DEF2("cartlist", itemlist),
  8603. ACMD_DEF2("itemlist", itemlist),
  8604. ACMD_DEF(stats),
  8605. ACMD_DEF(delitem),
  8606. ACMD_DEF(charcommands),
  8607. ACMD_DEF(font),
  8608. ACMD_DEF(accinfo),
  8609. ACMD_DEF(set),
  8610. ACMD_DEF(undisguiseguild),
  8611. ACMD_DEF(disguiseguild),
  8612. ACMD_DEF(sizeall),
  8613. ACMD_DEF(sizeguild),
  8614. ACMD_DEF(addperm),
  8615. ACMD_DEF2("rmvperm", addperm),
  8616. ACMD_DEF(unloadnpcfile),
  8617. ACMD_DEF(cart),
  8618. ACMD_DEF(mount2),
  8619. ACMD_DEF(join),
  8620. ACMD_DEF(channel),
  8621. ACMD_DEF(fontcolor),
  8622. ACMD_DEF(langtype),
  8623. #ifdef VIP_ENABLE
  8624. ACMD_DEF(vip),
  8625. ACMD_DEF(showrate),
  8626. #endif
  8627. ACMD_DEF(fullstrip),
  8628. ACMD_DEF(costume),
  8629. ACMD_DEF(cloneequip),
  8630. ACMD_DEF(clonestat),
  8631. };
  8632. AtCommandInfo* atcommand;
  8633. int i;
  8634. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8635. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8636. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8637. continue;
  8638. }
  8639. CREATE(atcommand, AtCommandInfo, 1);
  8640. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8641. atcommand->func = atcommand_base[i].func;
  8642. atcommand->restriction = atcommand_base[i].restriction;
  8643. strdb_put(atcommand_db, atcommand->command, atcommand);
  8644. }
  8645. return;
  8646. }
  8647. /*==========================================
  8648. * Command lookup functions
  8649. *------------------------------------------*/
  8650. bool atcommand_exists(const char* name)
  8651. {
  8652. return strdb_exists(atcommand_db, name);
  8653. }
  8654. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8655. {
  8656. if (strdb_exists(atcommand_db, name))
  8657. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8658. return NULL;
  8659. }
  8660. static const char* atcommand_checkalias(const char *aliasname)
  8661. {
  8662. AliasInfo *alias_info = NULL;
  8663. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8664. return alias_info->command->command;
  8665. return aliasname;
  8666. }
  8667. /// AtCommand suggestion
  8668. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8669. DBIterator* atcommand_iter;
  8670. DBIterator* alias_iter;
  8671. AtCommandInfo* command_info = NULL;
  8672. AliasInfo* alias_info = NULL;
  8673. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8674. char* full_match[MAX_SUGGESTIONS];
  8675. char* suggestions[MAX_SUGGESTIONS];
  8676. char* match;
  8677. int prefix_count = 0, full_count = 0;
  8678. bool can_use;
  8679. if (!battle_config.atcommand_suggestions_enabled)
  8680. return;
  8681. atcommand_iter = db_iterator(atcommand_db);
  8682. alias_iter = db_iterator(atcommand_alias_db);
  8683. // Build the matches
  8684. for (command_info = (AtCommandInfo*)dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = (AtCommandInfo*)dbi_next(atcommand_iter)) {
  8685. match = strstr(command_info->command, name);
  8686. can_use = pc_can_use_command(sd, command_info->command, type);
  8687. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8688. suggestions[prefix_count] = command_info->command;
  8689. ++prefix_count;
  8690. }
  8691. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8692. full_match[full_count] = command_info->command;
  8693. ++full_count;
  8694. }
  8695. }
  8696. for (alias_info = (AliasInfo *)dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = (AliasInfo *)dbi_next(alias_iter)) {
  8697. match = strstr(alias_info->alias, name);
  8698. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8699. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8700. suggestions[prefix_count] = alias_info->alias;
  8701. ++prefix_count;
  8702. }
  8703. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8704. full_match[full_count] = alias_info->alias;
  8705. ++full_count;
  8706. }
  8707. }
  8708. if ((full_count+prefix_count) > 0) {
  8709. char buffer[512];
  8710. int i;
  8711. // Merge full match and prefix match results
  8712. if (prefix_count < MAX_SUGGESTIONS) {
  8713. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8714. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8715. }
  8716. // Build the suggestion string
  8717. strcpy(buffer, msg_txt(sd,205));
  8718. strcat(buffer,"\n");
  8719. for(i=0; i < prefix_count; ++i) {
  8720. strcat(buffer,suggestions[i]);
  8721. strcat(buffer," ");
  8722. }
  8723. clif_displaymessage(sd->fd, buffer);
  8724. }
  8725. dbi_destroy(atcommand_iter);
  8726. dbi_destroy(alias_iter);
  8727. }
  8728. /**
  8729. * Executes an at-command
  8730. * @param fd
  8731. * @param sd
  8732. * @param message
  8733. * @param type
  8734. * 0 : script call (atcommand)
  8735. * 1 : normal player @atcommand
  8736. * 2 : console (admin:@atcommand)
  8737. * 3 : script call (useatcmd)
  8738. */
  8739. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8740. {
  8741. char charname[NAME_LENGTH], charname2[NAME_LENGTH];
  8742. char command[CHAT_SIZE_MAX], params[CHAT_SIZE_MAX];
  8743. char output[CHAT_SIZE_MAX];
  8744. //Reconstructed message
  8745. char atcmd_msg[CHAT_SIZE_MAX];
  8746. TBL_PC * ssd = NULL; //sd for target
  8747. AtCommandInfo * info;
  8748. nullpo_retr(false, sd);
  8749. //Shouldn't happen
  8750. if ( !message || !*message )
  8751. return false;
  8752. //If cannot use atcomamnd while talking with NPC [Kichi]
  8753. if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
  8754. return false;
  8755. //Block NOCHAT but do not display it as a normal message
  8756. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8757. return true;
  8758. // skip 10/11-langtype's codepage indicator, if detected
  8759. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8760. message += 3;
  8761. //Should display as a normal message
  8762. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8763. return false;
  8764. // type value 0|2 = script|console invoked: bypass restrictions
  8765. if ( type == 1 || type == 3) {
  8766. //Commands are disabled on maps flagged as 'nocommand'
  8767. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8768. clif_displaymessage(fd, msg_txt(sd,143));
  8769. return false;
  8770. }
  8771. }
  8772. if (*message == charcommand_symbol) {
  8773. do {
  8774. int x, y, z;
  8775. char params2[CHAT_SIZE_MAX];
  8776. //Checks to see if #command has a name or a name + parameters.
  8777. x = sscanf(message, "%255s \"%23[^\"]\" %255[^\n]", command, charname, params);
  8778. y = sscanf(message, "%255s %23s %255[^\n]", command, charname2, params2);
  8779. //z always has the value of the scan that was successful
  8780. z = ( x > 1 ) ? x : y;
  8781. //#command + name means the sufficient target was used and anything else after
  8782. //can be looked at by the actual command function since most scan to see if the
  8783. //right parameters are used.
  8784. if ( x > 2 ) {
  8785. sprintf(atcmd_msg, "%s %s", command, params);
  8786. break;
  8787. }
  8788. else if ( y > 2 ) {
  8789. sprintf(atcmd_msg, "%s %s", command, params2);
  8790. break;
  8791. }
  8792. //Regardless of what style the #command is used, if it's correct, it will always have
  8793. //this value if there is no parameter. Send it as just the #command
  8794. else if ( z == 2 ) {
  8795. sprintf(atcmd_msg, "%s", command);
  8796. break;
  8797. }
  8798. if( !pc_get_group_level(sd) ) {
  8799. if( x >= 1 || y >= 1 ) { /* we have command */
  8800. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8801. 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 */
  8802. return false;
  8803. } else
  8804. return false;/* display as normal message */
  8805. }
  8806. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8807. clif_displaymessage(fd, output);
  8808. return true;
  8809. } while(0);
  8810. }
  8811. else if (*message == atcommand_symbol) {
  8812. //atcmd_msg is constructed above differently for charcommands
  8813. //it's copied from message if not a charcommand so it can
  8814. //pass through the rest of the code compatible with both symbols
  8815. sprintf(atcmd_msg, "%s", message);
  8816. }
  8817. if (battle_config.idletime_option&IDLE_ATCOMMAND)
  8818. sd->idletime = last_tick;
  8819. //Clearing these to be used once more.
  8820. memset(command, '\0', sizeof(command));
  8821. memset(params, '\0', sizeof(params));
  8822. //check to see if any params exist within this command
  8823. if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
  8824. params[0] = '\0';
  8825. // @commands (script based)
  8826. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8827. struct atcmd_binding_data * binding;
  8828. // Check if the command initiated is a character command
  8829. if (*message == charcommand_symbol &&
  8830. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8831. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8832. clif_displaymessage(fd, output);
  8833. return true;
  8834. }
  8835. // Get atcommand binding
  8836. binding = get_atcommandbind_byname(command);
  8837. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8838. if( binding != NULL && binding->npc_event[0] &&
  8839. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8840. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8841. {
  8842. // Check if self or character invoking; if self == character invoked, then self invoke.
  8843. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8844. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8845. return true;
  8846. }
  8847. }
  8848. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8849. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8850. if (info == NULL) {
  8851. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8852. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8853. clif_displaymessage(fd, output);
  8854. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8855. return true;
  8856. } else
  8857. return false;
  8858. }
  8859. //check restriction
  8860. if (info->restriction) {
  8861. if (info->restriction&ATCMD_NOCONSOLE && type == 2) //console prevent
  8862. return true;
  8863. if (info->restriction&ATCMD_NOSCRIPT && (type == 0 || type == 3)) //scripts prevent
  8864. return true;
  8865. if (info->restriction&ATCMD_NOAUTOTRADE && (type == 0 || type == 3)
  8866. && ((*atcmd_msg == atcommand_symbol && sd && sd->state.autotrade) || (ssd && ssd->state.autotrade)))
  8867. return true;
  8868. }
  8869. // type == 1 : player invoked
  8870. if (type == 1) {
  8871. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8872. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8873. return false;
  8874. }
  8875. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8876. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8877. return true;
  8878. }
  8879. }
  8880. // Check if target is valid only if confirmed that player can use command.
  8881. if (*message == charcommand_symbol &&
  8882. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8883. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8884. clif_displaymessage(fd, output);
  8885. return true;
  8886. }
  8887. //Attempt to use the command
  8888. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8889. {
  8890. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8891. clif_displaymessage(fd, output);
  8892. return true;
  8893. }
  8894. //Log only if successful.
  8895. if ( *atcmd_msg == atcommand_symbol )
  8896. log_atcommand(sd, atcmd_msg);
  8897. else if ( *atcmd_msg == charcommand_symbol )
  8898. log_atcommand(sd, message);
  8899. return true;
  8900. }
  8901. /*==========================================
  8902. *
  8903. *------------------------------------------*/
  8904. static void atcommand_config_read(const char* config_filename)
  8905. {
  8906. config_setting_t *aliases = NULL, *help = NULL;
  8907. const char *symbol = NULL;
  8908. int num_aliases = 0;
  8909. if (conf_read_file(&atcommand_config, config_filename))
  8910. return;
  8911. // Command symbols
  8912. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8913. if (ISPRINT(*symbol) && // no control characters
  8914. *symbol != '/' && // symbol of client commands
  8915. *symbol != '%' && // symbol of party chat
  8916. *symbol != '$' && // symbol of guild chat
  8917. *symbol != charcommand_symbol)
  8918. atcommand_symbol = *symbol;
  8919. }
  8920. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8921. if (ISPRINT(*symbol) && // no control characters
  8922. *symbol != '/' && // symbol of client commands
  8923. *symbol != '%' && // symbol of party chat
  8924. *symbol != '$' && // symbol of guild chat
  8925. *symbol != atcommand_symbol)
  8926. charcommand_symbol = *symbol;
  8927. }
  8928. // Command aliases
  8929. aliases = config_lookup(&atcommand_config, "aliases");
  8930. if (aliases != NULL) {
  8931. int i = 0;
  8932. int count = config_setting_length(aliases);
  8933. for (i = 0; i < count; ++i) {
  8934. config_setting_t *command;
  8935. const char *commandname = NULL;
  8936. int j = 0, alias_count = 0;
  8937. AtCommandInfo *commandinfo = NULL;
  8938. command = config_setting_get_elem(aliases, i);
  8939. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8940. continue;
  8941. commandname = config_setting_name(command);
  8942. if (!atcommand_exists(commandname)) {
  8943. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8944. continue;
  8945. }
  8946. commandinfo = get_atcommandinfo_byname(commandname);
  8947. alias_count = config_setting_length(command);
  8948. for (j = 0; j < alias_count; ++j) {
  8949. const char *alias = config_setting_get_string_elem(command, j);
  8950. if (alias != NULL) {
  8951. AliasInfo *alias_info;
  8952. if (strdb_exists(atcommand_alias_db, alias)) {
  8953. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8954. continue;
  8955. }
  8956. CREATE(alias_info, AliasInfo, 1);
  8957. alias_info->command = commandinfo;
  8958. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8959. strdb_put(atcommand_alias_db, alias, alias_info);
  8960. ++num_aliases;
  8961. }
  8962. }
  8963. }
  8964. }
  8965. // Commands help
  8966. // We only check if all commands exist
  8967. help = config_lookup(&atcommand_config, "help");
  8968. if (help != NULL) {
  8969. int count = config_setting_length(help);
  8970. int i;
  8971. for (i = 0; i < count; ++i) {
  8972. config_setting_t *command;
  8973. const char *commandname;
  8974. command = config_setting_get_elem(help, i);
  8975. commandname = config_setting_name(command);
  8976. if (!atcommand_exists(commandname))
  8977. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8978. }
  8979. }
  8980. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8981. return;
  8982. }
  8983. void atcommand_db_load_groups(int* group_ids) {
  8984. DBIterator *iter = db_iterator(atcommand_db);
  8985. AtCommandInfo* cmd;
  8986. int i;
  8987. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  8988. cmd->at_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  8989. cmd->char_groups = (char*)aMalloc( pc_group_max * sizeof(char) );
  8990. for(i = 0; i < pc_group_max; i++) {
  8991. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8992. cmd->at_groups[i] = 1;
  8993. else
  8994. cmd->at_groups[i] = 0;
  8995. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8996. cmd->char_groups[i] = 1;
  8997. else
  8998. cmd->char_groups[i] = 0;
  8999. }
  9000. }
  9001. dbi_destroy(iter);
  9002. return;
  9003. }
  9004. void atcommand_db_clear(void) {
  9005. if (atcommand_db != NULL) {
  9006. DBIterator *iter = db_iterator(atcommand_db);
  9007. AtCommandInfo* cmd;
  9008. for (cmd = (AtCommandInfo*)dbi_first(iter); dbi_exists(iter); cmd = (AtCommandInfo*)dbi_next(iter)) {
  9009. aFree(cmd->at_groups);
  9010. aFree(cmd->char_groups);
  9011. }
  9012. dbi_destroy(iter);
  9013. db_destroy(atcommand_db);
  9014. }
  9015. if (atcommand_alias_db != NULL)
  9016. db_destroy(atcommand_alias_db);
  9017. config_destroy(&atcommand_config);
  9018. }
  9019. void atcommand_doload(void) {
  9020. atcommand_db_clear();
  9021. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9022. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  9023. atcommand_basecommands(); //fills initial atcommand_db with known commands
  9024. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  9025. }
  9026. void do_init_atcommand(void) {
  9027. atcommand_doload();
  9028. }
  9029. void do_final_atcommand(void) {
  9030. atcommand_db_clear();
  9031. }