atcommand.c 298 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007
  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/core.h"
  8. #include "../common/showmsg.h"
  9. #include "../common/malloc.h"
  10. #include "../common/random.h"
  11. #include "../common/socket.h"
  12. #include "../common/strlib.h"
  13. #include "../common/utils.h"
  14. #include "../common/conf.h"
  15. #include "atcommand.h"
  16. #include "battle.h"
  17. #include "chat.h"
  18. #include "channel.h"
  19. #include "clif.h"
  20. #include "chrif.h"
  21. #include "duel.h"
  22. #include "instance.h"
  23. #include "intif.h"
  24. #include "itemdb.h"
  25. #include "log.h"
  26. #include "map.h"
  27. #include "pc.h"
  28. #include "pc_groups.h" // groupid2name
  29. #include "status.h"
  30. #include "skill.h"
  31. #include "mob.h"
  32. #include "npc.h"
  33. #include "pet.h"
  34. #include "homunculus.h"
  35. #include "mail.h"
  36. #include "mercenary.h"
  37. #include "elemental.h"
  38. #include "party.h"
  39. #include "guild.h"
  40. #include "script.h"
  41. #include "storage.h"
  42. #include "trade.h"
  43. #include "unit.h"
  44. #include "mapreg.h"
  45. #include "quest.h"
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49. #include <math.h>
  50. #define ATCOMMAND_LENGTH 50
  51. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  52. typedef struct AtCommandInfo AtCommandInfo;
  53. typedef struct AliasInfo AliasInfo;
  54. int atcmd_binding_count = 0;
  55. struct AtCommandInfo {
  56. char command[ATCOMMAND_LENGTH];
  57. AtCommandFunc func;
  58. char* at_groups;/* quick @commands "can-use" lookup */
  59. char* char_groups;/* quick @charcommands "can-use" lookup */
  60. int restriction; //prevent : 1 console, 2 script...
  61. };
  62. struct AliasInfo {
  63. AtCommandInfo *command;
  64. char alias[ATCOMMAND_LENGTH];
  65. };
  66. char atcommand_symbol = '@'; // first char of the commands
  67. char charcommand_symbol = '#';
  68. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  69. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  70. static config_t atcommand_config;
  71. static char atcmd_output[CHAT_SIZE_MAX];
  72. static char atcmd_player_name[NAME_LENGTH];
  73. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  74. static const char* atcommand_checkalias(const char *aliasname); // @help
  75. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  76. // @commands (script-based)
  77. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  78. int i = 0;
  79. if( *name == atcommand_symbol || *name == charcommand_symbol )
  80. name++; // for backwards compatibility
  81. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  82. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  83. }
  84. /**
  85. * retrieves the help string associated with a given command.
  86. *
  87. * @param name the name of the command to retrieve help information for
  88. * @return the string associated with the command, or NULL
  89. */
  90. static const char* atcommand_help_string(const char* command)
  91. {
  92. const char* str = NULL;
  93. config_setting_t* info;
  94. if( *command == atcommand_symbol || *command == charcommand_symbol )
  95. {// remove the prefix symbol for the raw name of the command
  96. command ++;
  97. }
  98. // convert alias to the real command name
  99. command = atcommand_checkalias(command);
  100. // attept to find the first default help command
  101. info = config_lookup(&atcommand_config, "help");
  102. if( info == NULL )
  103. {// failed to find the help property in the configuration file
  104. return NULL;
  105. }
  106. if( !config_setting_lookup_string( info, command, &str ) )
  107. {// failed to find the matching help string
  108. return NULL;
  109. }
  110. // push the result from the method
  111. return str;
  112. }
  113. /*==========================================
  114. * @send (used for testing packet sends from the client)
  115. *------------------------------------------*/
  116. ACMD_FUNC(send)
  117. {
  118. int len=0,off,end,type;
  119. long num;
  120. // read message type as hex number (without the 0x)
  121. if(!message || !*message ||
  122. !((sscanf(message, "len %x", &type)==1 && (len=1))
  123. || sscanf(message, "%x", &type)==1) )
  124. {
  125. int i;
  126. for (i = 900; i <= 903; ++i)
  127. clif_displaymessage(fd, msg_txt(sd,i));
  128. return -1;
  129. }
  130. #define PARSE_ERROR(error,p) \
  131. {\
  132. clif_displaymessage(fd, (error));\
  133. sprintf(atcmd_output, ">%s", (p));\
  134. clif_displaymessage(fd, atcmd_output);\
  135. }
  136. //define PARSE_ERROR
  137. #define CHECK_EOS(p) \
  138. if(*(p) == 0){\
  139. clif_displaymessage(fd, "Unexpected end of string");\
  140. return -1;\
  141. }
  142. //define CHECK_EOS
  143. #define SKIP_VALUE(p) \
  144. {\
  145. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  146. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  147. }
  148. //define SKIP_VALUE
  149. #define GET_VALUE(p,num) \
  150. {\
  151. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  152. PARSE_ERROR("Invalid number in:",(p));\
  153. return -1;\
  154. }\
  155. }
  156. //define GET_VALUE
  157. if (type > 0 && type < MAX_PACKET_DB) {
  158. if(len)
  159. {// show packet length
  160. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  161. clif_displaymessage(fd, atcmd_output);
  162. return 0;
  163. }
  164. len=packet_db[sd->packet_ver][type].len;
  165. off=2;
  166. if(len == 0)
  167. {// unknown packet - ERROR
  168. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  169. clif_displaymessage(fd, atcmd_output);
  170. return -1;
  171. } else if(len == -1)
  172. {// dynamic packet
  173. len=SHRT_MAX-4; // maximum length
  174. off=4;
  175. }
  176. WFIFOHEAD(fd, len);
  177. WFIFOW(fd,0)=TOW(type);
  178. // parse packet contents
  179. SKIP_VALUE(message);
  180. while(*message != 0 && off < len){
  181. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  182. {// default (byte)
  183. GET_VALUE(message,num);
  184. WFIFOB(fd,off)=TOB(num);
  185. ++off;
  186. } else if(TOUPPER(*message) == 'B')
  187. {// byte
  188. ++message;
  189. GET_VALUE(message,num);
  190. WFIFOB(fd,off)=TOB(num);
  191. ++off;
  192. } else if(TOUPPER(*message) == 'W')
  193. {// word (2 bytes)
  194. ++message;
  195. GET_VALUE(message,num);
  196. WFIFOW(fd,off)=TOW(num);
  197. off+=2;
  198. } else if(TOUPPER(*message) == 'L')
  199. {// long word (4 bytes)
  200. ++message;
  201. GET_VALUE(message,num);
  202. WFIFOL(fd,off)=TOL(num);
  203. off+=4;
  204. } else if(TOUPPER(*message) == 'S')
  205. {// string - escapes are valid
  206. // get string length - num <= 0 means not fixed length (default)
  207. ++message;
  208. if(*message == '"'){
  209. num=0;
  210. } else {
  211. GET_VALUE(message,num);
  212. while(*message != '"')
  213. {// find start of string
  214. if(*message == 0 || ISSPACE(*message)){
  215. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  216. return -1;
  217. }
  218. ++message;
  219. }
  220. }
  221. // parse string
  222. ++message;
  223. CHECK_EOS(message);
  224. end=(num<=0? 0: min(off+((int)num),len));
  225. for(; *message != '"' && (off < end || end == 0); ++off){
  226. if(*message == '\\'){
  227. ++message;
  228. CHECK_EOS(message);
  229. switch(*message){
  230. case 'a': num=0x07; break; // Bell
  231. case 'b': num=0x08; break; // Backspace
  232. case 't': num=0x09; break; // Horizontal tab
  233. case 'n': num=0x0A; break; // Line feed
  234. case 'v': num=0x0B; break; // Vertical tab
  235. case 'f': num=0x0C; break; // Form feed
  236. case 'r': num=0x0D; break; // Carriage return
  237. case 'e': num=0x1B; break; // Escape
  238. default: num=*message; break;
  239. case 'x': // Hexadecimal
  240. {
  241. ++message;
  242. CHECK_EOS(message);
  243. if(!ISXDIGIT(*message)){
  244. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  245. return -1;
  246. }
  247. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  248. if(ISXDIGIT(*message)){
  249. ++message;
  250. CHECK_EOS(message);
  251. num<<=8;
  252. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  253. }
  254. WFIFOB(fd,off)=TOB(num);
  255. ++message;
  256. CHECK_EOS(message);
  257. continue;
  258. }
  259. case '0':
  260. case '1':
  261. case '2':
  262. case '3':
  263. case '4':
  264. case '5':
  265. case '6':
  266. case '7': // Octal
  267. {
  268. num=*message-'0'; // 1st octal digit
  269. ++message;
  270. CHECK_EOS(message);
  271. if(ISDIGIT(*message) && *message < '8'){
  272. num<<=3;
  273. num+=*message-'0'; // 2nd octal digit
  274. ++message;
  275. CHECK_EOS(message);
  276. if(ISDIGIT(*message) && *message < '8'){
  277. num<<=3;
  278. num+=*message-'0'; // 3rd octal digit
  279. ++message;
  280. CHECK_EOS(message);
  281. }
  282. }
  283. WFIFOB(fd,off)=TOB(num);
  284. continue;
  285. }
  286. }
  287. } else
  288. num=*message;
  289. WFIFOB(fd,off)=TOB(num);
  290. ++message;
  291. CHECK_EOS(message);
  292. }//for
  293. while(*message != '"')
  294. {// ignore extra characters
  295. ++message;
  296. CHECK_EOS(message);
  297. }
  298. // terminate the string
  299. if(off < end)
  300. {// fill the rest with 0's
  301. memset(WFIFOP(fd,off),0,end-off);
  302. off=end;
  303. }
  304. } else
  305. {// unknown
  306. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  307. return -1;
  308. }
  309. SKIP_VALUE(message);
  310. }
  311. if(packet_db[sd->packet_ver][type].len == -1)
  312. {// send dynamic packet
  313. WFIFOW(fd,2)=TOW(off);
  314. WFIFOSET(fd,off);
  315. } else
  316. {// send static packet
  317. if(off < len)
  318. memset(WFIFOP(fd,off),0,len-off);
  319. WFIFOSET(fd,len);
  320. }
  321. } else {
  322. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  323. return -1;
  324. }
  325. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  326. clif_displaymessage(fd, atcmd_output);
  327. return 0;
  328. #undef PARSE_ERROR
  329. #undef CHECK_EOS
  330. #undef SKIP_VALUE
  331. #undef GET_VALUE
  332. }
  333. /*==========================================
  334. * @rura, @warp, @mapmove
  335. *------------------------------------------*/
  336. ACMD_FUNC(mapmove)
  337. {
  338. char map_name[MAP_NAME_LENGTH_EXT];
  339. unsigned short mapindex;
  340. short x = 0, y = 0;
  341. int16 m = -1;
  342. nullpo_retr(-1, sd);
  343. memset(map_name, '\0', sizeof(map_name));
  344. if (!message || !*message ||
  345. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  346. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  347. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  348. return -1;
  349. }
  350. mapindex = mapindex_name2id(map_name);
  351. if (mapindex)
  352. m = map_mapindex2mapid(mapindex);
  353. if (!mapindex) { // m < 0 means on different server! [Kevin]
  354. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  355. return -1;
  356. }
  357. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  358. { //This is to prevent the pc_setpos call from printing an error.
  359. clif_displaymessage(fd, msg_txt(sd,2));
  360. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  361. x = y = 0; //Invalid cell, use random spot.
  362. }
  363. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  364. clif_displaymessage(fd, msg_txt(sd,247));
  365. return -1;
  366. }
  367. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  368. clif_displaymessage(fd, msg_txt(sd,248));
  369. return -1;
  370. }
  371. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  372. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  373. return -1;
  374. }
  375. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  376. return 0;
  377. }
  378. /*==========================================
  379. * Displays where a character is. Corrected version by Silent. [Skotlex]
  380. *------------------------------------------*/
  381. ACMD_FUNC(where)
  382. {
  383. struct map_session_data* pl_sd;
  384. nullpo_retr(-1, sd);
  385. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  386. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  387. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  388. return -1;
  389. }
  390. pl_sd = map_nick2sd(atcmd_player_name);
  391. if (pl_sd == NULL ||
  392. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  393. (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))
  394. ) {
  395. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  396. return -1;
  397. }
  398. 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);
  399. clif_displaymessage(fd, atcmd_output);
  400. return 0;
  401. }
  402. /*==========================================
  403. *
  404. *------------------------------------------*/
  405. ACMD_FUNC(jumpto)
  406. {
  407. struct map_session_data *pl_sd = NULL;
  408. nullpo_retr(-1, sd);
  409. if (!message || !*message) {
  410. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  411. return -1;
  412. }
  413. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  414. {
  415. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  416. return -1;
  417. }
  418. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  419. {
  420. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  421. return -1;
  422. }
  423. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  424. {
  425. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  426. return -1;
  427. }
  428. if( pc_isdead(sd) )
  429. {
  430. clif_displaymessage(fd, msg_txt(sd,664));
  431. return -1;
  432. }
  433. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  434. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  435. clif_displaymessage(fd, atcmd_output);
  436. return 0;
  437. }
  438. /*==========================================
  439. *
  440. *------------------------------------------*/
  441. ACMD_FUNC(jump)
  442. {
  443. short x = 0, y = 0;
  444. nullpo_retr(-1, sd);
  445. memset(atcmd_output, '\0', sizeof(atcmd_output));
  446. sscanf(message, "%hd %hd", &x, &y);
  447. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  448. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  449. return -1;
  450. }
  451. if( pc_isdead(sd) )
  452. {
  453. clif_displaymessage(fd, msg_txt(sd,664));
  454. return -1;
  455. }
  456. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  457. { //This is to prevent the pc_setpos call from printing an error.
  458. clif_displaymessage(fd, msg_txt(sd,2));
  459. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  460. x = y = 0; //Invalid cell, use random spot.
  461. }
  462. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  463. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  464. clif_displaymessage(fd, atcmd_output);
  465. return 0;
  466. }
  467. /*==========================================
  468. * Display list of online characters with
  469. * various info.
  470. *------------------------------------------*/
  471. ACMD_FUNC(who) {
  472. struct map_session_data *pl_sd = NULL;
  473. struct s_mapiterator *iter = NULL;
  474. char map_name[MAP_NAME_LENGTH_EXT] = "";
  475. char player_name[NAME_LENGTH] = "";
  476. int count = 0;
  477. int level = 0;
  478. StringBuf buf;
  479. /**
  480. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  481. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  482. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  483. */
  484. int display_type = 1;
  485. int map_id = -1;
  486. nullpo_retr(-1, sd);
  487. if (strstr(command, "map") != NULL) {
  488. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  489. map_id = sd->bl.m;
  490. } else {
  491. sscanf(message, "%23s", player_name);
  492. }
  493. if (strstr(command, "2") != NULL)
  494. display_type = 2;
  495. else if (strstr(command, "3") != NULL)
  496. display_type = 3;
  497. level = pc_get_group_level(sd);
  498. StringBuf_Init(&buf);
  499. iter = mapit_getallusers();
  500. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  501. 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
  502. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  503. || (map_id >= 0 && pl_sd->bl.m != map_id))
  504. continue;
  505. switch (display_type) {
  506. case 2: {
  507. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  508. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  509. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  510. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  511. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  512. break;
  513. }
  514. case 3: {
  515. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  516. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  517. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  518. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  519. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  520. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  521. break;
  522. }
  523. default: {
  524. struct party_data *p = party_search(pl_sd->status.party_id);
  525. struct guild *g = pl_sd->guild;
  526. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  527. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  528. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  529. if (p != NULL)
  530. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  531. if (g != NULL)
  532. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  533. break;
  534. }
  535. }
  536. clif_displaymessage(fd, StringBuf_Value(&buf));
  537. StringBuf_Clear(&buf);
  538. count++;
  539. }
  540. }
  541. mapit_free(iter);
  542. if (map_id < 0) {
  543. if (count == 0)
  544. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  545. else if (count == 1)
  546. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  547. else
  548. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  549. } else {
  550. if (count == 0)
  551. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  552. else if (count == 1)
  553. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  554. else
  555. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  556. }
  557. clif_displaymessage(fd, StringBuf_Value(&buf));
  558. StringBuf_Destroy(&buf);
  559. return 0;
  560. }
  561. /*==========================================
  562. *
  563. *------------------------------------------*/
  564. ACMD_FUNC(whogm)
  565. {
  566. struct map_session_data* pl_sd;
  567. struct s_mapiterator* iter;
  568. int j, count;
  569. int pl_level, level;
  570. char match_text[CHAT_SIZE_MAX];
  571. char player_name[NAME_LENGTH];
  572. struct guild *g;
  573. struct party_data *p;
  574. nullpo_retr(-1, sd);
  575. memset(atcmd_output, '\0', sizeof(atcmd_output));
  576. memset(match_text, '\0', sizeof(match_text));
  577. memset(player_name, '\0', sizeof(player_name));
  578. if (sscanf(message, "%199[^\n]", match_text) < 1)
  579. strcpy(match_text, "");
  580. for (j = 0; match_text[j]; j++)
  581. match_text[j] = TOLOWER(match_text[j]);
  582. count = 0;
  583. level = pc_get_group_level(sd);
  584. iter = mapit_getallusers();
  585. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  586. {
  587. pl_level = pc_get_group_level(pl_sd);
  588. if (!pl_level)
  589. continue;
  590. if (match_text[0])
  591. {
  592. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  593. for (j = 0; player_name[j]; j++)
  594. player_name[j] = TOLOWER(player_name[j]);
  595. // search with no case sensitive
  596. if (strstr(player_name, match_text) == NULL)
  597. continue;
  598. }
  599. if (pl_level > level) {
  600. if (pl_sd->sc.option & OPTION_INVISIBLE)
  601. continue;
  602. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  603. clif_displaymessage(fd, atcmd_output);
  604. count++;
  605. continue;
  606. }
  607. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  608. pl_sd->status.name, pl_level,
  609. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  610. clif_displaymessage(fd, atcmd_output);
  611. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  612. pl_sd->status.base_level,
  613. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  614. clif_displaymessage(fd, atcmd_output);
  615. p = party_search(pl_sd->status.party_id);
  616. g = pl_sd->guild;
  617. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  618. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  619. clif_displaymessage(fd, atcmd_output);
  620. count++;
  621. }
  622. mapit_free(iter);
  623. if (count == 0)
  624. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  625. else if (count == 1)
  626. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  627. else {
  628. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  629. clif_displaymessage(fd, atcmd_output);
  630. }
  631. return 0;
  632. }
  633. /*==========================================
  634. *
  635. *------------------------------------------*/
  636. ACMD_FUNC(save)
  637. {
  638. nullpo_retr(-1, sd);
  639. if( map[sd->bl.m].instance_id ) {
  640. clif_displaymessage(fd, msg_txt(sd,383)); // You cannot create a savepoint in an instance.
  641. return 1;
  642. }
  643. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  644. if (sd->status.pet_id > 0 && sd->pd)
  645. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  646. chrif_save(sd,0);
  647. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  648. return 0;
  649. }
  650. /*==========================================
  651. *
  652. *------------------------------------------*/
  653. ACMD_FUNC(load)
  654. {
  655. int16 m;
  656. nullpo_retr(-1, sd);
  657. m = map_mapindex2mapid(sd->status.save_point.map);
  658. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  659. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  660. return -1;
  661. }
  662. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  663. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  664. return -1;
  665. }
  666. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  667. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  668. return 0;
  669. }
  670. /*==========================================
  671. *
  672. *------------------------------------------*/
  673. ACMD_FUNC(speed)
  674. {
  675. int speed;
  676. nullpo_retr(-1, sd);
  677. memset(atcmd_output, '\0', sizeof(atcmd_output));
  678. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  679. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  680. clif_displaymessage(fd, atcmd_output);
  681. return -1;
  682. }
  683. if (speed < 0) {
  684. sd->base_status.speed = DEFAULT_WALK_SPEED;
  685. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  686. } else {
  687. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  688. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  689. }
  690. status_calc_bl(&sd->bl, SCB_SPEED);
  691. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  692. return 0;
  693. }
  694. /*==========================================
  695. *
  696. *------------------------------------------*/
  697. ACMD_FUNC(storage)
  698. {
  699. nullpo_retr(-1, sd);
  700. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  701. return -1;
  702. if (storage_storageopen(sd) == 1)
  703. { //Already open.
  704. clif_displaymessage(fd, msg_txt(sd,250));
  705. return -1;
  706. }
  707. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  708. return 0;
  709. }
  710. /*==========================================
  711. *
  712. *------------------------------------------*/
  713. ACMD_FUNC(guildstorage)
  714. {
  715. nullpo_retr(-1, sd);
  716. if (!sd->status.guild_id) {
  717. clif_displaymessage(fd, msg_txt(sd,252));
  718. return -1;
  719. }
  720. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  721. return -1;
  722. if (sd->state.storage_flag == 1) {
  723. clif_displaymessage(fd, msg_txt(sd,250));
  724. return -1;
  725. }
  726. if (sd->state.storage_flag == 2) {
  727. clif_displaymessage(fd, msg_txt(sd,251));
  728. return -1;
  729. }
  730. storage_guild_storageopen(sd);
  731. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  732. return 0;
  733. }
  734. /*==========================================
  735. *
  736. *------------------------------------------*/
  737. ACMD_FUNC(option)
  738. {
  739. int param1 = 0, param2 = 0, param3 = 0;
  740. nullpo_retr(-1, sd);
  741. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  742. {// failed to match the parameters so inform the user of the options
  743. const char* text;
  744. // attempt to find the setting information for this command
  745. text = atcommand_help_string( command );
  746. // notify the user of the requirement to enter an option
  747. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  748. if( text )
  749. {// send the help text associated with this command
  750. clif_displaymessage( fd, text );
  751. }
  752. return -1;
  753. }
  754. sd->sc.opt1 = param1;
  755. sd->sc.opt2 = param2;
  756. pc_setoption(sd, param3);
  757. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  758. return 0;
  759. }
  760. /*==========================================
  761. *
  762. *------------------------------------------*/
  763. ACMD_FUNC(hide)
  764. {
  765. nullpo_retr(-1, sd);
  766. if (sd->sc.option & OPTION_INVISIBLE) {
  767. sd->sc.option &= ~OPTION_INVISIBLE;
  768. if (sd->disguise)
  769. status_set_viewdata(&sd->bl, sd->disguise);
  770. else
  771. status_set_viewdata(&sd->bl, sd->status.class_);
  772. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  773. // increment the number of pvp players on the map
  774. map[sd->bl.m].users_pvp++;
  775. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  776. {// register the player for ranking calculations
  777. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  778. }
  779. //bugreport:2266
  780. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  781. } else {
  782. sd->sc.option |= OPTION_INVISIBLE;
  783. sd->vd.class_ = INVISIBLE_CLASS;
  784. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  785. // decrement the number of pvp players on the map
  786. map[sd->bl.m].users_pvp--;
  787. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  788. {// unregister the player for ranking
  789. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  790. sd->pvp_timer = INVALID_TIMER;
  791. }
  792. }
  793. clif_changeoption(&sd->bl);
  794. return 0;
  795. }
  796. /*==========================================
  797. * Changes a character's class
  798. *------------------------------------------*/
  799. ACMD_FUNC(jobchange)
  800. {
  801. int job = 0, upper = 0;
  802. const char* text;
  803. nullpo_retr(-1, sd);
  804. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  805. int i;
  806. bool found = false;
  807. upper = 0;
  808. // Normal Jobs
  809. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
  810. if (strncmpi(message, job_name(i), 16) == 0) {
  811. job = i;
  812. found = true;
  813. }
  814. }
  815. // High Jobs, Babys and Third
  816. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ) {
  817. if (strncmpi(message, job_name(i), 16) == 0) {
  818. job = i;
  819. found = true;
  820. }
  821. }
  822. if (!found) {
  823. text = atcommand_help_string(command);
  824. if (text)
  825. clif_displaymessage(fd, text);
  826. return -1;
  827. }
  828. }
  829. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK
  830. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  831. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2))
  832. { // Deny direct transformation into dummy jobs
  833. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  834. return 0;
  835. }
  836. if (pcdb_checkid(job))
  837. {
  838. if (pc_jobchange(sd, job, upper) == 0)
  839. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  840. else {
  841. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  842. return -1;
  843. }
  844. } else {
  845. text = atcommand_help_string(command);
  846. if (text)
  847. clif_displaymessage(fd, text);
  848. return -1;
  849. }
  850. return 0;
  851. }
  852. /*==========================================
  853. *
  854. *------------------------------------------*/
  855. ACMD_FUNC(kill)
  856. {
  857. nullpo_retr(-1, sd);
  858. status_kill(&sd->bl);
  859. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  860. if (fd != sd->fd)
  861. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  862. return 0;
  863. }
  864. /*==========================================
  865. *
  866. *------------------------------------------*/
  867. ACMD_FUNC(alive)
  868. {
  869. nullpo_retr(-1, sd);
  870. if (!status_revive(&sd->bl, 100, 100))
  871. {
  872. clif_displaymessage(fd, msg_txt(sd,667));
  873. return -1;
  874. }
  875. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  876. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  877. return 0;
  878. }
  879. /*==========================================
  880. * +kamic [LuzZza]
  881. *------------------------------------------*/
  882. ACMD_FUNC(kami)
  883. {
  884. unsigned long color=0;
  885. nullpo_retr(-1, sd);
  886. memset(atcmd_output, '\0', sizeof(atcmd_output));
  887. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  888. if (!message || !*message) {
  889. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  890. return -1;
  891. }
  892. sscanf(message, "%199[^\n]", atcmd_output);
  893. if (strstr(command, "l") != NULL)
  894. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  895. else
  896. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  897. } else {
  898. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  899. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  900. return -1;
  901. }
  902. if(color > 0xFFFFFF) {
  903. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  904. return -1;
  905. }
  906. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  907. }
  908. return 0;
  909. }
  910. /*==========================================
  911. *
  912. *------------------------------------------*/
  913. ACMD_FUNC(heal)
  914. {
  915. int hp = 0, sp = 0; // [Valaris] thanks to fov
  916. nullpo_retr(-1, sd);
  917. sscanf(message, "%d %d", &hp, &sp);
  918. // some overflow checks
  919. if( hp == INT_MIN ) hp++;
  920. if( sp == INT_MIN ) sp++;
  921. if ( hp == 0 && sp == 0 ) {
  922. if (!status_percent_heal(&sd->bl, 100, 100))
  923. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  924. else
  925. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  926. return 0;
  927. }
  928. if ( hp > 0 && sp >= 0 ) {
  929. if(!status_heal(&sd->bl, hp, sp, 0))
  930. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  931. else
  932. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  933. return 0;
  934. }
  935. if ( hp < 0 && sp <= 0 ) {
  936. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  937. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  938. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  939. return 0;
  940. }
  941. //Opposing signs.
  942. if ( hp ) {
  943. if (hp > 0)
  944. status_heal(&sd->bl, hp, 0, 0);
  945. else {
  946. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  947. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  948. }
  949. }
  950. if ( sp ) {
  951. if (sp > 0)
  952. status_heal(&sd->bl, 0, sp, 0);
  953. else
  954. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  955. }
  956. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  957. return 0;
  958. }
  959. /*==========================================
  960. * @item command (usage: @item <itemdid1:itemid2:itemname:..> <quantity>) (modified by [Yor] for pet_egg)
  961. * @itembound command (usage: @itembound <name/id_of_item> <quantity> <bound_type>)
  962. *------------------------------------------*/
  963. ACMD_FUNC(item)
  964. {
  965. char item_name[100];
  966. int number = 0, flag = 0, bound = 0;
  967. struct item item_tmp;
  968. struct item_data *item_data[10];
  969. int get_count, i, j=0;
  970. char *itemlist;
  971. nullpo_retr(-1, sd);
  972. memset(item_name, '\0', sizeof(item_name));
  973. if (!strcmpi(command+1,"itembound") && (!message || !*message || (
  974. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &number, &bound) < 2 &&
  975. sscanf(message, "%99s %d %d", item_name, &number, &bound) < 2
  976. ))) {
  977. clif_displaymessage(fd, msg_txt(sd,295)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity> <bound_type>).
  978. return -1;
  979. } else if (!message || !*message || (
  980. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  981. sscanf(message, "%99s %d", item_name, &number) < 1
  982. )) {
  983. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  984. return -1;
  985. }
  986. itemlist = strtok(item_name, ":");
  987. while (itemlist != NULL && j<10) {
  988. if ((item_data[j] = itemdb_searchname(itemlist)) == NULL &&
  989. (item_data[j] = itemdb_exists(atoi(itemlist))) == NULL){
  990. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  991. return -1;
  992. }
  993. itemlist = strtok(NULL, ":"); //next itemline
  994. j++;
  995. }
  996. if( bound < 0 || bound > 4 ) {
  997. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  998. return -1;
  999. }
  1000. if (number <= 0)
  1001. number = 1;
  1002. get_count = number;
  1003. for(j--; j>=0; j--){ //produce items in list
  1004. int16 item_id = item_data[j]->nameid;
  1005. //Check if it's stackable.
  1006. if (!itemdb_isstackable2(item_data[j]))
  1007. get_count = 1;
  1008. for (i = 0; i < number; i += get_count) {
  1009. // if not pet egg
  1010. if (!pet_create_egg(sd, item_id)) {
  1011. memset(&item_tmp, 0, sizeof(item_tmp));
  1012. item_tmp.nameid = item_id;
  1013. item_tmp.identify = 1;
  1014. item_tmp.bound = bound;
  1015. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1016. clif_additem(sd, 0, 0, flag);
  1017. }
  1018. }
  1019. }
  1020. if (flag == 0)
  1021. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1022. return 0;
  1023. }
  1024. /*==========================================
  1025. *
  1026. *------------------------------------------*/
  1027. ACMD_FUNC(item2)
  1028. {
  1029. struct item item_tmp;
  1030. struct item_data *item_data;
  1031. char item_name[100];
  1032. int item_id, number = 0, bound = 0;
  1033. int identify = 0, refine = 0, attr = 0;
  1034. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1035. nullpo_retr(-1, sd);
  1036. memset(item_name, '\0', sizeof(item_name));
  1037. if (!strcmpi(command+1,"itembound2") && (!message || !*message || (
  1038. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 &&
  1039. sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) {
  1040. clif_displaymessage(fd, msg_txt(sd,296)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1041. clif_displaymessage(fd, msg_txt(sd,297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>).
  1042. return -1;
  1043. } else if ( !message || !*message || (
  1044. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1045. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1046. )) {
  1047. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1048. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1049. return -1;
  1050. }
  1051. if (number <= 0)
  1052. number = 1;
  1053. if( bound < 0 || bound > 4 ) {
  1054. clif_displaymessage(fd, msg_txt(sd,298)); // Invalid bound type
  1055. return -1;
  1056. }
  1057. item_id = 0;
  1058. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1059. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1060. item_id = item_data->nameid;
  1061. if (item_id > 500) {
  1062. int flag = 0;
  1063. int loop, get_count, i;
  1064. loop = 1;
  1065. get_count = number;
  1066. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1067. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1068. loop = number;
  1069. get_count = 1;
  1070. if (item_data->type == IT_PETEGG) {
  1071. identify = 1;
  1072. refine = 0;
  1073. }
  1074. if (item_data->type == IT_PETARMOR)
  1075. refine = 0;
  1076. if (refine > MAX_REFINE)
  1077. refine = MAX_REFINE;
  1078. } else {
  1079. identify = 1;
  1080. refine = attr = 0;
  1081. }
  1082. for (i = 0; i < loop; i++) {
  1083. memset(&item_tmp, 0, sizeof(item_tmp));
  1084. item_tmp.nameid = item_id;
  1085. item_tmp.identify = identify;
  1086. item_tmp.refine = refine;
  1087. item_tmp.attribute = attr;
  1088. item_tmp.card[0] = c1;
  1089. item_tmp.card[1] = c2;
  1090. item_tmp.card[2] = c3;
  1091. item_tmp.card[3] = c4;
  1092. item_tmp.bound = bound;
  1093. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1094. clif_additem(sd, 0, 0, flag);
  1095. }
  1096. if (flag == 0)
  1097. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1098. } else {
  1099. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1100. return -1;
  1101. }
  1102. return 0;
  1103. }
  1104. /*==========================================
  1105. *
  1106. *------------------------------------------*/
  1107. ACMD_FUNC(itemreset)
  1108. {
  1109. int i;
  1110. nullpo_retr(-1, sd);
  1111. for (i = 0; i < MAX_INVENTORY; i++) {
  1112. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1113. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1114. }
  1115. }
  1116. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1117. return 0;
  1118. }
  1119. /*==========================================
  1120. * Atcommand @lvlup
  1121. *------------------------------------------*/
  1122. ACMD_FUNC(baselevelup)
  1123. {
  1124. int level=0, i=0, status_point=0;
  1125. nullpo_retr(-1, sd);
  1126. level = atoi(message);
  1127. if (!message || !*message || !level) {
  1128. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1129. return -1;
  1130. }
  1131. if (level > 0) {
  1132. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1133. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1134. return -1;
  1135. } // End Addition
  1136. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1137. level = pc_maxbaselv(sd) - sd->status.base_level;
  1138. for (i = 0; i < level; i++)
  1139. status_point += pc_gets_status_point(sd->status.base_level + i);
  1140. sd->status.status_point += status_point;
  1141. sd->status.base_level += (unsigned int)level;
  1142. status_percent_heal(&sd->bl, 100, 100);
  1143. clif_misceffect(&sd->bl, 0);
  1144. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1145. } else {
  1146. if (sd->status.base_level == 1) {
  1147. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1148. return -1;
  1149. }
  1150. level*=-1;
  1151. if ((unsigned int)level >= sd->status.base_level)
  1152. level = sd->status.base_level-1;
  1153. for (i = 0; i > -level; i--)
  1154. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1155. if (sd->status.status_point < status_point)
  1156. pc_resetstate(sd);
  1157. if (sd->status.status_point < status_point)
  1158. sd->status.status_point = 0;
  1159. else
  1160. sd->status.status_point -= status_point;
  1161. sd->status.base_level -= (unsigned int)level;
  1162. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1163. }
  1164. sd->status.base_exp = 0;
  1165. clif_updatestatus(sd, SP_STATUSPOINT);
  1166. clif_updatestatus(sd, SP_BASELEVEL);
  1167. clif_updatestatus(sd, SP_BASEEXP);
  1168. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1169. status_calc_pc(sd, 0);
  1170. pc_baselevelchanged(sd);
  1171. if(sd->status.party_id)
  1172. party_send_levelup(sd);
  1173. return 0;
  1174. }
  1175. /*==========================================
  1176. *
  1177. *------------------------------------------*/
  1178. ACMD_FUNC(joblevelup)
  1179. {
  1180. int level=0;
  1181. nullpo_retr(-1, sd);
  1182. level = atoi(message);
  1183. if (!message || !*message || !level) {
  1184. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1185. return -1;
  1186. }
  1187. if (level > 0) {
  1188. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1189. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1190. return -1;
  1191. }
  1192. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1193. level = pc_maxjoblv(sd) - sd->status.job_level;
  1194. sd->status.job_level += (unsigned int)level;
  1195. sd->status.skill_point += level;
  1196. clif_misceffect(&sd->bl, 1);
  1197. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1198. } else {
  1199. if (sd->status.job_level == 1) {
  1200. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1201. return -1;
  1202. }
  1203. level *=-1;
  1204. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1205. level = sd->status.job_level-1;
  1206. sd->status.job_level -= (unsigned int)level;
  1207. if (sd->status.skill_point < level)
  1208. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1209. if (sd->status.skill_point < level)
  1210. sd->status.skill_point = 0;
  1211. else
  1212. sd->status.skill_point -= level;
  1213. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1214. }
  1215. sd->status.job_exp = 0;
  1216. clif_updatestatus(sd, SP_JOBLEVEL);
  1217. clif_updatestatus(sd, SP_JOBEXP);
  1218. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1219. clif_updatestatus(sd, SP_SKILLPOINT);
  1220. status_calc_pc(sd, 0);
  1221. return 0;
  1222. }
  1223. /*==========================================
  1224. * @help
  1225. *------------------------------------------*/
  1226. ACMD_FUNC(help)
  1227. {
  1228. config_setting_t *help;
  1229. const char *text = NULL;
  1230. const char *command_name = NULL;
  1231. char *default_command = "help";
  1232. nullpo_retr(-1, sd);
  1233. help = config_lookup(&atcommand_config, "help");
  1234. if (help == NULL) {
  1235. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1236. return -1;
  1237. }
  1238. if (!message || !*message) {
  1239. command_name = default_command; // If no command_name specified, display help for @help.
  1240. } else {
  1241. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1242. ++message;
  1243. command_name = atcommand_checkalias(message);
  1244. }
  1245. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1246. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1247. clif_displaymessage(fd, atcmd_output);
  1248. atcommand_get_suggestions(sd, command_name, true);
  1249. return -1;
  1250. }
  1251. if (!config_setting_lookup_string(help, command_name, &text)) {
  1252. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1253. clif_displaymessage(fd, atcmd_output);
  1254. atcommand_get_suggestions(sd, command_name, true);
  1255. return -1;
  1256. }
  1257. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1258. clif_displaymessage(fd, atcmd_output);
  1259. { // Display aliases
  1260. DBIterator* iter;
  1261. AtCommandInfo *command_info;
  1262. AliasInfo *alias_info = NULL;
  1263. StringBuf buf;
  1264. bool has_aliases = false;
  1265. StringBuf_Init(&buf);
  1266. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1267. command_info = get_atcommandinfo_byname(command_name);
  1268. iter = db_iterator(atcommand_alias_db);
  1269. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1270. if (alias_info->command == command_info) {
  1271. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1272. has_aliases = true;
  1273. }
  1274. }
  1275. dbi_destroy(iter);
  1276. if (has_aliases)
  1277. clif_displaymessage(fd, StringBuf_Value(&buf));
  1278. StringBuf_Destroy(&buf);
  1279. }
  1280. // Display help contents
  1281. clif_displaymessage(fd, text);
  1282. return 0;
  1283. }
  1284. // helper function, used in foreach calls to stop auto-attack timers
  1285. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1286. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1287. {
  1288. struct unit_data *ud = unit_bl2ud(bl);
  1289. int id = va_arg(ap, int);
  1290. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1291. {
  1292. unit_stop_attack(bl);
  1293. return 1;
  1294. }
  1295. return 0;
  1296. }
  1297. /*==========================================
  1298. *
  1299. *------------------------------------------*/
  1300. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1301. {
  1302. TBL_PC* sd = (TBL_PC*)bl;
  1303. clif_pvpset(sd, 0, 0, 2);
  1304. if (sd->pvp_timer != INVALID_TIMER) {
  1305. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1306. sd->pvp_timer = INVALID_TIMER;
  1307. }
  1308. return 0;
  1309. }
  1310. ACMD_FUNC(pvpoff)
  1311. {
  1312. nullpo_retr(-1, sd);
  1313. if (!map[sd->bl.m].flag.pvp) {
  1314. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1315. return -1;
  1316. }
  1317. map[sd->bl.m].flag.pvp = 0;
  1318. if (!battle_config.pk_mode){
  1319. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1320. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1321. }
  1322. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1323. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1324. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1325. return 0;
  1326. }
  1327. /*==========================================
  1328. *
  1329. *------------------------------------------*/
  1330. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1331. {
  1332. TBL_PC* sd = (TBL_PC*)bl;
  1333. if (sd->pvp_timer == INVALID_TIMER) {
  1334. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1335. sd->pvp_rank = 0;
  1336. sd->pvp_lastusers = 0;
  1337. sd->pvp_point = 5;
  1338. sd->pvp_won = 0;
  1339. sd->pvp_lost = 0;
  1340. }
  1341. return 0;
  1342. }
  1343. ACMD_FUNC(pvpon)
  1344. {
  1345. nullpo_retr(-1, sd);
  1346. if (map[sd->bl.m].flag.pvp) {
  1347. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1348. return -1;
  1349. }
  1350. map[sd->bl.m].flag.pvp = 1;
  1351. if (!battle_config.pk_mode) {// display pvp circle and rank
  1352. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1353. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1354. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1355. }
  1356. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1357. return 0;
  1358. }
  1359. /*==========================================
  1360. *
  1361. *------------------------------------------*/
  1362. ACMD_FUNC(gvgoff)
  1363. {
  1364. nullpo_retr(-1, sd);
  1365. if (!map[sd->bl.m].flag.gvg) {
  1366. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1367. return -1;
  1368. }
  1369. map[sd->bl.m].flag.gvg = 0;
  1370. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1371. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1372. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1373. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1374. return 0;
  1375. }
  1376. /*==========================================
  1377. *
  1378. *------------------------------------------*/
  1379. ACMD_FUNC(gvgon)
  1380. {
  1381. nullpo_retr(-1, sd);
  1382. if (map[sd->bl.m].flag.gvg) {
  1383. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1384. return -1;
  1385. }
  1386. map[sd->bl.m].flag.gvg = 1;
  1387. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1388. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1389. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1390. return 0;
  1391. }
  1392. /*==========================================
  1393. *
  1394. *------------------------------------------*/
  1395. ACMD_FUNC(model)
  1396. {
  1397. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1398. nullpo_retr(-1, sd);
  1399. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1400. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1401. 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>).
  1402. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1403. clif_displaymessage(fd, atcmd_output);
  1404. return -1;
  1405. }
  1406. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1407. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1408. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1409. pc_changelook(sd, LOOK_HAIR, hair_style);
  1410. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1411. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1412. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1413. } else {
  1414. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1415. return -1;
  1416. }
  1417. return 0;
  1418. }
  1419. /*==========================================
  1420. * @dye && @ccolor
  1421. *------------------------------------------*/
  1422. ACMD_FUNC(dye)
  1423. {
  1424. int cloth_color = 0;
  1425. nullpo_retr(-1, sd);
  1426. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1427. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1428. 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>).
  1429. clif_displaymessage(fd, atcmd_output);
  1430. return -1;
  1431. }
  1432. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1433. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1434. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1435. } else {
  1436. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1437. return -1;
  1438. }
  1439. return 0;
  1440. }
  1441. /*==========================================
  1442. * @hairstyle && @hstyle
  1443. *------------------------------------------*/
  1444. ACMD_FUNC(hair_style)
  1445. {
  1446. int hair_style = 0;
  1447. nullpo_retr(-1, sd);
  1448. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1449. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1450. 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>).
  1451. clif_displaymessage(fd, atcmd_output);
  1452. return -1;
  1453. }
  1454. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1455. pc_changelook(sd, LOOK_HAIR, hair_style);
  1456. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1457. } else {
  1458. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1459. return -1;
  1460. }
  1461. return 0;
  1462. }
  1463. /*==========================================
  1464. * @haircolor && @hcolor
  1465. *------------------------------------------*/
  1466. ACMD_FUNC(hair_color)
  1467. {
  1468. int hair_color = 0;
  1469. nullpo_retr(-1, sd);
  1470. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1471. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1472. 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>).
  1473. clif_displaymessage(fd, atcmd_output);
  1474. return -1;
  1475. }
  1476. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1477. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1478. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1479. } else {
  1480. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1481. return -1;
  1482. }
  1483. return 0;
  1484. }
  1485. /*==========================================
  1486. * @go [city_number or city_name] - Updated by Harbin
  1487. *------------------------------------------*/
  1488. ACMD_FUNC(go)
  1489. {
  1490. int i;
  1491. int town;
  1492. char map_name[MAP_NAME_LENGTH];
  1493. int16 m;
  1494. const struct {
  1495. char map[MAP_NAME_LENGTH];
  1496. int x, y;
  1497. } data[] = {
  1498. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1499. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1500. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1501. { MAP_PAYON, 162, 233 }, // 3=Payon
  1502. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1503. #ifdef RENEWAL
  1504. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1505. #else
  1506. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1507. #endif
  1508. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1509. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1510. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1511. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1512. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1513. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1514. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1515. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1516. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1517. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1518. { MAP_JAIL, 23, 61 }, // 16=Prison
  1519. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1520. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1521. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1522. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1523. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1524. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1525. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1526. { MAP_VEINS, 216, 123 }, // 24=Veins
  1527. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1528. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1529. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1530. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1531. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1532. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1533. { MAP_MORA, 44, 151 }, // 31=Mora
  1534. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1535. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1536. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1537. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1538. };
  1539. nullpo_retr(-1, sd);
  1540. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1541. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1542. return 0;
  1543. }
  1544. memset(map_name, '\0', sizeof(map_name));
  1545. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1546. // get the number
  1547. town = atoi(message);
  1548. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1549. {// no value matched so send the list of locations
  1550. const char* text;
  1551. // attempt to find the text help string
  1552. text = atcommand_help_string( command );
  1553. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1554. if( text )
  1555. {// send the text to the client
  1556. clif_displaymessage( fd, text );
  1557. }
  1558. return -1;
  1559. }
  1560. // get possible name of the city
  1561. map_name[MAP_NAME_LENGTH-1] = '\0';
  1562. for (i = 0; map_name[i]; i++)
  1563. map_name[i] = TOLOWER(map_name[i]);
  1564. // try to identify the map name
  1565. if (strncmp(map_name, "prontera", 3) == 0) {
  1566. town = 0;
  1567. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1568. strncmp(map_name, "morroc", 4) == 0) {
  1569. town = 1;
  1570. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1571. town = 2;
  1572. } else if (strncmp(map_name, "payon", 3) == 0) {
  1573. town = 3;
  1574. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1575. town = 4;
  1576. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1577. town = 5;
  1578. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1579. town = 6;
  1580. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1581. strcmp(map_name, "christmas") == 0 ||
  1582. strncmp(map_name, "xmas", 3) == 0 ||
  1583. strncmp(map_name, "x-mas", 3) == 0) {
  1584. town = 7;
  1585. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1586. town = 8;
  1587. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1588. strncmp(map_name, "yuno", 3) == 0) {
  1589. town = 9;
  1590. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1591. town = 10;
  1592. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1593. strncmp(map_name, "gonryun", 3) == 0) {
  1594. town = 11;
  1595. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1596. town = 12;
  1597. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1598. town = 13;
  1599. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1600. town = 14;
  1601. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1602. strncmp(map_name, "startpoint", 3) == 0 ||
  1603. strncmp(map_name, "beginning", 3) == 0) {
  1604. town = 15;
  1605. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1606. strncmp(map_name, "prison", 3) == 0 ||
  1607. strncmp(map_name, "jail", 3) == 0) {
  1608. town = 16;
  1609. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1610. town = 17;
  1611. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1612. town = 18;
  1613. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1614. town = 19;
  1615. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1616. town = 20;
  1617. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1618. town = 21;
  1619. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1620. town = 22;
  1621. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1622. town = 23;
  1623. } else if (strncmp(map_name, "veins", 3) == 0) {
  1624. town = 24;
  1625. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1626. town = 25;
  1627. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1628. town = 26;
  1629. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1630. town = 27;
  1631. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1632. town = 28;
  1633. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1634. town = 29;
  1635. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1636. town = 30;
  1637. } else if (strcmp(map_name, "mora") == 0) {
  1638. town = 31;
  1639. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1640. town = 32;
  1641. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1642. town = 33;
  1643. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1644. town = 34;
  1645. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1646. town = 35;
  1647. }
  1648. if (town >= 0 && town < ARRAYLENGTH(data))
  1649. {
  1650. m = map_mapname2mapid(data[town].map);
  1651. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1652. clif_displaymessage(fd, msg_txt(sd,247));
  1653. return -1;
  1654. }
  1655. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1656. clif_displaymessage(fd, msg_txt(sd,248));
  1657. return -1;
  1658. }
  1659. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1660. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1661. } else {
  1662. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1663. return -1;
  1664. }
  1665. } else { // if you arrive here, you have an error in town variable when reading of names
  1666. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1667. return -1;
  1668. }
  1669. return 0;
  1670. }
  1671. /*==========================================
  1672. *
  1673. *------------------------------------------*/
  1674. ACMD_FUNC(monster)
  1675. {
  1676. char name[NAME_LENGTH];
  1677. char monster[NAME_LENGTH];
  1678. char eventname[EVENT_NAME_LENGTH] = "";
  1679. int mob_id;
  1680. int number = 0;
  1681. int count;
  1682. int i, k, range;
  1683. short mx, my;
  1684. unsigned int size;
  1685. nullpo_retr(-1, sd);
  1686. memset(name, '\0', sizeof(name));
  1687. memset(monster, '\0', sizeof(monster));
  1688. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1689. if (!message || !*message) {
  1690. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1691. return -1;
  1692. }
  1693. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1694. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1695. //All data can be left as it is.
  1696. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1697. //Here, it is possible name was not given and we are using monster for it.
  1698. if (count < 3) //Blank mob's name.
  1699. name[0] = '\0';
  1700. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1701. //All data can be left as it is.
  1702. } else if (sscanf(message, "%23s", monster) > 0) {
  1703. //As before, name may be already filled.
  1704. name[0] = '\0';
  1705. } else {
  1706. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1707. return -1;
  1708. }
  1709. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1710. mob_id = mobdb_checkid(atoi(monster));
  1711. if (mob_id == 0) {
  1712. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1713. return -1;
  1714. }
  1715. if (mob_id == MOBID_EMPERIUM) {
  1716. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1717. return -1;
  1718. }
  1719. if (number <= 0)
  1720. number = 1;
  1721. if( !name[0] )
  1722. strcpy(name, "--ja--");
  1723. // 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
  1724. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1725. number = battle_config.atc_spawn_quantity_limit;
  1726. if (strcmp(command+1, "monstersmall") == 0)
  1727. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1728. else if (strcmp(command+1, "monsterbig") == 0)
  1729. size = SZ_BIG;
  1730. else
  1731. size = SZ_SMALL;
  1732. if (battle_config.etc_log)
  1733. 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);
  1734. count = 0;
  1735. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1736. for (i = 0; i < number; i++) {
  1737. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1738. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1739. count += (k != 0) ? 1 : 0;
  1740. }
  1741. if (count != 0)
  1742. if (number == count)
  1743. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1744. else {
  1745. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1746. clif_displaymessage(fd, atcmd_output);
  1747. }
  1748. else {
  1749. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1750. return -1;
  1751. }
  1752. return 0;
  1753. }
  1754. /*==========================================
  1755. *
  1756. *------------------------------------------*/
  1757. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1758. {
  1759. struct mob_data *md;
  1760. int flag;
  1761. nullpo_ret(md=(struct mob_data *)bl);
  1762. flag = va_arg(ap, int);
  1763. if (md->guardian_data)
  1764. return 0; //Do not touch WoE mobs!
  1765. if (flag)
  1766. status_zap(bl,md->status.hp, 0);
  1767. else
  1768. status_kill(bl);
  1769. return 1;
  1770. }
  1771. ACMD_FUNC(killmonster)
  1772. {
  1773. int map_id, drop_flag;
  1774. char map_name[MAP_NAME_LENGTH_EXT];
  1775. nullpo_retr(-1, sd);
  1776. memset(map_name, '\0', sizeof(map_name));
  1777. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1778. map_id = sd->bl.m;
  1779. else {
  1780. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1781. map_id = sd->bl.m;
  1782. }
  1783. drop_flag = strcmp(command+1, "killmonster2");
  1784. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1785. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1786. return 0;
  1787. }
  1788. /*==========================================
  1789. *
  1790. *------------------------------------------*/
  1791. ACMD_FUNC(refine)
  1792. {
  1793. int i,j, position = 0, refine = 0, current_position, final_refine;
  1794. int count;
  1795. nullpo_retr(-1, sd);
  1796. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1797. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1798. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1799. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1800. clif_displaymessage(fd, atcmd_output);
  1801. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1802. clif_displaymessage(fd, atcmd_output);
  1803. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1804. clif_displaymessage(fd, atcmd_output);
  1805. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1806. clif_displaymessage(fd, atcmd_output);
  1807. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1808. clif_displaymessage(fd, atcmd_output);
  1809. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1810. clif_displaymessage(fd, atcmd_output);
  1811. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1812. clif_displaymessage(fd, atcmd_output);
  1813. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1814. clif_displaymessage(fd, atcmd_output);
  1815. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1816. clif_displaymessage(fd, atcmd_output);
  1817. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1818. clif_displaymessage(fd, atcmd_output);
  1819. return -1;
  1820. }
  1821. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1822. count = 0;
  1823. for (j = 0; j < EQI_MAX; j++) {
  1824. if ((i = sd->equip_index[j]) < 0)
  1825. continue;
  1826. if(j == EQI_AMMO) continue;
  1827. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1828. continue;
  1829. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1830. continue;
  1831. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1832. continue;
  1833. if(position && !(sd->status.inventory[i].equip & position))
  1834. continue;
  1835. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1836. if (sd->status.inventory[i].refine != final_refine) {
  1837. sd->status.inventory[i].refine = final_refine;
  1838. current_position = sd->status.inventory[i].equip;
  1839. pc_unequipitem(sd, i, 3);
  1840. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1841. clif_delitem(sd, i, 1, 3);
  1842. clif_additem(sd, i, 1, 0);
  1843. pc_equipitem(sd, i, current_position);
  1844. clif_misceffect(&sd->bl, 3);
  1845. count++;
  1846. }
  1847. }
  1848. if (count == 0)
  1849. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1850. else if (count == 1)
  1851. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1852. else {
  1853. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1854. clif_displaymessage(fd, atcmd_output);
  1855. }
  1856. return 0;
  1857. }
  1858. /*==========================================
  1859. *
  1860. *------------------------------------------*/
  1861. ACMD_FUNC(produce)
  1862. {
  1863. char item_name[100];
  1864. int item_id, attribute = 0, star = 0;
  1865. struct item_data *item_data;
  1866. struct item tmp_item;
  1867. nullpo_retr(-1, sd);
  1868. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1869. memset(item_name, '\0', sizeof(item_name));
  1870. if (!message || !*message || (
  1871. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1872. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1873. )) {
  1874. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1875. return -1;
  1876. }
  1877. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1878. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1879. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1880. return -1;
  1881. }
  1882. item_id = item_data->nameid;
  1883. if (itemdb_isequip2(item_data)) {
  1884. int flag = 0;
  1885. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1886. attribute = ATTRIBUTE_NORMAL;
  1887. if (star < MIN_STAR || star > MAX_STAR)
  1888. star = 0;
  1889. memset(&tmp_item, 0, sizeof tmp_item);
  1890. tmp_item.nameid = item_id;
  1891. tmp_item.amount = 1;
  1892. tmp_item.identify = 1;
  1893. tmp_item.card[0] = CARD0_FORGE;
  1894. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1895. ((star*5) << 8) + attribute:0;
  1896. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1897. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1898. clif_produceeffect(sd, 0, item_id);
  1899. clif_misceffect(&sd->bl, 3);
  1900. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1901. clif_additem(sd, 0, 0, flag);
  1902. } else {
  1903. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1904. clif_displaymessage(fd, atcmd_output);
  1905. return -1;
  1906. }
  1907. return 0;
  1908. }
  1909. /*==========================================
  1910. *
  1911. *------------------------------------------*/
  1912. ACMD_FUNC(memo)
  1913. {
  1914. int position = 0;
  1915. nullpo_retr(-1, sd);
  1916. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1917. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1918. {
  1919. int i;
  1920. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1921. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1922. {
  1923. if( sd->status.memo_point[i].map )
  1924. 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);
  1925. else
  1926. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  1927. clif_displaymessage(sd->fd, atcmd_output);
  1928. }
  1929. return 0;
  1930. }
  1931. if( position < 0 || position >= MAX_MEMOPOINTS )
  1932. {
  1933. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1934. clif_displaymessage(fd, atcmd_output);
  1935. return -1;
  1936. }
  1937. return !pc_memo( sd, position );
  1938. }
  1939. /*==========================================
  1940. *
  1941. *------------------------------------------*/
  1942. ACMD_FUNC(gat)
  1943. {
  1944. int y;
  1945. nullpo_retr(-1, sd);
  1946. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1947. for (y = 2; y >= -2; y--) {
  1948. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1949. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1950. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1951. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1952. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1953. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1954. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1955. clif_displaymessage(fd, atcmd_output);
  1956. }
  1957. return 0;
  1958. }
  1959. /*==========================================
  1960. *
  1961. *------------------------------------------*/
  1962. ACMD_FUNC(displaystatus)
  1963. {
  1964. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1965. nullpo_retr(-1, sd);
  1966. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1967. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1968. return -1;
  1969. }
  1970. if (i < 2) flag = 1;
  1971. if (i < 3) tick = 0;
  1972. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1973. return 0;
  1974. }
  1975. /*==========================================
  1976. * @stpoint (Rewritten by [Yor])
  1977. *------------------------------------------*/
  1978. ACMD_FUNC(statuspoint)
  1979. {
  1980. int point;
  1981. unsigned int new_status_point;
  1982. if (!message || !*message || (point = atoi(message)) == 0) {
  1983. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  1984. return -1;
  1985. }
  1986. if(point < 0)
  1987. {
  1988. if(sd->status.status_point < (unsigned int)(-point))
  1989. {
  1990. new_status_point = 0;
  1991. }
  1992. else
  1993. {
  1994. new_status_point = sd->status.status_point + point;
  1995. }
  1996. }
  1997. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  1998. {
  1999. new_status_point = UINT_MAX;
  2000. }
  2001. else
  2002. {
  2003. new_status_point = sd->status.status_point + point;
  2004. }
  2005. if (new_status_point != sd->status.status_point) {
  2006. sd->status.status_point = new_status_point;
  2007. clif_updatestatus(sd, SP_STATUSPOINT);
  2008. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  2009. } else {
  2010. if (point < 0)
  2011. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2012. else
  2013. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2014. return -1;
  2015. }
  2016. return 0;
  2017. }
  2018. /*==========================================
  2019. * @skpoint (Rewritten by [Yor])
  2020. *------------------------------------------*/
  2021. ACMD_FUNC(skillpoint)
  2022. {
  2023. int point;
  2024. unsigned int new_skill_point;
  2025. nullpo_retr(-1, sd);
  2026. if (!message || !*message || (point = atoi(message)) == 0) {
  2027. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  2028. return -1;
  2029. }
  2030. if(point < 0)
  2031. {
  2032. if(sd->status.skill_point < (unsigned int)(-point))
  2033. {
  2034. new_skill_point = 0;
  2035. }
  2036. else
  2037. {
  2038. new_skill_point = sd->status.skill_point + point;
  2039. }
  2040. }
  2041. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2042. {
  2043. new_skill_point = UINT_MAX;
  2044. }
  2045. else
  2046. {
  2047. new_skill_point = sd->status.skill_point + point;
  2048. }
  2049. if (new_skill_point != sd->status.skill_point) {
  2050. sd->status.skill_point = new_skill_point;
  2051. clif_updatestatus(sd, SP_SKILLPOINT);
  2052. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2053. } else {
  2054. if (point < 0)
  2055. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2056. else
  2057. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2058. return -1;
  2059. }
  2060. return 0;
  2061. }
  2062. /*==========================================
  2063. * @zeny
  2064. *------------------------------------------*/
  2065. ACMD_FUNC(zeny)
  2066. {
  2067. int zeny=0, ret=-1;
  2068. nullpo_retr(-1, sd);
  2069. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2070. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2071. return -1;
  2072. }
  2073. if(zeny > 0){
  2074. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2075. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2076. }
  2077. else {
  2078. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2079. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2080. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2081. }
  2082. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2083. return 0;
  2084. }
  2085. /*==========================================
  2086. *
  2087. *------------------------------------------*/
  2088. ACMD_FUNC(param)
  2089. {
  2090. uint8 i;
  2091. int value = 0;
  2092. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2093. short new_value, *status[6], max_status[6];
  2094. //we don't use direct initialization because it isn't part of the c standard.
  2095. nullpo_retr(-1, sd);
  2096. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2097. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2098. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2099. return -1;
  2100. }
  2101. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2102. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2103. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2104. return -1;
  2105. }
  2106. status[0] = &sd->status.str;
  2107. status[1] = &sd->status.agi;
  2108. status[2] = &sd->status.vit;
  2109. status[3] = &sd->status.int_;
  2110. status[4] = &sd->status.dex;
  2111. status[5] = &sd->status.luk;
  2112. if( battle_config.atcommand_max_stat_bypass )
  2113. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2114. else {
  2115. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2116. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2117. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2118. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2119. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2120. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2121. }
  2122. if(value > 0 && *status[i] + value >= max_status[i])
  2123. new_value = max_status[i];
  2124. else if(value < 0 && *status[i] <= -value)
  2125. new_value = 1;
  2126. else
  2127. new_value = *status[i] + value;
  2128. if (new_value != *status[i]) {
  2129. *status[i] = new_value;
  2130. clif_updatestatus(sd, SP_STR + i);
  2131. clif_updatestatus(sd, SP_USTR + i);
  2132. status_calc_pc(sd, 0);
  2133. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2134. } else {
  2135. if (value < 0)
  2136. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2137. else
  2138. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2139. return -1;
  2140. }
  2141. return 0;
  2142. }
  2143. /*==========================================
  2144. * Stat all by fritz (rewritten by [Yor])
  2145. *------------------------------------------*/
  2146. ACMD_FUNC(stat_all)
  2147. {
  2148. int value = 0;
  2149. uint8 count, i;
  2150. short *status[PARAM_MAX], max_status[PARAM_MAX];
  2151. //we don't use direct initialization because it isn't part of the c standard.
  2152. nullpo_retr(-1, sd);
  2153. status[0] = &sd->status.str;
  2154. status[1] = &sd->status.agi;
  2155. status[2] = &sd->status.vit;
  2156. status[3] = &sd->status.int_;
  2157. status[4] = &sd->status.dex;
  2158. status[5] = &sd->status.luk;
  2159. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2160. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2161. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2162. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2163. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2164. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2165. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2166. value = SHRT_MAX;
  2167. } else {
  2168. if( battle_config.atcommand_max_stat_bypass )
  2169. max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
  2170. else {
  2171. max_status[0] = pc_maxparameter(sd,PARAM_STR);
  2172. max_status[1] = pc_maxparameter(sd,PARAM_AGI);
  2173. max_status[2] = pc_maxparameter(sd,PARAM_VIT);
  2174. max_status[3] = pc_maxparameter(sd,PARAM_INT);
  2175. max_status[4] = pc_maxparameter(sd,PARAM_DEX);
  2176. max_status[5] = pc_maxparameter(sd,PARAM_LUK);
  2177. }
  2178. }
  2179. count = 0;
  2180. for (i = 0; i < ARRAYLENGTH(status); i++) {
  2181. short new_value;
  2182. if (value > 0 && *status[i] + value >= max_status[i])
  2183. new_value = max_status[i];
  2184. else if (value < 0 && *status[i] <= -value)
  2185. new_value = 1;
  2186. else
  2187. new_value = *status[i] + value;
  2188. if (new_value != *status[i]) {
  2189. *status[i] = new_value;
  2190. clif_updatestatus(sd, SP_STR + i);
  2191. clif_updatestatus(sd, SP_USTR + i);
  2192. count++;
  2193. }
  2194. }
  2195. if (count > 0) { // if at least 1 stat modified
  2196. status_calc_pc(sd, 0);
  2197. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2198. } else {
  2199. if (value < 0)
  2200. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2201. else
  2202. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2203. return -1;
  2204. }
  2205. return 0;
  2206. }
  2207. /*==========================================
  2208. *
  2209. *------------------------------------------*/
  2210. ACMD_FUNC(guildlevelup) {
  2211. int level = 0;
  2212. short added_level;
  2213. struct guild *guild_info;
  2214. nullpo_retr(-1, sd);
  2215. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2216. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2217. return -1;
  2218. }
  2219. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2220. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2221. return -1;
  2222. }
  2223. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2224. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2225. // return -1;
  2226. //}
  2227. added_level = (short)level;
  2228. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2229. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2230. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2231. added_level = 1 - guild_info->guild_lv;
  2232. if (added_level != 0) {
  2233. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2234. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2235. } else {
  2236. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2237. return -1;
  2238. }
  2239. return 0;
  2240. }
  2241. /*==========================================
  2242. *
  2243. *------------------------------------------*/
  2244. ACMD_FUNC(makeegg) {
  2245. struct item_data *item_data;
  2246. int id, pet_id;
  2247. nullpo_retr(-1, sd);
  2248. if (!message || !*message) {
  2249. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2250. return -1;
  2251. }
  2252. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2253. id = item_data->nameid;
  2254. else
  2255. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2256. ;
  2257. else
  2258. id = atoi(message);
  2259. pet_id = search_petDB_index(id, PET_CLASS);
  2260. if (pet_id < 0)
  2261. pet_id = search_petDB_index(id, PET_EGG);
  2262. if (pet_id >= 0) {
  2263. sd->catch_target_class = pet_db[pet_id].class_;
  2264. intif_create_pet(
  2265. sd->status.account_id, sd->status.char_id,
  2266. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2267. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2268. 100, 0, 1, pet_db[pet_id].jname);
  2269. } else {
  2270. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2271. return -1;
  2272. }
  2273. return 0;
  2274. }
  2275. /*==========================================
  2276. *
  2277. *------------------------------------------*/
  2278. ACMD_FUNC(hatch) {
  2279. nullpo_retr(-1, sd);
  2280. if (sd->status.pet_id <= 0)
  2281. clif_sendegg(sd);
  2282. else {
  2283. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2284. return -1;
  2285. }
  2286. return 0;
  2287. }
  2288. /*==========================================
  2289. *
  2290. *------------------------------------------*/
  2291. ACMD_FUNC(petfriendly) {
  2292. int friendly;
  2293. struct pet_data *pd;
  2294. nullpo_retr(-1, sd);
  2295. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2296. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2297. return -1;
  2298. }
  2299. pd = sd->pd;
  2300. if (!pd) {
  2301. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2302. return -1;
  2303. }
  2304. if (friendly < 0 || friendly > 1000)
  2305. {
  2306. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2307. return -1;
  2308. }
  2309. if (friendly == pd->pet.intimate) {
  2310. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2311. return -1;
  2312. }
  2313. pet_set_intimate(pd, friendly);
  2314. clif_send_petstatus(sd);
  2315. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2316. return 0;
  2317. }
  2318. /*==========================================
  2319. *
  2320. *------------------------------------------*/
  2321. ACMD_FUNC(pethungry)
  2322. {
  2323. int hungry;
  2324. struct pet_data *pd;
  2325. nullpo_retr(-1, sd);
  2326. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2327. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2328. return -1;
  2329. }
  2330. pd = sd->pd;
  2331. if (!sd->status.pet_id || !pd) {
  2332. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2333. return -1;
  2334. }
  2335. if (hungry < 0 || hungry > 100) {
  2336. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2337. return -1;
  2338. }
  2339. if (hungry == pd->pet.hungry) {
  2340. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2341. return -1;
  2342. }
  2343. pd->pet.hungry = hungry;
  2344. clif_send_petstatus(sd);
  2345. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2346. return 0;
  2347. }
  2348. /*==========================================
  2349. *
  2350. *------------------------------------------*/
  2351. ACMD_FUNC(petrename)
  2352. {
  2353. struct pet_data *pd;
  2354. nullpo_retr(-1, sd);
  2355. if (!sd->status.pet_id || !sd->pd) {
  2356. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2357. return -1;
  2358. }
  2359. pd = sd->pd;
  2360. if (!pd->pet.rename_flag) {
  2361. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2362. return -1;
  2363. }
  2364. pd->pet.rename_flag = 0;
  2365. intif_save_petdata(sd->status.account_id, &pd->pet);
  2366. clif_send_petstatus(sd);
  2367. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2368. return 0;
  2369. }
  2370. /*==========================================
  2371. *
  2372. *------------------------------------------*/
  2373. ACMD_FUNC(recall) {
  2374. struct map_session_data *pl_sd = NULL;
  2375. nullpo_retr(-1, sd);
  2376. if (!message || !*message) {
  2377. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2378. return -1;
  2379. }
  2380. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2381. {
  2382. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2383. return -1;
  2384. }
  2385. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2386. {
  2387. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2388. return -1;
  2389. }
  2390. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2391. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2392. return -1;
  2393. }
  2394. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2395. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2396. return -1;
  2397. }
  2398. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2399. return -1;
  2400. }
  2401. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2402. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2403. clif_displaymessage(fd, atcmd_output);
  2404. return 0;
  2405. }
  2406. /*==========================================
  2407. * charblock command (usage: charblock <player_name>)
  2408. * This command do a definitiv ban on a player
  2409. *------------------------------------------*/
  2410. ACMD_FUNC(char_block)
  2411. {
  2412. nullpo_retr(-1, sd);
  2413. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2414. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2415. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2416. return -1;
  2417. }
  2418. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0); // type: 1 - block
  2419. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2420. return 0;
  2421. }
  2422. /*==========================================
  2423. * accountban command (usage: ban <%time> <player_name>)
  2424. * charban command (usage: charban <%time> <player_name>)
  2425. * %time see common/timer.c::solve_time()
  2426. *------------------------------------------*/
  2427. ACMD_FUNC(char_ban)
  2428. {
  2429. char * modif_p;
  2430. int32 timediff=0; //don't set this as uint as we may want to decrease banned time
  2431. int bantype=2; //2=account block, 6=char specific
  2432. char output[256];
  2433. nullpo_retr(-1, sd);
  2434. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2435. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2436. bantype = strcmpi(command+1,"charban")?2:6; //! FIXME this breaking alias recognition
  2437. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2438. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2439. return -1;
  2440. }
  2441. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2442. modif_p = atcmd_output;
  2443. timediff = (int32)solve_time(modif_p); //discard seconds
  2444. if (timediff == 0) { //allow negative ?
  2445. char output[256];
  2446. safesnprintf(output,sizeof(output),msg_txt(sd,85),bantype==6?"charban":"ban",timediff); // Invalid time for %s command (time=%d)
  2447. clif_displaymessage(fd, output);
  2448. 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.
  2449. return -1;
  2450. }
  2451. if( timediff<0 && (
  2452. ( bantype==2 && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) )
  2453. || ( bantype==6 && !pc_can_use_command(sd, "charunban", COMMAND_ATCOMMAND)) )
  2454. ){
  2455. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to alter the time of a ban.
  2456. return -1;
  2457. }
  2458. if(bantype==2)
  2459. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 2, timediff, 0, 0); // type: 2 - ban
  2460. else
  2461. chrif_req_charban(sd->status.account_id, atcmd_player_name,timediff);
  2462. safesnprintf(output,sizeof(output),msg_txt(sd,88),bantype==6?"char":"login"); // Sending request to %s server...
  2463. clif_displaymessage(fd, output);
  2464. return 0;
  2465. }
  2466. /*==========================================
  2467. * charunblock command (usage: charunblock <player_name>)
  2468. *------------------------------------------*/
  2469. ACMD_FUNC(char_unblock)
  2470. {
  2471. nullpo_retr(-1, sd);
  2472. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2473. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2474. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2475. return -1;
  2476. }
  2477. // send answer to login server via char-server
  2478. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0); // type: 3 - unblock
  2479. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2480. return 0;
  2481. }
  2482. /*==========================================
  2483. * acc unban command (usage: unban <player_name>)
  2484. * char unban command (usage: charunban <player_name>)
  2485. *------------------------------------------*/
  2486. ACMD_FUNC(char_unban){
  2487. int unbantype=4;
  2488. nullpo_retr(-1, sd);
  2489. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2490. unbantype = strcmpi(command+1,"charunban")?4:7; //! FIXME this breaking alias recognition
  2491. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2492. if(unbantype==4) clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @unblock <char name>).
  2493. else clif_displaymessage(fd, msg_txt(sd,435)); //Please enter a player name (usage: @charunban <char name>).
  2494. return -1;
  2495. }
  2496. if(unbantype==4) // send answer to login server via char-server
  2497. chrif_req_login_operation(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0); // type: 4 - unban
  2498. else //directly unban via char-serv
  2499. chrif_req_charunban(sd->status.char_id);
  2500. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2501. return 0;
  2502. }
  2503. /*==========================================
  2504. *
  2505. *------------------------------------------*/
  2506. ACMD_FUNC(night)
  2507. {
  2508. nullpo_retr(-1, sd);
  2509. if (night_flag != 1) {
  2510. map_night_timer(night_timer_tid, 0, 0, 1);
  2511. } else {
  2512. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2513. return -1;
  2514. }
  2515. return 0;
  2516. }
  2517. /*==========================================
  2518. *
  2519. *------------------------------------------*/
  2520. ACMD_FUNC(day)
  2521. {
  2522. nullpo_retr(-1, sd);
  2523. if (night_flag != 0) {
  2524. map_day_timer(day_timer_tid, 0, 0, 1);
  2525. } else {
  2526. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2527. return -1;
  2528. }
  2529. return 0;
  2530. }
  2531. /*==========================================
  2532. *
  2533. *------------------------------------------*/
  2534. ACMD_FUNC(doom)
  2535. {
  2536. struct map_session_data* pl_sd;
  2537. struct s_mapiterator* iter;
  2538. nullpo_retr(-1, sd);
  2539. iter = mapit_getallusers();
  2540. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2541. {
  2542. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2543. {
  2544. status_kill(&pl_sd->bl);
  2545. clif_specialeffect(&pl_sd->bl,450,AREA);
  2546. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2547. }
  2548. }
  2549. mapit_free(iter);
  2550. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2551. return 0;
  2552. }
  2553. /*==========================================
  2554. *
  2555. *------------------------------------------*/
  2556. ACMD_FUNC(doommap)
  2557. {
  2558. struct map_session_data* pl_sd;
  2559. struct s_mapiterator* iter;
  2560. nullpo_retr(-1, sd);
  2561. iter = mapit_getallusers();
  2562. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2563. {
  2564. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2565. {
  2566. status_kill(&pl_sd->bl);
  2567. clif_specialeffect(&pl_sd->bl,450,AREA);
  2568. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2569. }
  2570. }
  2571. mapit_free(iter);
  2572. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2573. return 0;
  2574. }
  2575. /*==========================================
  2576. *
  2577. *------------------------------------------*/
  2578. static void atcommand_raise_sub(struct map_session_data* sd) {
  2579. status_revive(&sd->bl, 100, 100);
  2580. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2581. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2582. }
  2583. /*==========================================
  2584. *
  2585. *------------------------------------------*/
  2586. ACMD_FUNC(raise)
  2587. {
  2588. struct map_session_data* pl_sd;
  2589. struct s_mapiterator* iter;
  2590. nullpo_retr(-1, sd);
  2591. iter = mapit_getallusers();
  2592. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2593. if( pc_isdead(pl_sd) )
  2594. atcommand_raise_sub(pl_sd);
  2595. mapit_free(iter);
  2596. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2597. return 0;
  2598. }
  2599. /*==========================================
  2600. *
  2601. *------------------------------------------*/
  2602. ACMD_FUNC(raisemap)
  2603. {
  2604. struct map_session_data* pl_sd;
  2605. struct s_mapiterator* iter;
  2606. nullpo_retr(-1, sd);
  2607. iter = mapit_getallusers();
  2608. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2609. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2610. atcommand_raise_sub(pl_sd);
  2611. mapit_free(iter);
  2612. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2613. return 0;
  2614. }
  2615. /*==========================================
  2616. *
  2617. *------------------------------------------*/
  2618. ACMD_FUNC(kick)
  2619. {
  2620. struct map_session_data *pl_sd;
  2621. nullpo_retr(-1, sd);
  2622. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2623. if (!message || !*message) {
  2624. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2625. return -1;
  2626. }
  2627. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2628. {
  2629. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2630. return -1;
  2631. }
  2632. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2633. {
  2634. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2635. return -1;
  2636. }
  2637. clif_GM_kick(sd, pl_sd);
  2638. return 0;
  2639. }
  2640. /*==========================================
  2641. *
  2642. *------------------------------------------*/
  2643. ACMD_FUNC(kickall)
  2644. {
  2645. struct map_session_data* pl_sd;
  2646. struct s_mapiterator* iter;
  2647. nullpo_retr(-1, sd);
  2648. iter = mapit_getallusers();
  2649. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2650. {
  2651. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2652. if (sd->status.account_id != pl_sd->status.account_id)
  2653. clif_GM_kick(NULL, pl_sd);
  2654. }
  2655. }
  2656. mapit_free(iter);
  2657. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2658. return 0;
  2659. }
  2660. /*==========================================
  2661. *
  2662. *------------------------------------------*/
  2663. ACMD_FUNC(allskill)
  2664. {
  2665. nullpo_retr(-1, sd);
  2666. pc_allskillup(sd); // all skills
  2667. sd->status.skill_point = 0; // 0 skill points
  2668. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2669. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2670. return 0;
  2671. }
  2672. /*==========================================
  2673. *
  2674. *------------------------------------------*/
  2675. ACMD_FUNC(questskill)
  2676. {
  2677. uint16 skill_id;
  2678. nullpo_retr(-1, sd);
  2679. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2680. {// also send a list of skills applicable to this command
  2681. const char* text;
  2682. // attempt to find the text corresponding to this command
  2683. text = atcommand_help_string( command );
  2684. // send the error message as always
  2685. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2686. if( text )
  2687. {// send the skill ID list associated with this command
  2688. clif_displaymessage( fd, text );
  2689. }
  2690. return -1;
  2691. }
  2692. if (skill_id >= MAX_SKILL_DB) {
  2693. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2694. return -1;
  2695. }
  2696. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2697. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2698. return -1;
  2699. }
  2700. if (pc_checkskill(sd, skill_id) > 0) {
  2701. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2702. return -1;
  2703. }
  2704. pc_skill(sd, skill_id, 1, 0);
  2705. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2706. return 0;
  2707. }
  2708. /*==========================================
  2709. *
  2710. *------------------------------------------*/
  2711. ACMD_FUNC(lostskill)
  2712. {
  2713. uint16 skill_id;
  2714. nullpo_retr(-1, sd);
  2715. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2716. {// also send a list of skills applicable to this command
  2717. const char* text;
  2718. // attempt to find the text corresponding to this command
  2719. text = atcommand_help_string( command );
  2720. // send the error message as always
  2721. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2722. if( text )
  2723. {// send the skill ID list associated with this command
  2724. clif_displaymessage( fd, text );
  2725. }
  2726. return -1;
  2727. }
  2728. if (skill_id >= MAX_SKILL) {
  2729. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2730. return -1;
  2731. }
  2732. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2733. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2734. return -1;
  2735. }
  2736. if (pc_checkskill(sd, skill_id) == 0) {
  2737. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2738. return -1;
  2739. }
  2740. sd->status.skill[skill_id].lv = 0;
  2741. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2742. clif_deleteskill(sd,skill_id);
  2743. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2744. return 0;
  2745. }
  2746. /*==========================================
  2747. *
  2748. *------------------------------------------*/
  2749. ACMD_FUNC(spiritball)
  2750. {
  2751. int max_spiritballs;
  2752. int number;
  2753. nullpo_retr(-1, sd);
  2754. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2755. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2756. {
  2757. char msg[CHAT_SIZE_MAX];
  2758. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2759. clif_displaymessage(fd, msg);
  2760. return -1;
  2761. }
  2762. if( sd->spiritball > 0 )
  2763. pc_delspiritball(sd, sd->spiritball, 1);
  2764. sd->spiritball = number;
  2765. clif_spiritball(&sd->bl);
  2766. // no message, player can look the difference
  2767. return 0;
  2768. }
  2769. /*==========================================
  2770. *
  2771. *------------------------------------------*/
  2772. ACMD_FUNC(party)
  2773. {
  2774. char party[NAME_LENGTH];
  2775. nullpo_retr(-1, sd);
  2776. memset(party, '\0', sizeof(party));
  2777. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2778. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2779. return -1;
  2780. }
  2781. party_create(sd, party, 0, 0);
  2782. return 0;
  2783. }
  2784. /*==========================================
  2785. *
  2786. *------------------------------------------*/
  2787. ACMD_FUNC(guild)
  2788. {
  2789. char guild[NAME_LENGTH];
  2790. int prev;
  2791. nullpo_retr(-1, sd);
  2792. memset(guild, '\0', sizeof(guild));
  2793. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2794. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2795. return -1;
  2796. }
  2797. prev = battle_config.guild_emperium_check;
  2798. battle_config.guild_emperium_check = 0;
  2799. guild_create(sd, guild);
  2800. battle_config.guild_emperium_check = prev;
  2801. return 0;
  2802. }
  2803. ACMD_FUNC(breakguild)
  2804. {
  2805. nullpo_retr(-1, sd);
  2806. if (sd->status.guild_id) { // Check if the player has a guild
  2807. struct guild *g;
  2808. g = sd->guild; // Search the guild
  2809. if (g) { // Check if guild was found
  2810. if (sd->state.gmaster_flag) { // Check if player is guild master
  2811. int ret = 0;
  2812. ret = guild_break(sd, g->name); // Break guild
  2813. if (ret) { // Check if anything went wrong
  2814. return 0; // Guild was broken
  2815. } else {
  2816. return -1; // Something went wrong
  2817. }
  2818. } else { // Not guild master
  2819. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2820. return -1;
  2821. }
  2822. } else { // Guild was not found. HOW?
  2823. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2824. return -1;
  2825. }
  2826. } else { // Player does not have a guild
  2827. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2828. return -1;
  2829. }
  2830. return 0;
  2831. }
  2832. /*==========================================
  2833. *
  2834. *------------------------------------------*/
  2835. ACMD_FUNC(agitstart)
  2836. {
  2837. nullpo_retr(-1, sd);
  2838. if (agit_flag == 1) {
  2839. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2840. return -1;
  2841. }
  2842. agit_flag = 1;
  2843. guild_agit_start();
  2844. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2845. return 0;
  2846. }
  2847. /*==========================================
  2848. *
  2849. *------------------------------------------*/
  2850. ACMD_FUNC(agitstart2)
  2851. {
  2852. nullpo_retr(-1, sd);
  2853. if (agit2_flag == 1) {
  2854. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2855. return -1;
  2856. }
  2857. agit2_flag = 1;
  2858. guild_agit2_start();
  2859. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2860. return 0;
  2861. }
  2862. /*==========================================
  2863. *
  2864. *------------------------------------------*/
  2865. ACMD_FUNC(agitend)
  2866. {
  2867. nullpo_retr(-1, sd);
  2868. if (agit_flag == 0) {
  2869. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2870. return -1;
  2871. }
  2872. agit_flag = 0;
  2873. guild_agit_end();
  2874. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2875. return 0;
  2876. }
  2877. /*==========================================
  2878. *
  2879. *------------------------------------------*/
  2880. ACMD_FUNC(agitend2)
  2881. {
  2882. nullpo_retr(-1, sd);
  2883. if (agit2_flag == 0) {
  2884. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2885. return -1;
  2886. }
  2887. agit2_flag = 0;
  2888. guild_agit2_end();
  2889. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2890. return 0;
  2891. }
  2892. /*==========================================
  2893. * @mapexit - shuts down the map server
  2894. *------------------------------------------*/
  2895. ACMD_FUNC(mapexit)
  2896. {
  2897. nullpo_retr(-1, sd);
  2898. do_shutdown();
  2899. return 0;
  2900. }
  2901. /*==========================================
  2902. * idsearch <part_of_name>: revrited by [Yor]
  2903. *------------------------------------------*/
  2904. ACMD_FUNC(idsearch)
  2905. {
  2906. char item_name[100];
  2907. unsigned int i, match;
  2908. struct item_data *item_array[MAX_SEARCH];
  2909. nullpo_retr(-1, sd);
  2910. memset(item_name, '\0', sizeof(item_name));
  2911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2912. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2913. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2914. return -1;
  2915. }
  2916. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  2917. clif_displaymessage(fd, atcmd_output);
  2918. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2919. if (match > MAX_SEARCH) {
  2920. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  2921. clif_displaymessage(fd, atcmd_output);
  2922. match = MAX_SEARCH;
  2923. }
  2924. for(i = 0; i < match; i++) {
  2925. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2926. clif_displaymessage(fd, atcmd_output);
  2927. }
  2928. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  2929. clif_displaymessage(fd, atcmd_output);
  2930. return 0;
  2931. }
  2932. /*==========================================
  2933. * Recall All Characters Online To Your Location
  2934. *------------------------------------------*/
  2935. ACMD_FUNC(recallall)
  2936. {
  2937. struct map_session_data* pl_sd;
  2938. struct s_mapiterator* iter;
  2939. int count;
  2940. nullpo_retr(-1, sd);
  2941. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2942. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2943. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2944. return -1;
  2945. }
  2946. count = 0;
  2947. iter = mapit_getallusers();
  2948. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2949. {
  2950. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2951. {
  2952. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2953. continue; // Don't waste time warping the character to the same place.
  2954. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2955. count++;
  2956. else {
  2957. if (pc_isdead(pl_sd)) { //Wake them up
  2958. pc_setstand(pl_sd);
  2959. pc_setrestartvalue(pl_sd,1);
  2960. }
  2961. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2962. }
  2963. }
  2964. }
  2965. mapit_free(iter);
  2966. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  2967. if (count) {
  2968. 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.
  2969. clif_displaymessage(fd, atcmd_output);
  2970. }
  2971. return 0;
  2972. }
  2973. /*==========================================
  2974. * Recall online characters of a guild to your location
  2975. *------------------------------------------*/
  2976. ACMD_FUNC(guildrecall)
  2977. {
  2978. struct map_session_data* pl_sd;
  2979. struct s_mapiterator* iter;
  2980. int count;
  2981. char guild_name[NAME_LENGTH];
  2982. struct guild *g;
  2983. nullpo_retr(-1, sd);
  2984. memset(guild_name, '\0', sizeof(guild_name));
  2985. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2986. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2987. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  2988. return -1;
  2989. }
  2990. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2991. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2992. return -1;
  2993. }
  2994. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  2995. (g = guild_search(atoi(message))) == NULL)
  2996. {
  2997. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  2998. return -1;
  2999. }
  3000. count = 0;
  3001. iter = mapit_getallusers();
  3002. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3003. {
  3004. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  3005. {
  3006. 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))
  3007. continue; // Skip GMs greater than you... or chars already on the cell
  3008. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3009. count++;
  3010. else
  3011. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3012. }
  3013. }
  3014. mapit_free(iter);
  3015. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3016. clif_displaymessage(fd, atcmd_output);
  3017. if (count) {
  3018. 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.
  3019. clif_displaymessage(fd, atcmd_output);
  3020. }
  3021. return 0;
  3022. }
  3023. /*==========================================
  3024. * Recall online characters of a party to your location
  3025. *------------------------------------------*/
  3026. ACMD_FUNC(partyrecall)
  3027. {
  3028. struct map_session_data* pl_sd;
  3029. struct s_mapiterator* iter;
  3030. char party_name[NAME_LENGTH];
  3031. struct party_data *p;
  3032. int count;
  3033. nullpo_retr(-1, sd);
  3034. memset(party_name, '\0', sizeof(party_name));
  3035. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3036. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3037. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3038. return -1;
  3039. }
  3040. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3041. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3042. return -1;
  3043. }
  3044. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3045. (p = party_search(atoi(message))) == NULL)
  3046. {
  3047. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3048. return -1;
  3049. }
  3050. count = 0;
  3051. iter = mapit_getallusers();
  3052. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3053. {
  3054. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3055. {
  3056. 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))
  3057. continue; // Skip GMs greater than you... or chars already on the cell
  3058. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3059. count++;
  3060. else
  3061. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3062. }
  3063. }
  3064. mapit_free(iter);
  3065. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3066. clif_displaymessage(fd, atcmd_output);
  3067. if (count) {
  3068. 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.
  3069. clif_displaymessage(fd, atcmd_output);
  3070. }
  3071. return 0;
  3072. }
  3073. /*==========================================
  3074. *
  3075. *------------------------------------------*/
  3076. void atcommand_doload();
  3077. ACMD_FUNC(reload) {
  3078. nullpo_retr(-1, sd);
  3079. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3080. const char* text;
  3081. text = atcommand_help_string( command );
  3082. if(text)
  3083. clif_displaymessage( fd, text );
  3084. return -1;
  3085. }
  3086. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3087. itemdb_reload();
  3088. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3089. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3090. mob_reload();
  3091. read_petdb();
  3092. merc_reload();
  3093. read_mercenarydb();
  3094. read_mercenary_skilldb();
  3095. reload_elementaldb();
  3096. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3097. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3098. skill_reload();
  3099. merc_skill_reload();
  3100. reload_elemental_skilldb();
  3101. read_mercenary_skilldb();
  3102. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3103. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3104. config_t run_test;
  3105. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3106. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3107. return -1;
  3108. }
  3109. config_destroy(&run_test);
  3110. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3111. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3112. return -1;
  3113. }
  3114. config_destroy(&run_test);
  3115. atcommand_doload();
  3116. pc_groups_reload();
  3117. clif_displaymessage(fd, msg_txt(sd,254));
  3118. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3119. struct Battle_Config prev_config;
  3120. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3121. battle_config_read(BATTLE_CONF_FILENAME);
  3122. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3123. || prev_config.item_rate_common != battle_config.item_rate_common
  3124. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3125. || prev_config.item_rate_card != battle_config.item_rate_card
  3126. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3127. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3128. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3129. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3130. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3131. || prev_config.item_rate_use != battle_config.item_rate_use
  3132. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3133. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3134. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3135. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3136. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3137. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3138. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3139. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3140. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3141. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3142. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3143. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3144. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3145. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3146. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3147. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3148. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3149. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3150. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3151. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3152. )
  3153. { // Exp or Drop rates changed.
  3154. mob_reload(); //Needed as well so rate changes take effect.
  3155. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3156. }
  3157. clif_displaymessage(fd, msg_txt(sd,255));
  3158. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3159. status_readdb();
  3160. clif_displaymessage(fd, msg_txt(sd,256));
  3161. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3162. pc_readdb();
  3163. clif_displaymessage(fd, msg_txt(sd,257));
  3164. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3165. pc_read_motd();
  3166. clif_displaymessage(fd, msg_txt(sd,268));
  3167. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3168. struct s_mapiterator* iter;
  3169. struct map_session_data* pl_sd;
  3170. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3171. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3172. iter = mapit_getallusers();
  3173. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3174. pc_close_npc(pl_sd,2);
  3175. mapit_free(iter);
  3176. flush_fifos();
  3177. map_reloadnpc(true); // reload config files seeking for npcs
  3178. script_reload();
  3179. npc_reload();
  3180. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3181. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3182. map_msg_reload();
  3183. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3184. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3185. do_reload_quest();
  3186. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3187. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3188. packetdb_readdb();
  3189. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3190. } else if (strstr(command, "instancedb") || strncmp(message, "instancedb", 4) == 0) {
  3191. instance_readdb();
  3192. clif_displaymessage(fd, msg_txt(sd,516)); // Instance database has been reloaded.
  3193. }
  3194. return 0;
  3195. }
  3196. /*==========================================
  3197. * @partysharelvl <share_range> [Akinari]
  3198. * Updates char server party share level range in runtime
  3199. * Temporary - Permanent update in inter_athena.conf
  3200. *------------------------------------------*/
  3201. ACMD_FUNC(partysharelvl) {
  3202. unsigned int share_lvl;
  3203. nullpo_retr(-1, sd);
  3204. if(!message || !*message) {
  3205. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  3206. return -1;
  3207. } else
  3208. share_lvl = min(abs(atoi(message)),MAX_LEVEL);
  3209. if(intif_party_sharelvlupdate(share_lvl)) //Successfully updated
  3210. clif_displaymessage(fd, msg_txt(sd,1478)); // Party share level range has been changed successfully.
  3211. else //Char server offline
  3212. clif_displaymessage(fd, msg_txt(sd,1479)); // Failed to update configuration. Character server is offline.
  3213. return 0;
  3214. }
  3215. /*==========================================
  3216. * @mapinfo [0-3] <map name> by MC_Cameri
  3217. * => Shows information about the map [map name]
  3218. * 0 = no additional information
  3219. * 1 = Show users in that map and their location
  3220. * 2 = Shows NPCs in that map
  3221. * 3 = Shows the chats in that map
  3222. *------------------------------------------*/
  3223. ACMD_FUNC(mapinfo) {
  3224. struct map_session_data* pl_sd;
  3225. struct s_mapiterator* iter;
  3226. struct npc_data *nd = NULL;
  3227. struct chat_data *cd = NULL;
  3228. char direction[12];
  3229. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3230. unsigned short m_index;
  3231. char mapname[24];
  3232. nullpo_retr(-1, sd);
  3233. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3234. memset(mapname, '\0', sizeof(mapname));
  3235. memset(direction, '\0', sizeof(direction));
  3236. sscanf(message, "%d %23[^\n]", &list, mapname);
  3237. if (list < 0 || list > 3) {
  3238. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3239. return -1;
  3240. }
  3241. if (mapname[0] == '\0') {
  3242. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3243. m_id = map_mapindex2mapid(sd->mapindex);
  3244. } else {
  3245. m_id = map_mapname2mapid(mapname);
  3246. }
  3247. if (m_id < 0) {
  3248. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3249. return -1;
  3250. }
  3251. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3252. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3253. // count chats (for initial message)
  3254. chat_num = 0;
  3255. iter = mapit_getallusers();
  3256. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3257. if( pl_sd->mapindex == m_index ) {
  3258. if( pl_sd->state.vending )
  3259. vend_num++;
  3260. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3261. chat_num++;
  3262. }
  3263. }
  3264. mapit_free(iter);
  3265. 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
  3266. clif_displaymessage(fd, atcmd_output);
  3267. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3268. if (map[m_id].flag.town)
  3269. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3270. if (map[m_id].flag.restricted){
  3271. sprintf(atcmd_output, " Restricted (zone %d)",map[m_id].zone);
  3272. clif_displaymessage(fd, atcmd_output);
  3273. }
  3274. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3275. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3276. else
  3277. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3278. if (map[m_id].flag.battleground){
  3279. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3280. clif_displaymessage(fd, atcmd_output);
  3281. }
  3282. /* Skill damage adjustment info [Cydh] */
  3283. #ifdef ADJUST_SKILL_DAMAGE
  3284. if (map[m_id].flag.skill_damage) {
  3285. int j;
  3286. clif_displaymessage(fd,msg_txt(sd,1052)); // Skill Damage Adjustments:
  3287. sprintf(atcmd_output," > [Map] %d%%, %d%%, %d%%, %d%% | Caster:%d"
  3288. ,map[m_id].adjust.damage.pc
  3289. ,map[m_id].adjust.damage.mob
  3290. ,map[m_id].adjust.damage.boss
  3291. ,map[m_id].adjust.damage.other
  3292. ,map[m_id].adjust.damage.caster);
  3293. clif_displaymessage(fd, atcmd_output);
  3294. if (map[m_id].skill_damage[0].skill_id) {
  3295. clif_displaymessage(fd," > [Map Skill] Name : Player, Monster, Boss Monster, Other | Caster");
  3296. for (j = 0; j < MAX_MAP_SKILL_MODIFIER; j++) {
  3297. if (map[m_id].skill_damage[j].skill_id) {
  3298. sprintf(atcmd_output," %d. %s : %d%%, %d%%, %d%%, %d%% | %d"
  3299. ,j+1
  3300. ,skill_db[skill_get_index(map[m_id].skill_damage[j].skill_id)].name
  3301. ,map[m_id].skill_damage[j].pc
  3302. ,map[m_id].skill_damage[j].mob
  3303. ,map[m_id].skill_damage[j].boss
  3304. ,map[m_id].skill_damage[j].other
  3305. ,map[m_id].skill_damage[j].caster);
  3306. clif_displaymessage(fd,atcmd_output);
  3307. }
  3308. }
  3309. }
  3310. }
  3311. #endif
  3312. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3313. if (map[m_id].flag.pvp)
  3314. strcat(atcmd_output, " Pvp ON |");
  3315. if (map[m_id].flag.pvp_noguild)
  3316. strcat(atcmd_output, " NoGuild |");
  3317. if (map[m_id].flag.pvp_noparty)
  3318. strcat(atcmd_output, " NoParty |");
  3319. if (map[m_id].flag.pvp_nightmaredrop)
  3320. strcat(atcmd_output, " NightmareDrop |");
  3321. if (map[m_id].flag.pvp_nocalcrank)
  3322. strcat(atcmd_output, " NoCalcRank |");
  3323. clif_displaymessage(fd, atcmd_output);
  3324. strcpy(atcmd_output,msg_txt(sd,1047)); // GvG Flags:
  3325. if (map[m_id].flag.gvg)
  3326. strcat(atcmd_output, " GvG ON |");
  3327. if (map[m_id].flag.gvg_dungeon)
  3328. strcat(atcmd_output, " GvG Dungeon |");
  3329. if (map[m_id].flag.gvg_castle)
  3330. strcat(atcmd_output, " GvG Castle |");
  3331. if (map[m_id].flag.gvg_noparty)
  3332. strcat(atcmd_output, " NoParty |");
  3333. clif_displaymessage(fd, atcmd_output);
  3334. strcpy(atcmd_output,msg_txt(sd,1048)); // Teleport Flags:
  3335. if (map[m_id].flag.noteleport)
  3336. strcat(atcmd_output, " NoTeleport |");
  3337. if (map[m_id].flag.monster_noteleport)
  3338. strcat(atcmd_output, " Monster NoTeleport |");
  3339. if (map[m_id].flag.nowarp)
  3340. strcat(atcmd_output, " NoWarp |");
  3341. if (map[m_id].flag.nowarpto)
  3342. strcat(atcmd_output, " NoWarpTo |");
  3343. if (map[m_id].flag.noreturn)
  3344. strcat(atcmd_output, " NoReturn |");
  3345. if (map[m_id].flag.nogo)
  3346. strcat(atcmd_output, " NoGo |"); //
  3347. if (map[m_id].flag.nomemo)
  3348. strcat(atcmd_output, " NoMemo |");
  3349. clif_displaymessage(fd, atcmd_output);
  3350. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3351. (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
  3352. clif_displaymessage(fd, atcmd_output);
  3353. if (map[m_id].flag.nosave) {
  3354. if (!map[m_id].save.map)
  3355. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3356. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3357. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3358. clif_displaymessage(fd, atcmd_output);
  3359. }
  3360. else {
  3361. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3362. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3363. clif_displaymessage(fd, atcmd_output);
  3364. }
  3365. }
  3366. strcpy(atcmd_output,msg_txt(sd,1049)); // Weather Flags:
  3367. if (map[m_id].flag.snow)
  3368. strcat(atcmd_output, " Snow |");
  3369. if (map[m_id].flag.fog)
  3370. strcat(atcmd_output, " Fog |");
  3371. if (map[m_id].flag.sakura)
  3372. strcat(atcmd_output, " Sakura |");
  3373. if (map[m_id].flag.clouds)
  3374. strcat(atcmd_output, " Clouds |");
  3375. if (map[m_id].flag.clouds2)
  3376. strcat(atcmd_output, " Clouds2 |");
  3377. if (map[m_id].flag.fireworks)
  3378. strcat(atcmd_output, " Fireworks |");
  3379. if (map[m_id].flag.leaves)
  3380. strcat(atcmd_output, " Leaves |");
  3381. if (map[m_id].flag.nightenabled)
  3382. strcat(atcmd_output, " Displays Night |");
  3383. clif_displaymessage(fd, atcmd_output);
  3384. strcpy(atcmd_output,msg_txt(sd,1050)); // Other Flags:
  3385. if (map[m_id].flag.nobranch)
  3386. strcat(atcmd_output, " NoBranch |");
  3387. if (map[m_id].flag.notrade)
  3388. strcat(atcmd_output, " NoTrade |");
  3389. if (map[m_id].flag.novending)
  3390. strcat(atcmd_output, " NoVending |");
  3391. if (map[m_id].flag.nodrop)
  3392. strcat(atcmd_output, " NoDrop |");
  3393. if (map[m_id].flag.noskill)
  3394. strcat(atcmd_output, " NoSkill |");
  3395. if (map[m_id].flag.noicewall)
  3396. strcat(atcmd_output, " NoIcewall |");
  3397. if (map[m_id].flag.allowks)
  3398. strcat(atcmd_output, " AllowKS |");
  3399. if (map[m_id].flag.reset)
  3400. strcat(atcmd_output, " Reset |");
  3401. clif_displaymessage(fd, atcmd_output);
  3402. strcpy(atcmd_output,msg_txt(sd,1051)); // Other Flags2:
  3403. if (map[m_id].nocommand)
  3404. strcat(atcmd_output, " NoCommand |");
  3405. if (map[m_id].flag.nobaseexp)
  3406. strcat(atcmd_output, " NoBaseEXP |");
  3407. if (map[m_id].flag.nojobexp)
  3408. strcat(atcmd_output, " NoJobEXP |");
  3409. if (map[m_id].flag.nomobloot)
  3410. strcat(atcmd_output, " NoMobLoot |");
  3411. if (map[m_id].flag.nomvploot)
  3412. strcat(atcmd_output, " NoMVPLoot |");
  3413. if (map[m_id].flag.partylock)
  3414. strcat(atcmd_output, " PartyLock |");
  3415. if (map[m_id].flag.guildlock)
  3416. strcat(atcmd_output, " GuildLock |");
  3417. if (map[m_id].flag.loadevent)
  3418. strcat(atcmd_output, " Loadevent |");
  3419. if (map[m_id].flag.chmautojoin)
  3420. strcat(atcmd_output, " Chmautojoin |");
  3421. if (map[m_id].flag.nousecart)
  3422. strcat(atcmd_output, " NoUsecart |");
  3423. if (map[m_id].flag.noitemconsumption)
  3424. strcat(atcmd_output, " NoItemConsumption |");
  3425. if (map[m_id].flag.nosumstarmiracle)
  3426. strcat(atcmd_output, " NoSumStarMiracle |");
  3427. if (map[m_id].flag.nomineeffect)
  3428. strcat(atcmd_output, " NoMineEffect |");
  3429. if (map[m_id].flag.nolockon)
  3430. strcat(atcmd_output, " NoLockOn |");
  3431. if (map[m_id].flag.notomb)
  3432. strcat(atcmd_output, " NoTomb |");
  3433. clif_displaymessage(fd, atcmd_output);
  3434. switch (list) {
  3435. case 0:
  3436. // Do nothing. It's list 0, no additional display.
  3437. break;
  3438. case 1:
  3439. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3440. iter = mapit_getallusers();
  3441. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3442. {
  3443. if (pl_sd->mapindex == m_index) {
  3444. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3445. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3446. clif_displaymessage(fd, atcmd_output);
  3447. }
  3448. }
  3449. mapit_free(iter);
  3450. break;
  3451. case 2:
  3452. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3453. for (i = 0; i < map[m_id].npc_num;)
  3454. {
  3455. nd = map[m_id].npc[i];
  3456. switch(nd->ud.dir) {
  3457. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3458. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3459. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3460. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3461. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3462. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3463. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3464. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3465. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3466. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3467. }
  3468. if(strcmp(nd->name,nd->exname) == 0)
  3469. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3470. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3471. else
  3472. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3473. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3474. clif_displaymessage(fd, atcmd_output);
  3475. }
  3476. break;
  3477. case 3:
  3478. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3479. iter = mapit_getallusers();
  3480. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3481. {
  3482. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3483. pl_sd->mapindex == m_index &&
  3484. cd->usersd[0] == pl_sd)
  3485. {
  3486. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3487. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3488. clif_displaymessage(fd, atcmd_output);
  3489. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3490. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3491. clif_displaymessage(fd, atcmd_output);
  3492. }
  3493. }
  3494. mapit_free(iter);
  3495. break;
  3496. default: // normally impossible to arrive here
  3497. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3498. return -1;
  3499. break;
  3500. }
  3501. return 0;
  3502. }
  3503. /*==========================================
  3504. *
  3505. *------------------------------------------*/
  3506. ACMD_FUNC(mount_peco)
  3507. {
  3508. nullpo_retr(-1, sd);
  3509. if (sd->disguise) {
  3510. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3511. return -1;
  3512. }
  3513. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3514. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3515. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3516. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3517. } else {
  3518. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3519. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3520. }
  3521. return 0;
  3522. }
  3523. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3524. if( !pc_isridingwug(sd) ) {
  3525. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3526. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3527. } else {
  3528. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3529. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3530. }
  3531. return 0;
  3532. }
  3533. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3534. if( !pc_ismadogear(sd) ) {
  3535. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3536. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3537. } else {
  3538. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3539. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3540. }
  3541. return 0;
  3542. }
  3543. if (!pc_isriding(sd)) { // if actually no peco
  3544. if (!pc_checkskill(sd, KN_RIDING)) {
  3545. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3546. return -1;
  3547. }
  3548. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3549. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3550. } else {//Dismount
  3551. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3552. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3553. }
  3554. return 0;
  3555. }
  3556. /*==========================================
  3557. *Spy Commands by Syrus22
  3558. *------------------------------------------*/
  3559. ACMD_FUNC(guildspy)
  3560. {
  3561. char guild_name[NAME_LENGTH];
  3562. struct guild *g;
  3563. nullpo_retr(-1, sd);
  3564. memset(guild_name, '\0', sizeof(guild_name));
  3565. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3566. if (!enable_spy)
  3567. {
  3568. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3569. return -1;
  3570. }
  3571. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3572. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3573. return -1;
  3574. }
  3575. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3576. (g = guild_search(atoi(message))) != NULL) {
  3577. if (sd->guildspy == g->guild_id) {
  3578. sd->guildspy = 0;
  3579. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3580. clif_displaymessage(fd, atcmd_output);
  3581. } else {
  3582. sd->guildspy = g->guild_id;
  3583. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3584. clif_displaymessage(fd, atcmd_output);
  3585. }
  3586. } else {
  3587. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3588. return -1;
  3589. }
  3590. return 0;
  3591. }
  3592. /*==========================================
  3593. *
  3594. *------------------------------------------*/
  3595. ACMD_FUNC(partyspy)
  3596. {
  3597. char party_name[NAME_LENGTH];
  3598. struct party_data *p;
  3599. nullpo_retr(-1, sd);
  3600. memset(party_name, '\0', sizeof(party_name));
  3601. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3602. if (!enable_spy)
  3603. {
  3604. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3605. return -1;
  3606. }
  3607. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3608. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3609. return -1;
  3610. }
  3611. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3612. (p = party_search(atoi(message))) != NULL) {
  3613. if (sd->partyspy == p->party.party_id) {
  3614. sd->partyspy = 0;
  3615. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3616. clif_displaymessage(fd, atcmd_output);
  3617. } else {
  3618. sd->partyspy = p->party.party_id;
  3619. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3620. clif_displaymessage(fd, atcmd_output);
  3621. }
  3622. } else {
  3623. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3624. return -1;
  3625. }
  3626. return 0;
  3627. }
  3628. /*==========================================
  3629. * @repairall [Valaris]
  3630. *------------------------------------------*/
  3631. ACMD_FUNC(repairall)
  3632. {
  3633. int count, i;
  3634. nullpo_retr(-1, sd);
  3635. count = 0;
  3636. for (i = 0; i < MAX_INVENTORY; i++) {
  3637. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3638. sd->status.inventory[i].attribute = 0;
  3639. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3640. count++;
  3641. }
  3642. }
  3643. if (count > 0) {
  3644. clif_misceffect(&sd->bl, 3);
  3645. clif_equiplist(sd);
  3646. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3647. } else {
  3648. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3649. return -1;
  3650. }
  3651. return 0;
  3652. }
  3653. /*==========================================
  3654. * @nuke [Valaris]
  3655. *------------------------------------------*/
  3656. ACMD_FUNC(nuke)
  3657. {
  3658. struct map_session_data *pl_sd;
  3659. nullpo_retr(-1, sd);
  3660. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3661. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3662. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3663. return -1;
  3664. }
  3665. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3666. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3667. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3668. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3669. } else {
  3670. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3671. return -1;
  3672. }
  3673. } else {
  3674. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3675. return -1;
  3676. }
  3677. return 0;
  3678. }
  3679. /*==========================================
  3680. * @tonpc
  3681. *------------------------------------------*/
  3682. ACMD_FUNC(tonpc)
  3683. {
  3684. char npcname[NAME_LENGTH+1];
  3685. struct npc_data *nd;
  3686. nullpo_retr(-1, sd);
  3687. memset(npcname, 0, sizeof(npcname));
  3688. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3689. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3690. return -1;
  3691. }
  3692. if ((nd = npc_name2id(npcname)) != NULL) {
  3693. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3694. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3695. else
  3696. return -1;
  3697. } else {
  3698. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3699. return -1;
  3700. }
  3701. return 0;
  3702. }
  3703. /*==========================================
  3704. *
  3705. *------------------------------------------*/
  3706. ACMD_FUNC(shownpc)
  3707. {
  3708. char NPCname[NAME_LENGTH+1];
  3709. nullpo_retr(-1, sd);
  3710. memset(NPCname, '\0', sizeof(NPCname));
  3711. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3712. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3713. return -1;
  3714. }
  3715. if (npc_name2id(NPCname) != NULL) {
  3716. npc_enable(NPCname, 1);
  3717. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3718. } else {
  3719. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3720. return -1;
  3721. }
  3722. return 0;
  3723. }
  3724. /*==========================================
  3725. *
  3726. *------------------------------------------*/
  3727. ACMD_FUNC(hidenpc)
  3728. {
  3729. char NPCname[NAME_LENGTH+1];
  3730. nullpo_retr(-1, sd);
  3731. memset(NPCname, '\0', sizeof(NPCname));
  3732. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3733. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3734. return -1;
  3735. }
  3736. if (npc_name2id(NPCname) == NULL) {
  3737. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3738. return -1;
  3739. }
  3740. npc_enable(NPCname, 0);
  3741. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3742. return 0;
  3743. }
  3744. ACMD_FUNC(loadnpc)
  3745. {
  3746. FILE *fp;
  3747. if (!message || !*message) {
  3748. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3749. return -1;
  3750. }
  3751. // check if script file exists
  3752. if ((fp = fopen(message, "r")) == NULL) {
  3753. clif_displaymessage(fd, msg_txt(sd,261));
  3754. return -1;
  3755. }
  3756. fclose(fp);
  3757. // add to list of script sources and run it
  3758. npc_addsrcfile(message);
  3759. npc_parsesrcfile(message,true);
  3760. npc_read_event_script();
  3761. clif_displaymessage(fd, msg_txt(sd,262));
  3762. return 0;
  3763. }
  3764. ACMD_FUNC(unloadnpc)
  3765. {
  3766. struct npc_data *nd;
  3767. char NPCname[NAME_LENGTH+1];
  3768. nullpo_retr(-1, sd);
  3769. memset(NPCname, '\0', sizeof(NPCname));
  3770. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3771. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @unloadnpc <NPC_name>).
  3772. return -1;
  3773. }
  3774. if ((nd = npc_name2id(NPCname)) == NULL) {
  3775. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3776. return -1;
  3777. }
  3778. npc_unload_duplicates(nd);
  3779. npc_unload(nd,true);
  3780. npc_read_event_script();
  3781. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3782. return 0;
  3783. }
  3784. /*==========================================
  3785. * time in txt for time command (by [Yor])
  3786. *------------------------------------------*/
  3787. char* txt_time(unsigned int duration)
  3788. {
  3789. int days, hours, minutes, seconds;
  3790. char temp[CHAT_SIZE_MAX];
  3791. static char temp1[CHAT_SIZE_MAX];
  3792. memset(temp, '\0', sizeof(temp));
  3793. memset(temp1, '\0', sizeof(temp1));
  3794. days = duration / (60 * 60 * 24);
  3795. duration = duration - (60 * 60 * 24 * days);
  3796. hours = duration / (60 * 60);
  3797. duration = duration - (60 * 60 * hours);
  3798. minutes = duration / 60;
  3799. seconds = duration - (60 * minutes);
  3800. if (days == 1)
  3801. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3802. else if (days > 1)
  3803. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3804. if (hours == 1)
  3805. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3806. else if (hours > 1)
  3807. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3808. if (minutes < 2)
  3809. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3810. else
  3811. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3812. if (seconds == 1)
  3813. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3814. else if (seconds > 1)
  3815. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3816. return temp1;
  3817. }
  3818. /*==========================================
  3819. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3820. * Calculation management of GM modification (@day/@night GM commands) is done
  3821. *------------------------------------------*/
  3822. ACMD_FUNC(servertime)
  3823. {
  3824. const struct TimerData * timer_data;
  3825. const struct TimerData * timer_data2;
  3826. time_t time_server; // variable for number of seconds (used with time() function)
  3827. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3828. char temp[CHAT_SIZE_MAX];
  3829. nullpo_retr(-1, sd);
  3830. memset(temp, '\0', sizeof(temp));
  3831. time(&time_server); // get time in seconds since 1/1/1970
  3832. datetime = localtime(&time_server); // convert seconds in structure
  3833. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3834. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3835. clif_displaymessage(fd, temp);
  3836. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3837. if (night_flag == 0)
  3838. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3839. else
  3840. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3841. } else if (battle_config.night_duration == 0)
  3842. if (night_flag == 1) { // we start with night
  3843. timer_data = get_timer(day_timer_tid);
  3844. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in night for %s.
  3845. clif_displaymessage(fd, temp);
  3846. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3847. } else
  3848. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3849. else if (battle_config.day_duration == 0)
  3850. if (night_flag == 0) { // we start with day
  3851. timer_data = get_timer(night_timer_tid);
  3852. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3853. clif_displaymessage(fd, temp);
  3854. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3855. } else
  3856. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3857. else {
  3858. if (night_flag == 0) {
  3859. timer_data = get_timer(night_timer_tid);
  3860. timer_data2 = get_timer(day_timer_tid);
  3861. sprintf(temp, msg_txt(sd,235), txt_time(DIFF_TICK(timer_data->tick,gettick())/1000)); // Game time: The game is actualy in daylight for %s.
  3862. clif_displaymessage(fd, temp);
  3863. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3864. 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.
  3865. else
  3866. 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.
  3867. clif_displaymessage(fd, temp);
  3868. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3869. clif_displaymessage(fd, temp);
  3870. } else {
  3871. timer_data = get_timer(day_timer_tid);
  3872. timer_data2 = get_timer(night_timer_tid);
  3873. sprintf(temp, msg_txt(sd,233), txt_time(DIFF_TICK(timer_data->tick,gettick()) / 1000)); // Game time: The game is actualy in night for %s.
  3874. clif_displaymessage(fd, temp);
  3875. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3876. 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.
  3877. else
  3878. 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.
  3879. clif_displaymessage(fd, temp);
  3880. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3881. clif_displaymessage(fd, temp);
  3882. }
  3883. }
  3884. return 0;
  3885. }
  3886. /*==========================================
  3887. * @jail <char_name> by [Yor]
  3888. * Special warp! No check with nowarp and nowarpto flag
  3889. *------------------------------------------*/
  3890. ACMD_FUNC(jail)
  3891. {
  3892. struct map_session_data *pl_sd;
  3893. int x, y;
  3894. unsigned short m_index;
  3895. nullpo_retr(-1, sd);
  3896. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3897. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3898. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3899. return -1;
  3900. }
  3901. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3902. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3903. return -1;
  3904. }
  3905. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3906. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3907. return -1;
  3908. }
  3909. if (pl_sd->sc.data[SC_JAILED]) {
  3910. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3911. return -1;
  3912. }
  3913. switch(rnd() % 2) { //Jail Locations
  3914. case 0:
  3915. m_index = mapindex_name2id(MAP_JAIL);
  3916. x = 24;
  3917. y = 75;
  3918. break;
  3919. default:
  3920. m_index = mapindex_name2id(MAP_JAIL);
  3921. x = 49;
  3922. y = 75;
  3923. break;
  3924. }
  3925. //Duration of INT_MAX to specify infinity.
  3926. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3927. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  3928. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3929. return 0;
  3930. }
  3931. /*==========================================
  3932. * @unjail/@discharge <char_name> by [Yor]
  3933. * Special warp! No check with nowarp and nowarpto flag
  3934. *------------------------------------------*/
  3935. ACMD_FUNC(unjail)
  3936. {
  3937. struct map_session_data *pl_sd;
  3938. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3939. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3940. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3941. return -1;
  3942. }
  3943. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3944. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3945. return -1;
  3946. }
  3947. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3948. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3949. return -1;
  3950. }
  3951. if (!pl_sd->sc.data[SC_JAILED]) {
  3952. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  3953. return -1;
  3954. }
  3955. //Reset jail time to 1 sec.
  3956. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  3957. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  3958. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  3959. return 0;
  3960. }
  3961. ACMD_FUNC(jailfor) {
  3962. struct map_session_data *pl_sd = NULL;
  3963. char * modif_p;
  3964. int jailtime = 0,x,y;
  3965. short m_index = 0;
  3966. nullpo_retr(-1, sd);
  3967. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3968. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3969. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  3970. return -1;
  3971. }
  3972. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3973. modif_p = atcmd_output;
  3974. jailtime = (int)solve_time(modif_p)/60; // Change to minutes
  3975. if (jailtime == 0) {
  3976. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  3977. 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.
  3978. return -1;
  3979. }
  3980. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3981. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3982. return -1;
  3983. }
  3984. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  3985. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3986. return -1;
  3987. }
  3988. // Added by Coltaro
  3989. if(pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { // Update the player's jail time
  3990. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  3991. if (jailtime <= 0) {
  3992. jailtime = 0;
  3993. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  3994. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  3995. } else {
  3996. int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
  3997. char timestr[21];
  3998. time_t now=time(NULL);
  3999. split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
  4000. 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
  4001. clif_displaymessage(pl_sd->fd, atcmd_output);
  4002. 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
  4003. clif_displaymessage(fd, atcmd_output);
  4004. timestamp2string(timestr,20,now+jailtime*60,"%Y-%m-%d %H:%M");
  4005. sprintf(atcmd_output,"Release date is: %s",timestr);
  4006. clif_displaymessage(pl_sd->fd, atcmd_output);
  4007. clif_displaymessage(fd, atcmd_output);
  4008. }
  4009. } else if (jailtime < 0) {
  4010. clif_displaymessage(fd, msg_txt(sd,1136));
  4011. return -1;
  4012. }
  4013. // Jail locations, add more as you wish.
  4014. switch(rnd()%2) {
  4015. case 1: // Jail #1
  4016. m_index = mapindex_name2id(MAP_JAIL);
  4017. x = 49; y = 75;
  4018. break;
  4019. default: // Default Jail
  4020. m_index = mapindex_name2id(MAP_JAIL);
  4021. x = 24; y = 75;
  4022. break;
  4023. }
  4024. 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).
  4025. return 0;
  4026. }
  4027. //By Coltaro
  4028. ACMD_FUNC(jailtime){
  4029. int year, month, day, hour, minute, second;
  4030. char timestr[21];
  4031. time_t now = time(NULL);
  4032. nullpo_retr(-1, sd);
  4033. if (!sd->sc.data[SC_JAILED]) {
  4034. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4035. return -1;
  4036. }
  4037. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4038. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4039. return 0;
  4040. }
  4041. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4042. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4043. return -1;
  4044. }
  4045. // Get remaining jail time
  4046. split_time(sd->sc.data[SC_JAILED]->val1*60,&year,&month,&day,&hour,&minute,&second);
  4047. 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
  4048. clif_displaymessage(fd, atcmd_output);
  4049. timestamp2string(timestr,20,now+sd->sc.data[SC_JAILED]->val1*60,"%Y-%m-%d %H:%M");
  4050. sprintf(atcmd_output,"Release date is: %s",timestr);
  4051. clif_displaymessage(fd, atcmd_output);
  4052. return 0;
  4053. }
  4054. /*==========================================
  4055. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4056. *------------------------------------------*/
  4057. ACMD_FUNC(disguise)
  4058. {
  4059. int id = 0;
  4060. nullpo_retr(-1, sd);
  4061. if (!message || !*message) {
  4062. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4063. return -1;
  4064. }
  4065. if ((id = atoi(message)) > 0)
  4066. { //Acquired an ID
  4067. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4068. id = 0; //Invalid id for either mobs or npcs.
  4069. } else { //Acquired a Name
  4070. if ((id = mobdb_searchname(message)) == 0)
  4071. {
  4072. struct npc_data* nd = npc_name2id(message);
  4073. if (nd != NULL)
  4074. id = nd->class_;
  4075. }
  4076. }
  4077. if (id == 0)
  4078. {
  4079. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4080. return -1;
  4081. }
  4082. if(pc_isriding(sd))
  4083. {
  4084. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4085. return -1;
  4086. }
  4087. if (sd->sc.data[SC_MONSTER_TRANSFORM]) {
  4088. clif_displaymessage(fd, msg_txt(sd,1499)); // Character cannot be disguised while in monster transform.
  4089. return -1;
  4090. }
  4091. pc_disguise(sd, id);
  4092. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4093. return 0;
  4094. }
  4095. /*==========================================
  4096. * DisguiseAll
  4097. *------------------------------------------*/
  4098. ACMD_FUNC(disguiseall)
  4099. {
  4100. int mob_id=0;
  4101. struct map_session_data *pl_sd;
  4102. struct s_mapiterator* iter;
  4103. nullpo_retr(-1, sd);
  4104. if (!message || !*message) {
  4105. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4106. return -1;
  4107. }
  4108. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4109. mob_id = atoi(message);
  4110. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4111. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4112. return -1;
  4113. }
  4114. iter = mapit_getallusers();
  4115. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4116. pc_disguise(pl_sd, mob_id);
  4117. mapit_free(iter);
  4118. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4119. return 0;
  4120. }
  4121. /*==========================================
  4122. * DisguiseGuild
  4123. *------------------------------------------*/
  4124. ACMD_FUNC(disguiseguild)
  4125. {
  4126. int id = 0, i;
  4127. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4128. struct map_session_data *pl_sd;
  4129. struct guild *g;
  4130. memset(monster, '\0', sizeof(monster));
  4131. memset(guild, '\0', sizeof(guild));
  4132. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4133. 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>).
  4134. return -1;
  4135. }
  4136. if( (id = atoi(monster)) > 0 ) {
  4137. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4138. id = 0;
  4139. } else {
  4140. if( (id = mobdb_searchname(monster)) == 0 ) {
  4141. struct npc_data* nd = npc_name2id(monster);
  4142. if( nd != NULL )
  4143. id = nd->class_;
  4144. }
  4145. }
  4146. if( id == 0 ) {
  4147. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4148. return -1;
  4149. }
  4150. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4151. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4152. return -1;
  4153. }
  4154. for( i = 0; i < g->max_member; i++ )
  4155. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4156. pc_disguise(pl_sd, id);
  4157. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4158. return 0;
  4159. }
  4160. /*==========================================
  4161. * @undisguise by [Yor]
  4162. *------------------------------------------*/
  4163. ACMD_FUNC(undisguise)
  4164. {
  4165. nullpo_retr(-1, sd);
  4166. if (sd->disguise) {
  4167. pc_disguise(sd, 0);
  4168. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4169. } else {
  4170. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4171. return -1;
  4172. }
  4173. return 0;
  4174. }
  4175. /*==========================================
  4176. * UndisguiseAll
  4177. *------------------------------------------*/
  4178. ACMD_FUNC(undisguiseall)
  4179. {
  4180. struct map_session_data *pl_sd;
  4181. struct s_mapiterator* iter;
  4182. nullpo_retr(-1, sd);
  4183. iter = mapit_getallusers();
  4184. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4185. if( pl_sd->disguise )
  4186. pc_disguise(pl_sd, 0);
  4187. mapit_free(iter);
  4188. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4189. return 0;
  4190. }
  4191. /*==========================================
  4192. * UndisguiseGuild
  4193. *------------------------------------------*/
  4194. ACMD_FUNC(undisguiseguild)
  4195. {
  4196. char guild_name[NAME_LENGTH];
  4197. struct map_session_data *pl_sd;
  4198. struct guild *g;
  4199. int i;
  4200. nullpo_retr(-1, sd);
  4201. memset(guild_name, '\0', sizeof(guild_name));
  4202. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4203. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4204. return -1;
  4205. }
  4206. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4207. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4208. return -1;
  4209. }
  4210. for(i = 0; i < g->max_member; i++)
  4211. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4212. pc_disguise(pl_sd, 0);
  4213. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4214. return 0;
  4215. }
  4216. /*==========================================
  4217. * @exp by [Skotlex]
  4218. *------------------------------------------*/
  4219. ACMD_FUNC(exp)
  4220. {
  4221. char output[CHAT_SIZE_MAX];
  4222. double nextb, nextj;
  4223. nullpo_retr(-1, sd);
  4224. memset(output, '\0', sizeof(output));
  4225. nextb = pc_nextbaseexp(sd);
  4226. if (nextb)
  4227. nextb = sd->status.base_exp*100.0/nextb;
  4228. nextj = pc_nextjobexp(sd);
  4229. if (nextj)
  4230. nextj = sd->status.job_exp*100.0/nextj;
  4231. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4232. clif_displaymessage(fd, output);
  4233. return 0;
  4234. }
  4235. /*==========================================
  4236. * @broadcast by [Valaris]
  4237. *------------------------------------------*/
  4238. ACMD_FUNC(broadcast)
  4239. {
  4240. nullpo_retr(-1, sd);
  4241. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4242. if (!message || !*message) {
  4243. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4244. return -1;
  4245. }
  4246. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4247. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4248. return 0;
  4249. }
  4250. /*==========================================
  4251. * @localbroadcast by [Valaris]
  4252. *------------------------------------------*/
  4253. ACMD_FUNC(localbroadcast)
  4254. {
  4255. nullpo_retr(-1, sd);
  4256. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4257. if (!message || !*message) {
  4258. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4259. return -1;
  4260. }
  4261. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4262. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4263. return 0;
  4264. }
  4265. /*==========================================
  4266. * @email <actual@email> <new@email> by [Yor]
  4267. *------------------------------------------*/
  4268. ACMD_FUNC(email)
  4269. {
  4270. char actual_email[100];
  4271. char new_email[100];
  4272. nullpo_retr(-1, sd);
  4273. memset(actual_email, '\0', sizeof(actual_email));
  4274. memset(new_email, '\0', sizeof(new_email));
  4275. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4276. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4277. return -1;
  4278. }
  4279. if (e_mail_check(actual_email) == 0) {
  4280. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4281. return -1;
  4282. } else if (e_mail_check(new_email) == 0) {
  4283. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4284. return -1;
  4285. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4286. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4287. return -1;
  4288. } else if (strcmpi(actual_email, new_email) == 0) {
  4289. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4290. return -1;
  4291. }
  4292. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4293. clif_displaymessage(fd, msg_txt(sd,148)); // Information sended to login-server via char-server.
  4294. return 0;
  4295. }
  4296. /*==========================================
  4297. *@effect
  4298. *------------------------------------------*/
  4299. ACMD_FUNC(effect)
  4300. {
  4301. int type = 0, flag = 0;
  4302. nullpo_retr(-1, sd);
  4303. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4304. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4305. return -1;
  4306. }
  4307. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4308. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4309. return 0;
  4310. }
  4311. /*==========================================
  4312. * @killer by MouseJstr
  4313. * enable killing players even when not in pvp
  4314. *------------------------------------------*/
  4315. ACMD_FUNC(killer)
  4316. {
  4317. nullpo_retr(-1, sd);
  4318. sd->state.killer = !sd->state.killer;
  4319. if(sd->state.killer)
  4320. clif_displaymessage(fd, msg_txt(sd,241));
  4321. else {
  4322. clif_displaymessage(fd, msg_txt(sd,292));
  4323. pc_stop_attack(sd);
  4324. }
  4325. return 0;
  4326. }
  4327. /*==========================================
  4328. * @killable by MouseJstr
  4329. * enable other people killing you
  4330. *------------------------------------------*/
  4331. ACMD_FUNC(killable)
  4332. {
  4333. nullpo_retr(-1, sd);
  4334. sd->state.killable = !sd->state.killable;
  4335. if(sd->state.killable)
  4336. clif_displaymessage(fd, msg_txt(sd,242));
  4337. else {
  4338. clif_displaymessage(fd, msg_txt(sd,288));
  4339. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4340. }
  4341. return 0;
  4342. }
  4343. /*==========================================
  4344. * @skillon by MouseJstr
  4345. * turn skills on for the map
  4346. *------------------------------------------*/
  4347. ACMD_FUNC(skillon)
  4348. {
  4349. nullpo_retr(-1, sd);
  4350. map[sd->bl.m].flag.noskill = 0;
  4351. clif_displaymessage(fd, msg_txt(sd,244));
  4352. return 0;
  4353. }
  4354. /*==========================================
  4355. * @skilloff by MouseJstr
  4356. * Turn skills off on the map
  4357. *------------------------------------------*/
  4358. ACMD_FUNC(skilloff)
  4359. {
  4360. nullpo_retr(-1, sd);
  4361. map[sd->bl.m].flag.noskill = 1;
  4362. clif_displaymessage(fd, msg_txt(sd,243));
  4363. return 0;
  4364. }
  4365. /*==========================================
  4366. * @npcmove by MouseJstr
  4367. * move a npc
  4368. *------------------------------------------*/
  4369. ACMD_FUNC(npcmove)
  4370. {
  4371. int x = 0, y = 0, m;
  4372. struct npc_data *nd = 0;
  4373. nullpo_retr(-1, sd);
  4374. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4375. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4376. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4377. return -1;
  4378. }
  4379. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4380. {
  4381. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4382. return -1;
  4383. }
  4384. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4385. {
  4386. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4387. return -1; //Not on a map.
  4388. }
  4389. x = cap_value(x, 0, map[m].xs-1);
  4390. y = cap_value(y, 0, map[m].ys-1);
  4391. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4392. map_moveblock(&nd->bl, x, y, gettick());
  4393. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4394. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4395. return 0;
  4396. }
  4397. /*==========================================
  4398. * @addwarp by MouseJstr
  4399. * Create a new static warp point.
  4400. *------------------------------------------*/
  4401. ACMD_FUNC(addwarp)
  4402. {
  4403. char mapname[32], warpname[NAME_LENGTH+1];
  4404. int x,y;
  4405. unsigned short m;
  4406. struct npc_data* nd;
  4407. nullpo_retr(-1, sd);
  4408. memset(warpname, '\0', sizeof(warpname));
  4409. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4410. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4411. return -1;
  4412. }
  4413. m = mapindex_name2id(mapname);
  4414. if( m == 0 )
  4415. {
  4416. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4417. clif_displaymessage(fd, atcmd_output);
  4418. return -1;
  4419. }
  4420. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4421. if( nd == NULL )
  4422. return -1;
  4423. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4424. clif_displaymessage(fd, atcmd_output);
  4425. return 0;
  4426. }
  4427. /*==========================================
  4428. * @follow by [MouseJstr]
  4429. * Follow a player .. staying no more then 5 spaces away
  4430. *------------------------------------------*/
  4431. ACMD_FUNC(follow)
  4432. {
  4433. struct map_session_data *pl_sd = NULL;
  4434. nullpo_retr(-1, sd);
  4435. if (!message || !*message) {
  4436. if (sd->followtarget == -1)
  4437. return -1;
  4438. pc_stop_following (sd);
  4439. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4440. return 0;
  4441. }
  4442. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4443. {
  4444. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4445. return -1;
  4446. }
  4447. if (sd->followtarget == pl_sd->bl.id) {
  4448. pc_stop_following (sd);
  4449. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4450. } else {
  4451. pc_follow(sd, pl_sd->bl.id);
  4452. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4453. }
  4454. return 0;
  4455. }
  4456. /*==========================================
  4457. * @dropall by [MouseJstr] and [Xantara]
  4458. * Drops all your possession on the ground based on item type
  4459. *------------------------------------------*/
  4460. ACMD_FUNC(dropall)
  4461. {
  4462. int8 type = -1;
  4463. uint16 i, count = 0, count2 = 0;
  4464. struct item_data *item_data = NULL;
  4465. nullpo_retr(-1, sd);
  4466. if( message[0] ) {
  4467. type = atoi(message);
  4468. if( type != -1 && type != IT_HEALING && type != IT_USABLE && type != IT_ETC && type != IT_WEAPON &&
  4469. type != IT_ARMOR && type != IT_CARD && type != IT_PETEGG && type != IT_PETARMOR && type != IT_AMMO )
  4470. {
  4471. clif_displaymessage(fd, msg_txt(sd,1492));
  4472. clif_displaymessage(fd, msg_txt(sd,1493));
  4473. return -1;
  4474. }
  4475. }
  4476. for( i = 0; i < MAX_INVENTORY; i++ ) {
  4477. if( sd->status.inventory[i].amount ) {
  4478. if( (item_data = itemdb_exists(sd->status.inventory[i].nameid)) == NULL ) {
  4479. 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);
  4480. continue;
  4481. }
  4482. if( !pc_candrop(sd,&sd->status.inventory[i]) )
  4483. continue;
  4484. if( type == -1 || type == (uint8)item_data->type ) {
  4485. if( sd->status.inventory[i].equip != 0 )
  4486. pc_unequipitem(sd, i, 3);
  4487. if(pc_dropitem(sd, i, sd->status.inventory[i].amount))
  4488. count += sd->status.inventory[i].amount;
  4489. else count2 += sd->status.inventory[i].amount;
  4490. }
  4491. }
  4492. }
  4493. sprintf(atcmd_output, msg_txt(sd,1494), count,count2); // %d items are dropped (%d skipped)!
  4494. clif_displaymessage(fd, atcmd_output);
  4495. return 0;
  4496. }
  4497. /*==========================================
  4498. * @storeall by [MouseJstr]
  4499. * Put everything into storage
  4500. *------------------------------------------*/
  4501. ACMD_FUNC(storeall)
  4502. {
  4503. int i;
  4504. nullpo_retr(-1, sd);
  4505. if (sd->state.storage_flag != 1)
  4506. { //Open storage.
  4507. if( storage_storageopen(sd) == 1 ) {
  4508. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4509. return -1;
  4510. }
  4511. }
  4512. for (i = 0; i < MAX_INVENTORY; i++) {
  4513. if (sd->status.inventory[i].amount) {
  4514. if(sd->status.inventory[i].equip != 0)
  4515. pc_unequipitem(sd, i, 3);
  4516. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4517. }
  4518. }
  4519. storage_storageclose(sd);
  4520. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4521. return 0;
  4522. }
  4523. ACMD_FUNC(clearstorage)
  4524. {
  4525. int i, j;
  4526. nullpo_retr(-1, sd);
  4527. if (sd->state.storage_flag == 1) {
  4528. clif_displaymessage(fd, msg_txt(sd,250));
  4529. return -1;
  4530. }
  4531. j = sd->status.storage.storage_amount;
  4532. for (i = 0; i < j; ++i) {
  4533. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4534. }
  4535. storage_storageclose(sd);
  4536. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4537. return 0;
  4538. }
  4539. ACMD_FUNC(cleargstorage)
  4540. {
  4541. int i, j;
  4542. struct guild *g;
  4543. struct guild_storage *gstorage;
  4544. nullpo_retr(-1, sd);
  4545. g = sd->guild;
  4546. if (g == NULL) {
  4547. clif_displaymessage(fd, msg_txt(sd,43));
  4548. return -1;
  4549. }
  4550. if (sd->state.storage_flag == 1) {
  4551. clif_displaymessage(fd, msg_txt(sd,250));
  4552. return -1;
  4553. }
  4554. if (sd->state.storage_flag == 2) {
  4555. clif_displaymessage(fd, msg_txt(sd,251));
  4556. return -1;
  4557. }
  4558. gstorage = guild2storage2(sd->status.guild_id);
  4559. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4560. return -1;
  4561. }
  4562. j = gstorage->storage_amount;
  4563. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4564. for (i = 0; i < j; ++i) {
  4565. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4566. }
  4567. storage_guild_storageclose(sd);
  4568. gstorage->lock = 0; // Cleaning done, release lock
  4569. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4570. return 0;
  4571. }
  4572. ACMD_FUNC(clearcart)
  4573. {
  4574. int i;
  4575. nullpo_retr(-1, sd);
  4576. if (pc_iscarton(sd) == 0) {
  4577. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4578. return -1;
  4579. }
  4580. if (sd->state.vending == 1) { //Somehow...
  4581. return -1;
  4582. }
  4583. for( i = 0; i < MAX_CART; i++ )
  4584. if(sd->status.cart[i].nameid > 0)
  4585. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4586. clif_clearcart(fd);
  4587. clif_updatestatus(sd,SP_CARTINFO);
  4588. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4589. return 0;
  4590. }
  4591. /*==========================================
  4592. * @skillid by [MouseJstr]
  4593. * lookup a skill by name
  4594. *------------------------------------------*/
  4595. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4596. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4597. ACMD_FUNC(skillid) {
  4598. int skillen, idx, i, found = 0;
  4599. DBIterator* iter;
  4600. DBKey key;
  4601. DBData *data;
  4602. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4603. nullpo_retr(-1, sd);
  4604. if (!message || !*message) {
  4605. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4606. return -1;
  4607. }
  4608. skillen = strlen(message);
  4609. iter = db_iterator(skilldb_name2id);
  4610. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4611. idx = skill_get_index(db_data2i(data));
  4612. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4613. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4614. clif_displaymessage(fd, atcmd_output);
  4615. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4616. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4617. }
  4618. }
  4619. dbi_destroy(iter);
  4620. if( found ) {
  4621. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4622. clif_displaymessage(fd, atcmd_output);
  4623. }
  4624. for(i = 0; i < found; i++) { /* partials */
  4625. clif_displaymessage(fd, partials[i]);
  4626. }
  4627. return 0;
  4628. }
  4629. /*==========================================
  4630. * @useskill by [MouseJstr]
  4631. * A way of using skills without having to find them in the skills menu
  4632. *------------------------------------------*/
  4633. ACMD_FUNC(useskill)
  4634. {
  4635. struct map_session_data *pl_sd = NULL;
  4636. struct block_list *bl;
  4637. uint16 skill_id;
  4638. uint16 skill_lv;
  4639. char target[100];
  4640. nullpo_retr(-1, sd);
  4641. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4642. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4643. return -1;
  4644. }
  4645. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4646. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4647. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4648. return -1;
  4649. }
  4650. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4651. {
  4652. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4653. return -1;
  4654. }
  4655. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4656. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4657. bl = &sd->hd->bl;
  4658. else
  4659. bl = &sd->bl;
  4660. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4661. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4662. else
  4663. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4664. return 0;
  4665. }
  4666. /*==========================================
  4667. * @displayskill by [Skotlex]
  4668. * Debug command to locate new skill IDs. It sends the
  4669. * three possible skill-effect packets to the area.
  4670. *------------------------------------------*/
  4671. ACMD_FUNC(displayskill)
  4672. {
  4673. struct status_data * status;
  4674. unsigned int tick;
  4675. uint16 skill_id;
  4676. uint16 skill_lv = 1;
  4677. nullpo_retr(-1, sd);
  4678. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4679. {
  4680. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4681. return -1;
  4682. }
  4683. status = status_get_status_data(&sd->bl);
  4684. tick = gettick();
  4685. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4686. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4687. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4688. return 0;
  4689. }
  4690. /*==========================================
  4691. * @skilltree by [MouseJstr]
  4692. * prints the skill tree for a player required to get to a skill
  4693. *------------------------------------------*/
  4694. ACMD_FUNC(skilltree)
  4695. {
  4696. struct map_session_data *pl_sd = NULL;
  4697. uint16 skill_id;
  4698. int meets, j, c=0;
  4699. char target[NAME_LENGTH];
  4700. struct skill_tree_entry *ent;
  4701. nullpo_retr(-1, sd);
  4702. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4703. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4704. return -1;
  4705. }
  4706. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4707. {
  4708. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4709. return -1;
  4710. }
  4711. c = pc_calc_skilltree_normalize_job(pl_sd);
  4712. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4713. 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).
  4714. clif_displaymessage(fd, atcmd_output);
  4715. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4716. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4717. {
  4718. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4719. return 0;
  4720. }
  4721. ent = &skill_tree[c][j];
  4722. meets = 1;
  4723. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4724. {
  4725. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4726. {
  4727. sprintf(atcmd_output, msg_txt(sd,1170), ent->need[j].lv, skill_db[ent->need[j].id].desc); // Player requires level %d of skill %s.
  4728. clif_displaymessage(fd, atcmd_output);
  4729. meets = 0;
  4730. }
  4731. }
  4732. if (meets == 1) {
  4733. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4734. }
  4735. return 0;
  4736. }
  4737. // Hand a ring with partners name on it to this char
  4738. void getring (struct map_session_data* sd)
  4739. {
  4740. int flag, item_id;
  4741. struct item item_tmp;
  4742. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4743. memset(&item_tmp, 0, sizeof(item_tmp));
  4744. item_tmp.nameid = item_id;
  4745. item_tmp.identify = 1;
  4746. item_tmp.card[0] = 255;
  4747. item_tmp.card[2] = sd->status.partner_id;
  4748. item_tmp.card[3] = sd->status.partner_id >> 16;
  4749. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4750. clif_additem(sd,0,0,flag);
  4751. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4752. }
  4753. }
  4754. /*==========================================
  4755. * @marry by [MouseJstr], fixed by Lupus
  4756. * Marry two players
  4757. *------------------------------------------*/
  4758. ACMD_FUNC(marry)
  4759. {
  4760. struct map_session_data *pl_sd = NULL;
  4761. char player_name[NAME_LENGTH] = "";
  4762. nullpo_retr(-1, sd);
  4763. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4764. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4765. return -1;
  4766. }
  4767. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4768. clif_displaymessage(fd, msg_txt(sd,3));
  4769. return -1;
  4770. }
  4771. if (pc_marriage(sd, pl_sd)) {
  4772. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4773. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4774. getring(sd); // Auto-give named rings (Aru)
  4775. getring(pl_sd);
  4776. return 0;
  4777. }
  4778. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4779. return -1;
  4780. }
  4781. /*==========================================
  4782. * @divorce by [MouseJstr], fixed by [Lupus]
  4783. * divorce two players
  4784. *------------------------------------------*/
  4785. ACMD_FUNC(divorce)
  4786. {
  4787. nullpo_retr(-1, sd);
  4788. if (!pc_divorce(sd)) {
  4789. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4790. clif_displaymessage(fd, atcmd_output);
  4791. return -1;
  4792. }
  4793. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4794. clif_displaymessage(fd, atcmd_output);
  4795. return 0;
  4796. }
  4797. /*==========================================
  4798. * @changelook by [Celest]
  4799. *------------------------------------------*/
  4800. ACMD_FUNC(changelook)
  4801. {
  4802. int i, j = 0, k = 0;
  4803. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4804. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4805. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4806. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4807. return -1;
  4808. } else if ( i == 2 ) {
  4809. if (j < 1 || j > 7)
  4810. j = 1;
  4811. j = pos[j - 1];
  4812. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4813. k = j; // swap
  4814. j = LOOK_HEAD_TOP;
  4815. }
  4816. clif_changelook(&sd->bl,j,k);
  4817. return 0;
  4818. }
  4819. /*==========================================
  4820. * @autotrade by durf [Lupus] [Paradox924X]
  4821. * Turns on/off Autotrade for a specific player
  4822. *------------------------------------------*/
  4823. ACMD_FUNC(autotrade) {
  4824. nullpo_retr(-1, sd);
  4825. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4826. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4827. return -1;
  4828. }
  4829. if( pc_isdead(sd) ) {
  4830. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4831. return -1;
  4832. }
  4833. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4834. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4835. return -1;
  4836. }
  4837. sd->state.autotrade = 1;
  4838. if( battle_config.at_timeout ) {
  4839. int timeout = atoi(message);
  4840. 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, 0);
  4841. }
  4842. channel_pcquit(sd,0xF); //leave all chan
  4843. clif_authfail_fd(sd->fd, 15);
  4844. return 0;
  4845. }
  4846. /*==========================================
  4847. * @changegm by durf (changed by Lupus)
  4848. * Changes Master of your Guild to a specified guild member
  4849. *------------------------------------------*/
  4850. ACMD_FUNC(changegm)
  4851. {
  4852. struct guild *g;
  4853. struct map_session_data *pl_sd;
  4854. nullpo_retr(-1, sd);
  4855. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4856. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4857. return -1;
  4858. }
  4859. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4860. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4861. return -1;
  4862. }
  4863. if( !message[0] ) {
  4864. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4865. return -1;
  4866. }
  4867. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4868. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4869. return -1;
  4870. }
  4871. guild_gm_change(sd->status.guild_id, pl_sd);
  4872. return 0;
  4873. }
  4874. /*==========================================
  4875. * @changeleader by Skotlex
  4876. * Changes the leader of a party.
  4877. *------------------------------------------*/
  4878. ACMD_FUNC(changeleader)
  4879. {
  4880. nullpo_retr(-1, sd);
  4881. if( !message[0] )
  4882. {
  4883. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4884. return -1;
  4885. }
  4886. if (party_changeleader(sd, map_nick2sd((char *) message),NULL))
  4887. return 0;
  4888. return -1;
  4889. }
  4890. /*==========================================
  4891. * @partyoption by Skotlex
  4892. * Used to change the item share setting of a party.
  4893. *------------------------------------------*/
  4894. ACMD_FUNC(partyoption)
  4895. {
  4896. struct party_data *p;
  4897. int mi, option;
  4898. char w1[16], w2[16];
  4899. nullpo_retr(-1, sd);
  4900. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4901. {
  4902. clif_displaymessage(fd, msg_txt(sd,282));
  4903. return -1;
  4904. }
  4905. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4906. if (mi == MAX_PARTY)
  4907. return -1; //Shouldn't happen
  4908. if (!p->party.member[mi].leader)
  4909. {
  4910. clif_displaymessage(fd, msg_txt(sd,282));
  4911. return -1;
  4912. }
  4913. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4914. {
  4915. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4916. return -1;
  4917. }
  4918. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4919. //Change item share type.
  4920. if (option != p->party.item)
  4921. party_changeoption(sd, p->party.exp, option);
  4922. else
  4923. clif_displaymessage(fd, msg_txt(sd,286));
  4924. return 0;
  4925. }
  4926. /*==========================================
  4927. * @autoloot by Upa-Kun
  4928. * Turns on/off AutoLoot for a specific player
  4929. *------------------------------------------*/
  4930. ACMD_FUNC(autoloot)
  4931. {
  4932. int rate;
  4933. nullpo_retr(-1, sd);
  4934. // autoloot command without value
  4935. if(!message || !*message)
  4936. {
  4937. if (sd->state.autoloot)
  4938. rate = 0;
  4939. else
  4940. rate = 10000;
  4941. } else {
  4942. double drate;
  4943. drate = atof(message);
  4944. rate = (int)(drate*100);
  4945. }
  4946. if (rate < 0) rate = 0;
  4947. if (rate > 10000) rate = 10000;
  4948. sd->state.autoloot = rate;
  4949. if (sd->state.autoloot) {
  4950. 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.
  4951. clif_displaymessage(fd, atcmd_output);
  4952. }else
  4953. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  4954. return 0;
  4955. }
  4956. /*==========================================
  4957. * @alootid
  4958. *------------------------------------------*/
  4959. ACMD_FUNC(autolootitem)
  4960. {
  4961. struct item_data *item_data = NULL;
  4962. int i;
  4963. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4964. nullpo_retr(-1, sd);
  4965. if (message && *message) {
  4966. if (message[0] == '+') {
  4967. message++;
  4968. action = 1;
  4969. }
  4970. else if (message[0] == '-') {
  4971. message++;
  4972. action = 2;
  4973. }
  4974. else if (!strcmp(message,"reset"))
  4975. action = 4;
  4976. }
  4977. if (action < 3) // add or remove
  4978. {
  4979. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4980. item_data = itemdb_searchname(message);
  4981. if (!item_data) {
  4982. // No items founds in the DB with Id or Name
  4983. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  4984. return -1;
  4985. }
  4986. }
  4987. switch(action) {
  4988. case 1:
  4989. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4990. if (i != AUTOLOOTITEM_SIZE) {
  4991. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  4992. return -1;
  4993. }
  4994. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4995. if (i == AUTOLOOTITEM_SIZE) {
  4996. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4997. return -1;
  4998. }
  4999. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  5000. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  5001. clif_displaymessage(fd, atcmd_output);
  5002. sd->state.autolooting = 1;
  5003. break;
  5004. case 2:
  5005. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  5006. if (i == AUTOLOOTITEM_SIZE) {
  5007. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  5008. return -1;
  5009. }
  5010. sd->state.autolootid[i] = 0;
  5011. 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.
  5012. clif_displaymessage(fd, atcmd_output);
  5013. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5014. if (i == AUTOLOOTITEM_SIZE) {
  5015. sd->state.autolooting = 0;
  5016. }
  5017. break;
  5018. case 3:
  5019. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  5020. clif_displaymessage(fd, atcmd_output);
  5021. 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>".
  5022. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  5023. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  5024. if (i == AUTOLOOTITEM_SIZE) {
  5025. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  5026. } else {
  5027. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  5028. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  5029. {
  5030. if (sd->state.autolootid[i] == 0)
  5031. continue;
  5032. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  5033. 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);
  5034. continue;
  5035. }
  5036. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5037. clif_displaymessage(fd, atcmd_output);
  5038. }
  5039. }
  5040. break;
  5041. case 4:
  5042. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5043. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5044. sd->state.autolooting = 0;
  5045. break;
  5046. }
  5047. return 0;
  5048. }
  5049. /*==========================================
  5050. * @autoloottype
  5051. * Flags:
  5052. * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC,
  5053. * 16: IT_ARMOR, 32: IT_WEAPON, 64: IT_CARD, 128: IT_PETEGG,
  5054. * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME
  5055. * 262144: IT_CASH
  5056. *------------------------------------------
  5057. * Credits:
  5058. * chriser
  5059. * Aleos
  5060. *------------------------------------------*/
  5061. ACMD_FUNC(autoloottype)
  5062. {
  5063. uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  5064. enum item_types type = -1;
  5065. int ITEM_NONE = 0, ITEM_MAX = 1533;
  5066. nullpo_retr(-1, sd);
  5067. if (message && *message) {
  5068. if (message[0] == '+') {
  5069. message++;
  5070. action = 1;
  5071. }
  5072. else if (message[0] == '-') {
  5073. message++;
  5074. action = 2;
  5075. }
  5076. else if (!strcmp(message,"reset"))
  5077. action = 4;
  5078. }
  5079. if (action < 3) { // add or remove
  5080. if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0))
  5081. type = IT_HEALING;
  5082. else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2))
  5083. type = IT_USABLE;
  5084. else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3))
  5085. type = IT_ETC;
  5086. else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 4))
  5087. type = IT_ARMOR;
  5088. else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 5))
  5089. type = IT_WEAPON;
  5090. else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6))
  5091. type = IT_CARD;
  5092. else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7))
  5093. type = IT_PETEGG;
  5094. else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8))
  5095. type = IT_PETARMOR;
  5096. else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10))
  5097. type = IT_AMMO;
  5098. else {
  5099. clif_displaymessage(fd, msg_txt(sd,1480)); // Item type not found.
  5100. return -1;
  5101. }
  5102. }
  5103. switch (action) {
  5104. case 1:
  5105. if (sd->state.autoloottype&(1<<type)) {
  5106. clif_displaymessage(fd, msg_txt(sd,1481)); // You're already autolooting this item type.
  5107. return -1;
  5108. }
  5109. if (sd->state.autoloottype == ITEM_MAX) {
  5110. 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>.
  5111. return -1;
  5112. }
  5113. sd->state.autolootingtype = 1; // Autoloot Activated
  5114. sd->state.autoloottype |= (1<<type); // Stores the type
  5115. sprintf(atcmd_output, msg_txt(sd,1483), itemdb_typename(type), type); // Autolooting item type: '%s' {%d}
  5116. clif_displaymessage(fd, atcmd_output);
  5117. break;
  5118. case 2:
  5119. if (!(sd->state.autoloottype&(1<<type))) {
  5120. clif_displaymessage(fd, msg_txt(sd,1484)); // You're currently not autolooting this item type.
  5121. return -1;
  5122. }
  5123. sd->state.autoloottype &= ~(1<<type);
  5124. sprintf(atcmd_output, msg_txt(sd,1485), itemdb_typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list.
  5125. clif_displaymessage(fd, atcmd_output);
  5126. if (sd->state.autoloottype == ITEM_NONE)
  5127. sd->state.autolootingtype = 0;
  5128. break;
  5129. case 3:
  5130. 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>".
  5131. 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
  5132. clif_displaymessage(fd, msg_txt(sd,1488)); // "@aloottype reset" will clear your autoloottype list.
  5133. if (sd->state.autoloottype == ITEM_NONE)
  5134. clif_displaymessage(fd, msg_txt(sd,1489)); // Your autoloottype list is empty.
  5135. else {
  5136. clif_displaymessage(fd, msg_txt(sd,1490)); // Item types on your autoloottype list:
  5137. while (i < IT_MAX) {
  5138. if (sd->state.autoloottype&(1<<i)) {
  5139. sprintf(atcmd_output, " '%s' {%d}", itemdb_typename(i), i);
  5140. clif_displaymessage(fd, atcmd_output);
  5141. }
  5142. i++;
  5143. }
  5144. }
  5145. break;
  5146. case 4:
  5147. sd->state.autoloottype = ITEM_NONE;
  5148. sd->state.autolootingtype = 0;
  5149. clif_displaymessage(fd, msg_txt(sd,1491)); // Your autoloottype list has been reset.
  5150. break;
  5151. }
  5152. return 0;
  5153. }
  5154. /**
  5155. * No longer available, keeping here just in case it's back someday. [Ind]
  5156. **/
  5157. /*==========================================
  5158. * It is made to rain.
  5159. *------------------------------------------*/
  5160. //ACMD_FUNC(rain)
  5161. //{
  5162. // nullpo_retr(-1, sd);
  5163. // if (map[sd->bl.m].flag.rain) {
  5164. // map[sd->bl.m].flag.rain=0;
  5165. // clif_weather(sd->bl.m);
  5166. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5167. // } else {
  5168. // map[sd->bl.m].flag.rain=1;
  5169. // clif_weather(sd->bl.m);
  5170. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5171. // }
  5172. // return 0;
  5173. //}
  5174. /*==========================================
  5175. * It is made to snow.
  5176. *------------------------------------------*/
  5177. ACMD_FUNC(snow)
  5178. {
  5179. nullpo_retr(-1, sd);
  5180. if (map[sd->bl.m].flag.snow) {
  5181. map[sd->bl.m].flag.snow=0;
  5182. clif_weather(sd->bl.m);
  5183. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5184. } else {
  5185. map[sd->bl.m].flag.snow=1;
  5186. clif_weather(sd->bl.m);
  5187. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5188. }
  5189. return 0;
  5190. }
  5191. /*==========================================
  5192. * Cherry tree snowstorm is made to fall. (Sakura)
  5193. *------------------------------------------*/
  5194. ACMD_FUNC(sakura)
  5195. {
  5196. nullpo_retr(-1, sd);
  5197. if (map[sd->bl.m].flag.sakura) {
  5198. map[sd->bl.m].flag.sakura=0;
  5199. clif_weather(sd->bl.m);
  5200. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5201. } else {
  5202. map[sd->bl.m].flag.sakura=1;
  5203. clif_weather(sd->bl.m);
  5204. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5205. }
  5206. return 0;
  5207. }
  5208. /*==========================================
  5209. * Clouds appear.
  5210. *------------------------------------------*/
  5211. ACMD_FUNC(clouds)
  5212. {
  5213. nullpo_retr(-1, sd);
  5214. if (map[sd->bl.m].flag.clouds) {
  5215. map[sd->bl.m].flag.clouds=0;
  5216. clif_weather(sd->bl.m);
  5217. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5218. } else {
  5219. map[sd->bl.m].flag.clouds=1;
  5220. clif_weather(sd->bl.m);
  5221. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5222. }
  5223. return 0;
  5224. }
  5225. /*==========================================
  5226. * Different type of clouds using effect 516
  5227. *------------------------------------------*/
  5228. ACMD_FUNC(clouds2)
  5229. {
  5230. nullpo_retr(-1, sd);
  5231. if (map[sd->bl.m].flag.clouds2) {
  5232. map[sd->bl.m].flag.clouds2=0;
  5233. clif_weather(sd->bl.m);
  5234. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5235. } else {
  5236. map[sd->bl.m].flag.clouds2=1;
  5237. clif_weather(sd->bl.m);
  5238. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5239. }
  5240. return 0;
  5241. }
  5242. /*==========================================
  5243. * Fog hangs over.
  5244. *------------------------------------------*/
  5245. ACMD_FUNC(fog)
  5246. {
  5247. nullpo_retr(-1, sd);
  5248. if (map[sd->bl.m].flag.fog) {
  5249. map[sd->bl.m].flag.fog=0;
  5250. clif_weather(sd->bl.m);
  5251. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5252. } else {
  5253. map[sd->bl.m].flag.fog=1;
  5254. clif_weather(sd->bl.m);
  5255. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5256. }
  5257. return 0;
  5258. }
  5259. /*==========================================
  5260. * Fallen leaves fall.
  5261. *------------------------------------------*/
  5262. ACMD_FUNC(leaves)
  5263. {
  5264. nullpo_retr(-1, sd);
  5265. if (map[sd->bl.m].flag.leaves) {
  5266. map[sd->bl.m].flag.leaves=0;
  5267. clif_weather(sd->bl.m);
  5268. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5269. } else {
  5270. map[sd->bl.m].flag.leaves=1;
  5271. clif_weather(sd->bl.m);
  5272. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5273. }
  5274. return 0;
  5275. }
  5276. /*==========================================
  5277. * Fireworks appear.
  5278. *------------------------------------------*/
  5279. ACMD_FUNC(fireworks)
  5280. {
  5281. nullpo_retr(-1, sd);
  5282. if (map[sd->bl.m].flag.fireworks) {
  5283. map[sd->bl.m].flag.fireworks=0;
  5284. clif_weather(sd->bl.m);
  5285. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5286. } else {
  5287. map[sd->bl.m].flag.fireworks=1;
  5288. clif_weather(sd->bl.m);
  5289. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5290. }
  5291. return 0;
  5292. }
  5293. /*==========================================
  5294. * Clearing Weather Effects by Dexity
  5295. *------------------------------------------*/
  5296. ACMD_FUNC(clearweather)
  5297. {
  5298. nullpo_retr(-1, sd);
  5299. /**
  5300. * No longer available, keeping here just in case it's back someday. [Ind]
  5301. **/
  5302. //map[sd->bl.m].flag.rain=0;
  5303. map[sd->bl.m].flag.snow=0;
  5304. map[sd->bl.m].flag.sakura=0;
  5305. map[sd->bl.m].flag.clouds=0;
  5306. map[sd->bl.m].flag.clouds2=0;
  5307. map[sd->bl.m].flag.fog=0;
  5308. map[sd->bl.m].flag.fireworks=0;
  5309. map[sd->bl.m].flag.leaves=0;
  5310. clif_weather(sd->bl.m);
  5311. clif_displaymessage(fd, msg_txt(sd,291));
  5312. return 0;
  5313. }
  5314. /*===============================================================
  5315. * Sound Command - plays a sound for everyone around! [Codemaster]
  5316. *---------------------------------------------------------------*/
  5317. ACMD_FUNC(sound)
  5318. {
  5319. char sound_file[100];
  5320. memset(sound_file, '\0', sizeof(sound_file));
  5321. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5322. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5323. return -1;
  5324. }
  5325. if(strstr(sound_file, ".wav") == NULL)
  5326. strcat(sound_file, ".wav");
  5327. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5328. return 0;
  5329. }
  5330. /*==========================================
  5331. * MOB Search
  5332. *------------------------------------------*/
  5333. ACMD_FUNC(mobsearch)
  5334. {
  5335. char mob_name[100];
  5336. int mob_id;
  5337. int number = 0;
  5338. struct s_mapiterator* it;
  5339. nullpo_retr(-1, sd);
  5340. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5341. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5342. return -1;
  5343. }
  5344. if ((mob_id = atoi(mob_name)) == 0)
  5345. mob_id = mobdb_searchname(mob_name);
  5346. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5347. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5348. clif_displaymessage(fd, atcmd_output);
  5349. return -1;
  5350. }
  5351. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5352. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5353. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5354. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5355. clif_displaymessage(fd, atcmd_output);
  5356. it = mapit_geteachmob();
  5357. for(;;)
  5358. {
  5359. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5360. if( md == NULL )
  5361. break;// no more mobs
  5362. if( md->bl.m != sd->bl.m )
  5363. continue;
  5364. if( mob_id != -1 && md->class_ != mob_id )
  5365. continue;
  5366. ++number;
  5367. if( md->spawn_timer == INVALID_TIMER )
  5368. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5369. else
  5370. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5371. clif_displaymessage(fd, atcmd_output);
  5372. }
  5373. mapit_free(it);
  5374. return 0;
  5375. }
  5376. /*==========================================
  5377. * @cleanmap - cleans items on the ground
  5378. * @cleanarea - cleans items on the ground within an specified area
  5379. *------------------------------------------*/
  5380. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5381. {
  5382. nullpo_ret(bl);
  5383. map_clearflooritem(bl);
  5384. return 0;
  5385. }
  5386. ACMD_FUNC(cleanmap)
  5387. {
  5388. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5389. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5390. return 0;
  5391. }
  5392. ACMD_FUNC(cleanarea)
  5393. {
  5394. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5395. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5396. 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);
  5397. }
  5398. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5399. 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);
  5400. }
  5401. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5402. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5403. }
  5404. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5405. return 0;
  5406. }
  5407. /*==========================================
  5408. * make a NPC/PET talk
  5409. * @npctalkc [SnakeDrak]
  5410. *------------------------------------------*/
  5411. ACMD_FUNC(npctalk)
  5412. {
  5413. char name[NAME_LENGTH],mes[100],temp[100];
  5414. struct npc_data *nd;
  5415. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5416. unsigned long color=0;
  5417. if (sd->sc.cant.chat)
  5418. return -1; //no "chatting" while muted.
  5419. if(!ifcolor) {
  5420. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5421. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5422. return -1;
  5423. }
  5424. }
  5425. else {
  5426. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5427. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5428. return -1;
  5429. }
  5430. }
  5431. if (!(nd = npc_name2id(name))) {
  5432. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5433. return -1;
  5434. }
  5435. strtok(name, "#"); // discard extra name identifier if present
  5436. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5437. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5438. else clif_disp_overhead(&nd->bl, temp);
  5439. return 0;
  5440. }
  5441. ACMD_FUNC(pettalk)
  5442. {
  5443. char mes[100],temp[100];
  5444. struct pet_data *pd;
  5445. nullpo_retr(-1, sd);
  5446. if ( battle_config.min_chat_delay ) {
  5447. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5448. return 0;
  5449. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5450. }
  5451. if(!sd->status.pet_id || !(pd=sd->pd))
  5452. {
  5453. clif_displaymessage(fd, msg_txt(sd,184));
  5454. return -1;
  5455. }
  5456. if (sd->sc.cant.chat)
  5457. return -1; //no "chatting" while muted.
  5458. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5459. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5460. return -1;
  5461. }
  5462. if (message[0] == '/')
  5463. {// pet emotion processing
  5464. const char* emo[] = {
  5465. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5466. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5467. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5468. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5469. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5470. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5471. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5472. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5473. "/whisp"
  5474. };
  5475. int i;
  5476. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5477. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5478. if( i < ARRAYLENGTH(emo) )
  5479. {
  5480. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5481. sd->emotionlasttime = time(NULL);
  5482. return 0;
  5483. }
  5484. sd->emotionlasttime = time(NULL);
  5485. clif_emotion(&pd->bl, i);
  5486. return 0;
  5487. }
  5488. }
  5489. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5490. clif_disp_overhead(&pd->bl, temp);
  5491. return 0;
  5492. }
  5493. /// @users - displays the number of players present on each map (and percentage)
  5494. /// #users displays on the target user instead of self
  5495. ACMD_FUNC(users)
  5496. {
  5497. char buf[CHAT_SIZE_MAX];
  5498. int i;
  5499. int users[MAX_MAPINDEX];
  5500. int users_all;
  5501. struct s_mapiterator* iter;
  5502. memset(users, 0, sizeof(users));
  5503. users_all = 0;
  5504. // count users on each map
  5505. iter = mapit_getallusers();
  5506. for(;;)
  5507. {
  5508. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5509. if( sd2 == NULL )
  5510. break;// no more users
  5511. if( sd2->mapindex >= MAX_MAPINDEX )
  5512. continue;// invalid mapindex
  5513. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5514. if( users_all < INT_MAX ) ++users_all;
  5515. }
  5516. mapit_free(iter);
  5517. // display results for each map
  5518. for( i = 0; i < MAX_MAPINDEX; ++i )
  5519. {
  5520. if( users[i] == 0 )
  5521. continue;// empty
  5522. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5523. clif_displaymessage(sd->fd, buf);
  5524. }
  5525. // display overall count
  5526. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5527. clif_displaymessage(sd->fd, buf);
  5528. return 0;
  5529. }
  5530. /*==========================================
  5531. *
  5532. *------------------------------------------*/
  5533. ACMD_FUNC(reset)
  5534. {
  5535. pc_resetstate(sd);
  5536. pc_resetskill(sd,1);
  5537. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5538. clif_displaymessage(fd, atcmd_output);
  5539. return 0;
  5540. }
  5541. /*==========================================
  5542. *
  5543. *------------------------------------------*/
  5544. ACMD_FUNC(summon)
  5545. {
  5546. char name[NAME_LENGTH];
  5547. int mob_id = 0;
  5548. int duration = 0;
  5549. struct mob_data *md;
  5550. unsigned int tick=gettick();
  5551. nullpo_retr(-1, sd);
  5552. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5553. {
  5554. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5555. return -1;
  5556. }
  5557. if (duration < 1)
  5558. duration =1;
  5559. else if (duration > 60)
  5560. duration =60;
  5561. if ((mob_id = atoi(name)) == 0)
  5562. mob_id = mobdb_searchname(name);
  5563. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5564. {
  5565. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5566. return -1;
  5567. }
  5568. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5569. if(!md)
  5570. return -1;
  5571. md->master_id=sd->bl.id;
  5572. md->special_state.ai=AI_ATTACK;
  5573. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5574. clif_specialeffect(&md->bl,344,AREA);
  5575. mob_spawn(md);
  5576. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5577. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5578. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5579. return 0;
  5580. }
  5581. /*==========================================
  5582. * @adjgroup
  5583. * Temporarily move player to another group
  5584. * Useful during beta testing to allow players to use GM commands for short periods of time
  5585. *------------------------------------------*/
  5586. ACMD_FUNC(adjgroup)
  5587. {
  5588. int new_group = 0;
  5589. nullpo_retr(-1, sd);
  5590. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5591. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5592. return -1;
  5593. }
  5594. if (!pc_group_exists(new_group)) {
  5595. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5596. return -1;
  5597. }
  5598. sd->group_id = new_group;
  5599. pc_group_pc_load(sd);/* update cache */
  5600. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5601. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5602. return 0;
  5603. }
  5604. /*==========================================
  5605. * @trade by [MouseJstr]
  5606. * Open a trade window with a remote player
  5607. *------------------------------------------*/
  5608. ACMD_FUNC(trade)
  5609. {
  5610. struct map_session_data *pl_sd = NULL;
  5611. nullpo_retr(-1, sd);
  5612. if (!message || !*message) {
  5613. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5614. return -1;
  5615. }
  5616. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5617. {
  5618. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5619. return -1;
  5620. }
  5621. trade_traderequest(sd, pl_sd);
  5622. return 0;
  5623. }
  5624. /*==========================================
  5625. * @setbattleflag by [MouseJstr]
  5626. * set a battle_config flag without having to reboot
  5627. *------------------------------------------*/
  5628. ACMD_FUNC(setbattleflag)
  5629. {
  5630. char flag[128], value[128];
  5631. nullpo_retr(-1, sd);
  5632. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5633. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5634. return -1;
  5635. }
  5636. if (battle_set_value(flag, value) == 0)
  5637. {
  5638. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5639. return -1;
  5640. }
  5641. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5642. return 0;
  5643. }
  5644. /*==========================================
  5645. * @unmute [Valaris]
  5646. *------------------------------------------*/
  5647. ACMD_FUNC(unmute)
  5648. {
  5649. struct map_session_data *pl_sd = NULL;
  5650. nullpo_retr(-1, sd);
  5651. if (!message || !*message) {
  5652. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5653. return -1;
  5654. }
  5655. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5656. {
  5657. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5658. return -1;
  5659. }
  5660. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5661. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5662. return -1;
  5663. }
  5664. pl_sd->status.manner = 0;
  5665. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5666. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5667. return 0;
  5668. }
  5669. /*==========================================
  5670. * @uptime by MC Cameri
  5671. *------------------------------------------*/
  5672. ACMD_FUNC(uptime)
  5673. {
  5674. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5675. minute = 60, days = 0, hours = 0, minutes = 0;
  5676. nullpo_retr(-1, sd);
  5677. seconds = get_uptime();
  5678. days = seconds/day;
  5679. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5680. hours = seconds/hour;
  5681. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5682. minutes = seconds/minute;
  5683. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5684. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5685. clif_displaymessage(fd, atcmd_output);
  5686. return 0;
  5687. }
  5688. /*==========================================
  5689. * @changesex <sex>
  5690. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5691. *------------------------------------------*/
  5692. ACMD_FUNC(changesex)
  5693. {
  5694. int i;
  5695. nullpo_retr(-1, sd);
  5696. pc_resetskill(sd,4);
  5697. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5698. for( i=0; i<EQI_MAX; i++ )
  5699. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5700. chrif_changesex(sd);
  5701. return 0;
  5702. }
  5703. /*================================================
  5704. * @mute - Mutes a player for a set amount of time
  5705. *------------------------------------------------*/
  5706. ACMD_FUNC(mute)
  5707. {
  5708. struct map_session_data *pl_sd = NULL;
  5709. int manner;
  5710. nullpo_retr(-1, sd);
  5711. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5712. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5713. return -1;
  5714. }
  5715. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5716. {
  5717. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5718. return -1;
  5719. }
  5720. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5721. {
  5722. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5723. return -1;
  5724. }
  5725. clif_manner_message(sd, 0);
  5726. clif_manner_message(pl_sd, 5);
  5727. if( pl_sd->status.manner < manner ) {
  5728. pl_sd->status.manner -= manner;
  5729. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5730. } else {
  5731. pl_sd->status.manner = 0;
  5732. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5733. }
  5734. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5735. return 0;
  5736. }
  5737. /*==========================================
  5738. * @refresh (like @jumpto <<yourself>>)
  5739. *------------------------------------------*/
  5740. ACMD_FUNC(refresh)
  5741. {
  5742. nullpo_retr(-1, sd);
  5743. clif_refresh(sd);
  5744. return 0;
  5745. }
  5746. ACMD_FUNC(refreshall)
  5747. {
  5748. struct map_session_data* iter_sd;
  5749. struct s_mapiterator* iter;
  5750. nullpo_retr(-1, sd);
  5751. iter = mapit_getallusers();
  5752. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5753. clif_refresh(iter_sd);
  5754. mapit_free(iter);
  5755. return 0;
  5756. }
  5757. /*==========================================
  5758. * @identify
  5759. * => GM's magnifier.
  5760. *------------------------------------------*/
  5761. ACMD_FUNC(identify)
  5762. {
  5763. int i,num;
  5764. nullpo_retr(-1, sd);
  5765. for(i=num=0;i<MAX_INVENTORY;i++){
  5766. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5767. num++;
  5768. }
  5769. }
  5770. if (num > 0) {
  5771. clif_item_identify_list(sd);
  5772. } else {
  5773. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5774. }
  5775. return 0;
  5776. }
  5777. /*===============================================
  5778. * @identifyall
  5779. * => Indentify all items in inventory - Akinari
  5780. *-----------------------------------------------*/
  5781. ACMD_FUNC(identifyall)
  5782. {
  5783. int i;
  5784. nullpo_retr(-1, sd);
  5785. for(i=0; i<MAX_INVENTORY; i++) {
  5786. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5787. sd->status.inventory[i].identify=1;
  5788. clif_item_identified(sd,i,0);
  5789. }
  5790. }
  5791. return 0;
  5792. }
  5793. /*==========================================
  5794. * @gmotd (Global MOTD)
  5795. * by davidsiaw :P
  5796. *------------------------------------------*/
  5797. ACMD_FUNC(gmotd)
  5798. {
  5799. FILE* fp;
  5800. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5801. {
  5802. char buf[CHAT_SIZE_MAX];
  5803. size_t len;
  5804. while( fgets(buf, sizeof(buf), fp) )
  5805. {
  5806. if( buf[0] == '/' && buf[1] == '/' )
  5807. {
  5808. continue;
  5809. }
  5810. len = strlen(buf);
  5811. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5812. {// strip trailing EOL characters
  5813. len--;
  5814. }
  5815. if( len )
  5816. {
  5817. buf[len] = 0;
  5818. intif_broadcast(buf, len+1, 0);
  5819. }
  5820. }
  5821. fclose(fp);
  5822. }
  5823. return 0;
  5824. }
  5825. ACMD_FUNC(misceffect)
  5826. {
  5827. int effect = 0;
  5828. nullpo_retr(-1, sd);
  5829. if (!message || !*message)
  5830. return -1;
  5831. if (sscanf(message, "%d", &effect) < 1)
  5832. return -1;
  5833. clif_misceffect(&sd->bl,effect);
  5834. return 0;
  5835. }
  5836. /*==========================================
  5837. * MAIL SYSTEM
  5838. *------------------------------------------*/
  5839. ACMD_FUNC(mail)
  5840. {
  5841. nullpo_ret(sd);
  5842. mail_openmail(sd);
  5843. return 0;
  5844. }
  5845. /*==========================================
  5846. * Show Monster DB Info v 1.0
  5847. * originally by [Lupus]
  5848. *------------------------------------------*/
  5849. ACMD_FUNC(mobinfo)
  5850. {
  5851. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5852. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5853. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5854. char atcmd_output2[CHAT_SIZE_MAX];
  5855. struct item_data *item_data;
  5856. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5857. int count;
  5858. int i, j, k;
  5859. unsigned int base_exp, job_exp;
  5860. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5861. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5862. if (!message || !*message) {
  5863. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5864. return -1;
  5865. }
  5866. // If monster identifier/name argument is a name
  5867. if ((i = mobdb_checkid(atoi(message))))
  5868. {
  5869. mob_array[0] = mob_db(i);
  5870. count = 1;
  5871. } else
  5872. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5873. if (!count) {
  5874. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5875. return -1;
  5876. }
  5877. if (count > MAX_SEARCH) {
  5878. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5879. clif_displaymessage(fd, atcmd_output);
  5880. count = MAX_SEARCH;
  5881. }
  5882. for (k = 0; k < count; k++) {
  5883. mob = mob_array[k];
  5884. base_exp = mob->base_exp;
  5885. job_exp = mob->job_exp;
  5886. #ifdef RENEWAL_EXP
  5887. if( battle_config.atcommand_mobinfo_type ) {
  5888. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5889. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5890. }
  5891. #endif
  5892. // stats
  5893. if (mob->mexp)
  5894. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5895. else
  5896. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5897. clif_displaymessage(fd, atcmd_output);
  5898. 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
  5899. clif_displaymessage(fd, atcmd_output);
  5900. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5901. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5902. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5903. clif_displaymessage(fd, atcmd_output);
  5904. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5905. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5906. mob->range2 , mob->range3, msize[mob->status.size],
  5907. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5908. clif_displaymessage(fd, atcmd_output);
  5909. // drops
  5910. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  5911. strcpy(atcmd_output, " ");
  5912. j = 0;
  5913. for (i = 0; i < MAX_MOB_DROP; i++) {
  5914. int droprate;
  5915. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5916. continue;
  5917. droprate = mob->dropitem[i].p;
  5918. #ifdef RENEWAL_DROP
  5919. if( battle_config.atcommand_mobinfo_type ) {
  5920. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 2) / 100;
  5921. if (droprate <= 0 && !battle_config.drop_rate0item)
  5922. droprate = 1;
  5923. }
  5924. #endif
  5925. if (item_data->slot)
  5926. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5927. else
  5928. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5929. strcat(atcmd_output, atcmd_output2);
  5930. if (++j % 3 == 0) {
  5931. clif_displaymessage(fd, atcmd_output);
  5932. strcpy(atcmd_output, " ");
  5933. }
  5934. }
  5935. if (j == 0)
  5936. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  5937. else if (j % 3 != 0)
  5938. clif_displaymessage(fd, atcmd_output);
  5939. // mvp
  5940. if (mob->mexp) {
  5941. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  5942. clif_displaymessage(fd, atcmd_output);
  5943. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  5944. j = 0;
  5945. for (i = 0; i < MAX_MVP_DROP; i++) {
  5946. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5947. continue;
  5948. if (mob->mvpitem[i].p > 0) {
  5949. j++;
  5950. if (j == 1) {
  5951. if (item_data->slot)
  5952. sprintf(atcmd_output2, " %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  5953. else
  5954. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5955. } else {
  5956. if (item_data->slot)
  5957. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)mob->mvpitem[i].p / 100);
  5958. else
  5959. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5960. }
  5961. strcat(atcmd_output, atcmd_output2);
  5962. }
  5963. }
  5964. if (j == 0)
  5965. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  5966. else
  5967. clif_displaymessage(fd, atcmd_output);
  5968. }
  5969. }
  5970. return 0;
  5971. }
  5972. /*=========================================
  5973. * @showmobs by KarLaeda
  5974. * => For 15 sec displays the mobs on minimap
  5975. *------------------------------------------*/
  5976. ACMD_FUNC(showmobs)
  5977. {
  5978. char mob_name[100];
  5979. int mob_id;
  5980. int number = 0;
  5981. struct s_mapiterator* it;
  5982. nullpo_retr(-1, sd);
  5983. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5984. return -1;
  5985. if((mob_id = atoi(mob_name)) == 0)
  5986. mob_id = mobdb_searchname(mob_name);
  5987. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5988. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  5989. clif_displaymessage(fd, atcmd_output);
  5990. return 0;
  5991. }
  5992. 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.
  5993. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  5994. return 0;
  5995. }
  5996. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5997. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5998. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5999. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  6000. mob_name, mapindex_id2name(sd->mapindex));
  6001. clif_displaymessage(fd, atcmd_output);
  6002. it = mapit_geteachmob();
  6003. for(;;)
  6004. {
  6005. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  6006. if( md == NULL )
  6007. break;// no more mobs
  6008. if( md->bl.m != sd->bl.m )
  6009. continue;
  6010. if( mob_id != -1 && md->class_ != mob_id )
  6011. continue;
  6012. if( md->special_state.ai || md->master_id )
  6013. continue; // hide slaves and player summoned mobs
  6014. if( md->spawn_timer != INVALID_TIMER )
  6015. continue; // hide mobs waiting for respawn
  6016. ++number;
  6017. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  6018. }
  6019. mapit_free(it);
  6020. return 0;
  6021. }
  6022. /*==========================================
  6023. * homunculus level up [orn]
  6024. *------------------------------------------*/
  6025. ACMD_FUNC(homlevel)
  6026. {
  6027. TBL_HOM * hd;
  6028. int level = 0, i = 0;
  6029. nullpo_retr(-1, sd);
  6030. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  6031. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  6032. return -1;
  6033. }
  6034. if ( !merc_is_hom_active(sd->hd) ) {
  6035. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6036. return -1;
  6037. }
  6038. hd = sd->hd;
  6039. for (i = 1; i <= level && hd->exp_next; i++){
  6040. hd->homunculus.exp += hd->exp_next;
  6041. if( !merc_hom_levelup(hd) ){
  6042. break;
  6043. }
  6044. }
  6045. status_calc_homunculus(hd,0);
  6046. status_percent_heal(&hd->bl, 100, 100);
  6047. clif_specialeffect(&hd->bl,568,AREA);
  6048. return 0;
  6049. }
  6050. /*==========================================
  6051. * homunculus evolution H [orn]
  6052. *------------------------------------------*/
  6053. ACMD_FUNC(homevolution)
  6054. {
  6055. nullpo_retr(-1, sd);
  6056. if ( !merc_is_hom_active(sd->hd) ) {
  6057. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6058. return -1;
  6059. }
  6060. if ( !merc_hom_evolution(sd->hd) ) {
  6061. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  6062. return -1;
  6063. }
  6064. clif_homskillinfoblock(sd);
  6065. return 0;
  6066. }
  6067. ACMD_FUNC(hommutate)
  6068. {
  6069. int homun_id, m_class = 0, m_id;
  6070. nullpo_retr(-1, sd);
  6071. if (!merc_is_hom_active(sd->hd)) {
  6072. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6073. return -1;
  6074. }
  6075. if (!message || !*message) {
  6076. homun_id = 6048 + (rnd() % 4);
  6077. } else {
  6078. homun_id = atoi(message);
  6079. }
  6080. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  6081. m_id = hom_class2mapid(homun_id);
  6082. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  6083. hom_mutate(sd->hd, homun_id);
  6084. } else {
  6085. clif_emotion(&sd->hd->bl, E_SWT);
  6086. }
  6087. return 0;
  6088. }
  6089. /*==========================================
  6090. * call choosen homunculus [orn]
  6091. *------------------------------------------*/
  6092. ACMD_FUNC(makehomun)
  6093. {
  6094. int homunid;
  6095. nullpo_retr(-1, sd);
  6096. if ( sd->status.hom_id ) {
  6097. clif_displaymessage(fd, msg_txt(sd,450));
  6098. return -1;
  6099. }
  6100. if (!message || !*message) {
  6101. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  6102. return -1;
  6103. }
  6104. homunid = atoi(message);
  6105. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  6106. {
  6107. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  6108. return -1;
  6109. }
  6110. merc_create_homunculus_request(sd,homunid);
  6111. return 0;
  6112. }
  6113. /*==========================================
  6114. * modify homunculus intimacy [orn]
  6115. *------------------------------------------*/
  6116. ACMD_FUNC(homfriendly)
  6117. {
  6118. int friendly = 0;
  6119. nullpo_retr(-1, sd);
  6120. if ( !merc_is_hom_active(sd->hd) ) {
  6121. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6122. return -1;
  6123. }
  6124. if (!message || !*message) {
  6125. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  6126. return -1;
  6127. }
  6128. friendly = atoi(message);
  6129. friendly = cap_value(friendly, 0, 1000);
  6130. sd->hd->homunculus.intimacy = friendly * 100 ;
  6131. clif_send_homdata(sd,SP_INTIMATE,friendly);
  6132. return 0;
  6133. }
  6134. /*==========================================
  6135. * modify homunculus hunger [orn]
  6136. *------------------------------------------*/
  6137. ACMD_FUNC(homhungry)
  6138. {
  6139. int hungry = 0;
  6140. nullpo_retr(-1, sd);
  6141. if ( !merc_is_hom_active(sd->hd) ) {
  6142. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6143. return -1;
  6144. }
  6145. if (!message || !*message) {
  6146. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6147. return -1;
  6148. }
  6149. hungry = atoi(message);
  6150. hungry = cap_value(hungry, 0, 100);
  6151. sd->hd->homunculus.hunger = hungry;
  6152. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6153. return 0;
  6154. }
  6155. /*==========================================
  6156. * make the homunculus speak [orn]
  6157. *------------------------------------------*/
  6158. ACMD_FUNC(homtalk)
  6159. {
  6160. char mes[100],temp[100];
  6161. nullpo_retr(-1, sd);
  6162. if ( battle_config.min_chat_delay ) {
  6163. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6164. return 0;
  6165. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6166. }
  6167. if (sd->sc.cant.chat)
  6168. return -1; //no "chatting" while muted.
  6169. if ( !merc_is_hom_active(sd->hd) ) {
  6170. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6171. return -1;
  6172. }
  6173. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6174. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6175. return -1;
  6176. }
  6177. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6178. clif_disp_overhead(&sd->hd->bl, temp);
  6179. return 0;
  6180. }
  6181. /*==========================================
  6182. * Show homunculus stats
  6183. *------------------------------------------*/
  6184. ACMD_FUNC(hominfo)
  6185. {
  6186. struct homun_data *hd;
  6187. struct status_data *status;
  6188. nullpo_retr(-1, sd);
  6189. if ( !merc_is_hom_active(sd->hd) ) {
  6190. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6191. return -1;
  6192. }
  6193. hd = sd->hd;
  6194. status = status_get_status_data(&hd->bl);
  6195. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6196. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6197. status->hp, status->max_hp, status->sp, status->max_sp);
  6198. clif_displaymessage(fd, atcmd_output);
  6199. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6200. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6201. clif_displaymessage(fd, atcmd_output);
  6202. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6203. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6204. clif_displaymessage(fd, atcmd_output);
  6205. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6206. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6207. status->str, status->agi, status->vit,
  6208. status->int_, status->dex, status->luk);
  6209. clif_displaymessage(fd, atcmd_output);
  6210. return 0;
  6211. }
  6212. ACMD_FUNC(homstats)
  6213. {
  6214. struct homun_data *hd;
  6215. struct s_homunculus_db *db;
  6216. struct s_homunculus *hom;
  6217. int lv, min, max, evo;
  6218. nullpo_retr(-1, sd);
  6219. if ( !merc_is_hom_active(sd->hd) ) {
  6220. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6221. return -1;
  6222. }
  6223. hd = sd->hd;
  6224. hom = &hd->homunculus;
  6225. db = hd->homunculusDB;
  6226. lv = hom->level;
  6227. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6228. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6229. clif_displaymessage(fd, atcmd_output);
  6230. lv--; //Since the first increase is at level 2.
  6231. evo = (hom->class_ == db->evo_class);
  6232. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6233. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6234. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6235. clif_displaymessage(fd, atcmd_output);
  6236. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6237. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6238. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6239. clif_displaymessage(fd, atcmd_output);
  6240. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6241. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6242. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6243. clif_displaymessage(fd, atcmd_output);
  6244. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6245. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6246. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6247. clif_displaymessage(fd, atcmd_output);
  6248. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6249. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6250. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6251. clif_displaymessage(fd, atcmd_output);
  6252. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6253. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6254. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6255. clif_displaymessage(fd, atcmd_output);
  6256. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6257. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6258. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6259. clif_displaymessage(fd, atcmd_output);
  6260. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6261. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6262. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6263. clif_displaymessage(fd, atcmd_output);
  6264. return 0;
  6265. }
  6266. ACMD_FUNC(homshuffle)
  6267. {
  6268. nullpo_retr(-1, sd);
  6269. if(!sd->hd)
  6270. return -1; // nothing to do
  6271. if(!merc_hom_shuffle(sd->hd))
  6272. return -1;
  6273. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6274. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6275. return 0;
  6276. }
  6277. /*==========================================
  6278. * Show Items DB Info v 1.0
  6279. * originally by [Lupus]
  6280. *------------------------------------------*/
  6281. ACMD_FUNC(iteminfo)
  6282. {
  6283. struct item_data *item_data, *item_array[MAX_SEARCH];
  6284. int i, count = 1;
  6285. if (!message || !*message) {
  6286. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6287. return -1;
  6288. }
  6289. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6290. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6291. if (!count) {
  6292. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6293. return -1;
  6294. }
  6295. if (count > MAX_SEARCH) {
  6296. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6297. clif_displaymessage(fd, atcmd_output);
  6298. count = MAX_SEARCH;
  6299. }
  6300. for (i = 0; i < count; i++) {
  6301. item_data = item_array[i];
  6302. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6303. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6304. itemdb_typename(item_data->type),
  6305. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6306. );
  6307. clif_displaymessage(fd, atcmd_output);
  6308. 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
  6309. clif_displaymessage(fd, atcmd_output);
  6310. if (item_data->maxchance == -1)
  6311. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6312. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6313. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6314. else
  6315. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6316. clif_displaymessage(fd, atcmd_output);
  6317. }
  6318. return 0;
  6319. }
  6320. /*==========================================
  6321. * Show who drops the item.
  6322. *------------------------------------------*/
  6323. ACMD_FUNC(whodrops)
  6324. {
  6325. struct item_data *item_data, *item_array[MAX_SEARCH];
  6326. int i,j, count = 1;
  6327. if (!message || !*message) {
  6328. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6329. return -1;
  6330. }
  6331. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6332. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6333. if (!count) {
  6334. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6335. return -1;
  6336. }
  6337. if (count > MAX_SEARCH) {
  6338. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6339. clif_displaymessage(fd, atcmd_output);
  6340. count = MAX_SEARCH;
  6341. }
  6342. for (i = 0; i < count; i++) {
  6343. item_data = item_array[i];
  6344. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname, item_data->slot, item_data->nameid); // Item: '%s'[%d] (ID:%d)
  6345. clif_displaymessage(fd, atcmd_output);
  6346. if (item_data->mob[0].chance == 0) {
  6347. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6348. clif_displaymessage(fd, atcmd_output);
  6349. } else {
  6350. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6351. clif_displaymessage(fd, atcmd_output);
  6352. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6353. {
  6354. int dropchance = item_data->mob[j].chance;
  6355. #ifdef RENEWAL_DROP
  6356. if( battle_config.atcommand_mobinfo_type )
  6357. dropchance = dropchance * pc_level_penalty_mod(sd, mob_db(item_data->mob[j].id)->lv, mob_db(item_data->mob[j].id)->status.race, mob_db(item_data->mob[j].id)->status.mode, 2) / 100;
  6358. #endif
  6359. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6360. clif_displaymessage(fd, atcmd_output);
  6361. }
  6362. }
  6363. }
  6364. return 0;
  6365. }
  6366. ACMD_FUNC(whereis)
  6367. {
  6368. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6369. int count;
  6370. int i, j, k;
  6371. if (!message || !*message) {
  6372. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6373. return -1;
  6374. }
  6375. // If monster identifier/name argument is a name
  6376. if ((i = mobdb_checkid(atoi(message))))
  6377. {
  6378. mob_array[0] = mob_db(i);
  6379. count = 1;
  6380. } else
  6381. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6382. if (!count) {
  6383. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6384. return -1;
  6385. }
  6386. if (count > MAX_SEARCH) {
  6387. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6388. clif_displaymessage(fd, atcmd_output);
  6389. count = MAX_SEARCH;
  6390. }
  6391. for (k = 0; k < count; k++) {
  6392. mob = mob_array[k];
  6393. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6394. clif_displaymessage(fd, atcmd_output);
  6395. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6396. {
  6397. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6398. if (j < 0) continue;
  6399. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6400. clif_displaymessage(fd, atcmd_output);
  6401. }
  6402. if (i == 0)
  6403. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6404. }
  6405. return 0;
  6406. }
  6407. ACMD_FUNC(version)
  6408. {
  6409. pc_show_version(sd);
  6410. return 0;
  6411. }
  6412. /*==========================================
  6413. * @mutearea by MouseJstr
  6414. *------------------------------------------*/
  6415. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6416. {
  6417. int time, id;
  6418. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6419. if (pl_sd == NULL)
  6420. return 0;
  6421. id = va_arg(ap, int);
  6422. time = va_arg(ap, int);
  6423. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6424. pl_sd->status.manner -= time;
  6425. if (pl_sd->status.manner < 0)
  6426. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6427. else
  6428. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6429. }
  6430. return 0;
  6431. }
  6432. ACMD_FUNC(mutearea)
  6433. {
  6434. int time;
  6435. nullpo_ret(sd);
  6436. if (!message || !*message) {
  6437. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6438. return -1;
  6439. }
  6440. time = atoi(message);
  6441. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6442. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6443. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6444. return 0;
  6445. }
  6446. ACMD_FUNC(rates)
  6447. {
  6448. char buf[CHAT_SIZE_MAX];
  6449. int base_exp_rate = 0, job_exp_rate = 0, item_rate = 0;
  6450. nullpo_ret(sd);
  6451. memset(buf, '\0', sizeof(buf));
  6452. // Display EXP and item rate increase for VIP.
  6453. if (pc_isvip(sd) && (battle_config.vip_base_exp_increase || battle_config.vip_job_exp_increase || battle_config.vip_drop_increase)) {
  6454. base_exp_rate += battle_config.vip_base_exp_increase;
  6455. job_exp_rate += battle_config.vip_job_exp_increase;
  6456. item_rate += battle_config.vip_drop_increase;
  6457. }
  6458. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6459. (battle_config.base_exp_rate+base_exp_rate)/100., (battle_config.job_exp_rate+job_exp_rate)/100.);
  6460. clif_displaymessage(fd, buf);
  6461. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6462. (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.);
  6463. clif_displaymessage(fd, buf);
  6464. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6465. (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.);
  6466. clif_displaymessage(fd, buf);
  6467. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6468. (battle_config.item_rate_mvp+item_rate)/100., (battle_config.item_rate_adddrop+item_rate)/100., (battle_config.item_rate_treasure+item_rate)/100.);
  6469. clif_displaymessage(fd, buf);
  6470. return 0;
  6471. }
  6472. /*==========================================
  6473. * @me by lordalfa
  6474. * => Displays the OUTPUT string on top of the Visible players Heads.
  6475. *------------------------------------------*/
  6476. ACMD_FUNC(me)
  6477. {
  6478. char tempmes[CHAT_SIZE_MAX];
  6479. nullpo_retr(-1, sd);
  6480. memset(tempmes, '\0', sizeof(tempmes));
  6481. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6482. if (sd->sc.cant.chat)
  6483. return -1; //no "chatting" while muted.
  6484. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6485. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6486. return -1;
  6487. }
  6488. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6489. clif_disp_overhead(&sd->bl, atcmd_output);
  6490. return 0;
  6491. }
  6492. /*==========================================
  6493. * @size
  6494. * => Resize your character sprite. [Valaris]
  6495. *------------------------------------------*/
  6496. ACMD_FUNC(size)
  6497. {
  6498. int size = 0;
  6499. nullpo_retr(-1, sd);
  6500. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6501. if(sd->state.size) {
  6502. sd->state.size = SZ_SMALL;
  6503. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6504. }
  6505. sd->state.size = size;
  6506. if( size == SZ_MEDIUM )
  6507. clif_specialeffect(&sd->bl,420,AREA);
  6508. else if( size == SZ_BIG )
  6509. clif_specialeffect(&sd->bl,422,AREA);
  6510. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6511. return 0;
  6512. }
  6513. ACMD_FUNC(sizeall)
  6514. {
  6515. int size;
  6516. struct map_session_data *pl_sd;
  6517. struct s_mapiterator* iter;
  6518. size = atoi(message);
  6519. size = cap_value(size,0,2);
  6520. iter = mapit_getallusers();
  6521. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6522. if( pl_sd->state.size != size ) {
  6523. if( pl_sd->state.size ) {
  6524. pl_sd->state.size = SZ_SMALL;
  6525. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6526. }
  6527. pl_sd->state.size = size;
  6528. if( size == SZ_MEDIUM )
  6529. clif_specialeffect(&pl_sd->bl,420,AREA);
  6530. else if( size == SZ_BIG )
  6531. clif_specialeffect(&pl_sd->bl,422,AREA);
  6532. }
  6533. }
  6534. mapit_free(iter);
  6535. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6536. return 0;
  6537. }
  6538. ACMD_FUNC(sizeguild)
  6539. {
  6540. int size = 0, i;
  6541. char guild[NAME_LENGTH];
  6542. struct map_session_data *pl_sd;
  6543. struct guild *g;
  6544. nullpo_retr(-1, sd);
  6545. memset(guild, '\0', sizeof(guild));
  6546. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6547. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6548. return -1;
  6549. }
  6550. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6551. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6552. return -1;
  6553. }
  6554. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6555. for( i = 0; i < g->max_member; i++ ) {
  6556. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6557. if( pl_sd->state.size ) {
  6558. pl_sd->state.size = SZ_SMALL;
  6559. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6560. }
  6561. pl_sd->state.size = size;
  6562. if( size == SZ_MEDIUM )
  6563. clif_specialeffect(&pl_sd->bl,420,AREA);
  6564. else if( size == SZ_BIG )
  6565. clif_specialeffect(&pl_sd->bl,422,AREA);
  6566. }
  6567. }
  6568. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6569. return 0;
  6570. }
  6571. /*==========================================
  6572. * @monsterignore
  6573. * => Makes monsters ignore you. [Valaris]
  6574. *------------------------------------------*/
  6575. ACMD_FUNC(monsterignore)
  6576. {
  6577. nullpo_retr(-1, sd);
  6578. if (!sd->state.monster_ignore) {
  6579. sd->state.monster_ignore = 1;
  6580. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6581. } else {
  6582. sd->state.monster_ignore = 0;
  6583. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6584. }
  6585. return 0;
  6586. }
  6587. /*==========================================
  6588. * @fakename
  6589. * => Gives your character a fake name. [Valaris]
  6590. *------------------------------------------*/
  6591. ACMD_FUNC(fakename)
  6592. {
  6593. nullpo_retr(-1, sd);
  6594. if( !message || !*message )
  6595. {
  6596. if( sd->fakename[0] )
  6597. {
  6598. sd->fakename[0] = '\0';
  6599. clif_charnameack(0, &sd->bl);
  6600. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6601. return 0;
  6602. }
  6603. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6604. return -1;
  6605. }
  6606. if( strlen(message) < 2 )
  6607. {
  6608. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6609. return -1;
  6610. }
  6611. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6612. clif_charnameack(0, &sd->bl);
  6613. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6614. return 0;
  6615. }
  6616. /*==========================================
  6617. * Ragnarok Resources
  6618. *------------------------------------------*/
  6619. ACMD_FUNC(mapflag) {
  6620. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6621. #define setflag( cmd ) \
  6622. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6623. map[ sd->bl.m ].flag.cmd = flag;\
  6624. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6625. clif_displaymessage(sd->fd,atcmd_output);\
  6626. return 0;\
  6627. }
  6628. char flag_name[100];
  6629. short flag=0,i;
  6630. nullpo_retr(-1, sd);
  6631. memset(flag_name, '\0', sizeof(flag_name));
  6632. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6633. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6634. clif_displaymessage(sd->fd,"----------------------------------");
  6635. checkflag(town); checkflag(autotrade); checkflag(allowks); checkflag(nomemo);
  6636. checkflag(noteleport); checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave);
  6637. checkflag(nobranch); checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty);
  6638. checkflag(pvp_noguild); checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle);
  6639. checkflag(gvg); checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);
  6640. checkflag(nozenypenalty); checkflag(notrade); checkflag(noskill); checkflag(nowarp);
  6641. checkflag(nowarpto); checkflag(noicewall); checkflag(snow); checkflag(clouds);
  6642. checkflag(clouds2); checkflag(fog); checkflag(fireworks); checkflag(sakura);
  6643. checkflag(leaves); checkflag(nogo); checkflag(nobaseexp); checkflag(nojobexp);
  6644. checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled); checkflag(restricted);
  6645. checkflag(nodrop); checkflag(novending); checkflag(loadevent); checkflag(nochat);
  6646. checkflag(partylock); checkflag(guildlock); checkflag(reset); checkflag(chmautojoin);
  6647. checkflag(nousecart); checkflag(noitemconsumption); checkflag(nosumstarmiracle); checkflag(nomineeffect);
  6648. checkflag(nolockon); checkflag(notomb);
  6649. #ifdef ADJUST_SKILL_DAMAGE
  6650. checkflag(skill_damage);
  6651. #endif
  6652. clif_displaymessage(sd->fd," ");
  6653. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6654. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6655. return 1;
  6656. }
  6657. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6658. setflag(town); setflag(autotrade); setflag(allowks); setflag(nomemo);
  6659. setflag(noteleport); setflag(noreturn); setflag(monster_noteleport); setflag(nosave);
  6660. setflag(nobranch); setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty);
  6661. setflag(pvp_noguild); setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle);
  6662. setflag(gvg); setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground);
  6663. setflag(nozenypenalty); setflag(notrade); setflag(noskill); setflag(nowarp);
  6664. setflag(nowarpto); setflag(noicewall); setflag(snow); setflag(clouds);
  6665. setflag(clouds2); setflag(fog); setflag(fireworks); setflag(sakura);
  6666. setflag(leaves); setflag(nogo); setflag(nobaseexp); setflag(nojobexp);
  6667. setflag(nomobloot); setflag(nomvploot); setflag(nightenabled); setflag(restricted);
  6668. setflag(nodrop); setflag(novending); setflag(loadevent); setflag(nochat);
  6669. setflag(partylock); setflag(guildlock); setflag(reset); setflag(chmautojoin);
  6670. setflag(nousecart); setflag(noitemconsumption); setflag(nosumstarmiracle); setflag(nomineeffect);
  6671. setflag(nolockon); setflag(notomb);
  6672. #ifdef ADJUST_SKILL_DAMAGE
  6673. setflag(skill_damage);
  6674. #endif
  6675. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6676. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6677. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6678. clif_displaymessage(sd->fd,"----------------------------------");
  6679. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6680. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6681. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6682. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6683. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot, nomvploot,");
  6684. clif_displaymessage(sd->fd,"nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock, guildlock,");
  6685. clif_displaymessage(sd->fd,"reset, chmautojoin, nousecart, noitemconsumption, nosumstarmiracle, nolockon, notomb");
  6686. #ifdef ADJUST_SKILL_DAMAGE
  6687. clif_displaymessage(sd->fd,"skill_damage");
  6688. #endif
  6689. #undef checkflag
  6690. #undef setflag
  6691. return 0;
  6692. }
  6693. /*===================================
  6694. * Remove some messages
  6695. *-----------------------------------*/
  6696. ACMD_FUNC(showexp)
  6697. {
  6698. if (sd->state.showexp) {
  6699. sd->state.showexp = 0;
  6700. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6701. return 0;
  6702. }
  6703. sd->state.showexp = 1;
  6704. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6705. return 0;
  6706. }
  6707. ACMD_FUNC(showzeny)
  6708. {
  6709. if (sd->state.showzeny) {
  6710. sd->state.showzeny = 0;
  6711. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6712. return 0;
  6713. }
  6714. sd->state.showzeny = 1;
  6715. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6716. return 0;
  6717. }
  6718. ACMD_FUNC(showdelay)
  6719. {
  6720. if (sd->state.showdelay) {
  6721. sd->state.showdelay = 0;
  6722. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6723. return 0;
  6724. }
  6725. sd->state.showdelay = 1;
  6726. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6727. return 0;
  6728. }
  6729. /*==========================================
  6730. * Duel organizing functions [LuzZza]
  6731. *
  6732. * @duel [limit|nick] - create a duel
  6733. * @invite <nick> - invite player
  6734. * @accept - accept invitation
  6735. * @reject - reject invitation
  6736. * @leave - leave duel
  6737. *------------------------------------------*/
  6738. ACMD_FUNC(invite)
  6739. {
  6740. unsigned int did = sd->duel_group;
  6741. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6742. if(did == 0) {
  6743. // "Duel: @invite without @duel."
  6744. clif_displaymessage(fd, msg_txt(sd,350));
  6745. return 0;
  6746. }
  6747. if(duel_list[did].max_players_limit > 0 &&
  6748. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6749. // "Duel: Limit of players is reached."
  6750. clif_displaymessage(fd, msg_txt(sd,351));
  6751. return 0;
  6752. }
  6753. if(target_sd == NULL) {
  6754. // "Duel: Player not found."
  6755. clif_displaymessage(fd, msg_txt(sd,352));
  6756. return 0;
  6757. }
  6758. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6759. // "Duel: Player already in duel."
  6760. clif_displaymessage(fd, msg_txt(sd,353));
  6761. return 0;
  6762. }
  6763. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6764. {
  6765. sprintf(atcmd_output, msg_txt(sd,364), message);
  6766. clif_displaymessage(fd, atcmd_output);
  6767. return 0;
  6768. }
  6769. duel_invite(did, sd, target_sd);
  6770. // "Duel: Invitation has been sent."
  6771. clif_displaymessage(fd, msg_txt(sd,354));
  6772. return 0;
  6773. }
  6774. ACMD_FUNC(duel)
  6775. {
  6776. unsigned int maxpl = 0;
  6777. if(sd->duel_group > 0) {
  6778. duel_showinfo(sd->duel_group, sd);
  6779. return 0;
  6780. }
  6781. if(sd->duel_invite > 0) {
  6782. // "Duel: @duel without @reject."
  6783. clif_displaymessage(fd, msg_txt(sd,355));
  6784. return 0;
  6785. }
  6786. if(!duel_checktime(sd)) {
  6787. char output[CHAT_SIZE_MAX];
  6788. // "Duel: You can take part in duel only one time per %d minutes."
  6789. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6790. clif_displaymessage(fd, output);
  6791. return 0;
  6792. }
  6793. if( message[0] ) {
  6794. if(sscanf(message, "%d", &maxpl) >= 1) {
  6795. if(maxpl < 2 || maxpl > 65535) {
  6796. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6797. return 0;
  6798. }
  6799. duel_create(sd, maxpl);
  6800. } else {
  6801. struct map_session_data *target_sd;
  6802. target_sd = map_nick2sd((char *)message);
  6803. if(target_sd != NULL) {
  6804. unsigned int newduel;
  6805. if((newduel = duel_create(sd, 2)) != -1) {
  6806. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6807. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6808. return 0;
  6809. }
  6810. duel_invite(newduel, sd, target_sd);
  6811. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6812. }
  6813. } else {
  6814. // "Duel: Player not found."
  6815. clif_displaymessage(fd, msg_txt(sd,352));
  6816. return 0;
  6817. }
  6818. }
  6819. } else
  6820. duel_create(sd, 0);
  6821. return 0;
  6822. }
  6823. ACMD_FUNC(leave)
  6824. {
  6825. if(sd->duel_group <= 0) {
  6826. // "Duel: @leave without @duel."
  6827. clif_displaymessage(fd, msg_txt(sd,358));
  6828. return 0;
  6829. }
  6830. duel_leave(sd->duel_group, sd);
  6831. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6832. return 0;
  6833. }
  6834. ACMD_FUNC(accept)
  6835. {
  6836. if(!duel_checktime(sd)) {
  6837. char output[CHAT_SIZE_MAX];
  6838. // "Duel: You can take part in duel only one time per %d minutes."
  6839. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6840. clif_displaymessage(fd, output);
  6841. return 0;
  6842. }
  6843. if(sd->duel_invite <= 0) {
  6844. // "Duel: @accept without invititation."
  6845. clif_displaymessage(fd, msg_txt(sd,360));
  6846. return 0;
  6847. }
  6848. 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 )
  6849. {
  6850. // "Duel: Limit of players is reached."
  6851. clif_displaymessage(fd, msg_txt(sd,351));
  6852. return 0;
  6853. }
  6854. duel_accept(sd->duel_invite, sd);
  6855. // "Duel: Invitation has been accepted."
  6856. clif_displaymessage(fd, msg_txt(sd,361));
  6857. return 0;
  6858. }
  6859. ACMD_FUNC(reject)
  6860. {
  6861. if(sd->duel_invite <= 0) {
  6862. // "Duel: @reject without invititation."
  6863. clif_displaymessage(fd, msg_txt(sd,362));
  6864. return 0;
  6865. }
  6866. duel_reject(sd->duel_invite, sd);
  6867. // "Duel: Invitation has been rejected."
  6868. clif_displaymessage(fd, msg_txt(sd,363));
  6869. return 0;
  6870. }
  6871. /*===================================
  6872. * Cash Points
  6873. *-----------------------------------*/
  6874. ACMD_FUNC(cash)
  6875. {
  6876. char output[128];
  6877. int value;
  6878. int ret=0;
  6879. nullpo_retr(-1, sd);
  6880. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6881. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  6882. return -1;
  6883. }
  6884. if( !strcmpi(command+1,"cash") )
  6885. {
  6886. if( value > 0 ) {
  6887. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  6888. // If this option is set, the message is already sent by pc function
  6889. if( !battle_config.cashshop_show_points ){
  6890. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  6891. clif_disp_onlyself(sd, output, strlen(output));
  6892. }
  6893. }
  6894. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6895. } else {
  6896. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  6897. // If this option is set, the message is already sent by pc function
  6898. if( !battle_config.cashshop_show_points ){
  6899. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  6900. clif_disp_onlyself(sd, output, strlen(output));
  6901. }
  6902. }
  6903. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6904. }
  6905. }
  6906. else
  6907. { // @points
  6908. if( value > 0 ) {
  6909. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  6910. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  6911. clif_disp_onlyself(sd, output, strlen(output));
  6912. }
  6913. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6914. } else {
  6915. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  6916. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  6917. clif_disp_onlyself(sd, output, strlen(output));
  6918. }
  6919. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6920. }
  6921. }
  6922. return 0;
  6923. }
  6924. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6925. ACMD_FUNC(clone)
  6926. {
  6927. int x=0,y=0,flag=0,master=0,i=0;
  6928. struct map_session_data *pl_sd=NULL;
  6929. if (!message || !*message) {
  6930. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  6931. return 0;
  6932. }
  6933. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6934. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6935. return 0;
  6936. }
  6937. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6938. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  6939. return 0;
  6940. }
  6941. if (strcmpi(command+1, "clone") == 0)
  6942. flag = 1;
  6943. else if (strcmpi(command+1, "slaveclone") == 0) {
  6944. flag = 2;
  6945. if(pc_isdead(sd)){
  6946. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  6947. return 0;
  6948. }
  6949. master = sd->bl.id;
  6950. if (battle_config.atc_slave_clone_limit
  6951. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6952. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  6953. return 0;
  6954. }
  6955. }
  6956. do {
  6957. x = sd->bl.x + (rnd() % 10 - 5);
  6958. y = sd->bl.y + (rnd() % 10 - 5);
  6959. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6960. if (i >= 10) {
  6961. x = sd->bl.x;
  6962. y = sd->bl.y;
  6963. }
  6964. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6965. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6966. return 0;
  6967. }
  6968. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6969. return 0;
  6970. }
  6971. /*=====================================
  6972. * Autorejecting Invites/Deals [LuzZza]
  6973. * Usage: @noask
  6974. *-------------------------------------*/
  6975. ACMD_FUNC(noask)
  6976. {
  6977. if(sd->state.noask) {
  6978. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  6979. sd->state.noask = 0;
  6980. } else {
  6981. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  6982. sd->state.noask = 1;
  6983. }
  6984. return 0;
  6985. }
  6986. /*=====================================
  6987. * Send a @request message to all GMs of lowest_gm_level.
  6988. * Usage: @request <petition>
  6989. *-------------------------------------*/
  6990. ACMD_FUNC(request)
  6991. {
  6992. if (!message || !*message) {
  6993. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  6994. return -1;
  6995. }
  6996. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  6997. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6998. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6999. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  7000. return 0;
  7001. }
  7002. /*==========================================
  7003. * Feel (SG save map) Reset [HiddenDragon]
  7004. *------------------------------------------*/
  7005. ACMD_FUNC(feelreset)
  7006. {
  7007. pc_resetfeel(sd);
  7008. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  7009. return 0;
  7010. }
  7011. /*==========================================
  7012. * AUCTION SYSTEM
  7013. *------------------------------------------*/
  7014. ACMD_FUNC(auction)
  7015. {
  7016. nullpo_ret(sd);
  7017. clif_Auction_openwindow(sd);
  7018. return 0;
  7019. }
  7020. /*==========================================
  7021. * Kill Steal Protection
  7022. *------------------------------------------*/
  7023. ACMD_FUNC(ksprotection)
  7024. {
  7025. nullpo_retr(-1,sd);
  7026. if( sd->state.noks ) {
  7027. sd->state.noks = 0;
  7028. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  7029. }
  7030. else
  7031. {
  7032. if( !message || !*message || !strcmpi(message, "party") )
  7033. { // Default is Party
  7034. sd->state.noks = 2;
  7035. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  7036. }
  7037. else if( !strcmpi(message, "self") )
  7038. {
  7039. sd->state.noks = 1;
  7040. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  7041. }
  7042. else if( !strcmpi(message, "guild") )
  7043. {
  7044. sd->state.noks = 3;
  7045. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  7046. }
  7047. else
  7048. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  7049. }
  7050. return 0;
  7051. }
  7052. /*==========================================
  7053. * Map Kill Steal Protection Setting
  7054. *------------------------------------------*/
  7055. ACMD_FUNC(allowks)
  7056. {
  7057. nullpo_retr(-1,sd);
  7058. if( map[sd->bl.m].flag.allowks ) {
  7059. map[sd->bl.m].flag.allowks = 0;
  7060. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  7061. } else {
  7062. map[sd->bl.m].flag.allowks = 1;
  7063. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  7064. }
  7065. return 0;
  7066. }
  7067. ACMD_FUNC(resetstat)
  7068. {
  7069. nullpo_retr(-1, sd);
  7070. pc_resetstate(sd);
  7071. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  7072. clif_displaymessage(fd, atcmd_output);
  7073. return 0;
  7074. }
  7075. ACMD_FUNC(resetskill)
  7076. {
  7077. nullpo_retr(-1,sd);
  7078. pc_resetskill(sd,1);
  7079. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  7080. clif_displaymessage(fd, atcmd_output);
  7081. return 0;
  7082. }
  7083. /*==========================================
  7084. * #storagelist: Displays the items list of a player's storage.
  7085. * #cartlist: Displays contents of target's cart.
  7086. * #itemlist: Displays contents of target's inventory.
  7087. *------------------------------------------*/
  7088. ACMD_FUNC(itemlist)
  7089. {
  7090. int i, j, count, counter;
  7091. const char* location;
  7092. const struct item* items;
  7093. int size;
  7094. StringBuf buf;
  7095. nullpo_retr(-1, sd);
  7096. if( strcmp(command+1, "storagelist") == 0 )
  7097. {
  7098. location = "storage";
  7099. items = sd->status.storage.items;
  7100. size = sd->storage_size;
  7101. }
  7102. else
  7103. if( strcmp(command+1, "cartlist") == 0 )
  7104. {
  7105. location = "cart";
  7106. items = sd->status.cart;
  7107. size = MAX_CART;
  7108. }
  7109. else
  7110. if( strcmp(command+1, "itemlist") == 0 )
  7111. {
  7112. location = "inventory";
  7113. items = sd->status.inventory;
  7114. size = MAX_INVENTORY;
  7115. }
  7116. else
  7117. return 1;
  7118. StringBuf_Init(&buf);
  7119. count = 0; // total slots occupied
  7120. counter = 0; // total items found
  7121. for( i = 0; i < size; ++i )
  7122. {
  7123. const struct item* it = &items[i];
  7124. struct item_data* itd;
  7125. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  7126. continue;
  7127. counter += it->amount;
  7128. count++;
  7129. if( count == 1 )
  7130. {
  7131. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  7132. clif_displaymessage(fd, StringBuf_Value(&buf));
  7133. StringBuf_Clear(&buf);
  7134. }
  7135. if( it->refine )
  7136. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  7137. else
  7138. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  7139. if( it->equip )
  7140. {
  7141. char equipstr[CHAT_SIZE_MAX];
  7142. strcpy(equipstr, msg_txt(sd,1333)); // | equipped:
  7143. if( it->equip & EQP_GARMENT )
  7144. strcat(equipstr, msg_txt(sd,1334)); // garment,
  7145. if( it->equip & EQP_ACC_L )
  7146. strcat(equipstr, msg_txt(sd,1335)); // left accessory,
  7147. if( it->equip & EQP_ARMOR )
  7148. strcat(equipstr, msg_txt(sd,1336)); // body/armor,
  7149. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  7150. strcat(equipstr, msg_txt(sd,1337)); // right hand,
  7151. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  7152. strcat(equipstr, msg_txt(sd,1338)); // left hand,
  7153. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  7154. strcat(equipstr, msg_txt(sd,1339)); // both hands,
  7155. if( it->equip & EQP_SHOES )
  7156. strcat(equipstr, msg_txt(sd,1340)); // feet,
  7157. if( it->equip & EQP_ACC_R )
  7158. strcat(equipstr, msg_txt(sd,1341)); // right accessory,
  7159. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7160. strcat(equipstr, msg_txt(sd,1342)); // lower head,
  7161. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7162. strcat(equipstr, msg_txt(sd,1343)); // top head,
  7163. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7164. strcat(equipstr, msg_txt(sd,1344)); // lower/top head,
  7165. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7166. strcat(equipstr, msg_txt(sd,1345)); // mid head,
  7167. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7168. strcat(equipstr, msg_txt(sd,1346)); // lower/mid head,
  7169. if( (it->equip & EQP_HELM) == EQP_HELM )
  7170. strcat(equipstr, msg_txt(sd,1347)); // lower/mid/top head,
  7171. // remove final ', '
  7172. equipstr[strlen(equipstr) - 2] = '\0';
  7173. StringBuf_AppendStr(&buf, equipstr);
  7174. }
  7175. clif_displaymessage(fd, StringBuf_Value(&buf));
  7176. StringBuf_Clear(&buf);
  7177. if( it->card[0] == CARD0_PET )
  7178. {// pet egg
  7179. if (it->card[3])
  7180. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7181. else
  7182. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7183. }
  7184. else
  7185. if(it->card[0] == CARD0_FORGE)
  7186. {// forged item
  7187. 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)
  7188. }
  7189. else
  7190. if(it->card[0] == CARD0_CREATE)
  7191. {// created item
  7192. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7193. }
  7194. else
  7195. {// normal item
  7196. int counter2 = 0;
  7197. for( j = 0; j < itd->slot; ++j )
  7198. {
  7199. struct item_data* card;
  7200. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7201. continue;
  7202. counter2++;
  7203. if( counter2 == 1 )
  7204. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7205. if( counter2 != 1 )
  7206. StringBuf_AppendStr(&buf, ", ");
  7207. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7208. }
  7209. if( counter2 > 0 )
  7210. StringBuf_AppendStr(&buf, ")");
  7211. }
  7212. if( StringBuf_Length(&buf) > 0 )
  7213. clif_displaymessage(fd, StringBuf_Value(&buf));
  7214. StringBuf_Clear(&buf);
  7215. }
  7216. if( count == 0 )
  7217. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7218. else
  7219. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7220. clif_displaymessage(fd, StringBuf_Value(&buf));
  7221. StringBuf_Destroy(&buf);
  7222. return 0;
  7223. }
  7224. ACMD_FUNC(stats)
  7225. {
  7226. char job_jobname[100];
  7227. char output[CHAT_SIZE_MAX];
  7228. int i;
  7229. struct {
  7230. const char* format;
  7231. int value;
  7232. } output_table[] = {
  7233. { "Base Level - %d", 0 },
  7234. { NULL, 0 },
  7235. { "Hp - %d", 0 },
  7236. { "MaxHp - %d", 0 },
  7237. { "Sp - %d", 0 },
  7238. { "MaxSp - %d", 0 },
  7239. { "Str - %3d", 0 },
  7240. { "Agi - %3d", 0 },
  7241. { "Vit - %3d", 0 },
  7242. { "Int - %3d", 0 },
  7243. { "Dex - %3d", 0 },
  7244. { "Luk - %3d", 0 },
  7245. { "Zeny - %d", 0 },
  7246. { "Free SK Points - %d", 0 },
  7247. { "JobChangeLvl (2nd) - %d", 0 },
  7248. { "JobChangeLvl (3rd) - %d", 0 },
  7249. { NULL, 0 }
  7250. };
  7251. memset(job_jobname, '\0', sizeof(job_jobname));
  7252. memset(output, '\0', sizeof(output));
  7253. //direct array initialization with variables is not standard C compliant.
  7254. output_table[0].value = sd->status.base_level;
  7255. output_table[1].format = job_jobname;
  7256. output_table[1].value = sd->status.job_level;
  7257. output_table[2].value = sd->status.hp;
  7258. output_table[3].value = sd->status.max_hp;
  7259. output_table[4].value = sd->status.sp;
  7260. output_table[5].value = sd->status.max_sp;
  7261. output_table[6].value = sd->status.str;
  7262. output_table[7].value = sd->status.agi;
  7263. output_table[8].value = sd->status.vit;
  7264. output_table[9].value = sd->status.int_;
  7265. output_table[10].value = sd->status.dex;
  7266. output_table[11].value = sd->status.luk;
  7267. output_table[12].value = sd->status.zeny;
  7268. output_table[13].value = sd->status.skill_point;
  7269. output_table[14].value = sd->change_level_2nd;
  7270. output_table[15].value = sd->change_level_3rd;
  7271. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7272. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7273. clif_displaymessage(fd, output);
  7274. for (i = 0; output_table[i].format != NULL; i++) {
  7275. sprintf(output, output_table[i].format, output_table[i].value);
  7276. clif_displaymessage(fd, output);
  7277. }
  7278. return 0;
  7279. }
  7280. ACMD_FUNC(delitem)
  7281. {
  7282. char item_name[100];
  7283. int nameid, amount = 0, total, idx;
  7284. struct item_data* id;
  7285. nullpo_retr(-1, sd);
  7286. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7287. {
  7288. 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>).
  7289. return -1;
  7290. }
  7291. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7292. {
  7293. nameid = id->nameid;
  7294. }
  7295. else
  7296. {
  7297. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7298. return -1;
  7299. }
  7300. total = amount;
  7301. // delete items
  7302. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7303. {
  7304. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7305. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7306. {// delete pet
  7307. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7308. }
  7309. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7310. amount-= delamount;
  7311. }
  7312. // notify target
  7313. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7314. clif_displaymessage(sd->fd, atcmd_output);
  7315. // notify source
  7316. if( amount == total )
  7317. {
  7318. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7319. }
  7320. else if( amount )
  7321. {
  7322. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7323. clif_displaymessage(fd, atcmd_output);
  7324. }
  7325. else
  7326. {
  7327. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7328. clif_displaymessage(fd, atcmd_output);
  7329. }
  7330. return 0;
  7331. }
  7332. /*==========================================
  7333. * Custom Fonts
  7334. *------------------------------------------*/
  7335. ACMD_FUNC(font)
  7336. {
  7337. int font_id;
  7338. nullpo_retr(-1,sd);
  7339. font_id = atoi(message);
  7340. if( font_id == 0 )
  7341. {
  7342. if( sd->user_font )
  7343. {
  7344. sd->user_font = 0;
  7345. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7346. clif_font(sd);
  7347. }
  7348. else
  7349. {
  7350. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7351. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7352. }
  7353. }
  7354. else if( font_id < 0 || font_id > 9 )
  7355. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7356. else if( font_id != sd->user_font )
  7357. {
  7358. sd->user_font = font_id;
  7359. clif_font(sd);
  7360. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7361. }
  7362. else
  7363. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7364. return 0;
  7365. }
  7366. /*==========================================
  7367. * type: 1 = commands (@), 2 = charcommands (#)
  7368. *------------------------------------------*/
  7369. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7370. {
  7371. char line_buff[CHATBOX_SIZE];
  7372. char* cur = line_buff;
  7373. AtCommandInfo* cmd;
  7374. DBIterator *iter = db_iterator(atcommand_db);
  7375. int count = 0;
  7376. memset(line_buff,' ',CHATBOX_SIZE);
  7377. line_buff[CHATBOX_SIZE-1] = 0;
  7378. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7379. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7380. unsigned int slen = 0;
  7381. switch( type ) {
  7382. case COMMAND_CHARCOMMAND:
  7383. if( cmd->char_groups[sd->group_pos] == 0 )
  7384. continue;
  7385. break;
  7386. case COMMAND_ATCOMMAND:
  7387. if( cmd->at_groups[sd->group_pos] == 0 )
  7388. continue;
  7389. break;
  7390. default:
  7391. continue;
  7392. }
  7393. slen = strlen(cmd->command);
  7394. // flush the text buffer if this command won't fit into it
  7395. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7396. clif_displaymessage(fd,line_buff);
  7397. cur = line_buff;
  7398. memset(line_buff,' ',CHATBOX_SIZE);
  7399. line_buff[CHATBOX_SIZE-1] = 0;
  7400. }
  7401. memcpy(cur,cmd->command,slen);
  7402. cur += slen+(10-slen%10);
  7403. count++;
  7404. }
  7405. dbi_destroy(iter);
  7406. clif_displaymessage(fd,line_buff);
  7407. if ( atcmd_binding_count ) {
  7408. int i, count_bind, gm_lvl = pc_get_group_level(sd);
  7409. for( i = count_bind = 0; i < atcmd_binding_count; i++ ) {
  7410. if ( gm_lvl >= ( type -1 ? atcmd_binding[i]->level2 : atcmd_binding[i]->level ) ) {
  7411. unsigned int slen = strlen(atcmd_binding[i]->command);
  7412. if ( count_bind == 0 ) {
  7413. cur = line_buff;
  7414. memset(line_buff,' ',CHATBOX_SIZE);
  7415. line_buff[CHATBOX_SIZE-1] = 0;
  7416. clif_displaymessage(fd, "-----------------");
  7417. clif_displaymessage(fd, msg_txt(sd,509)); // Script-bound commands:
  7418. }
  7419. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7420. clif_displaymessage(fd,line_buff);
  7421. cur = line_buff;
  7422. memset(line_buff,' ',CHATBOX_SIZE);
  7423. line_buff[CHATBOX_SIZE-1] = 0;
  7424. }
  7425. memcpy(cur,atcmd_binding[i]->command,slen);
  7426. cur += slen+(10-slen%10);
  7427. count_bind++;
  7428. }
  7429. }
  7430. if ( count_bind )
  7431. clif_displaymessage(fd,line_buff);// last one
  7432. count += count_bind;
  7433. }
  7434. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7435. clif_displaymessage(fd, atcmd_output);
  7436. return;
  7437. }
  7438. /*==========================================
  7439. * @commands Lists available @ commands to you
  7440. *------------------------------------------*/
  7441. ACMD_FUNC(commands)
  7442. {
  7443. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7444. return 0;
  7445. }
  7446. /*==========================================
  7447. * @charcommands Lists available # commands to you
  7448. *------------------------------------------*/
  7449. ACMD_FUNC(charcommands)
  7450. {
  7451. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7452. return 0;
  7453. }
  7454. /* for new mounts */
  7455. ACMD_FUNC(mount2) {
  7456. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7457. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7458. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7459. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7460. } else {
  7461. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7462. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7463. }
  7464. return 0;
  7465. }
  7466. ACMD_FUNC(accinfo) {
  7467. char query[NAME_LENGTH];
  7468. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7469. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7470. 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".
  7471. return -1;
  7472. }
  7473. //remove const type
  7474. safestrncpy(query, message, NAME_LENGTH);
  7475. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7476. return 0;
  7477. }
  7478. /* [Ind] */
  7479. ACMD_FUNC(set) {
  7480. char reg[32], val[128];
  7481. struct script_data* data;
  7482. int toset = 0, len;
  7483. bool is_str = false;
  7484. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7485. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7486. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7487. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7488. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7489. return -1;
  7490. }
  7491. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7492. if( reg[0] == '.' ) {
  7493. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7494. return -1;
  7495. } else if( reg[0] == '\'' ) {
  7496. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7497. return -1;
  7498. }
  7499. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7500. if( ( len = strlen(val) ) > 1 ) {
  7501. if( val[0] == '"' && val[len-1] == '"') {
  7502. val[len-1] = '\0'; //Strip quotes.
  7503. memmove(val, val+1, len-1);
  7504. }
  7505. }
  7506. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7507. if( is_str )
  7508. set_var(sd, reg, (void*) val);
  7509. else
  7510. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7511. }
  7512. CREATE(data, struct script_data,1);
  7513. if( is_str ) {// string variable
  7514. switch( reg[0] ) {
  7515. case '@':
  7516. data->u.str = pc_readregstr(sd, add_str(reg));
  7517. break;
  7518. case '$':
  7519. data->u.str = mapreg_readregstr(add_str(reg));
  7520. break;
  7521. case '#':
  7522. if( reg[1] == '#' )
  7523. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7524. else
  7525. data->u.str = pc_readaccountregstr(sd, reg);// local
  7526. break;
  7527. default:
  7528. data->u.str = pc_readglobalreg_str(sd, reg);
  7529. break;
  7530. }
  7531. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7532. data->type = C_CONSTSTR;
  7533. data->u.str = "";
  7534. } else {// duplicate string
  7535. data->type = C_STR;
  7536. data->u.str = aStrdup(data->u.str);
  7537. }
  7538. } else {// integer variable
  7539. data->type = C_INT;
  7540. switch( reg[0] ) {
  7541. case '@':
  7542. data->u.num = pc_readreg(sd, add_str(reg));
  7543. break;
  7544. case '$':
  7545. data->u.num = mapreg_readreg(add_str(reg));
  7546. break;
  7547. case '#':
  7548. if( reg[1] == '#' )
  7549. data->u.num = pc_readaccountreg2(sd, reg);// global
  7550. else
  7551. data->u.num = pc_readaccountreg(sd, reg);// local
  7552. break;
  7553. default:
  7554. data->u.num = pc_readglobalreg(sd, reg);
  7555. break;
  7556. }
  7557. }
  7558. switch( data->type ) {
  7559. case C_INT:
  7560. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7561. break;
  7562. case C_STR:
  7563. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7564. break;
  7565. case C_CONSTSTR:
  7566. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7567. break;
  7568. default:
  7569. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7570. break;
  7571. }
  7572. clif_displaymessage(fd, atcmd_output);
  7573. aFree(data);
  7574. return 0;
  7575. }
  7576. ACMD_FUNC(addperm) {
  7577. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7578. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7579. int i;
  7580. if( !message || !*message ) {
  7581. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7582. clif_displaymessage(fd, atcmd_output);
  7583. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7584. for( i = 0; i < perm_size; i++ ) {
  7585. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7586. clif_displaymessage(fd, atcmd_output);
  7587. }
  7588. return -1;
  7589. }
  7590. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7591. if( i == perm_size ) {
  7592. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7593. clif_displaymessage(fd, atcmd_output);
  7594. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7595. for( i = 0; i < perm_size; i++ ) {
  7596. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7597. clif_displaymessage(fd, atcmd_output);
  7598. }
  7599. return -1;
  7600. }
  7601. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7602. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7603. clif_displaymessage(fd, atcmd_output);
  7604. return -1;
  7605. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7606. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7607. clif_displaymessage(fd, atcmd_output);
  7608. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7609. clif_displaymessage(fd, atcmd_output);
  7610. for( i = 0; i < perm_size; i++ ) {
  7611. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7612. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7613. clif_displaymessage(fd, atcmd_output);
  7614. }
  7615. }
  7616. return -1;
  7617. }
  7618. if( add )
  7619. sd->permissions |= pc_g_permission_name[i].permission;
  7620. else
  7621. sd->permissions &=~ pc_g_permission_name[i].permission;
  7622. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7623. clif_displaymessage(fd, atcmd_output);
  7624. return 0;
  7625. }
  7626. ACMD_FUNC(unloadnpcfile) {
  7627. if( !message || !*message ) {
  7628. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7629. return -1;
  7630. }
  7631. if( npc_unloadfile(message) )
  7632. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7633. else {
  7634. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7635. return -1;
  7636. }
  7637. return 0;
  7638. }
  7639. ACMD_FUNC(cart) {
  7640. #define MC_CART_MDFY(x) \
  7641. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7642. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7643. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7644. int val = atoi(message);
  7645. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7646. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7647. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7648. clif_displaymessage(fd, atcmd_output);
  7649. return -1;
  7650. }
  7651. if( val == 0 && !pc_iscarton(sd) ) {
  7652. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7653. return -1;
  7654. }
  7655. if( need_skill ) {
  7656. MC_CART_MDFY(1);
  7657. }
  7658. if( !pc_setcart(sd, val) ) {
  7659. if( need_skill ) {
  7660. MC_CART_MDFY(0);
  7661. }
  7662. return -1;/* @cart failed */
  7663. }
  7664. if( need_skill ) {
  7665. MC_CART_MDFY(0);
  7666. }
  7667. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7668. return 0;
  7669. #undef MC_CART_MDFY
  7670. }
  7671. /* Channel System [Ind] */
  7672. ACMD_FUNC(join){
  7673. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7674. if( !message || !*message || sscanf(message, "%19s %19s", chname, pass) < 1 ) {
  7675. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7676. clif_displaymessage(fd, atcmd_output);
  7677. return -1;
  7678. }
  7679. return channel_pcjoin(sd, chname, pass);
  7680. }
  7681. /*
  7682. * Display available option for @channel command
  7683. * @command : the name of used command (for alias case)
  7684. */
  7685. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7686. {
  7687. int fd = sd->fd;
  7688. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7689. bool can_create = (can_delete || Channel_Config.user_chenable);
  7690. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7691. //option create
  7692. if( can_create ) {
  7693. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7694. clif_displaymessage(fd, atcmd_output);
  7695. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7696. }
  7697. //option delete
  7698. if(can_delete){
  7699. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7700. clif_displaymessage(fd, atcmd_output);
  7701. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7702. }
  7703. //option list
  7704. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7705. clif_displaymessage(fd, atcmd_output);
  7706. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7707. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7708. clif_displaymessage(fd, atcmd_output);
  7709. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7710. if( can_create ) {
  7711. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7712. clif_displaymessage(fd, atcmd_output);
  7713. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7714. }
  7715. //option setcolor
  7716. if(can_create){
  7717. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7718. clif_displaymessage(fd, atcmd_output);
  7719. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7720. }
  7721. //option join
  7722. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7723. clif_displaymessage(fd, atcmd_output);
  7724. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7725. //option leave
  7726. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7727. clif_displaymessage(fd, atcmd_output);
  7728. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7729. //option bindto
  7730. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7731. clif_displaymessage(fd, atcmd_output);
  7732. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7733. //option unbind
  7734. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7735. clif_displaymessage(fd, atcmd_output);
  7736. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7737. //option ban/unban/banlist
  7738. if( can_create ) {
  7739. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7740. clif_displaymessage(fd, atcmd_output);
  7741. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7742. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7743. clif_displaymessage(fd, atcmd_output);
  7744. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7745. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7746. clif_displaymessage(fd, atcmd_output);
  7747. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7748. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7749. clif_displaymessage(fd, atcmd_output);
  7750. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7751. }
  7752. //option setopt
  7753. if(can_create){
  7754. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7755. clif_displaymessage(fd, atcmd_output);
  7756. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7757. }
  7758. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7759. clif_displaymessage(fd, atcmd_output);
  7760. }
  7761. ACMD_FUNC(channel) {
  7762. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  7763. sub1[0] = sub2[0] = sub3[0] = '\0';
  7764. if( !message || !*message || sscanf(message, "%19s %19s %19s %19s", key, sub1, sub2, sub3) < 1 ) {
  7765. atcmd_channel_help(sd,command);
  7766. return 0;
  7767. }
  7768. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7769. if(sub3[0] != '\0'){
  7770. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  7771. return -1;
  7772. }
  7773. return channel_pccreate(sd,sub1,sub2);
  7774. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7775. return channel_pcdelete(sd,sub1);
  7776. } else if ( strcmpi(key,"list") == 0 ) {
  7777. return channel_display_list(sd,sub1);
  7778. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7779. return channel_pccolor(sd, sub1, sub2);
  7780. } else if ( strcmpi(key,"join") == 0 ) {
  7781. return channel_pcjoin(sd, sub1, sub2);
  7782. }else if ( strcmpi(key,"leave") == 0 ) {
  7783. return channel_pcleave(sd, sub1);
  7784. } else if ( strcmpi(key,"bindto") == 0 ) {
  7785. return channel_pcbind(sd, sub1);
  7786. } else if ( strcmpi(key,"unbind") == 0 ) {
  7787. return channel_pcunbind(sd);
  7788. } else if ( strcmpi(key,"ban") == 0 ) {
  7789. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  7790. } else if ( strcmpi(key,"banlist") == 0 ) {
  7791. return channel_pcban(sd,sub1,NULL,3);
  7792. } else if ( strcmpi(key,"unban") == 0 ) {
  7793. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  7794. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7795. return channel_pcban(sd,sub1,NULL,2);
  7796. } else if ( strcmpi(key,"setopt") == 0 ) {
  7797. return channel_pcsetopt(sd,sub1,sub2,sub3);
  7798. } else {
  7799. atcmd_channel_help(sd,command);
  7800. }
  7801. return 0;
  7802. }
  7803. ACMD_FUNC(fontcolor)
  7804. {
  7805. unsigned char k;
  7806. if( !message || !*message ) {
  7807. channel_display_list(sd,"colors");
  7808. return -1;
  7809. }
  7810. if( strcmpi(message,"Normal") == 0 ) {
  7811. sd->fontcolor = 0;
  7812. } else {
  7813. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  7814. if( k == Channel_Config.colors_count ) {
  7815. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7816. clif_displaymessage(fd, atcmd_output);
  7817. return -1;
  7818. }
  7819. sd->fontcolor = k;
  7820. }
  7821. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7822. clif_displaymessage(fd, atcmd_output);
  7823. return 0;
  7824. }
  7825. ACMD_FUNC(langtype)
  7826. {
  7827. char langstr[8];
  7828. int i=0, test=0;
  7829. memset(langstr, '\0', sizeof(langstr));
  7830. if(sscanf(message, "%3s", langstr) >= 1){
  7831. int lang=-1;
  7832. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7833. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  7834. char output[100];
  7835. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  7836. sd->langtype = lang;
  7837. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  7838. clif_displaymessage(fd,output);
  7839. return 0;
  7840. } else if (lang != -1) { //defined langage but failed check
  7841. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  7842. return -1;
  7843. }
  7844. }
  7845. //wrong or no entry
  7846. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  7847. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  7848. while(test!=-1){ //out of range
  7849. test = msg_checklangtype(i,false);
  7850. if(test == 1)
  7851. clif_displaymessage(fd,msg_langtype2langstr(i));
  7852. i++;
  7853. }
  7854. return -1;
  7855. }
  7856. #ifdef VIP_ENABLE
  7857. ACMD_FUNC(vip) {
  7858. struct map_session_data *pl_sd = NULL;
  7859. char * modif_p;
  7860. int32 vipdifftime = 0;
  7861. time_t now=time(NULL);
  7862. nullpo_retr(-1, sd);
  7863. memset(atcmd_output, '\0', sizeof(atcmd_output));
  7864. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  7865. clif_displaymessage(fd, msg_txt(sd,700)); //Usage: @vip <timef> <character name>
  7866. return -1;
  7867. }
  7868. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  7869. modif_p = atcmd_output;
  7870. vipdifftime = (int32)solve_time(modif_p);
  7871. if (vipdifftime == 0) {
  7872. clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
  7873. 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.
  7874. return -1;
  7875. }
  7876. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  7877. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7878. return -1;
  7879. }
  7880. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  7881. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  7882. return -1;
  7883. }
  7884. if(pl_sd->vip.time==0) pl_sd->vip.time=now;
  7885. pl_sd->vip.time += vipdifftime; //increase or reduce VIP duration
  7886. if (pl_sd->vip.time <= now) {
  7887. pl_sd->vip.time = 0;
  7888. pl_sd->vip.enabled = 0;
  7889. clif_displaymessage(pl_sd->fd, msg_txt(pl_sd,703)); // GM has removed your VIP time.
  7890. clif_displaymessage(fd, msg_txt(sd,704)); // Player is no longer VIP.
  7891. } else {
  7892. int year,month,day,hour,minute,second;
  7893. char timestr[21];
  7894. split_time(pl_sd->vip.time-now,&year,&month,&day,&hour,&minute,&second);
  7895. 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.
  7896. clif_displaymessage(pl_sd->fd,atcmd_output);
  7897. timestamp2string(timestr,20,pl_sd->vip.time,"%Y-%m-%d %H:%M");
  7898. sprintf(atcmd_output,msg_txt(pl_sd,707),timestr); // You are VIP until : %s
  7899. clif_displaymessage(pl_sd->fd,atcmd_output);
  7900. if (pl_sd != sd) {
  7901. 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.
  7902. clif_displaymessage(fd,atcmd_output);
  7903. sprintf(atcmd_output,msg_txt(sd,708),timestr); // The player is now VIP until : %s
  7904. clif_displaymessage(fd,atcmd_output);
  7905. }
  7906. }
  7907. chrif_req_login_operation(pl_sd->status.account_id, pl_sd->status.name, 6, vipdifftime, 7, 0);
  7908. return 0;
  7909. }
  7910. #endif
  7911. ACMD_FUNC(fullstrip) {
  7912. int i;
  7913. TBL_PC *tsd;
  7914. nullpo_retr(-1,sd);
  7915. if (!message || !*message) {
  7916. clif_displaymessage(fd, msg_txt(sd,349)); // Please enter a player name (usage: @fullstrip/@warpto/@goto <char name/ID>).
  7917. return -1;
  7918. }
  7919. if((tsd=map_nick2sd((char *)message)) == NULL && (tsd=map_id2sd(atoi(message))) == NULL){
  7920. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  7921. return -1;
  7922. }
  7923. for( i = 0; i < EQI_MAX; i++ ) {
  7924. if( tsd->equip_index[ i ] >= 0 )
  7925. pc_unequipitem( tsd , tsd->equip_index[ i ] , 2 );
  7926. }
  7927. return 0;
  7928. }
  7929. #include "../custom/atcommand.inc"
  7930. /**
  7931. * Fills the reference of available commands in atcommand DBMap
  7932. **/
  7933. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
  7934. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
  7935. //define with restriction
  7936. #define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
  7937. #define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
  7938. void atcommand_basecommands(void) {
  7939. /**
  7940. * Command reference list, place the base of your commands here
  7941. * TODO : all restricted command are crashing case, please look into it
  7942. **/
  7943. AtCommandInfo atcommand_base[] = {
  7944. #include "../custom/atcommand_def.inc"
  7945. ACMD_DEF2R("warp", mapmove, 1),
  7946. ACMD_DEF(where),
  7947. ACMD_DEF(jumpto),
  7948. ACMD_DEF(jump),
  7949. ACMD_DEF(who),
  7950. ACMD_DEF2("who2", who),
  7951. ACMD_DEF2("who3", who),
  7952. ACMD_DEF2("whomap", who),
  7953. ACMD_DEF2("whomap2", who),
  7954. ACMD_DEF2("whomap3", who),
  7955. ACMD_DEF(whogm),
  7956. ACMD_DEF(save),
  7957. ACMD_DEF(load),
  7958. ACMD_DEF(speed),
  7959. ACMD_DEF(storage),
  7960. ACMD_DEF(guildstorage),
  7961. ACMD_DEF(option),
  7962. ACMD_DEF(hide), // + /hide
  7963. ACMD_DEFR(jobchange, 1),
  7964. ACMD_DEF(kill),
  7965. ACMD_DEF(alive),
  7966. ACMD_DEF(kami),
  7967. ACMD_DEF2("kamib", kami),
  7968. ACMD_DEF2("kamic", kami),
  7969. ACMD_DEF2("lkami", kami),
  7970. ACMD_DEF(heal),
  7971. ACMD_DEF(item),
  7972. ACMD_DEF(item2),
  7973. ACMD_DEF2("itembound",item),
  7974. ACMD_DEF2("itembound2",item2),
  7975. ACMD_DEF(itemreset),
  7976. ACMD_DEF(clearstorage),
  7977. ACMD_DEF(cleargstorage),
  7978. ACMD_DEF(clearcart),
  7979. ACMD_DEF2R("blvl", baselevelup, 1),
  7980. ACMD_DEF2("jlvl", joblevelup),
  7981. ACMD_DEF(help),
  7982. ACMD_DEF(pvpoff),
  7983. ACMD_DEF(pvpon),
  7984. ACMD_DEF(gvgoff),
  7985. ACMD_DEF(gvgon),
  7986. ACMD_DEF(model),
  7987. ACMD_DEFR(go, 1),
  7988. ACMD_DEF(monster),
  7989. ACMD_DEF2("monstersmall", monster),
  7990. ACMD_DEF2("monsterbig", monster),
  7991. ACMD_DEF(killmonster),
  7992. ACMD_DEF2("killmonster2", killmonster),
  7993. ACMD_DEF(refine),
  7994. ACMD_DEF(produce),
  7995. ACMD_DEF(memo),
  7996. ACMD_DEF(gat),
  7997. ACMD_DEF(displaystatus),
  7998. ACMD_DEF2("stpoint", statuspoint),
  7999. ACMD_DEF2("skpoint", skillpoint),
  8000. ACMD_DEF(zeny),
  8001. ACMD_DEF2("str", param),
  8002. ACMD_DEF2("agi", param),
  8003. ACMD_DEF2("vit", param),
  8004. ACMD_DEF2("int", param),
  8005. ACMD_DEF2("dex", param),
  8006. ACMD_DEF2("luk", param),
  8007. ACMD_DEF2("glvl", guildlevelup),
  8008. ACMD_DEF(makeegg),
  8009. ACMD_DEF(hatch),
  8010. ACMD_DEF(petfriendly),
  8011. ACMD_DEF(pethungry),
  8012. ACMD_DEF(petrename),
  8013. ACMD_DEF(recall), // + /recall
  8014. ACMD_DEF(night),
  8015. ACMD_DEF(day),
  8016. ACMD_DEF(doom),
  8017. ACMD_DEF(doommap),
  8018. ACMD_DEF(raise),
  8019. ACMD_DEF(raisemap),
  8020. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  8021. ACMD_DEF(kickall),
  8022. ACMD_DEF(allskill),
  8023. ACMD_DEF(questskill),
  8024. ACMD_DEF(lostskill),
  8025. ACMD_DEF(spiritball),
  8026. ACMD_DEF(party),
  8027. ACMD_DEF(guild),
  8028. ACMD_DEF(breakguild),
  8029. ACMD_DEF(agitstart),
  8030. ACMD_DEF(agitend),
  8031. ACMD_DEF(mapexit),
  8032. ACMD_DEF(idsearch),
  8033. ACMD_DEF(broadcast), // + /b and /nb
  8034. ACMD_DEF(localbroadcast), // + /lb and /nlb
  8035. ACMD_DEF(recallall),
  8036. ACMD_DEFR(reload,2),
  8037. ACMD_DEF2("reloaditemdb", reload),
  8038. ACMD_DEF2("reloadmobdb", reload),
  8039. ACMD_DEF2("reloadskilldb", reload),
  8040. ACMD_DEF2R("reloadscript", reload,2),
  8041. ACMD_DEF2("reloadatcommand", reload),
  8042. ACMD_DEF2("reloadbattleconf", reload),
  8043. ACMD_DEF2("reloadstatusdb", reload),
  8044. ACMD_DEF2("reloadpcdb", reload),
  8045. ACMD_DEF2("reloadmotd", reload),
  8046. ACMD_DEF2("reloadquestdb", reload),
  8047. ACMD_DEF2("reloadmsgconf", reload),
  8048. ACMD_DEF2("reloadpacketdb", reload),
  8049. ACMD_DEF2("reloadinstancedb", reload),
  8050. ACMD_DEF(partysharelvl),
  8051. ACMD_DEF(mapinfo),
  8052. ACMD_DEF(dye),
  8053. ACMD_DEF2("hairstyle", hair_style),
  8054. ACMD_DEF2("haircolor", hair_color),
  8055. ACMD_DEF2("allstats", stat_all),
  8056. ACMD_DEF2("block", char_block),
  8057. ACMD_DEF2("ban", char_ban),
  8058. ACMD_DEF2("unblock", char_unblock),
  8059. ACMD_DEF2("unban", char_unban),
  8060. ACMD_DEF2("charban", char_ban),
  8061. ACMD_DEF2("charunban", char_unban),
  8062. ACMD_DEF2("mount", mount_peco),
  8063. ACMD_DEF(guildspy),
  8064. ACMD_DEF(partyspy),
  8065. ACMD_DEF(repairall),
  8066. ACMD_DEF(guildrecall),
  8067. ACMD_DEF(partyrecall),
  8068. ACMD_DEF(nuke),
  8069. ACMD_DEF(shownpc),
  8070. ACMD_DEF(hidenpc),
  8071. ACMD_DEF(loadnpc),
  8072. ACMD_DEF(unloadnpc),
  8073. ACMD_DEF2("time", servertime),
  8074. ACMD_DEF(jail),
  8075. ACMD_DEF(unjail),
  8076. ACMD_DEF(jailfor),
  8077. ACMD_DEF(jailtime),
  8078. ACMD_DEF(disguise),
  8079. ACMD_DEF(undisguise),
  8080. ACMD_DEF(email),
  8081. ACMD_DEF(effect),
  8082. ACMD_DEF(follow),
  8083. ACMD_DEF(addwarp),
  8084. ACMD_DEF(skillon),
  8085. ACMD_DEF(skilloff),
  8086. ACMD_DEF(killer),
  8087. ACMD_DEF(npcmove),
  8088. ACMD_DEF(killable),
  8089. ACMD_DEF(dropall),
  8090. ACMD_DEF(storeall),
  8091. ACMD_DEF(skillid),
  8092. ACMD_DEF(useskill),
  8093. ACMD_DEF(displayskill),
  8094. ACMD_DEF(snow),
  8095. ACMD_DEF(sakura),
  8096. ACMD_DEF(clouds),
  8097. ACMD_DEF(clouds2),
  8098. ACMD_DEF(fog),
  8099. ACMD_DEF(fireworks),
  8100. ACMD_DEF(leaves),
  8101. ACMD_DEF(summon),
  8102. ACMD_DEF(adjgroup),
  8103. ACMD_DEF(trade),
  8104. ACMD_DEF(send),
  8105. ACMD_DEF(setbattleflag),
  8106. ACMD_DEF(unmute),
  8107. ACMD_DEF(clearweather),
  8108. ACMD_DEF(uptime),
  8109. ACMD_DEF(changesex),
  8110. ACMD_DEF(mute),
  8111. ACMD_DEF(refresh),
  8112. ACMD_DEF(refreshall),
  8113. ACMD_DEF(identify),
  8114. ACMD_DEF(identifyall),
  8115. ACMD_DEF(gmotd),
  8116. ACMD_DEF(misceffect),
  8117. ACMD_DEF(mobsearch),
  8118. ACMD_DEF(cleanmap),
  8119. ACMD_DEF(cleanarea),
  8120. ACMD_DEF(npctalk),
  8121. ACMD_DEF(pettalk),
  8122. ACMD_DEF(users),
  8123. ACMD_DEF(reset),
  8124. ACMD_DEF(skilltree),
  8125. ACMD_DEF(marry),
  8126. ACMD_DEF(divorce),
  8127. ACMD_DEF(sound),
  8128. ACMD_DEF(undisguiseall),
  8129. ACMD_DEF(disguiseall),
  8130. ACMD_DEF(changelook),
  8131. ACMD_DEF(autoloot),
  8132. ACMD_DEF2("alootid", autolootitem),
  8133. ACMD_DEF(autoloottype),
  8134. ACMD_DEF(mobinfo),
  8135. ACMD_DEF(exp),
  8136. ACMD_DEF(version),
  8137. ACMD_DEF(mutearea),
  8138. ACMD_DEF(rates),
  8139. ACMD_DEF(iteminfo),
  8140. ACMD_DEF(whodrops),
  8141. ACMD_DEF(whereis),
  8142. ACMD_DEF(mapflag),
  8143. ACMD_DEF(me),
  8144. ACMD_DEF(monsterignore),
  8145. ACMD_DEF(fakename),
  8146. ACMD_DEF(size),
  8147. ACMD_DEF(showexp),
  8148. ACMD_DEF(showzeny),
  8149. ACMD_DEF(showdelay),
  8150. ACMD_DEF(autotrade),
  8151. ACMD_DEF(changegm),
  8152. ACMD_DEF(changeleader),
  8153. ACMD_DEF(partyoption),
  8154. ACMD_DEF(invite),
  8155. ACMD_DEF(duel),
  8156. ACMD_DEF(leave),
  8157. ACMD_DEF(accept),
  8158. ACMD_DEF(reject),
  8159. ACMD_DEF(clone),
  8160. ACMD_DEF2("slaveclone", clone),
  8161. ACMD_DEF2("evilclone", clone),
  8162. ACMD_DEF(tonpc),
  8163. ACMD_DEF(commands),
  8164. ACMD_DEF(noask),
  8165. ACMD_DEF(request),
  8166. ACMD_DEF(homlevel),
  8167. ACMD_DEF(homevolution),
  8168. ACMD_DEF(hommutate),
  8169. ACMD_DEF(makehomun),
  8170. ACMD_DEF(homfriendly),
  8171. ACMD_DEF(homhungry),
  8172. ACMD_DEF(homtalk),
  8173. ACMD_DEF(hominfo),
  8174. ACMD_DEF(homstats),
  8175. ACMD_DEF(homshuffle),
  8176. ACMD_DEF(showmobs),
  8177. ACMD_DEF(feelreset),
  8178. ACMD_DEF(auction),
  8179. ACMD_DEF(mail),
  8180. ACMD_DEF2("noks", ksprotection),
  8181. ACMD_DEF(allowks),
  8182. ACMD_DEF(cash),
  8183. ACMD_DEF2("points", cash),
  8184. ACMD_DEF(agitstart2),
  8185. ACMD_DEF(agitend2),
  8186. ACMD_DEF(resetskill),
  8187. ACMD_DEF(resetstat),
  8188. ACMD_DEF2("storagelist", itemlist),
  8189. ACMD_DEF2("cartlist", itemlist),
  8190. ACMD_DEF2("itemlist", itemlist),
  8191. ACMD_DEF(stats),
  8192. ACMD_DEF(delitem),
  8193. ACMD_DEF(charcommands),
  8194. ACMD_DEF(font),
  8195. ACMD_DEF(accinfo),
  8196. ACMD_DEF(set),
  8197. ACMD_DEF(undisguiseguild),
  8198. ACMD_DEF(disguiseguild),
  8199. ACMD_DEF(sizeall),
  8200. ACMD_DEF(sizeguild),
  8201. ACMD_DEF(addperm),
  8202. ACMD_DEF2("rmvperm", addperm),
  8203. ACMD_DEF(unloadnpcfile),
  8204. ACMD_DEF(cart),
  8205. ACMD_DEF(mount2),
  8206. ACMD_DEF(join),
  8207. ACMD_DEF(channel),
  8208. ACMD_DEF(fontcolor),
  8209. ACMD_DEF(langtype),
  8210. #ifdef VIP_ENABLE
  8211. ACMD_DEF(vip),
  8212. #endif
  8213. ACMD_DEF(fullstrip),
  8214. };
  8215. AtCommandInfo* atcommand;
  8216. int i;
  8217. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  8218. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  8219. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  8220. continue;
  8221. }
  8222. CREATE(atcommand, AtCommandInfo, 1);
  8223. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  8224. atcommand->func = atcommand_base[i].func;
  8225. atcommand->restriction = atcommand_base[i].restriction;
  8226. strdb_put(atcommand_db, atcommand->command, atcommand);
  8227. }
  8228. return;
  8229. }
  8230. /*==========================================
  8231. * Command lookup functions
  8232. *------------------------------------------*/
  8233. bool atcommand_exists(const char* name)
  8234. {
  8235. return strdb_exists(atcommand_db, name);
  8236. }
  8237. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  8238. {
  8239. if (strdb_exists(atcommand_db, name))
  8240. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  8241. return NULL;
  8242. }
  8243. static const char* atcommand_checkalias(const char *aliasname)
  8244. {
  8245. AliasInfo *alias_info = NULL;
  8246. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  8247. return alias_info->command->command;
  8248. return aliasname;
  8249. }
  8250. /// AtCommand suggestion
  8251. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  8252. DBIterator* atcommand_iter;
  8253. DBIterator* alias_iter;
  8254. AtCommandInfo* command_info = NULL;
  8255. AliasInfo* alias_info = NULL;
  8256. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  8257. char* full_match[MAX_SUGGESTIONS];
  8258. char* suggestions[MAX_SUGGESTIONS];
  8259. char* match;
  8260. int prefix_count = 0, full_count = 0;
  8261. bool can_use;
  8262. if (!battle_config.atcommand_suggestions_enabled)
  8263. return;
  8264. atcommand_iter = db_iterator(atcommand_db);
  8265. alias_iter = db_iterator(atcommand_alias_db);
  8266. // Build the matches
  8267. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  8268. match = strstr(command_info->command, name);
  8269. can_use = pc_can_use_command(sd, command_info->command, type);
  8270. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  8271. suggestions[prefix_count] = command_info->command;
  8272. ++prefix_count;
  8273. }
  8274. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8275. full_match[full_count] = command_info->command;
  8276. ++full_count;
  8277. }
  8278. }
  8279. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8280. match = strstr(alias_info->alias, name);
  8281. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8282. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8283. suggestions[prefix_count] = alias_info->alias;
  8284. ++prefix_count;
  8285. }
  8286. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8287. full_match[full_count] = alias_info->alias;
  8288. ++full_count;
  8289. }
  8290. }
  8291. if ((full_count+prefix_count) > 0) {
  8292. char buffer[512];
  8293. int i;
  8294. // Merge full match and prefix match results
  8295. if (prefix_count < MAX_SUGGESTIONS) {
  8296. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8297. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8298. }
  8299. // Build the suggestion string
  8300. strcpy(buffer, msg_txt(sd,205));
  8301. strcat(buffer,"\n");
  8302. for(i=0; i < prefix_count; ++i) {
  8303. strcat(buffer,suggestions[i]);
  8304. strcat(buffer," ");
  8305. }
  8306. clif_displaymessage(sd->fd, buffer);
  8307. }
  8308. dbi_destroy(atcommand_iter);
  8309. dbi_destroy(alias_iter);
  8310. }
  8311. /*
  8312. * Executes an at-command
  8313. * \param type :
  8314. * 0 : script call (atcommand)
  8315. * 1 : normal player @atcommand
  8316. * 2 : console
  8317. * 3 : script call (useatcmd)
  8318. */
  8319. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8320. {
  8321. char charname[NAME_LENGTH], params[100];
  8322. char charname2[NAME_LENGTH], params2[100];
  8323. char command[100];
  8324. char output[CHAT_SIZE_MAX];
  8325. //Reconstructed message
  8326. char atcmd_msg[CHAT_SIZE_MAX];
  8327. TBL_PC * ssd = NULL; //sd for target
  8328. AtCommandInfo * info;
  8329. nullpo_retr(false, sd);
  8330. //Shouldn't happen
  8331. if ( !message || !*message )
  8332. return false;
  8333. //Block NOCHAT but do not display it as a normal message
  8334. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8335. return true;
  8336. // skip 10/11-langtype's codepage indicator, if detected
  8337. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8338. message += 3;
  8339. //Should display as a normal message
  8340. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8341. return false;
  8342. // type value 0|2 = script|console invoked: bypass restrictions
  8343. if ( type == 1 || type == 3) {
  8344. //Commands are disabled on maps flagged as 'nocommand'
  8345. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8346. clif_displaymessage(fd, msg_txt(sd,143));
  8347. return false;
  8348. }
  8349. }
  8350. if (*message == charcommand_symbol) {
  8351. do {
  8352. int x, y, z;
  8353. //Checks to see if #command has a name or a name + parameters.
  8354. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8355. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8356. //z always has the value of the scan that was successful
  8357. z = ( x > 1 ) ? x : y;
  8358. //#command + name means the sufficient target was used and anything else after
  8359. //can be looked at by the actual command function since most scan to see if the
  8360. //right parameters are used.
  8361. if ( x > 2 ) {
  8362. sprintf(atcmd_msg, "%s %s", command, params);
  8363. break;
  8364. }
  8365. else if ( y > 2 ) {
  8366. sprintf(atcmd_msg, "%s %s", command, params2);
  8367. break;
  8368. }
  8369. //Regardless of what style the #command is used, if it's correct, it will always have
  8370. //this value if there is no parameter. Send it as just the #command
  8371. else if ( z == 2 ) {
  8372. sprintf(atcmd_msg, "%s", command);
  8373. break;
  8374. }
  8375. if( !pc_get_group_level(sd) ) {
  8376. if( x >= 1 || y >= 1 ) { /* we have command */
  8377. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8378. 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 */
  8379. return false;
  8380. } else
  8381. return false;/* display as normal message */
  8382. }
  8383. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8384. clif_displaymessage(fd, output);
  8385. return true;
  8386. } while(0);
  8387. }
  8388. else if (*message == atcommand_symbol) {
  8389. //atcmd_msg is constructed above differently for charcommands
  8390. //it's copied from message if not a charcommand so it can
  8391. //pass through the rest of the code compatible with both symbols
  8392. sprintf(atcmd_msg, "%s", message);
  8393. }
  8394. //Clearing these to be used once more.
  8395. memset(command, '\0', sizeof(command));
  8396. memset(params, '\0', sizeof(params));
  8397. //check to see if any params exist within this command
  8398. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8399. params[0] = '\0';
  8400. // @commands (script based)
  8401. if((type == 1 || type == 3) && atcmd_binding_count > 0) {
  8402. struct atcmd_binding_data * binding;
  8403. // Check if the command initiated is a character command
  8404. if (*message == charcommand_symbol &&
  8405. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8406. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8407. clif_displaymessage(fd, output);
  8408. return true;
  8409. }
  8410. // Get atcommand binding
  8411. binding = get_atcommandbind_byname(command);
  8412. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8413. if( binding != NULL && binding->npc_event[0] &&
  8414. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8415. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8416. {
  8417. // Check if self or character invoking; if self == character invoked, then self invoke.
  8418. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8419. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8420. return true;
  8421. }
  8422. }
  8423. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8424. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8425. if (info == NULL) {
  8426. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8427. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8428. clif_displaymessage(fd, output);
  8429. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8430. return true;
  8431. } else
  8432. return false;
  8433. }
  8434. //check restriction
  8435. if(info->restriction){
  8436. if(info->restriction&1 && type == 2) //console prevent
  8437. return true;
  8438. if(info->restriction&2 && (type == 0 || type == 3) ) //scripts prevent
  8439. return true;
  8440. }
  8441. // type == 1 : player invoked
  8442. if (type == 1) {
  8443. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8444. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8445. return false;
  8446. }
  8447. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8448. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8449. return true;
  8450. }
  8451. }
  8452. // Check if target is valid only if confirmed that player can use command.
  8453. if (*message == charcommand_symbol &&
  8454. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8455. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8456. clif_displaymessage(fd, output);
  8457. return true;
  8458. }
  8459. //Attempt to use the command
  8460. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8461. {
  8462. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8463. clif_displaymessage(fd, output);
  8464. return true;
  8465. }
  8466. //Log only if successful.
  8467. if ( *atcmd_msg == atcommand_symbol )
  8468. log_atcommand(sd, atcmd_msg);
  8469. else if ( *atcmd_msg == charcommand_symbol )
  8470. log_atcommand(sd, message);
  8471. return true;
  8472. }
  8473. /*==========================================
  8474. *
  8475. *------------------------------------------*/
  8476. static void atcommand_config_read(const char* config_filename)
  8477. {
  8478. config_setting_t *aliases = NULL, *help = NULL;
  8479. const char *symbol = NULL;
  8480. int num_aliases = 0;
  8481. if (conf_read_file(&atcommand_config, config_filename))
  8482. return;
  8483. // Command symbols
  8484. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8485. if (ISPRINT(*symbol) && // no control characters
  8486. *symbol != '/' && // symbol of client commands
  8487. *symbol != '%' && // symbol of party chat
  8488. *symbol != '$' && // symbol of guild chat
  8489. *symbol != charcommand_symbol)
  8490. atcommand_symbol = *symbol;
  8491. }
  8492. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8493. if (ISPRINT(*symbol) && // no control characters
  8494. *symbol != '/' && // symbol of client commands
  8495. *symbol != '%' && // symbol of party chat
  8496. *symbol != '$' && // symbol of guild chat
  8497. *symbol != atcommand_symbol)
  8498. charcommand_symbol = *symbol;
  8499. }
  8500. // Command aliases
  8501. aliases = config_lookup(&atcommand_config, "aliases");
  8502. if (aliases != NULL) {
  8503. int i = 0;
  8504. int count = config_setting_length(aliases);
  8505. for (i = 0; i < count; ++i) {
  8506. config_setting_t *command;
  8507. const char *commandname = NULL;
  8508. int j = 0, alias_count = 0;
  8509. AtCommandInfo *commandinfo = NULL;
  8510. command = config_setting_get_elem(aliases, i);
  8511. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8512. continue;
  8513. commandname = config_setting_name(command);
  8514. if (!atcommand_exists(commandname)) {
  8515. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8516. continue;
  8517. }
  8518. commandinfo = get_atcommandinfo_byname(commandname);
  8519. alias_count = config_setting_length(command);
  8520. for (j = 0; j < alias_count; ++j) {
  8521. const char *alias = config_setting_get_string_elem(command, j);
  8522. if (alias != NULL) {
  8523. AliasInfo *alias_info;
  8524. if (strdb_exists(atcommand_alias_db, alias)) {
  8525. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8526. continue;
  8527. }
  8528. CREATE(alias_info, AliasInfo, 1);
  8529. alias_info->command = commandinfo;
  8530. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8531. strdb_put(atcommand_alias_db, alias, alias_info);
  8532. ++num_aliases;
  8533. }
  8534. }
  8535. }
  8536. }
  8537. // Commands help
  8538. // We only check if all commands exist
  8539. help = config_lookup(&atcommand_config, "help");
  8540. if (help != NULL) {
  8541. int count = config_setting_length(help);
  8542. int i;
  8543. for (i = 0; i < count; ++i) {
  8544. config_setting_t *command;
  8545. const char *commandname;
  8546. command = config_setting_get_elem(help, i);
  8547. commandname = config_setting_name(command);
  8548. if (!atcommand_exists(commandname))
  8549. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8550. }
  8551. }
  8552. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8553. return;
  8554. }
  8555. void atcommand_db_load_groups(int* group_ids) {
  8556. DBIterator *iter = db_iterator(atcommand_db);
  8557. AtCommandInfo* cmd;
  8558. int i;
  8559. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8560. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8561. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8562. for(i = 0; i < pc_group_max; i++) {
  8563. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8564. cmd->at_groups[i] = 1;
  8565. else
  8566. cmd->at_groups[i] = 0;
  8567. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8568. cmd->char_groups[i] = 1;
  8569. else
  8570. cmd->char_groups[i] = 0;
  8571. }
  8572. }
  8573. dbi_destroy(iter);
  8574. return;
  8575. }
  8576. void atcommand_db_clear(void) {
  8577. if (atcommand_db != NULL) {
  8578. DBIterator *iter = db_iterator(atcommand_db);
  8579. AtCommandInfo* cmd;
  8580. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8581. aFree(cmd->at_groups);
  8582. aFree(cmd->char_groups);
  8583. }
  8584. dbi_destroy(iter);
  8585. db_destroy(atcommand_db);
  8586. }
  8587. if (atcommand_alias_db != NULL)
  8588. db_destroy(atcommand_alias_db);
  8589. config_destroy(&atcommand_config);
  8590. }
  8591. void atcommand_doload(void) {
  8592. atcommand_db_clear();
  8593. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8594. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8595. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8596. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8597. }
  8598. void do_init_atcommand(void) {
  8599. atcommand_doload();
  8600. }
  8601. void do_final_atcommand(void) {
  8602. atcommand_db_clear();
  8603. }