atcommand.c 285 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685
  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 "intif.h"
  23. #include "itemdb.h"
  24. #include "log.h"
  25. #include "map.h"
  26. #include "pc.h"
  27. #include "pc_groups.h" // groupid2name
  28. #include "status.h"
  29. #include "skill.h"
  30. #include "mob.h"
  31. #include "npc.h"
  32. #include "pet.h"
  33. #include "homunculus.h"
  34. #include "mail.h"
  35. #include "mercenary.h"
  36. #include "elemental.h"
  37. #include "party.h"
  38. #include "guild.h"
  39. #include "script.h"
  40. #include "storage.h"
  41. #include "trade.h"
  42. #include "unit.h"
  43. #include "mapreg.h"
  44. #include "quest.h"
  45. #include <stdio.h>
  46. #include <stdlib.h>
  47. #include <string.h>
  48. #include <math.h>
  49. #define ATCOMMAND_LENGTH 50
  50. #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)
  51. typedef struct AtCommandInfo AtCommandInfo;
  52. typedef struct AliasInfo AliasInfo;
  53. int atcmd_binding_count = 0;
  54. struct AtCommandInfo {
  55. char command[ATCOMMAND_LENGTH];
  56. AtCommandFunc func;
  57. char* at_groups;/* quick @commands "can-use" lookup */
  58. char* char_groups;/* quick @charcommands "can-use" lookup */
  59. };
  60. struct AliasInfo {
  61. AtCommandInfo *command;
  62. char alias[ATCOMMAND_LENGTH];
  63. };
  64. char atcommand_symbol = '@'; // first char of the commands
  65. char charcommand_symbol = '#';
  66. static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
  67. static DBMap* atcommand_alias_db = NULL; //alias -> AtCommandInfo
  68. static config_t atcommand_config;
  69. static char atcmd_output[CHAT_SIZE_MAX];
  70. static char atcmd_player_name[NAME_LENGTH];
  71. static AtCommandInfo* get_atcommandinfo_byname(const char *name); // @help
  72. static const char* atcommand_checkalias(const char *aliasname); // @help
  73. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand); // @help
  74. // @commands (script-based)
  75. struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
  76. int i = 0;
  77. if( *name == atcommand_symbol || *name == charcommand_symbol )
  78. name++; // for backwards compatibility
  79. ARR_FIND( 0, atcmd_binding_count, i, strcmp(atcmd_binding[i]->command, name) == 0 );
  80. return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
  81. }
  82. /**
  83. * retrieves the help string associated with a given command.
  84. *
  85. * @param name the name of the command to retrieve help information for
  86. * @return the string associated with the command, or NULL
  87. */
  88. static const char* atcommand_help_string(const char* command)
  89. {
  90. const char* str = NULL;
  91. config_setting_t* info;
  92. if( *command == atcommand_symbol || *command == charcommand_symbol )
  93. {// remove the prefix symbol for the raw name of the command
  94. command ++;
  95. }
  96. // convert alias to the real command name
  97. command = atcommand_checkalias(command);
  98. // attept to find the first default help command
  99. info = config_lookup(&atcommand_config, "help");
  100. if( info == NULL )
  101. {// failed to find the help property in the configuration file
  102. return NULL;
  103. }
  104. if( !config_setting_lookup_string( info, command, &str ) )
  105. {// failed to find the matching help string
  106. return NULL;
  107. }
  108. // push the result from the method
  109. return str;
  110. }
  111. /*==========================================
  112. * @send (used for testing packet sends from the client)
  113. *------------------------------------------*/
  114. ACMD_FUNC(send)
  115. {
  116. int len=0,off,end,type;
  117. long num;
  118. // read message type as hex number (without the 0x)
  119. if(!message || !*message ||
  120. !((sscanf(message, "len %x", &type)==1 && (len=1))
  121. || sscanf(message, "%x", &type)==1) )
  122. {
  123. int i;
  124. for (i = 900; i <= 903; ++i)
  125. clif_displaymessage(fd, msg_txt(sd,i));
  126. return -1;
  127. }
  128. #define PARSE_ERROR(error,p) \
  129. {\
  130. clif_displaymessage(fd, (error));\
  131. sprintf(atcmd_output, ">%s", (p));\
  132. clif_displaymessage(fd, atcmd_output);\
  133. }
  134. //define PARSE_ERROR
  135. #define CHECK_EOS(p) \
  136. if(*(p) == 0){\
  137. clif_displaymessage(fd, "Unexpected end of string");\
  138. return -1;\
  139. }
  140. //define CHECK_EOS
  141. #define SKIP_VALUE(p) \
  142. {\
  143. while(*(p) && !ISSPACE(*(p))) ++(p); /* non-space */\
  144. while(*(p) && ISSPACE(*(p))) ++(p); /* space */\
  145. }
  146. //define SKIP_VALUE
  147. #define GET_VALUE(p,num) \
  148. {\
  149. if(sscanf((p), "x%lx", &(num)) < 1 && sscanf((p), "%ld ", &(num)) < 1){\
  150. PARSE_ERROR("Invalid number in:",(p));\
  151. return -1;\
  152. }\
  153. }
  154. //define GET_VALUE
  155. if (type > 0 && type < MAX_PACKET_DB) {
  156. if(len)
  157. {// show packet length
  158. sprintf(atcmd_output, msg_txt(sd,904), type, packet_db[sd->packet_ver][type].len); // Packet 0x%x length: %d
  159. clif_displaymessage(fd, atcmd_output);
  160. return 0;
  161. }
  162. len=packet_db[sd->packet_ver][type].len;
  163. off=2;
  164. if(len == 0)
  165. {// unknown packet - ERROR
  166. sprintf(atcmd_output, msg_txt(sd,905), type); // Unknown packet: 0x%x
  167. clif_displaymessage(fd, atcmd_output);
  168. return -1;
  169. } else if(len == -1)
  170. {// dynamic packet
  171. len=SHRT_MAX-4; // maximum length
  172. off=4;
  173. }
  174. WFIFOHEAD(fd, len);
  175. WFIFOW(fd,0)=TOW(type);
  176. // parse packet contents
  177. SKIP_VALUE(message);
  178. while(*message != 0 && off < len){
  179. if(ISDIGIT(*message) || *message == '-' || *message == '+')
  180. {// default (byte)
  181. GET_VALUE(message,num);
  182. WFIFOB(fd,off)=TOB(num);
  183. ++off;
  184. } else if(TOUPPER(*message) == 'B')
  185. {// byte
  186. ++message;
  187. GET_VALUE(message,num);
  188. WFIFOB(fd,off)=TOB(num);
  189. ++off;
  190. } else if(TOUPPER(*message) == 'W')
  191. {// word (2 bytes)
  192. ++message;
  193. GET_VALUE(message,num);
  194. WFIFOW(fd,off)=TOW(num);
  195. off+=2;
  196. } else if(TOUPPER(*message) == 'L')
  197. {// long word (4 bytes)
  198. ++message;
  199. GET_VALUE(message,num);
  200. WFIFOL(fd,off)=TOL(num);
  201. off+=4;
  202. } else if(TOUPPER(*message) == 'S')
  203. {// string - escapes are valid
  204. // get string length - num <= 0 means not fixed length (default)
  205. ++message;
  206. if(*message == '"'){
  207. num=0;
  208. } else {
  209. GET_VALUE(message,num);
  210. while(*message != '"')
  211. {// find start of string
  212. if(*message == 0 || ISSPACE(*message)){
  213. PARSE_ERROR(msg_txt(sd,906),message); // Not a string:
  214. return -1;
  215. }
  216. ++message;
  217. }
  218. }
  219. // parse string
  220. ++message;
  221. CHECK_EOS(message);
  222. end=(num<=0? 0: min(off+((int)num),len));
  223. for(; *message != '"' && (off < end || end == 0); ++off){
  224. if(*message == '\\'){
  225. ++message;
  226. CHECK_EOS(message);
  227. switch(*message){
  228. case 'a': num=0x07; break; // Bell
  229. case 'b': num=0x08; break; // Backspace
  230. case 't': num=0x09; break; // Horizontal tab
  231. case 'n': num=0x0A; break; // Line feed
  232. case 'v': num=0x0B; break; // Vertical tab
  233. case 'f': num=0x0C; break; // Form feed
  234. case 'r': num=0x0D; break; // Carriage return
  235. case 'e': num=0x1B; break; // Escape
  236. default: num=*message; break;
  237. case 'x': // Hexadecimal
  238. {
  239. ++message;
  240. CHECK_EOS(message);
  241. if(!ISXDIGIT(*message)){
  242. PARSE_ERROR(msg_txt(sd,907),message); // Not a hexadecimal digit:
  243. return -1;
  244. }
  245. num=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  246. if(ISXDIGIT(*message)){
  247. ++message;
  248. CHECK_EOS(message);
  249. num<<=8;
  250. num+=(ISDIGIT(*message)?*message-'0':TOLOWER(*message)-'a'+10);
  251. }
  252. WFIFOB(fd,off)=TOB(num);
  253. ++message;
  254. CHECK_EOS(message);
  255. continue;
  256. }
  257. case '0':
  258. case '1':
  259. case '2':
  260. case '3':
  261. case '4':
  262. case '5':
  263. case '6':
  264. case '7': // Octal
  265. {
  266. num=*message-'0'; // 1st octal digit
  267. ++message;
  268. CHECK_EOS(message);
  269. if(ISDIGIT(*message) && *message < '8'){
  270. num<<=3;
  271. num+=*message-'0'; // 2nd octal digit
  272. ++message;
  273. CHECK_EOS(message);
  274. if(ISDIGIT(*message) && *message < '8'){
  275. num<<=3;
  276. num+=*message-'0'; // 3rd octal digit
  277. ++message;
  278. CHECK_EOS(message);
  279. }
  280. }
  281. WFIFOB(fd,off)=TOB(num);
  282. continue;
  283. }
  284. }
  285. } else
  286. num=*message;
  287. WFIFOB(fd,off)=TOB(num);
  288. ++message;
  289. CHECK_EOS(message);
  290. }//for
  291. while(*message != '"')
  292. {// ignore extra characters
  293. ++message;
  294. CHECK_EOS(message);
  295. }
  296. // terminate the string
  297. if(off < end)
  298. {// fill the rest with 0's
  299. memset(WFIFOP(fd,off),0,end-off);
  300. off=end;
  301. }
  302. } else
  303. {// unknown
  304. PARSE_ERROR(msg_txt(sd,908),message); // Unknown type of value in:
  305. return -1;
  306. }
  307. SKIP_VALUE(message);
  308. }
  309. if(packet_db[sd->packet_ver][type].len == -1)
  310. {// send dynamic packet
  311. WFIFOW(fd,2)=TOW(off);
  312. WFIFOSET(fd,off);
  313. } else
  314. {// send static packet
  315. if(off < len)
  316. memset(WFIFOP(fd,off),0,len-off);
  317. WFIFOSET(fd,len);
  318. }
  319. } else {
  320. clif_displaymessage(fd, msg_txt(sd,259)); // Invalid packet
  321. return -1;
  322. }
  323. sprintf (atcmd_output, msg_txt(sd,258), type, type); // Sent packet 0x%x (%d)
  324. clif_displaymessage(fd, atcmd_output);
  325. return 0;
  326. #undef PARSE_ERROR
  327. #undef CHECK_EOS
  328. #undef SKIP_VALUE
  329. #undef GET_VALUE
  330. }
  331. /*==========================================
  332. * @rura, @warp, @mapmove
  333. *------------------------------------------*/
  334. ACMD_FUNC(mapmove)
  335. {
  336. char map_name[MAP_NAME_LENGTH_EXT];
  337. unsigned short mapindex;
  338. short x = 0, y = 0;
  339. int16 m = -1;
  340. nullpo_retr(-1, sd);
  341. memset(map_name, '\0', sizeof(map_name));
  342. if (!message || !*message ||
  343. (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 &&
  344. sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) {
  345. clif_displaymessage(fd, msg_txt(sd,909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>).
  346. return -1;
  347. }
  348. mapindex = mapindex_name2id(map_name);
  349. if (mapindex)
  350. m = map_mapindex2mapid(mapindex);
  351. if (!mapindex) { // m < 0 means on different server! [Kevin]
  352. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  353. return -1;
  354. }
  355. if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
  356. { //This is to prevent the pc_setpos call from printing an error.
  357. clif_displaymessage(fd, msg_txt(sd,2));
  358. if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
  359. x = y = 0; //Invalid cell, use random spot.
  360. }
  361. if (map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  362. clif_displaymessage(fd, msg_txt(sd,247));
  363. return -1;
  364. }
  365. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  366. clif_displaymessage(fd, msg_txt(sd,248));
  367. return -1;
  368. }
  369. if (pc_setpos(sd, mapindex, x, y, CLR_TELEPORT) != 0) {
  370. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  371. return -1;
  372. }
  373. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  374. return 0;
  375. }
  376. /*==========================================
  377. * Displays where a character is. Corrected version by Silent. [Skotlex]
  378. *------------------------------------------*/
  379. ACMD_FUNC(where)
  380. {
  381. struct map_session_data* pl_sd;
  382. nullpo_retr(-1, sd);
  383. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  384. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  385. clif_displaymessage(fd, msg_txt(sd,910)); // Please enter a player name (usage: @where <char name>).
  386. return -1;
  387. }
  388. pl_sd = map_nick2sd(atcmd_player_name);
  389. if (pl_sd == NULL ||
  390. strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
  391. (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))
  392. ) {
  393. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  394. return -1;
  395. }
  396. 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);
  397. clif_displaymessage(fd, atcmd_output);
  398. return 0;
  399. }
  400. /*==========================================
  401. *
  402. *------------------------------------------*/
  403. ACMD_FUNC(jumpto)
  404. {
  405. struct map_session_data *pl_sd = NULL;
  406. nullpo_retr(-1, sd);
  407. if (!message || !*message) {
  408. clif_displaymessage(fd, msg_txt(sd,911)); // Please enter a player name (usage: @jumpto/@warpto/@goto <char name/ID>).
  409. return -1;
  410. }
  411. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  412. {
  413. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  414. return -1;
  415. }
  416. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  417. {
  418. clif_displaymessage(fd, msg_txt(sd,247)); // You are not authorized to warp to this map.
  419. return -1;
  420. }
  421. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  422. {
  423. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  424. return -1;
  425. }
  426. if( pc_isdead(sd) )
  427. {
  428. clif_displaymessage(fd, msg_txt(sd,664));
  429. return -1;
  430. }
  431. pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  432. sprintf(atcmd_output, msg_txt(sd,4), pl_sd->status.name); // Jumped to %s
  433. clif_displaymessage(fd, atcmd_output);
  434. return 0;
  435. }
  436. /*==========================================
  437. *
  438. *------------------------------------------*/
  439. ACMD_FUNC(jump)
  440. {
  441. short x = 0, y = 0;
  442. nullpo_retr(-1, sd);
  443. memset(atcmd_output, '\0', sizeof(atcmd_output));
  444. sscanf(message, "%hd %hd", &x, &y);
  445. if (map[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  446. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  447. return -1;
  448. }
  449. if( pc_isdead(sd) )
  450. {
  451. clif_displaymessage(fd, msg_txt(sd,664));
  452. return -1;
  453. }
  454. if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
  455. { //This is to prevent the pc_setpos call from printing an error.
  456. clif_displaymessage(fd, msg_txt(sd,2));
  457. if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
  458. x = y = 0; //Invalid cell, use random spot.
  459. }
  460. pc_setpos(sd, sd->mapindex, x, y, CLR_TELEPORT);
  461. sprintf(atcmd_output, msg_txt(sd,5), sd->bl.x, sd->bl.y); // Jumped to %d %d
  462. clif_displaymessage(fd, atcmd_output);
  463. return 0;
  464. }
  465. /*==========================================
  466. * Display list of online characters with
  467. * various info.
  468. *------------------------------------------*/
  469. ACMD_FUNC(who)
  470. {
  471. struct map_session_data *pl_sd = NULL;
  472. struct s_mapiterator *iter = NULL;
  473. char map_name[MAP_NAME_LENGTH_EXT] = "";
  474. char player_name[NAME_LENGTH] = "";
  475. int count = 0;
  476. int level = 0;
  477. StringBuf buf;
  478. /**
  479. * 1 = @who : Player name, [Title], [Party name], [Guild name]
  480. * 2 = @who2 : Player name, [Title], BLvl, JLvl, Job
  481. * 3 = @who3 : [CID/AID] Player name [Title], Map, X, Y
  482. */
  483. int display_type = 1;
  484. int map_id = -1;
  485. nullpo_retr(-1, sd);
  486. if (strstr(command, "map") != NULL) {
  487. if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
  488. map_id = sd->bl.m;
  489. } else {
  490. sscanf(message, "%23s", player_name);
  491. }
  492. if (strstr(command, "2") != NULL)
  493. display_type = 2;
  494. else if (strstr(command, "3") != NULL)
  495. display_type = 3;
  496. level = pc_get_group_level(sd);
  497. StringBuf_Init(&buf);
  498. iter = mapit_getallusers();
  499. for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
  500. 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
  501. if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
  502. || (map_id >= 0 && pl_sd->bl.m != map_id))
  503. continue;
  504. switch (display_type) {
  505. case 2: {
  506. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  507. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  508. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  509. StringBuf_Printf(&buf, msg_txt(sd,347), pl_sd->status.base_level, pl_sd->status.job_level,
  510. job_name(pl_sd->status.class_)); // "| Lv:%d/%d | Job: %s"
  511. break;
  512. }
  513. case 3: {
  514. if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
  515. StringBuf_Printf(&buf, msg_txt(sd,912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) "
  516. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  517. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  518. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  519. StringBuf_Printf(&buf, msg_txt(sd,348), mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); // "| Location: %s %d %d"
  520. break;
  521. }
  522. default: {
  523. struct party_data *p = party_search(pl_sd->status.party_id);
  524. struct guild *g = pl_sd->guild;
  525. StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
  526. if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
  527. StringBuf_Printf(&buf, msg_txt(sd,344), pc_group_id2name(pc_get_group_id(pl_sd))); // "(%s) "
  528. if (p != NULL)
  529. StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
  530. if (g != NULL)
  531. StringBuf_Printf(&buf, msg_txt(sd,346), g->name); // " | Guild: '%s'"
  532. break;
  533. }
  534. }
  535. clif_displaymessage(fd, StringBuf_Value(&buf));
  536. StringBuf_Clear(&buf);
  537. count++;
  538. }
  539. }
  540. mapit_free(iter);
  541. if (map_id < 0) {
  542. if (count == 0)
  543. StringBuf_Printf(&buf, msg_txt(sd,28)); // No player found.
  544. else if (count == 1)
  545. StringBuf_Printf(&buf, msg_txt(sd,29)); // 1 player found.
  546. else
  547. StringBuf_Printf(&buf, msg_txt(sd,30), count); // %d players found.
  548. } else {
  549. if (count == 0)
  550. StringBuf_Printf(&buf, msg_txt(sd,54), map[map_id].name); // No player found in map '%s'.
  551. else if (count == 1)
  552. StringBuf_Printf(&buf, msg_txt(sd,55), map[map_id].name); // 1 player found in map '%s'.
  553. else
  554. StringBuf_Printf(&buf, msg_txt(sd,56), count, map[map_id].name); // %d players found in map '%s'.
  555. }
  556. clif_displaymessage(fd, StringBuf_Value(&buf));
  557. StringBuf_Destroy(&buf);
  558. return 0;
  559. }
  560. /*==========================================
  561. *
  562. *------------------------------------------*/
  563. ACMD_FUNC(whogm)
  564. {
  565. struct map_session_data* pl_sd;
  566. struct s_mapiterator* iter;
  567. int j, count;
  568. int pl_level, level;
  569. char match_text[CHAT_SIZE_MAX];
  570. char player_name[NAME_LENGTH];
  571. struct guild *g;
  572. struct party_data *p;
  573. nullpo_retr(-1, sd);
  574. memset(atcmd_output, '\0', sizeof(atcmd_output));
  575. memset(match_text, '\0', sizeof(match_text));
  576. memset(player_name, '\0', sizeof(player_name));
  577. if (sscanf(message, "%199[^\n]", match_text) < 1)
  578. strcpy(match_text, "");
  579. for (j = 0; match_text[j]; j++)
  580. match_text[j] = TOLOWER(match_text[j]);
  581. count = 0;
  582. level = pc_get_group_level(sd);
  583. iter = mapit_getallusers();
  584. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  585. {
  586. pl_level = pc_get_group_level(pl_sd);
  587. if (!pl_level)
  588. continue;
  589. if (match_text[0])
  590. {
  591. memcpy(player_name, pl_sd->status.name, NAME_LENGTH);
  592. for (j = 0; player_name[j]; j++)
  593. player_name[j] = TOLOWER(player_name[j]);
  594. // search with no case sensitive
  595. if (strstr(player_name, match_text) == NULL)
  596. continue;
  597. }
  598. if (pl_level > level) {
  599. if (pl_sd->sc.option & OPTION_INVISIBLE)
  600. continue;
  601. sprintf(atcmd_output, msg_txt(sd,913), pl_sd->status.name); // Name: %s (GM)
  602. clif_displaymessage(fd, atcmd_output);
  603. count++;
  604. continue;
  605. }
  606. sprintf(atcmd_output, msg_txt(sd,914), // Name: %s (GM:%d) | Location: %s %d %d
  607. pl_sd->status.name, pl_level,
  608. mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y);
  609. clif_displaymessage(fd, atcmd_output);
  610. sprintf(atcmd_output, msg_txt(sd,915), // BLvl: %d | Job: %s (Lvl: %d)
  611. pl_sd->status.base_level,
  612. job_name(pl_sd->status.class_), pl_sd->status.job_level);
  613. clif_displaymessage(fd, atcmd_output);
  614. p = party_search(pl_sd->status.party_id);
  615. g = pl_sd->guild;
  616. sprintf(atcmd_output,msg_txt(sd,916), // Party: '%s' | Guild: '%s'
  617. p?p->party.name:msg_txt(sd,917), g?g->name:msg_txt(sd,917)); // None.
  618. clif_displaymessage(fd, atcmd_output);
  619. count++;
  620. }
  621. mapit_free(iter);
  622. if (count == 0)
  623. clif_displaymessage(fd, msg_txt(sd,150)); // No GM found.
  624. else if (count == 1)
  625. clif_displaymessage(fd, msg_txt(sd,151)); // 1 GM found.
  626. else {
  627. sprintf(atcmd_output, msg_txt(sd,152), count); // %d GMs found.
  628. clif_displaymessage(fd, atcmd_output);
  629. }
  630. return 0;
  631. }
  632. /*==========================================
  633. *
  634. *------------------------------------------*/
  635. ACMD_FUNC(save)
  636. {
  637. nullpo_retr(-1, sd);
  638. pc_setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y);
  639. if (sd->status.pet_id > 0 && sd->pd)
  640. intif_save_petdata(sd->status.account_id, &sd->pd->pet);
  641. chrif_save(sd,0);
  642. clif_displaymessage(fd, msg_txt(sd,6)); // Your save point has been changed.
  643. return 0;
  644. }
  645. /*==========================================
  646. *
  647. *------------------------------------------*/
  648. ACMD_FUNC(load)
  649. {
  650. int16 m;
  651. nullpo_retr(-1, sd);
  652. m = map_mapindex2mapid(sd->status.save_point.map);
  653. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  654. clif_displaymessage(fd, msg_txt(sd,249)); // You are not authorized to warp to your save map.
  655. return -1;
  656. }
  657. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  658. clif_displaymessage(fd, msg_txt(sd,248)); // You are not authorized to warp from your current map.
  659. return -1;
  660. }
  661. pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT);
  662. clif_displaymessage(fd, msg_txt(sd,7)); // Warping to save point..
  663. return 0;
  664. }
  665. /*==========================================
  666. *
  667. *------------------------------------------*/
  668. ACMD_FUNC(speed)
  669. {
  670. int speed;
  671. nullpo_retr(-1, sd);
  672. memset(atcmd_output, '\0', sizeof(atcmd_output));
  673. if (!message || !*message || sscanf(message, "%d", &speed) < 1) {
  674. sprintf(atcmd_output, msg_txt(sd,918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>).
  675. clif_displaymessage(fd, atcmd_output);
  676. return -1;
  677. }
  678. if (speed < 0) {
  679. sd->base_status.speed = DEFAULT_WALK_SPEED;
  680. sd->state.permanent_speed = 0; // Remove lock when set back to default speed.
  681. } else {
  682. sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
  683. sd->state.permanent_speed = 1; // Set lock when set to non-default speed.
  684. }
  685. status_calc_bl(&sd->bl, SCB_SPEED);
  686. clif_displaymessage(fd, msg_txt(sd,8)); // Speed changed.
  687. return 0;
  688. }
  689. /*==========================================
  690. *
  691. *------------------------------------------*/
  692. ACMD_FUNC(storage)
  693. {
  694. nullpo_retr(-1, sd);
  695. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
  696. return -1;
  697. if (storage_storageopen(sd) == 1)
  698. { //Already open.
  699. clif_displaymessage(fd, msg_txt(sd,250));
  700. return -1;
  701. }
  702. clif_displaymessage(fd, msg_txt(sd,919)); // Storage opened.
  703. return 0;
  704. }
  705. /*==========================================
  706. *
  707. *------------------------------------------*/
  708. ACMD_FUNC(guildstorage)
  709. {
  710. nullpo_retr(-1, sd);
  711. if (!sd->status.guild_id) {
  712. clif_displaymessage(fd, msg_txt(sd,252));
  713. return -1;
  714. }
  715. if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading)
  716. return -1;
  717. if (sd->state.storage_flag == 1) {
  718. clif_displaymessage(fd, msg_txt(sd,250));
  719. return -1;
  720. }
  721. if (sd->state.storage_flag == 2) {
  722. clif_displaymessage(fd, msg_txt(sd,251));
  723. return -1;
  724. }
  725. storage_guild_storageopen(sd);
  726. clif_displaymessage(fd, msg_txt(sd,920)); // Guild storage opened.
  727. return 0;
  728. }
  729. /*==========================================
  730. *
  731. *------------------------------------------*/
  732. ACMD_FUNC(option)
  733. {
  734. int param1 = 0, param2 = 0, param3 = 0;
  735. nullpo_retr(-1, sd);
  736. if (!message || !*message || sscanf(message, "%d %d %d", &param1, &param2, &param3) < 1 || param1 < 0 || param2 < 0 || param3 < 0)
  737. {// failed to match the parameters so inform the user of the options
  738. const char* text;
  739. // attempt to find the setting information for this command
  740. text = atcommand_help_string( command );
  741. // notify the user of the requirement to enter an option
  742. clif_displaymessage(fd, msg_txt(sd,921)); // Please enter at least one option.
  743. if( text )
  744. {// send the help text associated with this command
  745. clif_displaymessage( fd, text );
  746. }
  747. return -1;
  748. }
  749. sd->sc.opt1 = param1;
  750. sd->sc.opt2 = param2;
  751. pc_setoption(sd, param3);
  752. clif_displaymessage(fd, msg_txt(sd,9)); // Options changed.
  753. return 0;
  754. }
  755. /*==========================================
  756. *
  757. *------------------------------------------*/
  758. ACMD_FUNC(hide)
  759. {
  760. nullpo_retr(-1, sd);
  761. if (sd->sc.option & OPTION_INVISIBLE) {
  762. sd->sc.option &= ~OPTION_INVISIBLE;
  763. if (sd->disguise)
  764. status_set_viewdata(&sd->bl, sd->disguise);
  765. else
  766. status_set_viewdata(&sd->bl, sd->status.class_);
  767. clif_displaymessage(fd, msg_txt(sd,10)); // Invisible: Off
  768. // increment the number of pvp players on the map
  769. map[sd->bl.m].users_pvp++;
  770. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank )
  771. {// register the player for ranking calculations
  772. sd->pvp_timer = add_timer( gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0 );
  773. }
  774. //bugreport:2266
  775. map_foreachinmovearea(clif_insight, &sd->bl, AREA_SIZE, sd->bl.x, sd->bl.y, BL_ALL, &sd->bl);
  776. } else {
  777. sd->sc.option |= OPTION_INVISIBLE;
  778. sd->vd.class_ = INVISIBLE_CLASS;
  779. clif_displaymessage(fd, msg_txt(sd,11)); // Invisible: On
  780. // decrement the number of pvp players on the map
  781. map[sd->bl.m].users_pvp--;
  782. if( map[sd->bl.m].flag.pvp && !map[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER )
  783. {// unregister the player for ranking
  784. delete_timer( sd->pvp_timer, pc_calc_pvprank_timer );
  785. sd->pvp_timer = INVALID_TIMER;
  786. }
  787. }
  788. clif_changeoption(&sd->bl);
  789. return 0;
  790. }
  791. /*==========================================
  792. * Changes a character's class
  793. *------------------------------------------*/
  794. ACMD_FUNC(jobchange)
  795. {
  796. int job = 0, upper = 0;
  797. const char* text;
  798. nullpo_retr(-1, sd);
  799. if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
  800. int i;
  801. bool found = false;
  802. upper = 0;
  803. // Normal Jobs
  804. for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
  805. if (strncmpi(message, job_name(i), 16) == 0) {
  806. job = i;
  807. found = true;
  808. }
  809. }
  810. // High Jobs, Babys and Third
  811. for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
  812. if (strncmpi(message, job_name(i), 16) == 0) {
  813. job = i;
  814. found = true;
  815. }
  816. }
  817. if (!found) {
  818. text = atcommand_help_string(command);
  819. if (text)
  820. clif_displaymessage(fd, text);
  821. return -1;
  822. }
  823. }
  824. if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER || job == JOB_HANBOK
  825. || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
  826. || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
  827. ){ // Deny direct transformation into dummy jobs
  828. clif_displaymessage(fd, msg_txt(sd,923)); //"You can not change to this job by command."
  829. return 0;
  830. }
  831. if (pcdb_checkid(job))
  832. {
  833. if (pc_jobchange(sd, job, upper) == 0)
  834. clif_displaymessage(fd, msg_txt(sd,12)); // Your job has been changed.
  835. else {
  836. clif_displaymessage(fd, msg_txt(sd,155)); // You are unable to change your job.
  837. return -1;
  838. }
  839. } else {
  840. text = atcommand_help_string(command);
  841. if (text)
  842. clif_displaymessage(fd, text);
  843. return -1;
  844. }
  845. return 0;
  846. }
  847. /*==========================================
  848. *
  849. *------------------------------------------*/
  850. ACMD_FUNC(kill)
  851. {
  852. nullpo_retr(-1, sd);
  853. status_kill(&sd->bl);
  854. clif_displaymessage(sd->fd, msg_txt(sd,13)); // A pity! You've died.
  855. if (fd != sd->fd)
  856. clif_displaymessage(fd, msg_txt(sd,14)); // Character killed.
  857. return 0;
  858. }
  859. /*==========================================
  860. *
  861. *------------------------------------------*/
  862. ACMD_FUNC(alive)
  863. {
  864. nullpo_retr(-1, sd);
  865. if (!status_revive(&sd->bl, 100, 100))
  866. {
  867. clif_displaymessage(fd, msg_txt(sd,667));
  868. return -1;
  869. }
  870. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  871. clif_displaymessage(fd, msg_txt(sd,16)); // You've been revived! It's a miracle!
  872. return 0;
  873. }
  874. /*==========================================
  875. * +kamic [LuzZza]
  876. *------------------------------------------*/
  877. ACMD_FUNC(kami)
  878. {
  879. unsigned long color=0;
  880. nullpo_retr(-1, sd);
  881. memset(atcmd_output, '\0', sizeof(atcmd_output));
  882. if(*(command + 5) != 'c' && *(command + 5) != 'C') {
  883. if (!message || !*message) {
  884. clif_displaymessage(fd, msg_txt(sd,980)); // Please enter a message (usage: @kami <message>).
  885. return -1;
  886. }
  887. sscanf(message, "%199[^\n]", atcmd_output);
  888. if (strstr(command, "l") != NULL)
  889. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  890. else
  891. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? 0x10 : 0);
  892. } else {
  893. if(!message || !*message || (sscanf(message, "%lx %199[^\n]", &color, atcmd_output) < 2)) {
  894. clif_displaymessage(fd, msg_txt(sd,981)); // Please enter color and message (usage: @kamic <color> <message>).
  895. return -1;
  896. }
  897. if(color > 0xFFFFFF) {
  898. clif_displaymessage(fd, msg_txt(sd,982)); // Invalid color.
  899. return -1;
  900. }
  901. intif_broadcast2(atcmd_output, strlen(atcmd_output) + 1, color, 0x190, 12, 0, 0);
  902. }
  903. return 0;
  904. }
  905. /*==========================================
  906. *
  907. *------------------------------------------*/
  908. ACMD_FUNC(heal)
  909. {
  910. int hp = 0, sp = 0; // [Valaris] thanks to fov
  911. nullpo_retr(-1, sd);
  912. sscanf(message, "%d %d", &hp, &sp);
  913. // some overflow checks
  914. if( hp == INT_MIN ) hp++;
  915. if( sp == INT_MIN ) sp++;
  916. if ( hp == 0 && sp == 0 ) {
  917. if (!status_percent_heal(&sd->bl, 100, 100))
  918. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP have already been recovered.
  919. else
  920. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  921. return 0;
  922. }
  923. if ( hp > 0 && sp >= 0 ) {
  924. if(!status_heal(&sd->bl, hp, sp, 0))
  925. clif_displaymessage(fd, msg_txt(sd,157)); // HP and SP are already with the good value.
  926. else
  927. clif_displaymessage(fd, msg_txt(sd,17)); // HP, SP recovered.
  928. return 0;
  929. }
  930. if ( hp < 0 && sp <= 0 ) {
  931. status_damage(NULL, &sd->bl, -hp, -sp, 0, 0);
  932. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  933. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  934. return 0;
  935. }
  936. //Opposing signs.
  937. if ( hp ) {
  938. if (hp > 0)
  939. status_heal(&sd->bl, hp, 0, 0);
  940. else {
  941. status_damage(NULL, &sd->bl, -hp, 0, 0, 0);
  942. clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, 4, 0);
  943. }
  944. }
  945. if ( sp ) {
  946. if (sp > 0)
  947. status_heal(&sd->bl, 0, sp, 0);
  948. else
  949. status_damage(NULL, &sd->bl, 0, -sp, 0, 0);
  950. }
  951. clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
  952. return 0;
  953. }
  954. /*==========================================
  955. * @item command (usage: @item <name/id_of_item> <quantity>) (modified by [Yor] for pet_egg)
  956. *------------------------------------------*/
  957. ACMD_FUNC(item)
  958. {
  959. char item_name[100];
  960. int number = 0, item_id, flag = 0;
  961. struct item item_tmp;
  962. struct item_data *item_data;
  963. int get_count, i;
  964. nullpo_retr(-1, sd);
  965. memset(item_name, '\0', sizeof(item_name));
  966. if (!message || !*message || (
  967. sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 &&
  968. sscanf(message, "%99s %d", item_name, &number) < 1
  969. )) {
  970. clif_displaymessage(fd, msg_txt(sd,983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>).
  971. return -1;
  972. }
  973. if (number <= 0)
  974. number = 1;
  975. if ((item_data = itemdb_searchname(item_name)) == NULL &&
  976. (item_data = itemdb_exists(atoi(item_name))) == NULL)
  977. {
  978. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  979. return -1;
  980. }
  981. item_id = item_data->nameid;
  982. get_count = number;
  983. //Check if it's stackable.
  984. if (!itemdb_isstackable2(item_data))
  985. get_count = 1;
  986. for (i = 0; i < number; i += get_count) {
  987. // if not pet egg
  988. if (!pet_create_egg(sd, item_id)) {
  989. memset(&item_tmp, 0, sizeof(item_tmp));
  990. item_tmp.nameid = item_id;
  991. item_tmp.identify = 1;
  992. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  993. clif_additem(sd, 0, 0, flag);
  994. }
  995. }
  996. if (flag == 0)
  997. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  998. return 0;
  999. }
  1000. /*==========================================
  1001. *
  1002. *------------------------------------------*/
  1003. ACMD_FUNC(item2)
  1004. {
  1005. struct item item_tmp;
  1006. struct item_data *item_data;
  1007. char item_name[100];
  1008. int item_id, number = 0;
  1009. int identify = 0, refine = 0, attr = 0;
  1010. int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
  1011. nullpo_retr(-1, sd);
  1012. memset(item_name, '\0', sizeof(item_name));
  1013. if (!message || !*message || (
  1014. sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 &&
  1015. sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9
  1016. )) {
  1017. clif_displaymessage(fd, msg_txt(sd,984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity>
  1018. clif_displaymessage(fd, msg_txt(sd,985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>).
  1019. return -1;
  1020. }
  1021. if (number <= 0)
  1022. number = 1;
  1023. item_id = 0;
  1024. if ((item_data = itemdb_searchname(item_name)) != NULL ||
  1025. (item_data = itemdb_exists(atoi(item_name))) != NULL)
  1026. item_id = item_data->nameid;
  1027. if (item_id > 500) {
  1028. int flag = 0;
  1029. int loop, get_count, i;
  1030. loop = 1;
  1031. get_count = number;
  1032. if (item_data->type == IT_WEAPON || item_data->type == IT_ARMOR ||
  1033. item_data->type == IT_PETEGG || item_data->type == IT_PETARMOR) {
  1034. loop = number;
  1035. get_count = 1;
  1036. if (item_data->type == IT_PETEGG) {
  1037. identify = 1;
  1038. refine = 0;
  1039. }
  1040. if (item_data->type == IT_PETARMOR)
  1041. refine = 0;
  1042. if (refine > MAX_REFINE)
  1043. refine = MAX_REFINE;
  1044. } else {
  1045. identify = 1;
  1046. refine = attr = 0;
  1047. }
  1048. for (i = 0; i < loop; i++) {
  1049. memset(&item_tmp, 0, sizeof(item_tmp));
  1050. item_tmp.nameid = item_id;
  1051. item_tmp.identify = identify;
  1052. item_tmp.refine = refine;
  1053. item_tmp.attribute = attr;
  1054. item_tmp.card[0] = c1;
  1055. item_tmp.card[1] = c2;
  1056. item_tmp.card[2] = c3;
  1057. item_tmp.card[3] = c4;
  1058. if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
  1059. clif_additem(sd, 0, 0, flag);
  1060. }
  1061. if (flag == 0)
  1062. clif_displaymessage(fd, msg_txt(sd,18)); // Item created.
  1063. } else {
  1064. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  1065. return -1;
  1066. }
  1067. return 0;
  1068. }
  1069. /*==========================================
  1070. *
  1071. *------------------------------------------*/
  1072. ACMD_FUNC(itemreset)
  1073. {
  1074. int i;
  1075. nullpo_retr(-1, sd);
  1076. for (i = 0; i < MAX_INVENTORY; i++) {
  1077. if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) {
  1078. pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND);
  1079. }
  1080. }
  1081. clif_displaymessage(fd, msg_txt(sd,20)); // All of your items have been removed.
  1082. return 0;
  1083. }
  1084. /*==========================================
  1085. * Atcommand @lvlup
  1086. *------------------------------------------*/
  1087. ACMD_FUNC(baselevelup)
  1088. {
  1089. int level=0, i=0, status_point=0;
  1090. nullpo_retr(-1, sd);
  1091. level = atoi(message);
  1092. if (!message || !*message || !level) {
  1093. clif_displaymessage(fd, msg_txt(sd,986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>).
  1094. return -1;
  1095. }
  1096. if (level > 0) {
  1097. if (sd->status.base_level >= pc_maxbaselv(sd)) { // check for max level by Valaris
  1098. clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
  1099. return -1;
  1100. } // End Addition
  1101. if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positiv overflow
  1102. level = pc_maxbaselv(sd) - sd->status.base_level;
  1103. for (i = 0; i < level; i++)
  1104. status_point += pc_gets_status_point(sd->status.base_level + i);
  1105. sd->status.status_point += status_point;
  1106. sd->status.base_level += (unsigned int)level;
  1107. status_percent_heal(&sd->bl, 100, 100);
  1108. clif_misceffect(&sd->bl, 0);
  1109. clif_displaymessage(fd, msg_txt(sd,21)); // Base level raised.
  1110. } else {
  1111. if (sd->status.base_level == 1) {
  1112. clif_displaymessage(fd, msg_txt(sd,158)); // Base level can't go any lower.
  1113. return -1;
  1114. }
  1115. level*=-1;
  1116. if ((unsigned int)level >= sd->status.base_level)
  1117. level = sd->status.base_level-1;
  1118. for (i = 0; i > -level; i--)
  1119. status_point += pc_gets_status_point(sd->status.base_level + i - 1);
  1120. if (sd->status.status_point < status_point)
  1121. pc_resetstate(sd);
  1122. if (sd->status.status_point < status_point)
  1123. sd->status.status_point = 0;
  1124. else
  1125. sd->status.status_point -= status_point;
  1126. sd->status.base_level -= (unsigned int)level;
  1127. clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
  1128. }
  1129. sd->status.base_exp = 0;
  1130. clif_updatestatus(sd, SP_STATUSPOINT);
  1131. clif_updatestatus(sd, SP_BASELEVEL);
  1132. clif_updatestatus(sd, SP_BASEEXP);
  1133. clif_updatestatus(sd, SP_NEXTBASEEXP);
  1134. status_calc_pc(sd, 0);
  1135. pc_baselevelchanged(sd);
  1136. if(sd->status.party_id)
  1137. party_send_levelup(sd);
  1138. return 0;
  1139. }
  1140. /*==========================================
  1141. *
  1142. *------------------------------------------*/
  1143. ACMD_FUNC(joblevelup)
  1144. {
  1145. int level=0;
  1146. nullpo_retr(-1, sd);
  1147. level = atoi(message);
  1148. if (!message || !*message || !level) {
  1149. clif_displaymessage(fd, msg_txt(sd,987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>).
  1150. return -1;
  1151. }
  1152. if (level > 0) {
  1153. if (sd->status.job_level >= pc_maxjoblv(sd)) {
  1154. clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
  1155. return -1;
  1156. }
  1157. if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positiv overflow
  1158. level = pc_maxjoblv(sd) - sd->status.job_level;
  1159. sd->status.job_level += (unsigned int)level;
  1160. sd->status.skill_point += level;
  1161. clif_misceffect(&sd->bl, 1);
  1162. clif_displaymessage(fd, msg_txt(sd,24)); // Job level raised.
  1163. } else {
  1164. if (sd->status.job_level == 1) {
  1165. clif_displaymessage(fd, msg_txt(sd,159)); // Job level can't go any lower.
  1166. return -1;
  1167. }
  1168. level *=-1;
  1169. if ((unsigned int)level >= sd->status.job_level) // fix negativ overflow
  1170. level = sd->status.job_level-1;
  1171. sd->status.job_level -= (unsigned int)level;
  1172. if (sd->status.skill_point < level)
  1173. pc_resetskill(sd,0); //Reset skills since we need to substract more points.
  1174. if (sd->status.skill_point < level)
  1175. sd->status.skill_point = 0;
  1176. else
  1177. sd->status.skill_point -= level;
  1178. clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
  1179. }
  1180. sd->status.job_exp = 0;
  1181. clif_updatestatus(sd, SP_JOBLEVEL);
  1182. clif_updatestatus(sd, SP_JOBEXP);
  1183. clif_updatestatus(sd, SP_NEXTJOBEXP);
  1184. clif_updatestatus(sd, SP_SKILLPOINT);
  1185. status_calc_pc(sd, 0);
  1186. return 0;
  1187. }
  1188. /*==========================================
  1189. * @help
  1190. *------------------------------------------*/
  1191. ACMD_FUNC(help)
  1192. {
  1193. config_setting_t *help;
  1194. const char *text = NULL;
  1195. const char *command_name = NULL;
  1196. char *default_command = "help";
  1197. nullpo_retr(-1, sd);
  1198. help = config_lookup(&atcommand_config, "help");
  1199. if (help == NULL) {
  1200. clif_displaymessage(fd, msg_txt(sd,27)); // "Commands help is not available."
  1201. return -1;
  1202. }
  1203. if (!message || !*message) {
  1204. command_name = default_command; // If no command_name specified, display help for @help.
  1205. } else {
  1206. if (*message == atcommand_symbol || *message == charcommand_symbol)
  1207. ++message;
  1208. command_name = atcommand_checkalias(message);
  1209. }
  1210. if (!pc_can_use_command(sd, command_name, COMMAND_ATCOMMAND)) {
  1211. sprintf(atcmd_output, msg_txt(sd,153), message); // "%s is Unknown Command"
  1212. clif_displaymessage(fd, atcmd_output);
  1213. atcommand_get_suggestions(sd, command_name, true);
  1214. return -1;
  1215. }
  1216. if (!config_setting_lookup_string(help, command_name, &text)) {
  1217. sprintf(atcmd_output, msg_txt(sd,988), atcommand_symbol, command_name); // There is no help for %c%s.
  1218. clif_displaymessage(fd, atcmd_output);
  1219. atcommand_get_suggestions(sd, command_name, true);
  1220. return -1;
  1221. }
  1222. sprintf(atcmd_output, msg_txt(sd,989), atcommand_symbol, command_name); // Help for command %c%s:
  1223. clif_displaymessage(fd, atcmd_output);
  1224. { // Display aliases
  1225. DBIterator* iter;
  1226. AtCommandInfo *command_info;
  1227. AliasInfo *alias_info = NULL;
  1228. StringBuf buf;
  1229. bool has_aliases = false;
  1230. StringBuf_Init(&buf);
  1231. StringBuf_AppendStr(&buf, msg_txt(sd,990)); // Available aliases:
  1232. command_info = get_atcommandinfo_byname(command_name);
  1233. iter = db_iterator(atcommand_alias_db);
  1234. for (alias_info = dbi_first(iter); dbi_exists(iter); alias_info = dbi_next(iter)) {
  1235. if (alias_info->command == command_info) {
  1236. StringBuf_Printf(&buf, " %s", alias_info->alias);
  1237. has_aliases = true;
  1238. }
  1239. }
  1240. dbi_destroy(iter);
  1241. if (has_aliases)
  1242. clif_displaymessage(fd, StringBuf_Value(&buf));
  1243. StringBuf_Destroy(&buf);
  1244. }
  1245. // Display help contents
  1246. clif_displaymessage(fd, text);
  1247. return 0;
  1248. }
  1249. // helper function, used in foreach calls to stop auto-attack timers
  1250. // parameter: '0' - everyone, 'id' - only those attacking someone with that id
  1251. static int atcommand_stopattack(struct block_list *bl,va_list ap)
  1252. {
  1253. struct unit_data *ud = unit_bl2ud(bl);
  1254. int id = va_arg(ap, int);
  1255. if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
  1256. {
  1257. unit_stop_attack(bl);
  1258. return 1;
  1259. }
  1260. return 0;
  1261. }
  1262. /*==========================================
  1263. *
  1264. *------------------------------------------*/
  1265. static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
  1266. {
  1267. TBL_PC* sd = (TBL_PC*)bl;
  1268. clif_pvpset(sd, 0, 0, 2);
  1269. if (sd->pvp_timer != INVALID_TIMER) {
  1270. delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
  1271. sd->pvp_timer = INVALID_TIMER;
  1272. }
  1273. return 0;
  1274. }
  1275. ACMD_FUNC(pvpoff)
  1276. {
  1277. nullpo_retr(-1, sd);
  1278. if (!map[sd->bl.m].flag.pvp) {
  1279. clif_displaymessage(fd, msg_txt(sd,160)); // PvP is already Off.
  1280. return -1;
  1281. }
  1282. map[sd->bl.m].flag.pvp = 0;
  1283. if (!battle_config.pk_mode){
  1284. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1285. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1286. }
  1287. map_foreachinmap(atcommand_pvpoff_sub,sd->bl.m, BL_PC);
  1288. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1289. clif_displaymessage(fd, msg_txt(sd,31)); // PvP: Off.
  1290. return 0;
  1291. }
  1292. /*==========================================
  1293. *
  1294. *------------------------------------------*/
  1295. static int atcommand_pvpon_sub(struct block_list *bl,va_list ap)
  1296. {
  1297. TBL_PC* sd = (TBL_PC*)bl;
  1298. if (sd->pvp_timer == INVALID_TIMER) {
  1299. sd->pvp_timer = add_timer(gettick() + 200, pc_calc_pvprank_timer, sd->bl.id, 0);
  1300. sd->pvp_rank = 0;
  1301. sd->pvp_lastusers = 0;
  1302. sd->pvp_point = 5;
  1303. sd->pvp_won = 0;
  1304. sd->pvp_lost = 0;
  1305. }
  1306. return 0;
  1307. }
  1308. ACMD_FUNC(pvpon)
  1309. {
  1310. nullpo_retr(-1, sd);
  1311. if (map[sd->bl.m].flag.pvp) {
  1312. clif_displaymessage(fd, msg_txt(sd,161)); // PvP is already On.
  1313. return -1;
  1314. }
  1315. map[sd->bl.m].flag.pvp = 1;
  1316. if (!battle_config.pk_mode) {// display pvp circle and rank
  1317. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE);
  1318. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1319. map_foreachinmap(atcommand_pvpon_sub,sd->bl.m, BL_PC);
  1320. }
  1321. clif_displaymessage(fd, msg_txt(sd,32)); // PvP: On.
  1322. return 0;
  1323. }
  1324. /*==========================================
  1325. *
  1326. *------------------------------------------*/
  1327. ACMD_FUNC(gvgoff)
  1328. {
  1329. nullpo_retr(-1, sd);
  1330. if (!map[sd->bl.m].flag.gvg) {
  1331. clif_displaymessage(fd, msg_txt(sd,162)); // GvG is already Off.
  1332. return -1;
  1333. }
  1334. map[sd->bl.m].flag.gvg = 0;
  1335. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING);
  1336. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1337. map_foreachinmap(atcommand_stopattack,sd->bl.m, BL_CHAR, 0);
  1338. clif_displaymessage(fd, msg_txt(sd,33)); // GvG: Off.
  1339. return 0;
  1340. }
  1341. /*==========================================
  1342. *
  1343. *------------------------------------------*/
  1344. ACMD_FUNC(gvgon)
  1345. {
  1346. nullpo_retr(-1, sd);
  1347. if (map[sd->bl.m].flag.gvg) {
  1348. clif_displaymessage(fd, msg_txt(sd,163)); // GvG is already On.
  1349. return -1;
  1350. }
  1351. map[sd->bl.m].flag.gvg = 1;
  1352. clif_map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE);
  1353. clif_maptypeproperty2(&sd->bl,ALL_SAMEMAP);
  1354. clif_displaymessage(fd, msg_txt(sd,34)); // GvG: On.
  1355. return 0;
  1356. }
  1357. /*==========================================
  1358. *
  1359. *------------------------------------------*/
  1360. ACMD_FUNC(model)
  1361. {
  1362. int hair_style = 0, hair_color = 0, cloth_color = 0;
  1363. nullpo_retr(-1, sd);
  1364. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1365. if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) {
  1366. 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>).
  1367. MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR);
  1368. clif_displaymessage(fd, atcmd_output);
  1369. return -1;
  1370. }
  1371. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE &&
  1372. hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR &&
  1373. cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1374. pc_changelook(sd, LOOK_HAIR, hair_style);
  1375. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1376. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1377. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1378. } else {
  1379. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1380. return -1;
  1381. }
  1382. return 0;
  1383. }
  1384. /*==========================================
  1385. * @dye && @ccolor
  1386. *------------------------------------------*/
  1387. ACMD_FUNC(dye)
  1388. {
  1389. int cloth_color = 0;
  1390. nullpo_retr(-1, sd);
  1391. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1392. if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) {
  1393. 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>).
  1394. clif_displaymessage(fd, atcmd_output);
  1395. return -1;
  1396. }
  1397. if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) {
  1398. pc_changelook(sd, LOOK_CLOTHES_COLOR, cloth_color);
  1399. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1400. } else {
  1401. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1402. return -1;
  1403. }
  1404. return 0;
  1405. }
  1406. /*==========================================
  1407. * @hairstyle && @hstyle
  1408. *------------------------------------------*/
  1409. ACMD_FUNC(hair_style)
  1410. {
  1411. int hair_style = 0;
  1412. nullpo_retr(-1, sd);
  1413. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1414. if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) {
  1415. 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>).
  1416. clif_displaymessage(fd, atcmd_output);
  1417. return -1;
  1418. }
  1419. if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) {
  1420. pc_changelook(sd, LOOK_HAIR, hair_style);
  1421. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1422. } else {
  1423. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1424. return -1;
  1425. }
  1426. return 0;
  1427. }
  1428. /*==========================================
  1429. * @haircolor && @hcolor
  1430. *------------------------------------------*/
  1431. ACMD_FUNC(hair_color)
  1432. {
  1433. int hair_color = 0;
  1434. nullpo_retr(-1, sd);
  1435. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1436. if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) {
  1437. 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>).
  1438. clif_displaymessage(fd, atcmd_output);
  1439. return -1;
  1440. }
  1441. if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) {
  1442. pc_changelook(sd, LOOK_HAIR_COLOR, hair_color);
  1443. clif_displaymessage(fd, msg_txt(sd,36)); // Appearence changed.
  1444. } else {
  1445. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  1446. return -1;
  1447. }
  1448. return 0;
  1449. }
  1450. /*==========================================
  1451. * @go [city_number or city_name] - Updated by Harbin
  1452. *------------------------------------------*/
  1453. ACMD_FUNC(go)
  1454. {
  1455. int i;
  1456. int town;
  1457. char map_name[MAP_NAME_LENGTH];
  1458. int16 m;
  1459. const struct {
  1460. char map[MAP_NAME_LENGTH];
  1461. int x, y;
  1462. } data[] = {
  1463. { MAP_PRONTERA, 156, 191 }, // 0=Prontera
  1464. { MAP_MORROC, 156, 93 }, // 1=Morroc
  1465. { MAP_GEFFEN, 119, 59 }, // 2=Geffen
  1466. { MAP_PAYON, 162, 233 }, // 3=Payon
  1467. { MAP_ALBERTA, 192, 147 }, // 4=Alberta
  1468. #ifdef RENEWAL
  1469. { MAP_IZLUDE, 128, 146 }, // 5=Izlude (Renewal)
  1470. #else
  1471. { MAP_IZLUDE, 128, 114 }, // 5=Izlude
  1472. #endif
  1473. { MAP_ALDEBARAN, 140, 131 }, // 6=Al de Baran
  1474. { MAP_LUTIE, 147, 134 }, // 7=Lutie
  1475. { MAP_COMODO, 209, 143 }, // 8=Comodo
  1476. { MAP_YUNO, 157, 51 }, // 9=Yuno
  1477. { MAP_AMATSU, 198, 84 }, // 10=Amatsu
  1478. { MAP_GONRYUN, 160, 120 }, // 11=Gonryun
  1479. { MAP_UMBALA, 89, 157 }, // 12=Umbala
  1480. { MAP_NIFLHEIM, 21, 153 }, // 13=Niflheim
  1481. { MAP_LOUYANG, 217, 40 }, // 14=Louyang
  1482. { MAP_NOVICE, 53, 111 }, // 15=Training Grounds
  1483. { MAP_JAIL, 23, 61 }, // 16=Prison
  1484. { MAP_JAWAII, 249, 127 }, // 17=Jawaii
  1485. { MAP_AYOTHAYA, 151, 117 }, // 18=Ayothaya
  1486. { MAP_EINBROCH, 64, 200 }, // 19=Einbroch
  1487. { MAP_LIGHTHALZEN, 158, 92 }, // 20=Lighthalzen
  1488. { MAP_EINBECH, 70, 95 }, // 21=Einbech
  1489. { MAP_HUGEL, 96, 145 }, // 22=Hugel
  1490. { MAP_RACHEL, 130, 110 }, // 23=Rachel
  1491. { MAP_VEINS, 216, 123 }, // 24=Veins
  1492. { MAP_MOSCOVIA, 223, 184 }, // 25=Moscovia
  1493. { MAP_MIDCAMP, 180, 240 }, // 26=Midgard Camp
  1494. { MAP_MANUK, 282, 138 }, // 27=Manuk
  1495. { MAP_SPLENDIDE, 201, 147 }, // 28=Splendide
  1496. { MAP_BRASILIS, 182, 239 }, // 29=Brasilis
  1497. { MAP_DICASTES, 198, 187 }, // 30=El Dicastes
  1498. { MAP_MORA, 44, 151 }, // 31=Mora
  1499. { MAP_DEWATA, 200, 180 }, // 32=Dewata
  1500. { MAP_MALANGDO, 140, 114 }, // 33=Malangdo Island
  1501. { MAP_MALAYA, 242, 211 }, // 34=Malaya Port
  1502. { MAP_ECLAGE, 110, 39 }, // 35=Eclage
  1503. };
  1504. nullpo_retr(-1, sd);
  1505. if( map[sd->bl.m].flag.nogo && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) {
  1506. clif_displaymessage(sd->fd,msg_txt(sd,995)); // You cannot use @go on this map.
  1507. return 0;
  1508. }
  1509. memset(map_name, '\0', sizeof(map_name));
  1510. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1511. // get the number
  1512. town = atoi(message);
  1513. if (!message || !*message || sscanf(message, "%11s", map_name) < 1 || town < 0 || town >= ARRAYLENGTH(data))
  1514. {// no value matched so send the list of locations
  1515. const char* text;
  1516. // attempt to find the text help string
  1517. text = atcommand_help_string( command );
  1518. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number, or name.
  1519. if( text )
  1520. {// send the text to the client
  1521. clif_displaymessage( fd, text );
  1522. }
  1523. return -1;
  1524. }
  1525. // get possible name of the city
  1526. map_name[MAP_NAME_LENGTH-1] = '\0';
  1527. for (i = 0; map_name[i]; i++)
  1528. map_name[i] = TOLOWER(map_name[i]);
  1529. // try to identify the map name
  1530. if (strncmp(map_name, "prontera", 3) == 0) {
  1531. town = 0;
  1532. } else if (strncmp(map_name, "morocc", 4) == 0 ||
  1533. strncmp(map_name, "morroc", 4) == 0) {
  1534. town = 1;
  1535. } else if (strncmp(map_name, "geffen", 3) == 0) {
  1536. town = 2;
  1537. } else if (strncmp(map_name, "payon", 3) == 0) {
  1538. town = 3;
  1539. } else if (strncmp(map_name, "alberta", 3) == 0) {
  1540. town = 4;
  1541. } else if (strncmp(map_name, "izlude", 3) == 0) {
  1542. town = 5;
  1543. } else if (strncmp(map_name, "aldebaran", 3) == 0) {
  1544. town = 6;
  1545. } else if (strncmp(map_name, "lutie", 3) == 0 ||
  1546. strcmp(map_name, "christmas") == 0 ||
  1547. strncmp(map_name, "xmas", 3) == 0 ||
  1548. strncmp(map_name, "x-mas", 3) == 0) {
  1549. town = 7;
  1550. } else if (strncmp(map_name, "comodo", 3) == 0) {
  1551. town = 8;
  1552. } else if (strncmp(map_name, "juno", 3) == 0 ||
  1553. strncmp(map_name, "yuno", 3) == 0) {
  1554. town = 9;
  1555. } else if (strncmp(map_name, "amatsu", 3) == 0) {
  1556. town = 10;
  1557. } else if (strncmp(map_name, "kunlun", 3) == 0 ||
  1558. strncmp(map_name, "gonryun", 3) == 0) {
  1559. town = 11;
  1560. } else if (strncmp(map_name, "umbala", 3) == 0) {
  1561. town = 12;
  1562. } else if (strncmp(map_name, "niflheim", 3) == 0) {
  1563. town = 13;
  1564. } else if (strncmp(map_name, "louyang", 3) == 0) {
  1565. town = 14;
  1566. } else if (strncmp(map_name, "new_1-1", 3) == 0 ||
  1567. strncmp(map_name, "startpoint", 3) == 0 ||
  1568. strncmp(map_name, "beginning", 3) == 0) {
  1569. town = 15;
  1570. } else if (strncmp(map_name, "sec_pri", 3) == 0 ||
  1571. strncmp(map_name, "prison", 3) == 0 ||
  1572. strncmp(map_name, "jail", 3) == 0) {
  1573. town = 16;
  1574. } else if (strncmp(map_name, "jawaii", 3) == 0) {
  1575. town = 17;
  1576. } else if (strncmp(map_name, "ayothaya", 3) == 0) {
  1577. town = 18;
  1578. } else if (strncmp(map_name, "einbroch", 5) == 0) {
  1579. town = 19;
  1580. } else if (strncmp(map_name, "lighthalzen", 3) == 0) {
  1581. town = 20;
  1582. } else if (strncmp(map_name, "einbech", 5) == 0) {
  1583. town = 21;
  1584. } else if (strncmp(map_name, "hugel", 3) == 0) {
  1585. town = 22;
  1586. } else if (strncmp(map_name, "rachel", 3) == 0) {
  1587. town = 23;
  1588. } else if (strncmp(map_name, "veins", 3) == 0) {
  1589. town = 24;
  1590. } else if (strncmp(map_name, "moscovia", 3) == 0) {
  1591. town = 25;
  1592. } else if (strncmp(map_name, "mid_camp", 3) == 0) {
  1593. town = 26;
  1594. } else if (strncmp(map_name, "manuk", 3) == 0) {
  1595. town = 27;
  1596. } else if (strncmp(map_name, "splendide", 3) == 0) {
  1597. town = 28;
  1598. } else if (strncmp(map_name, "brasilis", 3) == 0) {
  1599. town = 29;
  1600. } else if (strncmp(map_name, "dicastes01", 3) == 0) {
  1601. town = 30;
  1602. } else if (strcmp(map_name, "mora") == 0) {
  1603. town = 31;
  1604. } else if (strncmp(map_name, "dewata", 3) == 0) {
  1605. town = 32;
  1606. } else if (strncmp(map_name, "malangdo", 5) == 0) {
  1607. town = 33;
  1608. } else if (strncmp(map_name, "malaya", 5) == 0) {
  1609. town = 34;
  1610. } else if (strncmp(map_name, "eclage", 3) == 0) {
  1611. town = 35;
  1612. }
  1613. if (town >= 0 && town < ARRAYLENGTH(data))
  1614. {
  1615. m = map_mapname2mapid(data[town].map);
  1616. if (m >= 0 && map[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1617. clif_displaymessage(fd, msg_txt(sd,247));
  1618. return -1;
  1619. }
  1620. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  1621. clif_displaymessage(fd, msg_txt(sd,248));
  1622. return -1;
  1623. }
  1624. if (pc_setpos(sd, mapindex_name2id(data[town].map), data[town].x, data[town].y, CLR_TELEPORT) == 0) {
  1625. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  1626. } else {
  1627. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  1628. return -1;
  1629. }
  1630. } else { // if you arrive here, you have an error in town variable when reading of names
  1631. clif_displaymessage(fd, msg_txt(sd,38)); // Invalid location number or name.
  1632. return -1;
  1633. }
  1634. return 0;
  1635. }
  1636. /*==========================================
  1637. *
  1638. *------------------------------------------*/
  1639. ACMD_FUNC(monster)
  1640. {
  1641. char name[NAME_LENGTH];
  1642. char monster[NAME_LENGTH];
  1643. char eventname[EVENT_NAME_LENGTH] = "";
  1644. int mob_id;
  1645. int number = 0;
  1646. int count;
  1647. int i, k, range;
  1648. short mx, my;
  1649. unsigned int size;
  1650. nullpo_retr(-1, sd);
  1651. memset(name, '\0', sizeof(name));
  1652. memset(monster, '\0', sizeof(monster));
  1653. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1654. if (!message || !*message) {
  1655. clif_displaymessage(fd, msg_txt(sd,80)); // Give the display name or monster name/id please.
  1656. return -1;
  1657. }
  1658. if (sscanf(message, "\"%23[^\"]\" %23s %d", name, monster, &number) > 1 ||
  1659. sscanf(message, "%23s \"%23[^\"]\" %d", monster, name, &number) > 1) {
  1660. //All data can be left as it is.
  1661. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) {
  1662. //Here, it is possible name was not given and we are using monster for it.
  1663. if (count < 3) //Blank mob's name.
  1664. name[0] = '\0';
  1665. } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) {
  1666. //All data can be left as it is.
  1667. } else if (sscanf(message, "%23s", monster) > 0) {
  1668. //As before, name may be already filled.
  1669. name[0] = '\0';
  1670. } else {
  1671. clif_displaymessage(fd, msg_txt(sd,80)); // Give a display name and monster name/id please.
  1672. return -1;
  1673. }
  1674. if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
  1675. mob_id = mobdb_checkid(atoi(monster));
  1676. if (mob_id == 0) {
  1677. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1678. return -1;
  1679. }
  1680. if (mob_id == MOBID_EMPERIUM) {
  1681. clif_displaymessage(fd, msg_txt(sd,83)); // Monster 'Emperium' cannot be spawned.
  1682. return -1;
  1683. }
  1684. if (number <= 0)
  1685. number = 1;
  1686. if( !name[0] )
  1687. strcpy(name, "--ja--");
  1688. // 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
  1689. if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit)
  1690. number = battle_config.atc_spawn_quantity_limit;
  1691. if (strcmp(command+1, "monstersmall") == 0)
  1692. size = SZ_MEDIUM; // This is just gorgeous [mkbu95]
  1693. else if (strcmp(command+1, "monsterbig") == 0)
  1694. size = SZ_BIG;
  1695. else
  1696. size = SZ_SMALL;
  1697. if (battle_config.etc_log)
  1698. 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);
  1699. count = 0;
  1700. range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
  1701. for (i = 0; i < number; i++) {
  1702. map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
  1703. k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
  1704. count += (k != 0) ? 1 : 0;
  1705. }
  1706. if (count != 0)
  1707. if (number == count)
  1708. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  1709. else {
  1710. sprintf(atcmd_output, msg_txt(sd,240), count); // %d monster(s) summoned!
  1711. clif_displaymessage(fd, atcmd_output);
  1712. }
  1713. else {
  1714. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  1715. return -1;
  1716. }
  1717. return 0;
  1718. }
  1719. /*==========================================
  1720. *
  1721. *------------------------------------------*/
  1722. static int atkillmonster_sub(struct block_list *bl, va_list ap)
  1723. {
  1724. struct mob_data *md;
  1725. int flag;
  1726. nullpo_ret(md=(struct mob_data *)bl);
  1727. flag = va_arg(ap, int);
  1728. if (md->guardian_data)
  1729. return 0; //Do not touch WoE mobs!
  1730. if (flag)
  1731. status_zap(bl,md->status.hp, 0);
  1732. else
  1733. status_kill(bl);
  1734. return 1;
  1735. }
  1736. ACMD_FUNC(killmonster)
  1737. {
  1738. int map_id, drop_flag;
  1739. char map_name[MAP_NAME_LENGTH_EXT];
  1740. nullpo_retr(-1, sd);
  1741. memset(map_name, '\0', sizeof(map_name));
  1742. if (!message || !*message || sscanf(message, "%15s", map_name) < 1)
  1743. map_id = sd->bl.m;
  1744. else {
  1745. if ((map_id = map_mapname2mapid(map_name)) < 0)
  1746. map_id = sd->bl.m;
  1747. }
  1748. drop_flag = strcmp(command+1, "killmonster2");
  1749. map_foreachinmap(atkillmonster_sub, map_id, BL_MOB, -drop_flag);
  1750. clif_displaymessage(fd, msg_txt(sd,165)); // All monsters killed!
  1751. return 0;
  1752. }
  1753. /*==========================================
  1754. *
  1755. *------------------------------------------*/
  1756. ACMD_FUNC(refine)
  1757. {
  1758. int i,j, position = 0, refine = 0, current_position, final_refine;
  1759. int count;
  1760. nullpo_retr(-1, sd);
  1761. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1762. if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) {
  1763. clif_displaymessage(fd, msg_txt(sd,996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>).
  1764. sprintf(atcmd_output, msg_txt(sd,997), EQP_HEAD_LOW); // %d: Lower Headgear
  1765. clif_displaymessage(fd, atcmd_output);
  1766. sprintf(atcmd_output, msg_txt(sd,998), EQP_HAND_R); // %d: Right Hand
  1767. clif_displaymessage(fd, atcmd_output);
  1768. sprintf(atcmd_output, msg_txt(sd,999), EQP_GARMENT); // %d: Garment
  1769. clif_displaymessage(fd, atcmd_output);
  1770. sprintf(atcmd_output, msg_txt(sd,1000), EQP_ACC_L); // %d: Left Accessory
  1771. clif_displaymessage(fd, atcmd_output);
  1772. sprintf(atcmd_output, msg_txt(sd,1001), EQP_ARMOR); // %d: Body Armor
  1773. clif_displaymessage(fd, atcmd_output);
  1774. sprintf(atcmd_output, msg_txt(sd,1002), EQP_HAND_L); // %d: Left Hand
  1775. clif_displaymessage(fd, atcmd_output);
  1776. sprintf(atcmd_output, msg_txt(sd,1003), EQP_SHOES); // %d: Shoes
  1777. clif_displaymessage(fd, atcmd_output);
  1778. sprintf(atcmd_output, msg_txt(sd,1004), EQP_ACC_R); // %d: Right Accessory
  1779. clif_displaymessage(fd, atcmd_output);
  1780. sprintf(atcmd_output, msg_txt(sd,1005), EQP_HEAD_TOP); // %d: Top Headgear
  1781. clif_displaymessage(fd, atcmd_output);
  1782. sprintf(atcmd_output, msg_txt(sd,1006), EQP_HEAD_MID); // %d: Mid Headgear
  1783. clif_displaymessage(fd, atcmd_output);
  1784. return -1;
  1785. }
  1786. refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
  1787. count = 0;
  1788. for (j = 0; j < EQI_MAX-1; j++) {
  1789. if ((i = sd->equip_index[j]) < 0)
  1790. continue;
  1791. if(j == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == i)
  1792. continue;
  1793. if(j == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == i)
  1794. continue;
  1795. if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i))
  1796. continue;
  1797. if(position && !(sd->status.inventory[i].equip & position))
  1798. continue;
  1799. final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
  1800. if (sd->status.inventory[i].refine != final_refine) {
  1801. sd->status.inventory[i].refine = final_refine;
  1802. current_position = sd->status.inventory[i].equip;
  1803. pc_unequipitem(sd, i, 3);
  1804. clif_refine(fd, 0, i, sd->status.inventory[i].refine);
  1805. clif_delitem(sd, i, 1, 3);
  1806. clif_additem(sd, i, 1, 0);
  1807. pc_equipitem(sd, i, current_position);
  1808. clif_misceffect(&sd->bl, 3);
  1809. count++;
  1810. }
  1811. }
  1812. if (count == 0)
  1813. clif_displaymessage(fd, msg_txt(sd,166)); // No item has been refined.
  1814. else if (count == 1)
  1815. clif_displaymessage(fd, msg_txt(sd,167)); // 1 item has been refined.
  1816. else {
  1817. sprintf(atcmd_output, msg_txt(sd,168), count); // %d items have been refined.
  1818. clif_displaymessage(fd, atcmd_output);
  1819. }
  1820. return 0;
  1821. }
  1822. /*==========================================
  1823. *
  1824. *------------------------------------------*/
  1825. ACMD_FUNC(produce)
  1826. {
  1827. char item_name[100];
  1828. int item_id, attribute = 0, star = 0;
  1829. struct item_data *item_data;
  1830. struct item tmp_item;
  1831. nullpo_retr(-1, sd);
  1832. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1833. memset(item_name, '\0', sizeof(item_name));
  1834. if (!message || !*message || (
  1835. sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 &&
  1836. sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1
  1837. )) {
  1838. clif_displaymessage(fd, msg_txt(sd,1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>).
  1839. return -1;
  1840. }
  1841. if ( (item_data = itemdb_searchname(item_name)) == NULL &&
  1842. (item_data = itemdb_exists(atoi(item_name))) == NULL ) {
  1843. clif_displaymessage(fd, msg_txt(sd,170)); //This item is not an equipment.
  1844. return -1;
  1845. }
  1846. item_id = item_data->nameid;
  1847. if (itemdb_isequip2(item_data)) {
  1848. int flag = 0;
  1849. if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
  1850. attribute = ATTRIBUTE_NORMAL;
  1851. if (star < MIN_STAR || star > MAX_STAR)
  1852. star = 0;
  1853. memset(&tmp_item, 0, sizeof tmp_item);
  1854. tmp_item.nameid = item_id;
  1855. tmp_item.amount = 1;
  1856. tmp_item.identify = 1;
  1857. tmp_item.card[0] = CARD0_FORGE;
  1858. tmp_item.card[1] = item_data->type==IT_WEAPON?
  1859. ((star*5) << 8) + attribute:0;
  1860. tmp_item.card[2] = GetWord(sd->status.char_id, 0);
  1861. tmp_item.card[3] = GetWord(sd->status.char_id, 1);
  1862. clif_produceeffect(sd, 0, item_id);
  1863. clif_misceffect(&sd->bl, 3);
  1864. if ((flag = pc_additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND)))
  1865. clif_additem(sd, 0, 0, flag);
  1866. } else {
  1867. sprintf(atcmd_output, msg_txt(sd,169), item_id, item_data->name); // The item (%d: '%s') is not equipable.
  1868. clif_displaymessage(fd, atcmd_output);
  1869. return -1;
  1870. }
  1871. return 0;
  1872. }
  1873. /*==========================================
  1874. *
  1875. *------------------------------------------*/
  1876. ACMD_FUNC(memo)
  1877. {
  1878. int position = 0;
  1879. nullpo_retr(-1, sd);
  1880. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1881. if( !message || !*message || sscanf(message, "%d", &position) < 1 )
  1882. {
  1883. int i;
  1884. clif_displaymessage(sd->fd, msg_txt(sd,668));
  1885. for( i = 0; i < MAX_MEMOPOINTS; i++ )
  1886. {
  1887. if( sd->status.memo_point[i].map )
  1888. 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);
  1889. else
  1890. sprintf(atcmd_output, msg_txt(sd,171), i); // %d - void
  1891. clif_displaymessage(sd->fd, atcmd_output);
  1892. }
  1893. return 0;
  1894. }
  1895. if( position < 0 || position >= MAX_MEMOPOINTS )
  1896. {
  1897. sprintf(atcmd_output, msg_txt(sd,1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>).
  1898. clif_displaymessage(fd, atcmd_output);
  1899. return -1;
  1900. }
  1901. pc_memo(sd, position);
  1902. return 0;
  1903. }
  1904. /*==========================================
  1905. *
  1906. *------------------------------------------*/
  1907. ACMD_FUNC(gat)
  1908. {
  1909. int y;
  1910. nullpo_retr(-1, sd);
  1911. memset(atcmd_output, '\0', sizeof(atcmd_output));
  1912. for (y = 2; y >= -2; y--) {
  1913. sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X",
  1914. map[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y,
  1915. map_getcell(sd->bl.m, sd->bl.x - 2, sd->bl.y + y, CELL_GETTYPE),
  1916. map_getcell(sd->bl.m, sd->bl.x - 1, sd->bl.y + y, CELL_GETTYPE),
  1917. map_getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE),
  1918. map_getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE),
  1919. map_getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE));
  1920. clif_displaymessage(fd, atcmd_output);
  1921. }
  1922. return 0;
  1923. }
  1924. /*==========================================
  1925. *
  1926. *------------------------------------------*/
  1927. ACMD_FUNC(displaystatus)
  1928. {
  1929. int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0;
  1930. nullpo_retr(-1, sd);
  1931. if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) {
  1932. clif_displaymessage(fd, msg_txt(sd,1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}).
  1933. return -1;
  1934. }
  1935. if (i < 2) flag = 1;
  1936. if (i < 3) tick = 0;
  1937. clif_status_change(&sd->bl, type, flag, tick, val1, val2, val3);
  1938. return 0;
  1939. }
  1940. /*==========================================
  1941. * @stpoint (Rewritten by [Yor])
  1942. *------------------------------------------*/
  1943. ACMD_FUNC(statuspoint)
  1944. {
  1945. int point;
  1946. unsigned int new_status_point;
  1947. if (!message || !*message || (point = atoi(message)) == 0) {
  1948. clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
  1949. return -1;
  1950. }
  1951. if(point < 0)
  1952. {
  1953. if(sd->status.status_point < (unsigned int)(-point))
  1954. {
  1955. new_status_point = 0;
  1956. }
  1957. else
  1958. {
  1959. new_status_point = sd->status.status_point + point;
  1960. }
  1961. }
  1962. else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
  1963. {
  1964. new_status_point = UINT_MAX;
  1965. }
  1966. else
  1967. {
  1968. new_status_point = sd->status.status_point + point;
  1969. }
  1970. if (new_status_point != sd->status.status_point) {
  1971. sd->status.status_point = new_status_point;
  1972. clif_updatestatus(sd, SP_STATUSPOINT);
  1973. clif_displaymessage(fd, msg_txt(sd,174)); // Number of status points changed.
  1974. } else {
  1975. if (point < 0)
  1976. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  1977. else
  1978. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  1979. return -1;
  1980. }
  1981. return 0;
  1982. }
  1983. /*==========================================
  1984. * @skpoint (Rewritten by [Yor])
  1985. *------------------------------------------*/
  1986. ACMD_FUNC(skillpoint)
  1987. {
  1988. int point;
  1989. unsigned int new_skill_point;
  1990. nullpo_retr(-1, sd);
  1991. if (!message || !*message || (point = atoi(message)) == 0) {
  1992. clif_displaymessage(fd, msg_txt(sd,1011)); // Please enter a number (usage: @skpoint <number of points>).
  1993. return -1;
  1994. }
  1995. if(point < 0)
  1996. {
  1997. if(sd->status.skill_point < (unsigned int)(-point))
  1998. {
  1999. new_skill_point = 0;
  2000. }
  2001. else
  2002. {
  2003. new_skill_point = sd->status.skill_point + point;
  2004. }
  2005. }
  2006. else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
  2007. {
  2008. new_skill_point = UINT_MAX;
  2009. }
  2010. else
  2011. {
  2012. new_skill_point = sd->status.skill_point + point;
  2013. }
  2014. if (new_skill_point != sd->status.skill_point) {
  2015. sd->status.skill_point = new_skill_point;
  2016. clif_updatestatus(sd, SP_SKILLPOINT);
  2017. clif_displaymessage(fd, msg_txt(sd,175)); // Number of skill points changed.
  2018. } else {
  2019. if (point < 0)
  2020. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2021. else
  2022. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2023. return -1;
  2024. }
  2025. return 0;
  2026. }
  2027. /*==========================================
  2028. * @zeny
  2029. *------------------------------------------*/
  2030. ACMD_FUNC(zeny)
  2031. {
  2032. int zeny=0, ret=-1;
  2033. nullpo_retr(-1, sd);
  2034. if (!message || !*message || (zeny = atoi(message)) == 0) {
  2035. clif_displaymessage(fd, msg_txt(sd,1012)); // Please enter an amount (usage: @zeny <amount>).
  2036. return -1;
  2037. }
  2038. if(zeny > 0){
  2039. if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2040. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2041. }
  2042. else {
  2043. if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
  2044. if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
  2045. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2046. }
  2047. if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
  2048. return 0;
  2049. }
  2050. /*==========================================
  2051. *
  2052. *------------------------------------------*/
  2053. ACMD_FUNC(param)
  2054. {
  2055. int i, value = 0, new_value, max;
  2056. const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" };
  2057. short* status[6];
  2058. //we don't use direct initialization because it isn't part of the c standard.
  2059. nullpo_retr(-1, sd);
  2060. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2061. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2062. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2063. return -1;
  2064. }
  2065. ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(command+1, param[i]) == 0 );
  2066. if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible...
  2067. clif_displaymessage(fd, msg_txt(sd,1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>).
  2068. return -1;
  2069. }
  2070. status[0] = &sd->status.str;
  2071. status[1] = &sd->status.agi;
  2072. status[2] = &sd->status.vit;
  2073. status[3] = &sd->status.int_;
  2074. status[4] = &sd->status.dex;
  2075. status[5] = &sd->status.luk;
  2076. if( battle_config.atcommand_max_stat_bypass )
  2077. max = SHRT_MAX;
  2078. else
  2079. max = pc_maxparameter(sd);
  2080. if(value < 0 && *status[i] <= -value) {
  2081. new_value = 1;
  2082. } else if(max - *status[i] < value) {
  2083. new_value = max;
  2084. } else {
  2085. new_value = *status[i] + value;
  2086. }
  2087. if (new_value != *status[i]) {
  2088. *status[i] = new_value;
  2089. clif_updatestatus(sd, SP_STR + i);
  2090. clif_updatestatus(sd, SP_USTR + i);
  2091. status_calc_pc(sd, 0);
  2092. clif_displaymessage(fd, msg_txt(sd,42)); // Stat changed.
  2093. } else {
  2094. if (value < 0)
  2095. clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  2096. else
  2097. clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
  2098. return -1;
  2099. }
  2100. return 0;
  2101. }
  2102. /*==========================================
  2103. * Stat all by fritz (rewritten by [Yor])
  2104. *------------------------------------------*/
  2105. ACMD_FUNC(stat_all)
  2106. {
  2107. int index, count, value, max, new_value;
  2108. short* status[6];
  2109. //we don't use direct initialization because it isn't part of the c standard.
  2110. nullpo_retr(-1, sd);
  2111. status[0] = &sd->status.str;
  2112. status[1] = &sd->status.agi;
  2113. status[2] = &sd->status.vit;
  2114. status[3] = &sd->status.int_;
  2115. status[4] = &sd->status.dex;
  2116. status[5] = &sd->status.luk;
  2117. if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) {
  2118. value = pc_maxparameter(sd);
  2119. max = pc_maxparameter(sd);
  2120. } else {
  2121. if( battle_config.atcommand_max_stat_bypass )
  2122. max = SHRT_MAX;
  2123. else
  2124. max = pc_maxparameter(sd);
  2125. }
  2126. count = 0;
  2127. for (index = 0; index < ARRAYLENGTH(status); index++) {
  2128. if (value > 0 && *status[index] > max - value)
  2129. new_value = max;
  2130. else if (value < 0 && *status[index] <= -value)
  2131. new_value = 1;
  2132. else
  2133. new_value = *status[index] +value;
  2134. if (new_value != (int)*status[index]) {
  2135. *status[index] = new_value;
  2136. clif_updatestatus(sd, SP_STR + index);
  2137. clif_updatestatus(sd, SP_USTR + index);
  2138. count++;
  2139. }
  2140. }
  2141. if (count > 0) { // if at least 1 stat modified
  2142. status_calc_pc(sd, 0);
  2143. clif_displaymessage(fd, msg_txt(sd,84)); // All stats changed!
  2144. } else {
  2145. if (value < 0)
  2146. clif_displaymessage(fd, msg_txt(sd,177)); // You cannot decrease that stat anymore.
  2147. else
  2148. clif_displaymessage(fd, msg_txt(sd,178)); // You cannot increase that stat anymore.
  2149. return -1;
  2150. }
  2151. return 0;
  2152. }
  2153. /*==========================================
  2154. *
  2155. *------------------------------------------*/
  2156. ACMD_FUNC(guildlevelup) {
  2157. int level = 0;
  2158. short added_level;
  2159. struct guild *guild_info;
  2160. nullpo_retr(-1, sd);
  2161. if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) {
  2162. clif_displaymessage(fd, msg_txt(sd,1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>).
  2163. return -1;
  2164. }
  2165. if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) {
  2166. clif_displaymessage(fd, msg_txt(sd,43)); // You're not in a guild.
  2167. return -1;
  2168. }
  2169. //if (strcmp(sd->status.name, guild_info->master) != 0) {
  2170. // clif_displaymessage(fd, msg_txt(sd,44)); // You're not the master of your guild.
  2171. // return -1;
  2172. //}
  2173. added_level = (short)level;
  2174. if (level > 0 && (level > MAX_GUILDLEVEL || added_level > ((short)MAX_GUILDLEVEL - guild_info->guild_lv))) // fix positiv overflow
  2175. added_level = (short)MAX_GUILDLEVEL - guild_info->guild_lv;
  2176. else if (level < 0 && (level < -MAX_GUILDLEVEL || added_level < (1 - guild_info->guild_lv))) // fix negativ overflow
  2177. added_level = 1 - guild_info->guild_lv;
  2178. if (added_level != 0) {
  2179. intif_guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level));
  2180. clif_displaymessage(fd, msg_txt(sd,179)); // Guild level changed.
  2181. } else {
  2182. clif_displaymessage(fd, msg_txt(sd,45)); // Guild level change failed.
  2183. return -1;
  2184. }
  2185. return 0;
  2186. }
  2187. /*==========================================
  2188. *
  2189. *------------------------------------------*/
  2190. ACMD_FUNC(makeegg) {
  2191. struct item_data *item_data;
  2192. int id, pet_id;
  2193. nullpo_retr(-1, sd);
  2194. if (!message || !*message) {
  2195. clif_displaymessage(fd, msg_txt(sd,1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>).
  2196. return -1;
  2197. }
  2198. if ((item_data = itemdb_searchname(message)) != NULL) // for egg name
  2199. id = item_data->nameid;
  2200. else
  2201. if ((id = mobdb_searchname(message)) != 0) // for monster name
  2202. ;
  2203. else
  2204. id = atoi(message);
  2205. pet_id = search_petDB_index(id, PET_CLASS);
  2206. if (pet_id < 0)
  2207. pet_id = search_petDB_index(id, PET_EGG);
  2208. if (pet_id >= 0) {
  2209. sd->catch_target_class = pet_db[pet_id].class_;
  2210. intif_create_pet(
  2211. sd->status.account_id, sd->status.char_id,
  2212. (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
  2213. (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
  2214. 100, 0, 1, pet_db[pet_id].jname);
  2215. } else {
  2216. clif_displaymessage(fd, msg_txt(sd,180)); // The monster/egg name/id doesn't exist.
  2217. return -1;
  2218. }
  2219. return 0;
  2220. }
  2221. /*==========================================
  2222. *
  2223. *------------------------------------------*/
  2224. ACMD_FUNC(hatch) {
  2225. nullpo_retr(-1, sd);
  2226. if (sd->status.pet_id <= 0)
  2227. clif_sendegg(sd);
  2228. else {
  2229. clif_displaymessage(fd, msg_txt(sd,181)); // You already have a pet.
  2230. return -1;
  2231. }
  2232. return 0;
  2233. }
  2234. /*==========================================
  2235. *
  2236. *------------------------------------------*/
  2237. ACMD_FUNC(petfriendly) {
  2238. int friendly;
  2239. struct pet_data *pd;
  2240. nullpo_retr(-1, sd);
  2241. if (!message || !*message || (friendly = atoi(message)) < 0) {
  2242. clif_displaymessage(fd, msg_txt(sd,1016)); // Please enter a valid value (usage: @petfriendly <0-1000>).
  2243. return -1;
  2244. }
  2245. pd = sd->pd;
  2246. if (!pd) {
  2247. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2248. return -1;
  2249. }
  2250. if (friendly < 0 || friendly > 1000)
  2251. {
  2252. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2253. return -1;
  2254. }
  2255. if (friendly == pd->pet.intimate) {
  2256. clif_displaymessage(fd, msg_txt(sd,183)); // Pet intimacy is already at maximum.
  2257. return -1;
  2258. }
  2259. pet_set_intimate(pd, friendly);
  2260. clif_send_petstatus(sd);
  2261. clif_displaymessage(fd, msg_txt(sd,182)); // Pet intimacy changed.
  2262. return 0;
  2263. }
  2264. /*==========================================
  2265. *
  2266. *------------------------------------------*/
  2267. ACMD_FUNC(pethungry)
  2268. {
  2269. int hungry;
  2270. struct pet_data *pd;
  2271. nullpo_retr(-1, sd);
  2272. if (!message || !*message || (hungry = atoi(message)) < 0) {
  2273. clif_displaymessage(fd, msg_txt(sd,1017)); // Please enter a valid number (usage: @pethungry <0-100>).
  2274. return -1;
  2275. }
  2276. pd = sd->pd;
  2277. if (!sd->status.pet_id || !pd) {
  2278. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2279. return -1;
  2280. }
  2281. if (hungry < 0 || hungry > 100) {
  2282. clif_displaymessage(fd, msg_txt(sd,37)); // An invalid number was specified.
  2283. return -1;
  2284. }
  2285. if (hungry == pd->pet.hungry) {
  2286. clif_displaymessage(fd, msg_txt(sd,186)); // Pet hunger is already at maximum.
  2287. return -1;
  2288. }
  2289. pd->pet.hungry = hungry;
  2290. clif_send_petstatus(sd);
  2291. clif_displaymessage(fd, msg_txt(sd,185)); // Pet hunger changed.
  2292. return 0;
  2293. }
  2294. /*==========================================
  2295. *
  2296. *------------------------------------------*/
  2297. ACMD_FUNC(petrename)
  2298. {
  2299. struct pet_data *pd;
  2300. nullpo_retr(-1, sd);
  2301. if (!sd->status.pet_id || !sd->pd) {
  2302. clif_displaymessage(fd, msg_txt(sd,184)); // Sorry, but you have no pet.
  2303. return -1;
  2304. }
  2305. pd = sd->pd;
  2306. if (!pd->pet.rename_flag) {
  2307. clif_displaymessage(fd, msg_txt(sd,188)); // You can already rename your pet.
  2308. return -1;
  2309. }
  2310. pd->pet.rename_flag = 0;
  2311. intif_save_petdata(sd->status.account_id, &pd->pet);
  2312. clif_send_petstatus(sd);
  2313. clif_displaymessage(fd, msg_txt(sd,187)); // You can now rename your pet.
  2314. return 0;
  2315. }
  2316. /*==========================================
  2317. *
  2318. *------------------------------------------*/
  2319. ACMD_FUNC(recall) {
  2320. struct map_session_data *pl_sd = NULL;
  2321. nullpo_retr(-1, sd);
  2322. if (!message || !*message) {
  2323. clif_displaymessage(fd, msg_txt(sd,1018)); // Please enter a player name (usage: @recall <char name/ID>).
  2324. return -1;
  2325. }
  2326. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2327. {
  2328. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2329. return -1;
  2330. }
  2331. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2332. {
  2333. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
  2334. return -1;
  2335. }
  2336. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2337. clif_displaymessage(fd, msg_txt(sd,1019)); // You are not authorized to warp someone to this map.
  2338. return -1;
  2339. }
  2340. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2341. clif_displaymessage(fd, msg_txt(sd,1020)); // You are not authorized to warp this player from their map.
  2342. return -1;
  2343. }
  2344. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) {
  2345. return -1;
  2346. }
  2347. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2348. sprintf(atcmd_output, msg_txt(sd,46), pl_sd->status.name); // %s recalled!
  2349. clif_displaymessage(fd, atcmd_output);
  2350. return 0;
  2351. }
  2352. /*==========================================
  2353. * charblock command (usage: charblock <player_name>)
  2354. * This command do a definitiv ban on a player
  2355. *------------------------------------------*/
  2356. ACMD_FUNC(char_block)
  2357. {
  2358. nullpo_retr(-1, sd);
  2359. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2360. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2361. clif_displaymessage(fd, msg_txt(sd,1021)); // Please enter a player name (usage: @charblock/@block <char name>).
  2362. return -1;
  2363. }
  2364. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block
  2365. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2366. return 0;
  2367. }
  2368. /*==========================================
  2369. * charban command (usage: charban <time> <player_name>)
  2370. * This command do a limited ban on a player
  2371. * Time is done as follows:
  2372. * Adjustment value (-1, 1, +1, etc...)
  2373. * Modified element:
  2374. * a or y: year
  2375. * m: month
  2376. * j or d: day
  2377. * h: hour
  2378. * mn: minute
  2379. * s: second
  2380. * <example> @ban +1m-2mn1s-6y test_player
  2381. * this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
  2382. *------------------------------------------*/
  2383. ACMD_FUNC(char_ban)
  2384. {
  2385. char * modif_p;
  2386. int year, month, day, hour, minute, second, value;
  2387. time_t timestamp;
  2388. struct tm *tmtime;
  2389. nullpo_retr(-1, sd);
  2390. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2391. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2392. if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) {
  2393. clif_displaymessage(fd, msg_txt(sd,1022)); // Please enter ban time and a player name (usage: @charban/@ban/@banish/@charbanish <time> <char name>).
  2394. return -1;
  2395. }
  2396. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  2397. modif_p = atcmd_output;
  2398. year = month = day = hour = minute = second = 0;
  2399. while (modif_p[0] != '\0') {
  2400. value = atoi(modif_p);
  2401. if (value == 0)
  2402. modif_p++;
  2403. else {
  2404. if (modif_p[0] == '-' || modif_p[0] == '+')
  2405. modif_p++;
  2406. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  2407. modif_p++;
  2408. if (modif_p[0] == 's') {
  2409. second = value;
  2410. modif_p++;
  2411. } else if (modif_p[0] == 'n') {
  2412. minute = value;
  2413. modif_p++;
  2414. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  2415. minute = value;
  2416. modif_p = modif_p + 2;
  2417. } else if (modif_p[0] == 'h') {
  2418. hour = value;
  2419. modif_p++;
  2420. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  2421. day = value;
  2422. modif_p++;
  2423. } else if (modif_p[0] == 'm') {
  2424. month = value;
  2425. modif_p++;
  2426. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  2427. year = value;
  2428. modif_p++;
  2429. } else if (modif_p[0] != '\0') {
  2430. modif_p++;
  2431. }
  2432. }
  2433. }
  2434. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) {
  2435. clif_displaymessage(fd, msg_txt(sd,85)); // Invalid time for ban command.
  2436. return -1;
  2437. }
  2438. /**
  2439. * We now check if you can adjust the ban to negative (and if this is the case)
  2440. **/
  2441. timestamp = time(NULL);
  2442. tmtime = localtime(&timestamp);
  2443. tmtime->tm_year = tmtime->tm_year + year;
  2444. tmtime->tm_mon = tmtime->tm_mon + month;
  2445. tmtime->tm_mday = tmtime->tm_mday + day;
  2446. tmtime->tm_hour = tmtime->tm_hour + hour;
  2447. tmtime->tm_min = tmtime->tm_min + minute;
  2448. tmtime->tm_sec = tmtime->tm_sec + second;
  2449. timestamp = mktime(tmtime);
  2450. if( timestamp <= time(NULL) && !pc_can_use_command(sd, "unban", COMMAND_ATCOMMAND) ) {
  2451. clif_displaymessage(fd,msg_txt(sd,1023)); // You are not allowed to reduce the length of a ban.
  2452. return -1;
  2453. }
  2454. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban
  2455. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2456. return 0;
  2457. }
  2458. /*==========================================
  2459. * charunblock command (usage: charunblock <player_name>)
  2460. *------------------------------------------*/
  2461. ACMD_FUNC(char_unblock)
  2462. {
  2463. nullpo_retr(-1, sd);
  2464. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2465. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2466. clif_displaymessage(fd, msg_txt(sd,1024)); // Please enter a player name (usage: @charunblock <char name>).
  2467. return -1;
  2468. }
  2469. // send answer to login server via char-server
  2470. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock
  2471. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2472. return 0;
  2473. }
  2474. /*==========================================
  2475. * charunban command (usage: charunban <player_name>)
  2476. *------------------------------------------*/
  2477. ACMD_FUNC(char_unban)
  2478. {
  2479. nullpo_retr(-1, sd);
  2480. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2481. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  2482. clif_displaymessage(fd, msg_txt(sd,1025)); // Please enter a player name (usage: @charunban <char name>).
  2483. return -1;
  2484. }
  2485. // send answer to login server via char-server
  2486. chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban
  2487. clif_displaymessage(fd, msg_txt(sd,88)); // Character name sent to char-server to ask it.
  2488. return 0;
  2489. }
  2490. /*==========================================
  2491. *
  2492. *------------------------------------------*/
  2493. ACMD_FUNC(night)
  2494. {
  2495. nullpo_retr(-1, sd);
  2496. if (night_flag != 1) {
  2497. map_night_timer(night_timer_tid, 0, 0, 1);
  2498. } else {
  2499. clif_displaymessage(fd, msg_txt(sd,89)); // Night mode is already enabled.
  2500. return -1;
  2501. }
  2502. return 0;
  2503. }
  2504. /*==========================================
  2505. *
  2506. *------------------------------------------*/
  2507. ACMD_FUNC(day)
  2508. {
  2509. nullpo_retr(-1, sd);
  2510. if (night_flag != 0) {
  2511. map_day_timer(day_timer_tid, 0, 0, 1);
  2512. } else {
  2513. clif_displaymessage(fd, msg_txt(sd,90)); // Day mode is already enabled.
  2514. return -1;
  2515. }
  2516. return 0;
  2517. }
  2518. /*==========================================
  2519. *
  2520. *------------------------------------------*/
  2521. ACMD_FUNC(doom)
  2522. {
  2523. struct map_session_data* pl_sd;
  2524. struct s_mapiterator* iter;
  2525. nullpo_retr(-1, sd);
  2526. iter = mapit_getallusers();
  2527. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2528. {
  2529. if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2530. {
  2531. status_kill(&pl_sd->bl);
  2532. clif_specialeffect(&pl_sd->bl,450,AREA);
  2533. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2534. }
  2535. }
  2536. mapit_free(iter);
  2537. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2538. return 0;
  2539. }
  2540. /*==========================================
  2541. *
  2542. *------------------------------------------*/
  2543. ACMD_FUNC(doommap)
  2544. {
  2545. struct map_session_data* pl_sd;
  2546. struct s_mapiterator* iter;
  2547. nullpo_retr(-1, sd);
  2548. iter = mapit_getallusers();
  2549. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2550. {
  2551. if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2552. {
  2553. status_kill(&pl_sd->bl);
  2554. clif_specialeffect(&pl_sd->bl,450,AREA);
  2555. clif_displaymessage(pl_sd->fd, msg_txt(sd,61)); // The holy messenger has given judgement.
  2556. }
  2557. }
  2558. mapit_free(iter);
  2559. clif_displaymessage(fd, msg_txt(sd,62)); // Judgement was made.
  2560. return 0;
  2561. }
  2562. /*==========================================
  2563. *
  2564. *------------------------------------------*/
  2565. static void atcommand_raise_sub(struct map_session_data* sd) {
  2566. status_revive(&sd->bl, 100, 100);
  2567. clif_skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1);
  2568. clif_displaymessage(sd->fd, msg_txt(sd,63)); // Mercy has been shown.
  2569. }
  2570. /*==========================================
  2571. *
  2572. *------------------------------------------*/
  2573. ACMD_FUNC(raise)
  2574. {
  2575. struct map_session_data* pl_sd;
  2576. struct s_mapiterator* iter;
  2577. nullpo_retr(-1, sd);
  2578. iter = mapit_getallusers();
  2579. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2580. if( pc_isdead(pl_sd) )
  2581. atcommand_raise_sub(pl_sd);
  2582. mapit_free(iter);
  2583. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2584. return 0;
  2585. }
  2586. /*==========================================
  2587. *
  2588. *------------------------------------------*/
  2589. ACMD_FUNC(raisemap)
  2590. {
  2591. struct map_session_data* pl_sd;
  2592. struct s_mapiterator* iter;
  2593. nullpo_retr(-1, sd);
  2594. iter = mapit_getallusers();
  2595. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2596. if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) )
  2597. atcommand_raise_sub(pl_sd);
  2598. mapit_free(iter);
  2599. clif_displaymessage(fd, msg_txt(sd,64)); // Mercy has been granted.
  2600. return 0;
  2601. }
  2602. /*==========================================
  2603. *
  2604. *------------------------------------------*/
  2605. ACMD_FUNC(kick)
  2606. {
  2607. struct map_session_data *pl_sd;
  2608. nullpo_retr(-1, sd);
  2609. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  2610. if (!message || !*message) {
  2611. clif_displaymessage(fd, msg_txt(sd,1026)); // Please enter a player name (usage: @kick <char name/ID>).
  2612. return -1;
  2613. }
  2614. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL)
  2615. {
  2616. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  2617. return -1;
  2618. }
  2619. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  2620. {
  2621. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  2622. return -1;
  2623. }
  2624. clif_GM_kick(sd, pl_sd);
  2625. return 0;
  2626. }
  2627. /*==========================================
  2628. *
  2629. *------------------------------------------*/
  2630. ACMD_FUNC(kickall)
  2631. {
  2632. struct map_session_data* pl_sd;
  2633. struct s_mapiterator* iter;
  2634. nullpo_retr(-1, sd);
  2635. iter = mapit_getallusers();
  2636. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2637. {
  2638. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
  2639. if (sd->status.account_id != pl_sd->status.account_id)
  2640. clif_GM_kick(NULL, pl_sd);
  2641. }
  2642. }
  2643. mapit_free(iter);
  2644. clif_displaymessage(fd, msg_txt(sd,195)); // All players have been kicked!
  2645. return 0;
  2646. }
  2647. /*==========================================
  2648. *
  2649. *------------------------------------------*/
  2650. ACMD_FUNC(allskill)
  2651. {
  2652. nullpo_retr(-1, sd);
  2653. pc_allskillup(sd); // all skills
  2654. sd->status.skill_point = 0; // 0 skill points
  2655. clif_updatestatus(sd, SP_SKILLPOINT); // update
  2656. clif_displaymessage(fd, msg_txt(sd,76)); // All skills have been added to your skill tree.
  2657. return 0;
  2658. }
  2659. /*==========================================
  2660. *
  2661. *------------------------------------------*/
  2662. ACMD_FUNC(questskill)
  2663. {
  2664. uint16 skill_id;
  2665. nullpo_retr(-1, sd);
  2666. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2667. {// also send a list of skills applicable to this command
  2668. const char* text;
  2669. // attempt to find the text corresponding to this command
  2670. text = atcommand_help_string( command );
  2671. // send the error message as always
  2672. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2673. if( text )
  2674. {// send the skill ID list associated with this command
  2675. clif_displaymessage( fd, text );
  2676. }
  2677. return -1;
  2678. }
  2679. if (skill_id >= MAX_SKILL_DB) {
  2680. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2681. return -1;
  2682. }
  2683. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2684. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2685. return -1;
  2686. }
  2687. if (pc_checkskill(sd, skill_id) > 0) {
  2688. clif_displaymessage(fd, msg_txt(sd,196)); // You already have this quest skill.
  2689. return -1;
  2690. }
  2691. pc_skill(sd, skill_id, 1, 0);
  2692. clif_displaymessage(fd, msg_txt(sd,70)); // You have learned the skill.
  2693. return 0;
  2694. }
  2695. /*==========================================
  2696. *
  2697. *------------------------------------------*/
  2698. ACMD_FUNC(lostskill)
  2699. {
  2700. uint16 skill_id;
  2701. nullpo_retr(-1, sd);
  2702. if (!message || !*message || (skill_id = atoi(message)) <= 0)
  2703. {// also send a list of skills applicable to this command
  2704. const char* text;
  2705. // attempt to find the text corresponding to this command
  2706. text = atcommand_help_string( command );
  2707. // send the error message as always
  2708. clif_displaymessage(fd, msg_txt(sd,1027)); // Please enter a quest skill number.
  2709. if( text )
  2710. {// send the skill ID list associated with this command
  2711. clif_displaymessage( fd, text );
  2712. }
  2713. return -1;
  2714. }
  2715. if (skill_id >= MAX_SKILL) {
  2716. clif_displaymessage(fd, msg_txt(sd,198)); // This skill number doesn't exist.
  2717. return -1;
  2718. }
  2719. if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) {
  2720. clif_displaymessage(fd, msg_txt(sd,197)); // This skill number doesn't exist or isn't a quest skill.
  2721. return -1;
  2722. }
  2723. if (pc_checkskill(sd, skill_id) == 0) {
  2724. clif_displaymessage(fd, msg_txt(sd,201)); // You don't have this quest skill.
  2725. return -1;
  2726. }
  2727. sd->status.skill[skill_id].lv = 0;
  2728. sd->status.skill[skill_id].flag = SKILL_FLAG_PERMANENT;
  2729. clif_deleteskill(sd,skill_id);
  2730. clif_displaymessage(fd, msg_txt(sd,71)); // You have forgotten the skill.
  2731. return 0;
  2732. }
  2733. /*==========================================
  2734. *
  2735. *------------------------------------------*/
  2736. ACMD_FUNC(spiritball)
  2737. {
  2738. int max_spiritballs;
  2739. int number;
  2740. nullpo_retr(-1, sd);
  2741. max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF);
  2742. if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs )
  2743. {
  2744. char msg[CHAT_SIZE_MAX];
  2745. safesnprintf(msg, sizeof(msg), msg_txt(sd,1028), max_spiritballs); // Please enter a party name (usage: @party <party_name>).
  2746. clif_displaymessage(fd, msg);
  2747. return -1;
  2748. }
  2749. if( sd->spiritball > 0 )
  2750. pc_delspiritball(sd, sd->spiritball, 1);
  2751. sd->spiritball = number;
  2752. clif_spiritball(&sd->bl);
  2753. // no message, player can look the difference
  2754. return 0;
  2755. }
  2756. /*==========================================
  2757. *
  2758. *------------------------------------------*/
  2759. ACMD_FUNC(party)
  2760. {
  2761. char party[NAME_LENGTH];
  2762. nullpo_retr(-1, sd);
  2763. memset(party, '\0', sizeof(party));
  2764. if (!message || !*message || sscanf(message, "%23[^\n]", party) < 1) {
  2765. clif_displaymessage(fd, msg_txt(sd,1029)); // Please enter a party name (usage: @party <party_name>).
  2766. return -1;
  2767. }
  2768. party_create(sd, party, 0, 0);
  2769. return 0;
  2770. }
  2771. /*==========================================
  2772. *
  2773. *------------------------------------------*/
  2774. ACMD_FUNC(guild)
  2775. {
  2776. char guild[NAME_LENGTH];
  2777. int prev;
  2778. nullpo_retr(-1, sd);
  2779. memset(guild, '\0', sizeof(guild));
  2780. if (!message || !*message || sscanf(message, "%23[^\n]", guild) < 1) {
  2781. clif_displaymessage(fd, msg_txt(sd,1030)); // Please enter a guild name (usage: @guild <guild_name>).
  2782. return -1;
  2783. }
  2784. prev = battle_config.guild_emperium_check;
  2785. battle_config.guild_emperium_check = 0;
  2786. guild_create(sd, guild);
  2787. battle_config.guild_emperium_check = prev;
  2788. return 0;
  2789. }
  2790. ACMD_FUNC(breakguild)
  2791. {
  2792. nullpo_retr(-1, sd);
  2793. if (sd->status.guild_id) { // Check if the player has a guild
  2794. struct guild *g;
  2795. g = sd->guild; // Search the guild
  2796. if (g) { // Check if guild was found
  2797. if (sd->state.gmaster_flag) { // Check if player is guild master
  2798. int ret = 0;
  2799. ret = guild_break(sd, g->name); // Break guild
  2800. if (ret) { // Check if anything went wrong
  2801. return 0; // Guild was broken
  2802. } else {
  2803. return -1; // Something went wrong
  2804. }
  2805. } else { // Not guild master
  2806. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  2807. return -1;
  2808. }
  2809. } else { // Guild was not found. HOW?
  2810. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2811. return -1;
  2812. }
  2813. } else { // Player does not have a guild
  2814. clif_displaymessage(fd, msg_txt(sd,252)); // You are not in a guild.
  2815. return -1;
  2816. }
  2817. return 0;
  2818. }
  2819. /*==========================================
  2820. *
  2821. *------------------------------------------*/
  2822. ACMD_FUNC(agitstart)
  2823. {
  2824. nullpo_retr(-1, sd);
  2825. if (agit_flag == 1) {
  2826. clif_displaymessage(fd, msg_txt(sd,73)); // War of Emperium is currently in progress.
  2827. return -1;
  2828. }
  2829. agit_flag = 1;
  2830. guild_agit_start();
  2831. clif_displaymessage(fd, msg_txt(sd,72)); // War of Emperium has been initiated.
  2832. return 0;
  2833. }
  2834. /*==========================================
  2835. *
  2836. *------------------------------------------*/
  2837. ACMD_FUNC(agitstart2)
  2838. {
  2839. nullpo_retr(-1, sd);
  2840. if (agit2_flag == 1) {
  2841. clif_displaymessage(fd, msg_txt(sd,404)); // "War of Emperium SE is currently in progress."
  2842. return -1;
  2843. }
  2844. agit2_flag = 1;
  2845. guild_agit2_start();
  2846. clif_displaymessage(fd, msg_txt(sd,403)); // "War of Emperium SE has been initiated."
  2847. return 0;
  2848. }
  2849. /*==========================================
  2850. *
  2851. *------------------------------------------*/
  2852. ACMD_FUNC(agitend)
  2853. {
  2854. nullpo_retr(-1, sd);
  2855. if (agit_flag == 0) {
  2856. clif_displaymessage(fd, msg_txt(sd,75)); // War of Emperium is currently not in progress.
  2857. return -1;
  2858. }
  2859. agit_flag = 0;
  2860. guild_agit_end();
  2861. clif_displaymessage(fd, msg_txt(sd,74)); // War of Emperium has been ended.
  2862. return 0;
  2863. }
  2864. /*==========================================
  2865. *
  2866. *------------------------------------------*/
  2867. ACMD_FUNC(agitend2)
  2868. {
  2869. nullpo_retr(-1, sd);
  2870. if (agit2_flag == 0) {
  2871. clif_displaymessage(fd, msg_txt(sd,406)); // "War of Emperium SE is currently not in progress."
  2872. return -1;
  2873. }
  2874. agit2_flag = 0;
  2875. guild_agit2_end();
  2876. clif_displaymessage(fd, msg_txt(sd,405)); // "War of Emperium SE has been ended."
  2877. return 0;
  2878. }
  2879. /*==========================================
  2880. * @mapexit - shuts down the map server
  2881. *------------------------------------------*/
  2882. ACMD_FUNC(mapexit)
  2883. {
  2884. nullpo_retr(-1, sd);
  2885. do_shutdown();
  2886. return 0;
  2887. }
  2888. /*==========================================
  2889. * idsearch <part_of_name>: revrited by [Yor]
  2890. *------------------------------------------*/
  2891. ACMD_FUNC(idsearch)
  2892. {
  2893. char item_name[100];
  2894. unsigned int i, match;
  2895. struct item_data *item_array[MAX_SEARCH];
  2896. nullpo_retr(-1, sd);
  2897. memset(item_name, '\0', sizeof(item_name));
  2898. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2899. if (!message || !*message || sscanf(message, "%99s", item_name) < 0) {
  2900. clif_displaymessage(fd, msg_txt(sd,1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>).
  2901. return -1;
  2902. }
  2903. sprintf(atcmd_output, msg_txt(sd,77), item_name); // The reference result of '%s' (name: id):
  2904. clif_displaymessage(fd, atcmd_output);
  2905. match = itemdb_searchname_array(item_array, MAX_SEARCH, item_name);
  2906. if (match > MAX_SEARCH) {
  2907. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, match);
  2908. clif_displaymessage(fd, atcmd_output);
  2909. match = MAX_SEARCH;
  2910. }
  2911. for(i = 0; i < match; i++) {
  2912. sprintf(atcmd_output, msg_txt(sd,78), item_array[i]->jname, item_array[i]->nameid); // %s: %d
  2913. clif_displaymessage(fd, atcmd_output);
  2914. }
  2915. sprintf(atcmd_output, msg_txt(sd,79), match); // It is %d affair above.
  2916. clif_displaymessage(fd, atcmd_output);
  2917. return 0;
  2918. }
  2919. /*==========================================
  2920. * Recall All Characters Online To Your Location
  2921. *------------------------------------------*/
  2922. ACMD_FUNC(recallall)
  2923. {
  2924. struct map_session_data* pl_sd;
  2925. struct s_mapiterator* iter;
  2926. int count;
  2927. nullpo_retr(-1, sd);
  2928. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2929. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2930. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2931. return -1;
  2932. }
  2933. count = 0;
  2934. iter = mapit_getallusers();
  2935. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2936. {
  2937. if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd))
  2938. {
  2939. if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)
  2940. continue; // Don't waste time warping the character to the same place.
  2941. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2942. count++;
  2943. else {
  2944. if (pc_isdead(pl_sd)) { //Wake them up
  2945. pc_setstand(pl_sd);
  2946. pc_setrestartvalue(pl_sd,1);
  2947. }
  2948. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2949. }
  2950. }
  2951. }
  2952. mapit_free(iter);
  2953. clif_displaymessage(fd, msg_txt(sd,92)); // All characters recalled!
  2954. if (count) {
  2955. 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.
  2956. clif_displaymessage(fd, atcmd_output);
  2957. }
  2958. return 0;
  2959. }
  2960. /*==========================================
  2961. * Recall online characters of a guild to your location
  2962. *------------------------------------------*/
  2963. ACMD_FUNC(guildrecall)
  2964. {
  2965. struct map_session_data* pl_sd;
  2966. struct s_mapiterator* iter;
  2967. int count;
  2968. char guild_name[NAME_LENGTH];
  2969. struct guild *g;
  2970. nullpo_retr(-1, sd);
  2971. memset(guild_name, '\0', sizeof(guild_name));
  2972. memset(atcmd_output, '\0', sizeof(atcmd_output));
  2973. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  2974. clif_displaymessage(fd, msg_txt(sd,1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>).
  2975. return -1;
  2976. }
  2977. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  2978. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  2979. return -1;
  2980. }
  2981. if ((g = guild_searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number
  2982. (g = guild_search(atoi(message))) == NULL)
  2983. {
  2984. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  2985. return -1;
  2986. }
  2987. count = 0;
  2988. iter = mapit_getallusers();
  2989. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  2990. {
  2991. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id)
  2992. {
  2993. 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))
  2994. continue; // Skip GMs greater than you... or chars already on the cell
  2995. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  2996. count++;
  2997. else
  2998. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  2999. }
  3000. }
  3001. mapit_free(iter);
  3002. sprintf(atcmd_output, msg_txt(sd,93), g->name); // All online characters of the %s guild have been recalled to your position.
  3003. clif_displaymessage(fd, atcmd_output);
  3004. if (count) {
  3005. 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.
  3006. clif_displaymessage(fd, atcmd_output);
  3007. }
  3008. return 0;
  3009. }
  3010. /*==========================================
  3011. * Recall online characters of a party to your location
  3012. *------------------------------------------*/
  3013. ACMD_FUNC(partyrecall)
  3014. {
  3015. struct map_session_data* pl_sd;
  3016. struct s_mapiterator* iter;
  3017. char party_name[NAME_LENGTH];
  3018. struct party_data *p;
  3019. int count;
  3020. nullpo_retr(-1, sd);
  3021. memset(party_name, '\0', sizeof(party_name));
  3022. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3023. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3024. clif_displaymessage(fd, msg_txt(sd,1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>).
  3025. return -1;
  3026. }
  3027. if (sd->bl.m >= 0 && map[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) {
  3028. clif_displaymessage(fd, msg_txt(sd,1032)); // You are not authorized to warp somenone to your current map.
  3029. return -1;
  3030. }
  3031. if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
  3032. (p = party_search(atoi(message))) == NULL)
  3033. {
  3034. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
  3035. return -1;
  3036. }
  3037. count = 0;
  3038. iter = mapit_getallusers();
  3039. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3040. {
  3041. if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id)
  3042. {
  3043. 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))
  3044. continue; // Skip GMs greater than you... or chars already on the cell
  3045. if (pl_sd->bl.m >= 0 && map[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
  3046. count++;
  3047. else
  3048. pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN);
  3049. }
  3050. }
  3051. mapit_free(iter);
  3052. sprintf(atcmd_output, msg_txt(sd,95), p->party.name); // All online characters of the %s party have been recalled to your position.
  3053. clif_displaymessage(fd, atcmd_output);
  3054. if (count) {
  3055. 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.
  3056. clif_displaymessage(fd, atcmd_output);
  3057. }
  3058. return 0;
  3059. }
  3060. /*==========================================
  3061. *
  3062. *------------------------------------------*/
  3063. void atcommand_doload();
  3064. ACMD_FUNC(reload) {
  3065. nullpo_retr(-1, sd);
  3066. if ((strlen(command) < 8 ) && (!message || !*message)) {
  3067. const char* text;
  3068. text = atcommand_help_string( command );
  3069. if(text)
  3070. clif_displaymessage( fd, text );
  3071. return -1;
  3072. }
  3073. if (strstr(command, "itemdb") || strncmp(message, "itemdb", 4) == 0) {
  3074. itemdb_reload();
  3075. clif_displaymessage(fd, msg_txt(sd,97)); // Item database has been reloaded.
  3076. } else if (strstr(command, "mobdb") || strncmp(message, "mobdb", 3) == 0) {
  3077. mob_reload();
  3078. read_petdb();
  3079. merc_reload();
  3080. read_mercenarydb();
  3081. read_mercenary_skilldb();
  3082. reload_elementaldb();
  3083. clif_displaymessage(fd, msg_txt(sd,98)); // Monster database has been reloaded.
  3084. } else if (strstr(command, "skilldb") || strncmp(message, "skilldb", 4) == 0) {
  3085. skill_reload();
  3086. merc_skill_reload();
  3087. reload_elemental_skilldb();
  3088. read_mercenary_skilldb();
  3089. clif_displaymessage(fd, msg_txt(sd,99)); // Skill database has been reloaded.
  3090. } else if (strstr(command, "atcommand") || strncmp(message, "atcommand", 4) == 0) {
  3091. config_t run_test;
  3092. if (conf_read_file(&run_test, "conf/groups.conf")) {
  3093. clif_displaymessage(fd, msg_txt(sd,1036)); // Error reading groups.conf, reload failed.
  3094. return -1;
  3095. }
  3096. config_destroy(&run_test);
  3097. if (conf_read_file(&run_test, ATCOMMAND_CONF_FILENAME)) {
  3098. clif_displaymessage(fd, msg_txt(sd,1037)); // Error reading atcommand_athena.conf, reload failed.
  3099. return -1;
  3100. }
  3101. config_destroy(&run_test);
  3102. atcommand_doload();
  3103. pc_groups_reload();
  3104. clif_displaymessage(fd, msg_txt(sd,254));
  3105. } else if (strstr(command, "battleconf") || strncmp(message, "battleconf", 3) == 0) {
  3106. struct Battle_Config prev_config;
  3107. memcpy(&prev_config, &battle_config, sizeof(prev_config));
  3108. battle_config_read(BATTLE_CONF_FILENAME);
  3109. if( prev_config.item_rate_mvp != battle_config.item_rate_mvp
  3110. || prev_config.item_rate_common != battle_config.item_rate_common
  3111. || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss
  3112. || prev_config.item_rate_card != battle_config.item_rate_card
  3113. || prev_config.item_rate_card_boss != battle_config.item_rate_card_boss
  3114. || prev_config.item_rate_equip != battle_config.item_rate_equip
  3115. || prev_config.item_rate_equip_boss != battle_config.item_rate_equip_boss
  3116. || prev_config.item_rate_heal != battle_config.item_rate_heal
  3117. || prev_config.item_rate_heal_boss != battle_config.item_rate_heal_boss
  3118. || prev_config.item_rate_use != battle_config.item_rate_use
  3119. || prev_config.item_rate_use_boss != battle_config.item_rate_use_boss
  3120. || prev_config.item_rate_treasure != battle_config.item_rate_treasure
  3121. || prev_config.item_rate_adddrop != battle_config.item_rate_adddrop
  3122. || prev_config.logarithmic_drops != battle_config.logarithmic_drops
  3123. || prev_config.item_drop_common_min != battle_config.item_drop_common_min
  3124. || prev_config.item_drop_common_max != battle_config.item_drop_common_max
  3125. || prev_config.item_drop_card_min != battle_config.item_drop_card_min
  3126. || prev_config.item_drop_card_max != battle_config.item_drop_card_max
  3127. || prev_config.item_drop_equip_min != battle_config.item_drop_equip_min
  3128. || prev_config.item_drop_equip_max != battle_config.item_drop_equip_max
  3129. || prev_config.item_drop_mvp_min != battle_config.item_drop_mvp_min
  3130. || prev_config.item_drop_mvp_max != battle_config.item_drop_mvp_max
  3131. || prev_config.item_drop_heal_min != battle_config.item_drop_heal_min
  3132. || prev_config.item_drop_heal_max != battle_config.item_drop_heal_max
  3133. || prev_config.item_drop_use_min != battle_config.item_drop_use_min
  3134. || prev_config.item_drop_use_max != battle_config.item_drop_use_max
  3135. || prev_config.item_drop_treasure_min != battle_config.item_drop_treasure_min
  3136. || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max
  3137. || prev_config.base_exp_rate != battle_config.base_exp_rate
  3138. || prev_config.job_exp_rate != battle_config.job_exp_rate
  3139. )
  3140. { // Exp or Drop rates changed.
  3141. mob_reload(); //Needed as well so rate changes take effect.
  3142. chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
  3143. }
  3144. clif_displaymessage(fd, msg_txt(sd,255));
  3145. } else if (strstr(command, "statusdb") || strncmp(message, "statusdb", 3) == 0) {
  3146. status_readdb();
  3147. clif_displaymessage(fd, msg_txt(sd,256));
  3148. } else if (strstr(command, "pcdb") || strncmp(message, "pcdb", 2) == 0) {
  3149. pc_readdb();
  3150. clif_displaymessage(fd, msg_txt(sd,257));
  3151. } else if (strstr(command, "motd") || strncmp(message, "motd", 4) == 0) {
  3152. pc_read_motd();
  3153. clif_displaymessage(fd, msg_txt(sd,268));
  3154. } else if (strstr(command, "script") || strncmp(message, "script", 3) == 0) {
  3155. struct s_mapiterator* iter;
  3156. struct map_session_data* pl_sd;
  3157. //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
  3158. //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
  3159. iter = mapit_getallusers();
  3160. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3161. pc_close_npc(pl_sd,2);
  3162. mapit_free(iter);
  3163. flush_fifos();
  3164. map_reloadnpc(true); // reload config files seeking for npcs
  3165. script_reload();
  3166. npc_reload();
  3167. clif_displaymessage(fd, msg_txt(sd,100)); // Scripts have been reloaded.
  3168. } else if (strstr(command, "msgconf") || strncmp(message, "msgconf", 3) == 0) {
  3169. map_msg_reload();
  3170. clif_displaymessage(fd, msg_txt(sd,463)); // Message configuration has been reloaded.
  3171. } else if (strstr(command, "questdb") || strncmp(message, "questdb", 3) == 0) {
  3172. do_reload_quest();
  3173. clif_displaymessage(fd, msg_txt(sd,1377)); // Quest database has been reloaded.
  3174. } else if (strstr(command, "packetdb") || strncmp(message, "packetdb", 4) == 0) {
  3175. packetdb_readdb();
  3176. clif_displaymessage(fd, msg_txt(sd,1477)); // Packet database has been reloaded.
  3177. }
  3178. return 0;
  3179. }
  3180. /*==========================================
  3181. * @mapinfo [0-3] <map name> by MC_Cameri
  3182. * => Shows information about the map [map name]
  3183. * 0 = no additional information
  3184. * 1 = Show users in that map and their location
  3185. * 2 = Shows NPCs in that map
  3186. * 3 = Shows the chats in that map
  3187. *------------------------------------------*/
  3188. ACMD_FUNC(mapinfo) {
  3189. struct map_session_data* pl_sd;
  3190. struct s_mapiterator* iter;
  3191. struct npc_data *nd = NULL;
  3192. struct chat_data *cd = NULL;
  3193. char direction[12];
  3194. int i, m_id, chat_num = 0, list = 0, vend_num = 0;
  3195. unsigned short m_index;
  3196. char mapname[24];
  3197. nullpo_retr(-1, sd);
  3198. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3199. memset(mapname, '\0', sizeof(mapname));
  3200. memset(direction, '\0', sizeof(direction));
  3201. sscanf(message, "%d %23[^\n]", &list, mapname);
  3202. if (list < 0 || list > 3) {
  3203. clif_displaymessage(fd, msg_txt(sd,1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3204. return -1;
  3205. }
  3206. if (mapname[0] == '\0') {
  3207. safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
  3208. m_id = map_mapindex2mapid(sd->mapindex);
  3209. } else {
  3210. m_id = map_mapname2mapid(mapname);
  3211. }
  3212. if (m_id < 0) {
  3213. clif_displaymessage(fd, msg_txt(sd,1)); // Map not found.
  3214. return -1;
  3215. }
  3216. m_index = mapindex_name2id(mapname); //This one shouldn't fail since the previous seek did not.
  3217. clif_displaymessage(fd, msg_txt(sd,1039)); // ------ Map Info ------
  3218. // count chats (for initial message)
  3219. chat_num = 0;
  3220. iter = mapit_getallusers();
  3221. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  3222. if( pl_sd->mapindex == m_index ) {
  3223. if( pl_sd->state.vending )
  3224. vend_num++;
  3225. else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
  3226. chat_num++;
  3227. }
  3228. }
  3229. mapit_free(iter);
  3230. 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
  3231. clif_displaymessage(fd, atcmd_output);
  3232. clif_displaymessage(fd, msg_txt(sd,1041)); // ------ Map Flags ------
  3233. if (map[m_id].flag.town)
  3234. clif_displaymessage(fd, msg_txt(sd,1042)); // Town Map
  3235. if (map[m_id].flag.restricted){
  3236. sprintf(atcmd_output, msg_txt(sd,1106),map[m_id].zone); // Restricted (zone %d)
  3237. clif_displaymessage(fd, atcmd_output);
  3238. }
  3239. if (battle_config.autotrade_mapflag == map[m_id].flag.autotrade)
  3240. clif_displaymessage(fd, msg_txt(sd,1043)); // Autotrade Enabled
  3241. else
  3242. clif_displaymessage(fd, msg_txt(sd,1044)); // Autotrade Disabled
  3243. if (map[m_id].flag.battleground){
  3244. sprintf(atcmd_output, msg_txt(sd,1045),map[m_id].flag.battleground); // Battlegrounds ON (type %d)
  3245. clif_displaymessage(fd, atcmd_output);
  3246. }
  3247. strcpy(atcmd_output,msg_txt(sd,1046)); // PvP Flags:
  3248. if (map[m_id].flag.pvp)
  3249. strcat(atcmd_output, msg_txt(sd,1047)); // Pvp ON |
  3250. if (map[m_id].flag.pvp_noguild)
  3251. strcat(atcmd_output, msg_txt(sd,1048)); // NoGuild |
  3252. if (map[m_id].flag.pvp_noparty)
  3253. strcat(atcmd_output, msg_txt(sd,1049)); // NoParty |
  3254. if (map[m_id].flag.pvp_nightmaredrop)
  3255. strcat(atcmd_output, msg_txt(sd,1050)); // NightmareDrop |
  3256. if (map[m_id].flag.pvp_nocalcrank)
  3257. strcat(atcmd_output, msg_txt(sd,1051)); // NoCalcRank |
  3258. clif_displaymessage(fd, atcmd_output);
  3259. strcpy(atcmd_output,msg_txt(sd,1052)); // GvG Flags:
  3260. if (map[m_id].flag.gvg)
  3261. strcat(atcmd_output, msg_txt(sd,1053)); // GvG ON |
  3262. if (map[m_id].flag.gvg_dungeon)
  3263. strcat(atcmd_output, msg_txt(sd,1054)); // GvG Dungeon |
  3264. if (map[m_id].flag.gvg_castle)
  3265. strcat(atcmd_output, msg_txt(sd,1055)); // GvG Castle |
  3266. if (map[m_id].flag.gvg_noparty)
  3267. strcat(atcmd_output, msg_txt(sd,1056)); // NoParty |
  3268. clif_displaymessage(fd, atcmd_output);
  3269. strcpy(atcmd_output,msg_txt(sd,1057)); // Teleport Flags:
  3270. if (map[m_id].flag.noteleport)
  3271. strcat(atcmd_output, msg_txt(sd,1058)); // NoTeleport |
  3272. if (map[m_id].flag.monster_noteleport)
  3273. strcat(atcmd_output, msg_txt(sd,1059)); // Monster NoTeleport |
  3274. if (map[m_id].flag.nowarp)
  3275. strcat(atcmd_output, msg_txt(sd,1060)); // NoWarp |
  3276. if (map[m_id].flag.nowarpto)
  3277. strcat(atcmd_output, msg_txt(sd,1061)); // NoWarpTo |
  3278. if (map[m_id].flag.noreturn)
  3279. strcat(atcmd_output, msg_txt(sd,1062)); // NoReturn |
  3280. if (map[m_id].flag.nogo)
  3281. strcat(atcmd_output, msg_txt(sd,1063)); // NoGo |
  3282. if (map[m_id].flag.nomemo)
  3283. strcat(atcmd_output, msg_txt(sd,1064)); // NoMemo |
  3284. clif_displaymessage(fd, atcmd_output);
  3285. sprintf(atcmd_output, msg_txt(sd,1065), // No Exp Penalty: %s | No Zeny Penalty: %s
  3286. (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
  3287. clif_displaymessage(fd, atcmd_output);
  3288. if (map[m_id].flag.nosave) {
  3289. if (!map[m_id].save.map)
  3290. clif_displaymessage(fd, msg_txt(sd,1068)); // No Save (Return to last Save Point)
  3291. else if (map[m_id].save.x == -1 || map[m_id].save.y == -1 ) {
  3292. sprintf(atcmd_output, msg_txt(sd,1069), mapindex_id2name(map[m_id].save.map)); // No Save, Save Point: %s,Random
  3293. clif_displaymessage(fd, atcmd_output);
  3294. }
  3295. else {
  3296. sprintf(atcmd_output, msg_txt(sd,1070), // No Save, Save Point: %s,%d,%d
  3297. mapindex_id2name(map[m_id].save.map),map[m_id].save.x,map[m_id].save.y);
  3298. clif_displaymessage(fd, atcmd_output);
  3299. }
  3300. }
  3301. strcpy(atcmd_output,msg_txt(sd,1071)); // Weather Flags:
  3302. if (map[m_id].flag.snow)
  3303. strcat(atcmd_output, msg_txt(sd,1072)); // Snow |
  3304. if (map[m_id].flag.fog)
  3305. strcat(atcmd_output, msg_txt(sd,1073)); // Fog |
  3306. if (map[m_id].flag.sakura)
  3307. strcat(atcmd_output, msg_txt(sd,1074)); // Sakura |
  3308. if (map[m_id].flag.clouds)
  3309. strcat(atcmd_output, msg_txt(sd,1075)); // Clouds |
  3310. if (map[m_id].flag.clouds2)
  3311. strcat(atcmd_output, msg_txt(sd,1076)); // Clouds2 |
  3312. if (map[m_id].flag.fireworks)
  3313. strcat(atcmd_output, msg_txt(sd,1077)); // Fireworks |
  3314. if (map[m_id].flag.leaves)
  3315. strcat(atcmd_output, msg_txt(sd,1078)); // Leaves |
  3316. if (map[m_id].flag.nightenabled)
  3317. strcat(atcmd_output, msg_txt(sd,1080)); // Displays Night |
  3318. clif_displaymessage(fd, atcmd_output);
  3319. strcpy(atcmd_output,msg_txt(sd,1081)); // Other Flags:
  3320. if (map[m_id].flag.nobranch)
  3321. strcat(atcmd_output, msg_txt(sd,1082)); // NoBranch |
  3322. if (map[m_id].flag.notrade)
  3323. strcat(atcmd_output, msg_txt(sd,1083)); // NoTrade |
  3324. if (map[m_id].flag.novending)
  3325. strcat(atcmd_output, msg_txt(sd,1084)); // NoVending |
  3326. if (map[m_id].flag.nodrop)
  3327. strcat(atcmd_output, msg_txt(sd,1085)); // NoDrop |
  3328. if (map[m_id].flag.noskill)
  3329. strcat(atcmd_output, msg_txt(sd,1086)); // NoSkill |
  3330. if (map[m_id].flag.noicewall)
  3331. strcat(atcmd_output, msg_txt(sd,1087)); // NoIcewall |
  3332. if (map[m_id].flag.allowks)
  3333. strcat(atcmd_output, msg_txt(sd,1088)); // AllowKS |
  3334. if (map[m_id].flag.reset)
  3335. strcat(atcmd_output, msg_txt(sd,1089)); // Reset |
  3336. clif_displaymessage(fd, atcmd_output);
  3337. strcpy(atcmd_output,msg_txt(sd,1090)); // Other Flags:
  3338. if (map[m_id].nocommand)
  3339. strcat(atcmd_output, msg_txt(sd,1091)); // NoCommand |
  3340. if (map[m_id].flag.nobaseexp)
  3341. strcat(atcmd_output, msg_txt(sd,1092)); // NoBaseEXP |
  3342. if (map[m_id].flag.nojobexp)
  3343. strcat(atcmd_output, msg_txt(sd,1093)); // NoJobEXP |
  3344. if (map[m_id].flag.nomobloot)
  3345. strcat(atcmd_output, msg_txt(sd,1094)); // NoMobLoot |
  3346. if (map[m_id].flag.nomvploot)
  3347. strcat(atcmd_output, msg_txt(sd,1095)); // NoMVPLoot |
  3348. if (map[m_id].flag.partylock)
  3349. strcat(atcmd_output, msg_txt(sd,1096)); // PartyLock |
  3350. if (map[m_id].flag.guildlock)
  3351. strcat(atcmd_output, msg_txt(sd,1097)); // GuildLock |
  3352. if (map[m_id].flag.loadevent)
  3353. strcat(atcmd_output, msg_txt(sd,1098)); //Loadevent |
  3354. if (map[m_id].flag.src4instance)
  3355. strcat(atcmd_output, msg_txt(sd,1099)); // Src4instance |
  3356. if (map[m_id].flag.chmautojoin)
  3357. strcat(atcmd_output, msg_txt(sd,1100)); // Chmautojoin |
  3358. if (map[m_id].flag.nousecart)
  3359. strcat(atcmd_output, msg_txt(sd,1101)); // nousecart |
  3360. if (map[m_id].flag.noitemconsumption)
  3361. strcat(atcmd_output, msg_txt(sd,1102)); // noitemconsumption |
  3362. if (map[m_id].flag.nosumstarmiracle)
  3363. strcat(atcmd_output, msg_txt(sd,1103)); // nosumstarmiracle |
  3364. if (map[m_id].flag.nomineeffect)
  3365. strcat(atcmd_output, msg_txt(sd,1104)); // nomineeffect |
  3366. if (map[m_id].flag.nolockon)
  3367. strcat(atcmd_output, msg_txt(sd,1105)); // nolockon |
  3368. clif_displaymessage(fd, atcmd_output);
  3369. switch (list) {
  3370. case 0:
  3371. // Do nothing. It's list 0, no additional display.
  3372. break;
  3373. case 1:
  3374. clif_displaymessage(fd, msg_txt(sd,480)); // ----- Players in Map -----
  3375. iter = mapit_getallusers();
  3376. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3377. {
  3378. if (pl_sd->mapindex == m_index) {
  3379. sprintf(atcmd_output, msg_txt(sd,481), // Player '%s' (session #%d) | Location: %d,%d
  3380. pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y);
  3381. clif_displaymessage(fd, atcmd_output);
  3382. }
  3383. }
  3384. mapit_free(iter);
  3385. break;
  3386. case 2:
  3387. clif_displaymessage(fd, msg_txt(sd,482)); // ----- NPCs in Map -----
  3388. for (i = 0; i < map[m_id].npc_num;)
  3389. {
  3390. nd = map[m_id].npc[i];
  3391. switch(nd->ud.dir) {
  3392. case 0: strcpy(direction, msg_txt(sd,491)); break; // North
  3393. case 1: strcpy(direction, msg_txt(sd,492)); break; // North West
  3394. case 2: strcpy(direction, msg_txt(sd,493)); break; // West
  3395. case 3: strcpy(direction, msg_txt(sd,494)); break; // South West
  3396. case 4: strcpy(direction, msg_txt(sd,495)); break; // South
  3397. case 5: strcpy(direction, msg_txt(sd,496)); break; // South East
  3398. case 6: strcpy(direction, msg_txt(sd,497)); break; // East
  3399. case 7: strcpy(direction, msg_txt(sd,498)); break; // North East
  3400. case 9: strcpy(direction, msg_txt(sd,491)); break; // North
  3401. default: strcpy(direction, msg_txt(sd,499)); break; // Unknown
  3402. }
  3403. if(strcmp(nd->name,nd->exname) == 0)
  3404. sprintf(atcmd_output, msg_txt(sd,490), // NPC %d: %s | Direction: %s | Sprite: %d | Location: %d %d
  3405. ++i, nd->name, direction, nd->class_, nd->bl.x, nd->bl.y);
  3406. else
  3407. sprintf(atcmd_output, msg_txt(sd,489), // NPC %d: %s::%s | Direction: %s | Sprite: %d | Location: %d %d
  3408. ++i, nd->name, nd->exname, direction, nd->class_, nd->bl.x, nd->bl.y);
  3409. clif_displaymessage(fd, atcmd_output);
  3410. }
  3411. break;
  3412. case 3:
  3413. clif_displaymessage(fd, msg_txt(sd,483)); // ----- Chats in Map -----
  3414. iter = mapit_getallusers();
  3415. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  3416. {
  3417. if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
  3418. pl_sd->mapindex == m_index &&
  3419. cd->usersd[0] == pl_sd)
  3420. {
  3421. sprintf(atcmd_output, msg_txt(sd,484), // Chat: %s | Player: %s | Location: %d %d
  3422. cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y);
  3423. clif_displaymessage(fd, atcmd_output);
  3424. sprintf(atcmd_output, msg_txt(sd,485), // Users: %d/%d | Password: %s | Public: %s
  3425. cd->users, cd->limit, cd->pass, (cd->pub) ? msg_txt(sd,486) : msg_txt(sd,487)); // Yes / No
  3426. clif_displaymessage(fd, atcmd_output);
  3427. }
  3428. }
  3429. mapit_free(iter);
  3430. break;
  3431. default: // normally impossible to arrive here
  3432. clif_displaymessage(fd, msg_txt(sd,488)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>).
  3433. return -1;
  3434. break;
  3435. }
  3436. return 0;
  3437. }
  3438. /*==========================================
  3439. *
  3440. *------------------------------------------*/
  3441. ACMD_FUNC(mount_peco)
  3442. {
  3443. nullpo_retr(-1, sd);
  3444. if (sd->disguise) {
  3445. clif_displaymessage(fd, msg_txt(sd,212)); // Cannot mount while in disguise.
  3446. return -1;
  3447. }
  3448. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
  3449. if( !(sd->sc.option&OPTION_DRAGON1) ) {
  3450. clif_displaymessage(sd->fd,msg_txt(sd,1119)); // You have mounted your Dragon.
  3451. pc_setoption(sd, sd->sc.option|OPTION_DRAGON1);
  3452. } else {
  3453. clif_displaymessage(sd->fd,msg_txt(sd,1120)); // You have released your Dragon.
  3454. pc_setoption(sd, sd->sc.option&~OPTION_DRAGON1);
  3455. }
  3456. return 0;
  3457. }
  3458. if( (sd->class_&MAPID_THIRDMASK) == MAPID_RANGER && pc_checkskill(sd,RA_WUGRIDER) > 0 ) {
  3459. if( !pc_isridingwug(sd) ) {
  3460. clif_displaymessage(sd->fd,msg_txt(sd,1121)); // You have mounted your Warg.
  3461. pc_setoption(sd, sd->sc.option|OPTION_WUGRIDER);
  3462. } else {
  3463. clif_displaymessage(sd->fd,msg_txt(sd,1122)); // You have released your Warg.
  3464. pc_setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
  3465. }
  3466. return 0;
  3467. }
  3468. if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {
  3469. if( !pc_ismadogear(sd) ) {
  3470. clif_displaymessage(sd->fd,msg_txt(sd,1123)); // You have mounted your Mado Gear.
  3471. pc_setoption(sd, sd->sc.option|OPTION_MADOGEAR);
  3472. } else {
  3473. clif_displaymessage(sd->fd,msg_txt(sd,1124)); // You have released your Mado Gear.
  3474. pc_setoption(sd, sd->sc.option&~OPTION_MADOGEAR);
  3475. }
  3476. return 0;
  3477. }
  3478. if (!pc_isriding(sd)) { // if actually no peco
  3479. if (!pc_checkskill(sd, KN_RIDING)) {
  3480. clif_displaymessage(fd, msg_txt(sd,213)); // You can not mount a Peco Peco with your current job.
  3481. return -1;
  3482. }
  3483. pc_setoption(sd, sd->sc.option | OPTION_RIDING);
  3484. clif_displaymessage(fd, msg_txt(sd,102)); // You have mounted a Peco Peco.
  3485. } else {//Dismount
  3486. pc_setoption(sd, sd->sc.option & ~OPTION_RIDING);
  3487. clif_displaymessage(fd, msg_txt(sd,214)); // You have released your Peco Peco.
  3488. }
  3489. return 0;
  3490. }
  3491. /*==========================================
  3492. *Spy Commands by Syrus22
  3493. *------------------------------------------*/
  3494. ACMD_FUNC(guildspy)
  3495. {
  3496. char guild_name[NAME_LENGTH];
  3497. struct guild *g;
  3498. nullpo_retr(-1, sd);
  3499. memset(guild_name, '\0', sizeof(guild_name));
  3500. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3501. if (!enable_spy)
  3502. {
  3503. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3504. return -1;
  3505. }
  3506. if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  3507. clif_displaymessage(fd, msg_txt(sd,1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>).
  3508. return -1;
  3509. }
  3510. if ((g = guild_searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number
  3511. (g = guild_search(atoi(message))) != NULL) {
  3512. if (sd->guildspy == g->guild_id) {
  3513. sd->guildspy = 0;
  3514. sprintf(atcmd_output, msg_txt(sd,103), g->name); // No longer spying on the %s guild.
  3515. clif_displaymessage(fd, atcmd_output);
  3516. } else {
  3517. sd->guildspy = g->guild_id;
  3518. sprintf(atcmd_output, msg_txt(sd,104), g->name); // Spying on the %s guild.
  3519. clif_displaymessage(fd, atcmd_output);
  3520. }
  3521. } else {
  3522. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the specified guild is online.
  3523. return -1;
  3524. }
  3525. return 0;
  3526. }
  3527. /*==========================================
  3528. *
  3529. *------------------------------------------*/
  3530. ACMD_FUNC(partyspy)
  3531. {
  3532. char party_name[NAME_LENGTH];
  3533. struct party_data *p;
  3534. nullpo_retr(-1, sd);
  3535. memset(party_name, '\0', sizeof(party_name));
  3536. memset(atcmd_output, '\0', sizeof(atcmd_output));
  3537. if (!enable_spy)
  3538. {
  3539. clif_displaymessage(fd, msg_txt(sd,1125)); // The mapserver has spy command support disabled.
  3540. return -1;
  3541. }
  3542. if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) {
  3543. clif_displaymessage(fd, msg_txt(sd,1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>).
  3544. return -1;
  3545. }
  3546. if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
  3547. (p = party_search(atoi(message))) != NULL) {
  3548. if (sd->partyspy == p->party.party_id) {
  3549. sd->partyspy = 0;
  3550. sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
  3551. clif_displaymessage(fd, atcmd_output);
  3552. } else {
  3553. sd->partyspy = p->party.party_id;
  3554. sprintf(atcmd_output, msg_txt(sd,106), p->party.name); // Spying on the %s party.
  3555. clif_displaymessage(fd, atcmd_output);
  3556. }
  3557. } else {
  3558. clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name/ID, or no one from the specified party is online.
  3559. return -1;
  3560. }
  3561. return 0;
  3562. }
  3563. /*==========================================
  3564. * @repairall [Valaris]
  3565. *------------------------------------------*/
  3566. ACMD_FUNC(repairall)
  3567. {
  3568. int count, i;
  3569. nullpo_retr(-1, sd);
  3570. count = 0;
  3571. for (i = 0; i < MAX_INVENTORY; i++) {
  3572. if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) {
  3573. sd->status.inventory[i].attribute = 0;
  3574. clif_produceeffect(sd, 0, sd->status.inventory[i].nameid);
  3575. count++;
  3576. }
  3577. }
  3578. if (count > 0) {
  3579. clif_misceffect(&sd->bl, 3);
  3580. clif_equiplist(sd);
  3581. clif_displaymessage(fd, msg_txt(sd,107)); // All items have been repaired.
  3582. } else {
  3583. clif_displaymessage(fd, msg_txt(sd,108)); // No item need to be repaired.
  3584. return -1;
  3585. }
  3586. return 0;
  3587. }
  3588. /*==========================================
  3589. * @nuke [Valaris]
  3590. *------------------------------------------*/
  3591. ACMD_FUNC(nuke)
  3592. {
  3593. struct map_session_data *pl_sd;
  3594. nullpo_retr(-1, sd);
  3595. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3596. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3597. clif_displaymessage(fd, msg_txt(sd,1128)); // Please enter a player name (usage: @nuke <char name>).
  3598. return -1;
  3599. }
  3600. if ((pl_sd = map_nick2sd(atcmd_player_name)) != NULL) {
  3601. if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
  3602. skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
  3603. clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
  3604. } else {
  3605. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3606. return -1;
  3607. }
  3608. } else {
  3609. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3610. return -1;
  3611. }
  3612. return 0;
  3613. }
  3614. /*==========================================
  3615. * @tonpc
  3616. *------------------------------------------*/
  3617. ACMD_FUNC(tonpc)
  3618. {
  3619. char npcname[NAME_LENGTH+1];
  3620. struct npc_data *nd;
  3621. nullpo_retr(-1, sd);
  3622. memset(npcname, 0, sizeof(npcname));
  3623. if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
  3624. clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
  3625. return -1;
  3626. }
  3627. if ((nd = npc_name2id(npcname)) != NULL) {
  3628. if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
  3629. clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
  3630. else
  3631. return -1;
  3632. } else {
  3633. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3634. return -1;
  3635. }
  3636. return 0;
  3637. }
  3638. /*==========================================
  3639. *
  3640. *------------------------------------------*/
  3641. ACMD_FUNC(shownpc)
  3642. {
  3643. char NPCname[NAME_LENGTH+1];
  3644. nullpo_retr(-1, sd);
  3645. memset(NPCname, '\0', sizeof(NPCname));
  3646. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3647. clif_displaymessage(fd, msg_txt(sd,1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>).
  3648. return -1;
  3649. }
  3650. if (npc_name2id(NPCname) != NULL) {
  3651. npc_enable(NPCname, 1);
  3652. clif_displaymessage(fd, msg_txt(sd,110)); // Npc Enabled.
  3653. } else {
  3654. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3655. return -1;
  3656. }
  3657. return 0;
  3658. }
  3659. /*==========================================
  3660. *
  3661. *------------------------------------------*/
  3662. ACMD_FUNC(hidenpc)
  3663. {
  3664. char NPCname[NAME_LENGTH+1];
  3665. nullpo_retr(-1, sd);
  3666. memset(NPCname, '\0', sizeof(NPCname));
  3667. if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) {
  3668. clif_displaymessage(fd, msg_txt(sd,1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>).
  3669. return -1;
  3670. }
  3671. if (npc_name2id(NPCname) == NULL) {
  3672. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3673. return -1;
  3674. }
  3675. npc_enable(NPCname, 0);
  3676. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3677. return 0;
  3678. }
  3679. ACMD_FUNC(loadnpc)
  3680. {
  3681. FILE *fp;
  3682. if (!message || !*message) {
  3683. clif_displaymessage(fd, msg_txt(sd,1132)); // Please enter a script file name (usage: @loadnpc <file name>).
  3684. return -1;
  3685. }
  3686. // check if script file exists
  3687. if ((fp = fopen(message, "r")) == NULL) {
  3688. clif_displaymessage(fd, msg_txt(sd,261));
  3689. return -1;
  3690. }
  3691. fclose(fp);
  3692. // add to list of script sources and run it
  3693. npc_addsrcfile(message);
  3694. npc_parsesrcfile(message,true);
  3695. npc_read_event_script();
  3696. clif_displaymessage(fd, msg_txt(sd,262));
  3697. return 0;
  3698. }
  3699. ACMD_FUNC(unloadnpc)
  3700. {
  3701. struct npc_data *nd;
  3702. char NPCname[NAME_LENGTH+1];
  3703. nullpo_retr(-1, sd);
  3704. memset(NPCname, '\0', sizeof(NPCname));
  3705. if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) {
  3706. clif_displaymessage(fd, msg_txt(sd,1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>).
  3707. return -1;
  3708. }
  3709. if ((nd = npc_name2id(NPCname)) == NULL) {
  3710. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  3711. return -1;
  3712. }
  3713. npc_unload_duplicates(nd);
  3714. npc_unload(nd,true);
  3715. npc_read_event_script();
  3716. clif_displaymessage(fd, msg_txt(sd,112)); // Npc Disabled.
  3717. return 0;
  3718. }
  3719. /*==========================================
  3720. * time in txt for time command (by [Yor])
  3721. *------------------------------------------*/
  3722. char* txt_time(unsigned int duration)
  3723. {
  3724. int days, hours, minutes, seconds;
  3725. char temp[CHAT_SIZE_MAX];
  3726. static char temp1[CHAT_SIZE_MAX];
  3727. memset(temp, '\0', sizeof(temp));
  3728. memset(temp1, '\0', sizeof(temp1));
  3729. days = duration / (60 * 60 * 24);
  3730. duration = duration - (60 * 60 * 24 * days);
  3731. hours = duration / (60 * 60);
  3732. duration = duration - (60 * 60 * hours);
  3733. minutes = duration / 60;
  3734. seconds = duration - (60 * minutes);
  3735. if (days == 1)
  3736. sprintf(temp, msg_txt(NULL,219), days); // %d day
  3737. else if (days > 1)
  3738. sprintf(temp, msg_txt(NULL,220), days); // %d days
  3739. if (hours == 1)
  3740. sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
  3741. else if (hours > 1)
  3742. sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
  3743. if (minutes < 2)
  3744. sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
  3745. else
  3746. sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
  3747. if (seconds == 1)
  3748. sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
  3749. else if (seconds > 1)
  3750. sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
  3751. return temp1;
  3752. }
  3753. /*==========================================
  3754. * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor]
  3755. * Calculation management of GM modification (@day/@night GM commands) is done
  3756. *------------------------------------------*/
  3757. ACMD_FUNC(servertime)
  3758. {
  3759. const struct TimerData * timer_data;
  3760. const struct TimerData * timer_data2;
  3761. time_t time_server; // variable for number of seconds (used with time() function)
  3762. struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
  3763. char temp[CHAT_SIZE_MAX];
  3764. nullpo_retr(-1, sd);
  3765. memset(temp, '\0', sizeof(temp));
  3766. time(&time_server); // get time in seconds since 1/1/1970
  3767. datetime = localtime(&time_server); // convert seconds in structure
  3768. // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52)
  3769. strftime(temp, sizeof(temp)-1, msg_txt(sd,230), datetime); // Server time (normal time): %A, %B %d %Y %X.
  3770. clif_displaymessage(fd, temp);
  3771. if (battle_config.night_duration == 0 && battle_config.day_duration == 0) {
  3772. if (night_flag == 0)
  3773. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3774. else
  3775. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3776. } else if (battle_config.night_duration == 0)
  3777. if (night_flag == 1) { // we start with night
  3778. timer_data = get_timer(day_timer_tid);
  3779. 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.
  3780. clif_displaymessage(fd, temp);
  3781. clif_displaymessage(fd, msg_txt(sd,234)); // Game time: After, the game will be in permanent daylight.
  3782. } else
  3783. clif_displaymessage(fd, msg_txt(sd,231)); // Game time: The game is in permanent daylight.
  3784. else if (battle_config.day_duration == 0)
  3785. if (night_flag == 0) { // we start with day
  3786. timer_data = get_timer(night_timer_tid);
  3787. 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.
  3788. clif_displaymessage(fd, temp);
  3789. clif_displaymessage(fd, msg_txt(sd,236)); // Game time: After, the game will be in permanent night.
  3790. } else
  3791. clif_displaymessage(fd, msg_txt(sd,232)); // Game time: The game is in permanent night.
  3792. else {
  3793. if (night_flag == 0) {
  3794. timer_data = get_timer(night_timer_tid);
  3795. timer_data2 = get_timer(day_timer_tid);
  3796. 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.
  3797. clif_displaymessage(fd, temp);
  3798. if (DIFF_TICK(timer_data->tick, timer_data2->tick) > 0)
  3799. 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.
  3800. else
  3801. 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.
  3802. clif_displaymessage(fd, temp);
  3803. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3804. clif_displaymessage(fd, temp);
  3805. } else {
  3806. timer_data = get_timer(day_timer_tid);
  3807. timer_data2 = get_timer(night_timer_tid);
  3808. 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.
  3809. clif_displaymessage(fd, temp);
  3810. if (DIFF_TICK(timer_data->tick,timer_data2->tick) > 0)
  3811. 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.
  3812. else
  3813. 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.
  3814. clif_displaymessage(fd, temp);
  3815. sprintf(temp, msg_txt(sd,238), txt_time(timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s.
  3816. clif_displaymessage(fd, temp);
  3817. }
  3818. }
  3819. return 0;
  3820. }
  3821. //Added by Coltaro
  3822. //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status_change_timer...).
  3823. //Well, using time_t could still work but for some reason that looks like more coding x_x
  3824. static void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute)
  3825. {
  3826. const int factor_year = 518400; //12*30*24*60 = 518400
  3827. const int factor_month = 43200; //30*24*60 = 43200
  3828. const int factor_day = 1440; //24*60 = 1440
  3829. const int factor_hour = 60;
  3830. *year = jailtime/factor_year;
  3831. jailtime -= *year*factor_year;
  3832. *month = jailtime/factor_month;
  3833. jailtime -= *month*factor_month;
  3834. *day = jailtime/factor_day;
  3835. jailtime -= *day*factor_day;
  3836. *hour = jailtime/factor_hour;
  3837. jailtime -= *hour*factor_hour;
  3838. *minute = jailtime;
  3839. *year = *year > 0? *year : 0;
  3840. *month = *month > 0? *month : 0;
  3841. *day = *day > 0? *day : 0;
  3842. *hour = *hour > 0? *hour : 0;
  3843. *minute = *minute > 0? *minute : 0;
  3844. return;
  3845. }
  3846. /*==========================================
  3847. * @jail <char_name> by [Yor]
  3848. * Special warp! No check with nowarp and nowarpto flag
  3849. *------------------------------------------*/
  3850. ACMD_FUNC(jail)
  3851. {
  3852. struct map_session_data *pl_sd;
  3853. int x, y;
  3854. unsigned short m_index;
  3855. nullpo_retr(-1, sd);
  3856. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3857. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3858. clif_displaymessage(fd, msg_txt(sd,1134)); // Please enter a player name (usage: @jail <char_name>).
  3859. return -1;
  3860. }
  3861. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3862. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3863. return -1;
  3864. }
  3865. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd))
  3866. { // you can jail only lower or same GM
  3867. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3868. return -1;
  3869. }
  3870. if (pl_sd->sc.data[SC_JAILED])
  3871. {
  3872. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3873. return -1;
  3874. }
  3875. switch(rnd() % 2) { //Jail Locations
  3876. case 0:
  3877. m_index = mapindex_name2id(MAP_JAIL);
  3878. x = 24;
  3879. y = 75;
  3880. break;
  3881. default:
  3882. m_index = mapindex_name2id(MAP_JAIL);
  3883. x = 49;
  3884. y = 75;
  3885. break;
  3886. }
  3887. //Duration of INT_MAX to specify infinity.
  3888. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000);
  3889. clif_displaymessage(pl_sd->fd, msg_txt(sd,117)); // GM has send you in jails.
  3890. clif_displaymessage(fd, msg_txt(sd,118)); // Player warped in jails.
  3891. return 0;
  3892. }
  3893. /*==========================================
  3894. * @unjail/@discharge <char_name> by [Yor]
  3895. * Special warp! No check with nowarp and nowarpto flag
  3896. *------------------------------------------*/
  3897. ACMD_FUNC(unjail)
  3898. {
  3899. struct map_session_data *pl_sd;
  3900. memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
  3901. if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) {
  3902. clif_displaymessage(fd, msg_txt(sd,1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>).
  3903. return -1;
  3904. }
  3905. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3906. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3907. return -1;
  3908. }
  3909. if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM
  3910. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3911. return -1;
  3912. }
  3913. if (!pl_sd->sc.data[SC_JAILED])
  3914. {
  3915. clif_displaymessage(fd, msg_txt(sd,119)); // This player is not in jails.
  3916. return -1;
  3917. }
  3918. //Reset jail time to 1 sec.
  3919. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000);
  3920. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // A GM has discharged you from jail.
  3921. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed.
  3922. return 0;
  3923. }
  3924. ACMD_FUNC(jailfor)
  3925. {
  3926. struct map_session_data *pl_sd = NULL;
  3927. int year, month, day, hour, minute, value;
  3928. char * modif_p;
  3929. int jailtime = 0,x,y;
  3930. short m_index = 0;
  3931. nullpo_retr(-1, sd);
  3932. if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
  3933. clif_displaymessage(fd, msg_txt(sd,400)); //Usage: @jailfor <time> <character name>
  3934. return -1;
  3935. }
  3936. atcmd_output[sizeof(atcmd_output)-1] = '\0';
  3937. modif_p = atcmd_output;
  3938. year = month = day = hour = minute = 0;
  3939. while (modif_p[0] != '\0') {
  3940. value = atoi(modif_p);
  3941. if (value == 0)
  3942. modif_p++;
  3943. else {
  3944. if (modif_p[0] == '-' || modif_p[0] == '+')
  3945. modif_p++;
  3946. while (modif_p[0] >= '0' && modif_p[0] <= '9')
  3947. modif_p++;
  3948. if (modif_p[0] == 'n') {
  3949. minute = value;
  3950. modif_p++;
  3951. } else if (modif_p[0] == 'm' && modif_p[1] == 'n') {
  3952. minute = value;
  3953. modif_p = modif_p + 2;
  3954. } else if (modif_p[0] == 'h') {
  3955. hour = value;
  3956. modif_p++;
  3957. } else if (modif_p[0] == 'd' || modif_p[0] == 'j') {
  3958. day = value;
  3959. modif_p++;
  3960. } else if (modif_p[0] == 'm') {
  3961. month = value;
  3962. modif_p++;
  3963. } else if (modif_p[0] == 'y' || modif_p[0] == 'a') {
  3964. year = value;
  3965. modif_p++;
  3966. } else if (modif_p[0] != '\0') {
  3967. modif_p++;
  3968. }
  3969. }
  3970. }
  3971. if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) {
  3972. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  3973. return -1;
  3974. }
  3975. if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) {
  3976. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  3977. return -1;
  3978. }
  3979. if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  3980. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  3981. return -1;
  3982. }
  3983. jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes
  3984. if(jailtime==0) {
  3985. clif_displaymessage(fd, msg_txt(sd,1136)); // Invalid time for jail command.
  3986. return -1;
  3987. }
  3988. //Added by Coltaro
  3989. if(pl_sd->sc.data[SC_JAILED] &&
  3990. pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX)
  3991. { //Update the player's jail time
  3992. jailtime += pl_sd->sc.data[SC_JAILED]->val1;
  3993. if (jailtime <= 0) {
  3994. jailtime = 0;
  3995. clif_displaymessage(pl_sd->fd, msg_txt(sd,120)); // GM has discharge you.
  3996. clif_displaymessage(fd, msg_txt(sd,121)); // Player unjailed
  3997. } else {
  3998. get_jail_time(jailtime,&year,&month,&day,&hour,&minute);
  3999. 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
  4000. clif_displaymessage(pl_sd->fd, atcmd_output);
  4001. 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
  4002. clif_displaymessage(fd, atcmd_output);
  4003. }
  4004. } else if (jailtime < 0) {
  4005. clif_displaymessage(fd, msg_txt(sd,1136));
  4006. return -1;
  4007. }
  4008. //Jail locations, add more as you wish.
  4009. switch(rnd()%2)
  4010. {
  4011. case 1: //Jail #1
  4012. m_index = mapindex_name2id(MAP_JAIL);
  4013. x = 49; y = 75;
  4014. break;
  4015. default: //Default Jail
  4016. m_index = mapindex_name2id(MAP_JAIL);
  4017. x = 24; y = 75;
  4018. break;
  4019. }
  4020. 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).
  4021. return 0;
  4022. }
  4023. //By Coltaro
  4024. ACMD_FUNC(jailtime)
  4025. {
  4026. int year, month, day, hour, minute;
  4027. nullpo_retr(-1, sd);
  4028. if (!sd->sc.data[SC_JAILED]) {
  4029. clif_displaymessage(fd, msg_txt(sd,1139)); // You are not in jail.
  4030. return -1;
  4031. }
  4032. if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) {
  4033. clif_displaymessage(fd, msg_txt(sd,1140)); // You have been jailed indefinitely.
  4034. return 0;
  4035. }
  4036. if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?)
  4037. clif_displaymessage(fd, msg_txt(sd,1141)); // You have been jailed for an unknown amount of time.
  4038. return -1;
  4039. }
  4040. //Get remaining jail time
  4041. get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute);
  4042. 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
  4043. clif_displaymessage(fd, atcmd_output);
  4044. return 0;
  4045. }
  4046. /*==========================================
  4047. * @disguise <mob_id> by [Valaris] (simplified by [Yor])
  4048. *------------------------------------------*/
  4049. ACMD_FUNC(disguise)
  4050. {
  4051. int id = 0;
  4052. nullpo_retr(-1, sd);
  4053. if (!message || !*message) {
  4054. clif_displaymessage(fd, msg_txt(sd,1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>).
  4055. return -1;
  4056. }
  4057. if ((id = atoi(message)) > 0)
  4058. { //Acquired an ID
  4059. if (!mobdb_checkid(id) && !npcdb_checkid(id))
  4060. id = 0; //Invalid id for either mobs or npcs.
  4061. } else { //Acquired a Name
  4062. if ((id = mobdb_searchname(message)) == 0)
  4063. {
  4064. struct npc_data* nd = npc_name2id(message);
  4065. if (nd != NULL)
  4066. id = nd->class_;
  4067. }
  4068. }
  4069. if (id == 0)
  4070. {
  4071. clif_displaymessage(fd, msg_txt(sd,123)); // Invalid Monster/NPC name/ID specified.
  4072. return -1;
  4073. }
  4074. if(pc_isriding(sd))
  4075. {
  4076. clif_displaymessage(fd, msg_txt(sd,1144)); // Character cannot be disguised while mounted.
  4077. return -1;
  4078. }
  4079. pc_disguise(sd, id);
  4080. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4081. return 0;
  4082. }
  4083. /*==========================================
  4084. * DisguiseAll
  4085. *------------------------------------------*/
  4086. ACMD_FUNC(disguiseall)
  4087. {
  4088. int mob_id=0;
  4089. struct map_session_data *pl_sd;
  4090. struct s_mapiterator* iter;
  4091. nullpo_retr(-1, sd);
  4092. if (!message || !*message) {
  4093. clif_displaymessage(fd, msg_txt(sd,1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>).
  4094. return -1;
  4095. }
  4096. if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
  4097. mob_id = atoi(message);
  4098. if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
  4099. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id not found.
  4100. return -1;
  4101. }
  4102. iter = mapit_getallusers();
  4103. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4104. pc_disguise(pl_sd, mob_id);
  4105. mapit_free(iter);
  4106. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4107. return 0;
  4108. }
  4109. /*==========================================
  4110. * DisguiseGuild
  4111. *------------------------------------------*/
  4112. ACMD_FUNC(disguiseguild)
  4113. {
  4114. int id = 0, i;
  4115. char monster[NAME_LENGTH], guild[NAME_LENGTH];
  4116. struct map_session_data *pl_sd;
  4117. struct guild *g;
  4118. memset(monster, '\0', sizeof(monster));
  4119. memset(guild, '\0', sizeof(guild));
  4120. if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild) < 2 ) {
  4121. 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>).
  4122. return -1;
  4123. }
  4124. if( (id = atoi(monster)) > 0 ) {
  4125. if( !mobdb_checkid(id) && !npcdb_checkid(id) )
  4126. id = 0;
  4127. } else {
  4128. if( (id = mobdb_searchname(monster)) == 0 ) {
  4129. struct npc_data* nd = npc_name2id(monster);
  4130. if( nd != NULL )
  4131. id = nd->class_;
  4132. }
  4133. }
  4134. if( id == 0 ) {
  4135. clif_displaymessage(fd, msg_txt(sd,123)); // Monster/NPC name/id hasn't been found.
  4136. return -1;
  4137. }
  4138. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  4139. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4140. return -1;
  4141. }
  4142. for( i = 0; i < g->max_member; i++ )
  4143. if( (pl_sd = g->member[i].sd) && !pc_isriding(pl_sd) )
  4144. pc_disguise(pl_sd, id);
  4145. clif_displaymessage(fd, msg_txt(sd,122)); // Disguise applied.
  4146. return 0;
  4147. }
  4148. /*==========================================
  4149. * @undisguise by [Yor]
  4150. *------------------------------------------*/
  4151. ACMD_FUNC(undisguise)
  4152. {
  4153. nullpo_retr(-1, sd);
  4154. if (sd->disguise) {
  4155. pc_disguise(sd, 0);
  4156. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4157. } else {
  4158. clif_displaymessage(fd, msg_txt(sd,125)); // You're not disguised.
  4159. return -1;
  4160. }
  4161. return 0;
  4162. }
  4163. /*==========================================
  4164. * UndisguiseAll
  4165. *------------------------------------------*/
  4166. ACMD_FUNC(undisguiseall)
  4167. {
  4168. struct map_session_data *pl_sd;
  4169. struct s_mapiterator* iter;
  4170. nullpo_retr(-1, sd);
  4171. iter = mapit_getallusers();
  4172. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
  4173. if( pl_sd->disguise )
  4174. pc_disguise(pl_sd, 0);
  4175. mapit_free(iter);
  4176. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4177. return 0;
  4178. }
  4179. /*==========================================
  4180. * UndisguiseGuild
  4181. *------------------------------------------*/
  4182. ACMD_FUNC(undisguiseguild)
  4183. {
  4184. char guild_name[NAME_LENGTH];
  4185. struct map_session_data *pl_sd;
  4186. struct guild *g;
  4187. int i;
  4188. nullpo_retr(-1, sd);
  4189. memset(guild_name, '\0', sizeof(guild_name));
  4190. if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) {
  4191. clif_displaymessage(fd, msg_txt(sd,1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>).
  4192. return -1;
  4193. }
  4194. if( (g = guild_searchname(guild_name)) == NULL && (g = guild_search(atoi(message))) == NULL ) {
  4195. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  4196. return -1;
  4197. }
  4198. for(i = 0; i < g->max_member; i++)
  4199. if( (pl_sd = g->member[i].sd) && pl_sd->disguise )
  4200. pc_disguise(pl_sd, 0);
  4201. clif_displaymessage(fd, msg_txt(sd,124)); // Undisguise applied.
  4202. return 0;
  4203. }
  4204. /*==========================================
  4205. * @exp by [Skotlex]
  4206. *------------------------------------------*/
  4207. ACMD_FUNC(exp)
  4208. {
  4209. char output[CHAT_SIZE_MAX];
  4210. double nextb, nextj;
  4211. nullpo_retr(-1, sd);
  4212. memset(output, '\0', sizeof(output));
  4213. nextb = pc_nextbaseexp(sd);
  4214. if (nextb)
  4215. nextb = sd->status.base_exp*100.0/nextb;
  4216. nextj = pc_nextjobexp(sd);
  4217. if (nextj)
  4218. nextj = sd->status.job_exp*100.0/nextj;
  4219. sprintf(output, msg_txt(sd,1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%)
  4220. clif_displaymessage(fd, output);
  4221. return 0;
  4222. }
  4223. /*==========================================
  4224. * @broadcast by [Valaris]
  4225. *------------------------------------------*/
  4226. ACMD_FUNC(broadcast)
  4227. {
  4228. nullpo_retr(-1, sd);
  4229. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4230. if (!message || !*message) {
  4231. clif_displaymessage(fd, msg_txt(sd,1149)); // Please enter a message (usage: @broadcast <message>).
  4232. return -1;
  4233. }
  4234. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4235. intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0);
  4236. return 0;
  4237. }
  4238. /*==========================================
  4239. * @localbroadcast by [Valaris]
  4240. *------------------------------------------*/
  4241. ACMD_FUNC(localbroadcast)
  4242. {
  4243. nullpo_retr(-1, sd);
  4244. memset(atcmd_output, '\0', sizeof(atcmd_output));
  4245. if (!message || !*message) {
  4246. clif_displaymessage(fd, msg_txt(sd,1150)); // Please enter a message (usage: @localbroadcast <message>).
  4247. return -1;
  4248. }
  4249. sprintf(atcmd_output, "%s: %s", sd->status.name, message);
  4250. clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, 0, ALL_SAMEMAP);
  4251. return 0;
  4252. }
  4253. /*==========================================
  4254. * @email <actual@email> <new@email> by [Yor]
  4255. *------------------------------------------*/
  4256. ACMD_FUNC(email)
  4257. {
  4258. char actual_email[100];
  4259. char new_email[100];
  4260. nullpo_retr(-1, sd);
  4261. memset(actual_email, '\0', sizeof(actual_email));
  4262. memset(new_email, '\0', sizeof(new_email));
  4263. if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) {
  4264. clif_displaymessage(fd, msg_txt(sd,1151)); // Please enter 2 emails (usage: @email <actual@email> <new@email>).
  4265. return -1;
  4266. }
  4267. if (e_mail_check(actual_email) == 0) {
  4268. clif_displaymessage(fd, msg_txt(sd,144)); // Invalid actual email. If you have default e-mail, give a@a.com.
  4269. return -1;
  4270. } else if (e_mail_check(new_email) == 0) {
  4271. clif_displaymessage(fd, msg_txt(sd,145)); // Invalid new email. Please enter a real e-mail.
  4272. return -1;
  4273. } else if (strcmpi(new_email, "a@a.com") == 0) {
  4274. clif_displaymessage(fd, msg_txt(sd,146)); // New email must be a real e-mail.
  4275. return -1;
  4276. } else if (strcmpi(actual_email, new_email) == 0) {
  4277. clif_displaymessage(fd, msg_txt(sd,147)); // New email must be different of the actual e-mail.
  4278. return -1;
  4279. }
  4280. chrif_changeemail(sd->status.account_id, actual_email, new_email);
  4281. clif_displaymessage(fd, msg_txt(sd,148)); // Information sended to login-server via char-server.
  4282. return 0;
  4283. }
  4284. /*==========================================
  4285. *@effect
  4286. *------------------------------------------*/
  4287. ACMD_FUNC(effect)
  4288. {
  4289. int type = 0, flag = 0;
  4290. nullpo_retr(-1, sd);
  4291. if (!message || !*message || sscanf(message, "%d", &type) < 1) {
  4292. clif_displaymessage(fd, msg_txt(sd,1152)); // Please enter an effect number (usage: @effect <effect number>).
  4293. return -1;
  4294. }
  4295. clif_specialeffect(&sd->bl, type, (send_target)flag);
  4296. clif_displaymessage(fd, msg_txt(sd,229)); // Your effect has changed.
  4297. return 0;
  4298. }
  4299. /*==========================================
  4300. * @killer by MouseJstr
  4301. * enable killing players even when not in pvp
  4302. *------------------------------------------*/
  4303. ACMD_FUNC(killer)
  4304. {
  4305. nullpo_retr(-1, sd);
  4306. sd->state.killer = !sd->state.killer;
  4307. if(sd->state.killer)
  4308. clif_displaymessage(fd, msg_txt(sd,241));
  4309. else {
  4310. clif_displaymessage(fd, msg_txt(sd,292));
  4311. pc_stop_attack(sd);
  4312. }
  4313. return 0;
  4314. }
  4315. /*==========================================
  4316. * @killable by MouseJstr
  4317. * enable other people killing you
  4318. *------------------------------------------*/
  4319. ACMD_FUNC(killable)
  4320. {
  4321. nullpo_retr(-1, sd);
  4322. sd->state.killable = !sd->state.killable;
  4323. if(sd->state.killable)
  4324. clif_displaymessage(fd, msg_txt(sd,242));
  4325. else {
  4326. clif_displaymessage(fd, msg_txt(sd,288));
  4327. map_foreachinrange(atcommand_stopattack,&sd->bl, AREA_SIZE, BL_CHAR, sd->bl.id);
  4328. }
  4329. return 0;
  4330. }
  4331. /*==========================================
  4332. * @skillon by MouseJstr
  4333. * turn skills on for the map
  4334. *------------------------------------------*/
  4335. ACMD_FUNC(skillon)
  4336. {
  4337. nullpo_retr(-1, sd);
  4338. map[sd->bl.m].flag.noskill = 0;
  4339. clif_displaymessage(fd, msg_txt(sd,244));
  4340. return 0;
  4341. }
  4342. /*==========================================
  4343. * @skilloff by MouseJstr
  4344. * Turn skills off on the map
  4345. *------------------------------------------*/
  4346. ACMD_FUNC(skilloff)
  4347. {
  4348. nullpo_retr(-1, sd);
  4349. map[sd->bl.m].flag.noskill = 1;
  4350. clif_displaymessage(fd, msg_txt(sd,243));
  4351. return 0;
  4352. }
  4353. /*==========================================
  4354. * @npcmove by MouseJstr
  4355. * move a npc
  4356. *------------------------------------------*/
  4357. ACMD_FUNC(npcmove)
  4358. {
  4359. int x = 0, y = 0, m;
  4360. struct npc_data *nd = 0;
  4361. nullpo_retr(-1, sd);
  4362. memset(atcmd_player_name, '\0', sizeof atcmd_player_name);
  4363. if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) {
  4364. clif_displaymessage(fd, msg_txt(sd,1153)); // Usage: @npcmove <X> <Y> <npc_name>
  4365. return -1;
  4366. }
  4367. if ((nd = npc_name2id(atcmd_player_name)) == NULL)
  4368. {
  4369. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
  4370. return -1;
  4371. }
  4372. if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL)
  4373. {
  4374. clif_displaymessage(fd, msg_txt(sd,1154)); // NPC is not on this map.
  4375. return -1; //Not on a map.
  4376. }
  4377. x = cap_value(x, 0, map[m].xs-1);
  4378. y = cap_value(y, 0, map[m].ys-1);
  4379. map_foreachinrange(clif_outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4380. map_moveblock(&nd->bl, x, y, gettick());
  4381. map_foreachinrange(clif_insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl);
  4382. clif_displaymessage(fd, msg_txt(sd,1155)); // NPC moved.
  4383. return 0;
  4384. }
  4385. /*==========================================
  4386. * @addwarp by MouseJstr
  4387. * Create a new static warp point.
  4388. *------------------------------------------*/
  4389. ACMD_FUNC(addwarp)
  4390. {
  4391. char mapname[32], warpname[NAME_LENGTH+1];
  4392. int x,y;
  4393. unsigned short m;
  4394. struct npc_data* nd;
  4395. nullpo_retr(-1, sd);
  4396. memset(warpname, '\0', sizeof(warpname));
  4397. if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) {
  4398. clif_displaymessage(fd, msg_txt(sd,1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name>
  4399. return -1;
  4400. }
  4401. m = mapindex_name2id(mapname);
  4402. if( m == 0 )
  4403. {
  4404. sprintf(atcmd_output, msg_txt(sd,1157), mapname); // Unknown map '%s'.
  4405. clif_displaymessage(fd, atcmd_output);
  4406. return -1;
  4407. }
  4408. nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
  4409. if( nd == NULL )
  4410. return -1;
  4411. sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
  4412. clif_displaymessage(fd, atcmd_output);
  4413. return 0;
  4414. }
  4415. /*==========================================
  4416. * @follow by [MouseJstr]
  4417. * Follow a player .. staying no more then 5 spaces away
  4418. *------------------------------------------*/
  4419. ACMD_FUNC(follow)
  4420. {
  4421. struct map_session_data *pl_sd = NULL;
  4422. nullpo_retr(-1, sd);
  4423. if (!message || !*message) {
  4424. if (sd->followtarget == -1)
  4425. return -1;
  4426. pc_stop_following (sd);
  4427. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4428. return 0;
  4429. }
  4430. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  4431. {
  4432. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4433. return -1;
  4434. }
  4435. if (sd->followtarget == pl_sd->bl.id) {
  4436. pc_stop_following (sd);
  4437. clif_displaymessage(fd, msg_txt(sd,1159)); // Follow mode OFF.
  4438. } else {
  4439. pc_follow(sd, pl_sd->bl.id);
  4440. clif_displaymessage(fd, msg_txt(sd,1160)); // Follow mode ON.
  4441. }
  4442. return 0;
  4443. }
  4444. /*==========================================
  4445. * @dropall by [MouseJstr]
  4446. * Drop all your possession on the ground
  4447. *------------------------------------------*/
  4448. ACMD_FUNC(dropall)
  4449. {
  4450. int i;
  4451. nullpo_retr(-1, sd);
  4452. for (i = 0; i < MAX_INVENTORY; i++) {
  4453. if (sd->status.inventory[i].amount) {
  4454. if(sd->status.inventory[i].equip != 0)
  4455. pc_unequipitem(sd, i, 3);
  4456. pc_dropitem(sd, i, sd->status.inventory[i].amount);
  4457. }
  4458. }
  4459. return 0;
  4460. }
  4461. /*==========================================
  4462. * @storeall by [MouseJstr]
  4463. * Put everything into storage
  4464. *------------------------------------------*/
  4465. ACMD_FUNC(storeall)
  4466. {
  4467. int i;
  4468. nullpo_retr(-1, sd);
  4469. if (sd->state.storage_flag != 1)
  4470. { //Open storage.
  4471. if( storage_storageopen(sd) == 1 ) {
  4472. clif_displaymessage(fd, msg_txt(sd,1161)); // You currently cannot open your storage.
  4473. return -1;
  4474. }
  4475. }
  4476. for (i = 0; i < MAX_INVENTORY; i++) {
  4477. if (sd->status.inventory[i].amount) {
  4478. if(sd->status.inventory[i].equip != 0)
  4479. pc_unequipitem(sd, i, 3);
  4480. storage_storageadd(sd, i, sd->status.inventory[i].amount);
  4481. }
  4482. }
  4483. storage_storageclose(sd);
  4484. clif_displaymessage(fd, msg_txt(sd,1162)); // All items stored.
  4485. return 0;
  4486. }
  4487. ACMD_FUNC(clearstorage)
  4488. {
  4489. int i, j;
  4490. nullpo_retr(-1, sd);
  4491. if (sd->state.storage_flag == 1) {
  4492. clif_displaymessage(fd, msg_txt(sd,250));
  4493. return -1;
  4494. }
  4495. j = sd->status.storage.storage_amount;
  4496. for (i = 0; i < j; ++i) {
  4497. storage_delitem(sd, i, sd->status.storage.items[i].amount);
  4498. }
  4499. storage_storageclose(sd);
  4500. clif_displaymessage(fd, msg_txt(sd,1394)); // Your storage was cleaned.
  4501. return 0;
  4502. }
  4503. ACMD_FUNC(cleargstorage)
  4504. {
  4505. int i, j;
  4506. struct guild *g;
  4507. struct guild_storage *gstorage;
  4508. nullpo_retr(-1, sd);
  4509. g = sd->guild;
  4510. if (g == NULL) {
  4511. clif_displaymessage(fd, msg_txt(sd,43));
  4512. return -1;
  4513. }
  4514. if (sd->state.storage_flag == 1) {
  4515. clif_displaymessage(fd, msg_txt(sd,250));
  4516. return -1;
  4517. }
  4518. if (sd->state.storage_flag == 2) {
  4519. clif_displaymessage(fd, msg_txt(sd,251));
  4520. return -1;
  4521. }
  4522. gstorage = guild2storage2(sd->status.guild_id);
  4523. if (gstorage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
  4524. return -1;
  4525. }
  4526. j = gstorage->storage_amount;
  4527. gstorage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member
  4528. for (i = 0; i < j; ++i) {
  4529. guild_storage_delitem(sd, gstorage, i, gstorage->items[i].amount);
  4530. }
  4531. storage_guild_storageclose(sd);
  4532. gstorage->lock = 0; // Cleaning done, release lock
  4533. clif_displaymessage(fd, msg_txt(sd,1395)); // Your guild storage was cleaned.
  4534. return 0;
  4535. }
  4536. ACMD_FUNC(clearcart)
  4537. {
  4538. int i;
  4539. nullpo_retr(-1, sd);
  4540. if (pc_iscarton(sd) == 0) {
  4541. clif_displaymessage(fd, msg_txt(sd,1396)); // You do not have a cart to be cleaned.
  4542. return -1;
  4543. }
  4544. if (sd->state.vending == 1) { //Somehow...
  4545. return -1;
  4546. }
  4547. for( i = 0; i < MAX_CART; i++ )
  4548. if(sd->status.cart[i].nameid > 0)
  4549. pc_cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER);
  4550. clif_clearcart(fd);
  4551. clif_updatestatus(sd,SP_CARTINFO);
  4552. clif_displaymessage(fd, msg_txt(sd,1397)); // Your cart was cleaned.
  4553. return 0;
  4554. }
  4555. /*==========================================
  4556. * @skillid by [MouseJstr]
  4557. * lookup a skill by name
  4558. *------------------------------------------*/
  4559. #define MAX_SKILLID_PARTIAL_RESULTS 5
  4560. #define MAX_SKILLID_PARTIAL_RESULTS_LEN 74 // "skill " (6) + "%d:" (up to 5) + "%s" (up to 30) + " (%s)" (up to 33)
  4561. ACMD_FUNC(skillid) {
  4562. int skillen, idx, i, found = 0;
  4563. DBIterator* iter;
  4564. DBKey key;
  4565. DBData *data;
  4566. char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN];
  4567. nullpo_retr(-1, sd);
  4568. if (!message || !*message) {
  4569. clif_displaymessage(fd, msg_txt(sd,1163)); // Please enter a skill name to look up (usage: @skillid <skill name>).
  4570. return -1;
  4571. }
  4572. skillen = strlen(message);
  4573. iter = db_iterator(skilldb_name2id);
  4574. for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
  4575. idx = skill_get_index(db_data2i(data));
  4576. if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill_db[idx].desc, message, skillen) == 0) {
  4577. sprintf(atcmd_output, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str); // skill %d: %s (%s)
  4578. clif_displaymessage(fd, atcmd_output);
  4579. } else if ( found < MAX_SKILLID_PARTIAL_RESULTS && ( stristr(key.str,message) || stristr(skill_db[idx].desc,message) ) ) {
  4580. snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(sd,1164), db_data2i(data), skill_db[idx].desc, key.str);
  4581. }
  4582. }
  4583. dbi_destroy(iter);
  4584. if( found ) {
  4585. sprintf(atcmd_output, msg_txt(sd,1398), found); // -- Displaying first %d partial matches
  4586. clif_displaymessage(fd, atcmd_output);
  4587. }
  4588. for(i = 0; i < found; i++) { /* partials */
  4589. clif_displaymessage(fd, partials[i]);
  4590. }
  4591. return 0;
  4592. }
  4593. /*==========================================
  4594. * @useskill by [MouseJstr]
  4595. * A way of using skills without having to find them in the skills menu
  4596. *------------------------------------------*/
  4597. ACMD_FUNC(useskill)
  4598. {
  4599. struct map_session_data *pl_sd = NULL;
  4600. struct block_list *bl;
  4601. uint16 skill_id;
  4602. uint16 skill_lv;
  4603. char target[100];
  4604. nullpo_retr(-1, sd);
  4605. if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) {
  4606. clif_displaymessage(fd, msg_txt(sd,1165)); // Usage: @useskill <skill ID> <skill level> <target>
  4607. return -1;
  4608. }
  4609. if(!strcmp(target,"self")) pl_sd = sd; //quick keyword
  4610. else if ( (pl_sd = map_nick2sd(target)) == NULL ){
  4611. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4612. return -1;
  4613. }
  4614. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  4615. {
  4616. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  4617. return -1;
  4618. }
  4619. if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL
  4620. && sd->hd && merc_is_hom_active(sd->hd)) // (If used with @useskill, put the homunc as dest)
  4621. bl = &sd->hd->bl;
  4622. else
  4623. bl = &sd->bl;
  4624. if (skill_get_inf(skill_id)&INF_GROUND_SKILL)
  4625. unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
  4626. else
  4627. unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
  4628. return 0;
  4629. }
  4630. /*==========================================
  4631. * @displayskill by [Skotlex]
  4632. * Debug command to locate new skill IDs. It sends the
  4633. * three possible skill-effect packets to the area.
  4634. *------------------------------------------*/
  4635. ACMD_FUNC(displayskill)
  4636. {
  4637. struct status_data * status;
  4638. unsigned int tick;
  4639. uint16 skill_id;
  4640. uint16 skill_lv = 1;
  4641. nullpo_retr(-1, sd);
  4642. if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1)
  4643. {
  4644. clif_displaymessage(fd, msg_txt(sd,1166)); // Usage: @displayskill <skill ID> {<skill level>}
  4645. return -1;
  4646. }
  4647. status = status_get_status_data(&sd->bl);
  4648. tick = gettick();
  4649. clif_skill_damage(&sd->bl,&sd->bl, tick, status->amotion, status->dmotion, 1, 1, skill_id, skill_lv, 5);
  4650. clif_skill_nodamage(&sd->bl, &sd->bl, skill_id, skill_lv, 1);
  4651. clif_skill_poseffect(&sd->bl, skill_id, skill_lv, sd->bl.x, sd->bl.y, tick);
  4652. return 0;
  4653. }
  4654. /*==========================================
  4655. * @skilltree by [MouseJstr]
  4656. * prints the skill tree for a player required to get to a skill
  4657. *------------------------------------------*/
  4658. ACMD_FUNC(skilltree)
  4659. {
  4660. struct map_session_data *pl_sd = NULL;
  4661. uint16 skill_id;
  4662. int meets, j, c=0;
  4663. char target[NAME_LENGTH];
  4664. struct skill_tree_entry *ent;
  4665. nullpo_retr(-1, sd);
  4666. if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) {
  4667. clif_displaymessage(fd, msg_txt(sd,1167)); // Usage: @skilltree <skill ID> <target>
  4668. return -1;
  4669. }
  4670. if ( (pl_sd = map_nick2sd(target)) == NULL )
  4671. {
  4672. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  4673. return -1;
  4674. }
  4675. c = pc_calc_skilltree_normalize_job(pl_sd);
  4676. c = pc_mapid2jobid(c, pl_sd->status.sex);
  4677. 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).
  4678. clif_displaymessage(fd, atcmd_output);
  4679. ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[c][j].id == 0 || skill_tree[c][j].id == skill_id );
  4680. if( j == MAX_SKILL_TREE || skill_tree[c][j].id == 0 )
  4681. {
  4682. clif_displaymessage(fd, msg_txt(sd,1169)); // The player cannot use that skill.
  4683. return 0;
  4684. }
  4685. ent = &skill_tree[c][j];
  4686. meets = 1;
  4687. for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
  4688. {
  4689. if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
  4690. {
  4691. 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.
  4692. clif_displaymessage(fd, atcmd_output);
  4693. meets = 0;
  4694. }
  4695. }
  4696. if (meets == 1) {
  4697. clif_displaymessage(fd, msg_txt(sd,1171)); // The player meets all the requirements for that skill.
  4698. }
  4699. return 0;
  4700. }
  4701. // Hand a ring with partners name on it to this char
  4702. void getring (struct map_session_data* sd)
  4703. {
  4704. int flag, item_id;
  4705. struct item item_tmp;
  4706. item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F;
  4707. memset(&item_tmp, 0, sizeof(item_tmp));
  4708. item_tmp.nameid = item_id;
  4709. item_tmp.identify = 1;
  4710. item_tmp.card[0] = 255;
  4711. item_tmp.card[2] = sd->status.partner_id;
  4712. item_tmp.card[3] = sd->status.partner_id >> 16;
  4713. if((flag = pc_additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) {
  4714. clif_additem(sd,0,0,flag);
  4715. map_addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,4);
  4716. }
  4717. }
  4718. /*==========================================
  4719. * @marry by [MouseJstr], fixed by Lupus
  4720. * Marry two players
  4721. *------------------------------------------*/
  4722. ACMD_FUNC(marry)
  4723. {
  4724. struct map_session_data *pl_sd = NULL;
  4725. char player_name[NAME_LENGTH] = "";
  4726. nullpo_retr(-1, sd);
  4727. if (!message || !*message || sscanf(message, "%23s", player_name) != 1) {
  4728. clif_displaymessage(fd, msg_txt(sd,1172)); // Usage: @marry <char name>
  4729. return -1;
  4730. }
  4731. if ((pl_sd = map_nick2sd(player_name)) == NULL) {
  4732. clif_displaymessage(fd, msg_txt(sd,3));
  4733. return -1;
  4734. }
  4735. if (pc_marriage(sd, pl_sd) == 0) {
  4736. clif_displaymessage(fd, msg_txt(sd,1173)); // They are married... wish them well.
  4737. clif_wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus]
  4738. getring(sd); // Auto-give named rings (Aru)
  4739. getring(pl_sd);
  4740. return 0;
  4741. }
  4742. clif_displaymessage(fd, msg_txt(sd,1174)); // The two cannot wed because one is either a baby or already married.
  4743. return -1;
  4744. }
  4745. /*==========================================
  4746. * @divorce by [MouseJstr], fixed by [Lupus]
  4747. * divorce two players
  4748. *------------------------------------------*/
  4749. ACMD_FUNC(divorce)
  4750. {
  4751. nullpo_retr(-1, sd);
  4752. if (pc_divorce(sd) != 0) {
  4753. sprintf(atcmd_output, msg_txt(sd,1175), sd->status.name); // '%s' is not married.
  4754. clif_displaymessage(fd, atcmd_output);
  4755. return -1;
  4756. }
  4757. sprintf(atcmd_output, msg_txt(sd,1176), sd->status.name); // '%s' and his/her partner are now divorced.
  4758. clif_displaymessage(fd, atcmd_output);
  4759. return 0;
  4760. }
  4761. /*==========================================
  4762. * @changelook by [Celest]
  4763. *------------------------------------------*/
  4764. ACMD_FUNC(changelook)
  4765. {
  4766. int i, j = 0, k = 0;
  4767. int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE };
  4768. if((i = sscanf(message, "%d %d", &j, &k)) < 1) {
  4769. clif_displaymessage(fd, msg_txt(sd,1177)); // Usage: @changelook {<position>} <view id>
  4770. clif_displaymessage(fd, msg_txt(sd,1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe
  4771. return -1;
  4772. } else if ( i == 2 ) {
  4773. if (j < 1 || j > 7)
  4774. j = 1;
  4775. j = pos[j - 1];
  4776. } else if( i == 1 ) { // position not defined, use HEAD_TOP as default
  4777. k = j; // swap
  4778. j = LOOK_HEAD_TOP;
  4779. }
  4780. clif_changelook(&sd->bl,j,k);
  4781. return 0;
  4782. }
  4783. /*==========================================
  4784. * @autotrade by durf [Lupus] [Paradox924X]
  4785. * Turns on/off Autotrade for a specific player
  4786. *------------------------------------------*/
  4787. ACMD_FUNC(autotrade) {
  4788. nullpo_retr(-1, sd);
  4789. if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
  4790. clif_displaymessage(fd, msg_txt(sd,1179)); // Autotrade is not allowed on this map.
  4791. return -1;
  4792. }
  4793. if( pc_isdead(sd) ) {
  4794. clif_displaymessage(fd, msg_txt(sd,1180)); // You cannot autotrade when dead.
  4795. return -1;
  4796. }
  4797. if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
  4798. clif_displaymessage(fd, msg_txt(sd,549)); // "You should have a shop open to use @autotrade."
  4799. return -1;
  4800. }
  4801. sd->state.autotrade = 1;
  4802. if( battle_config.at_timeout ) {
  4803. int timeout = atoi(message);
  4804. 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);
  4805. }
  4806. channel_pcquit(sd,0xF); //leave all chan
  4807. clif_authfail_fd(sd->fd, 15);
  4808. return 0;
  4809. }
  4810. /*==========================================
  4811. * @changegm by durf (changed by Lupus)
  4812. * Changes Master of your Guild to a specified guild member
  4813. *------------------------------------------*/
  4814. ACMD_FUNC(changegm)
  4815. {
  4816. struct guild *g;
  4817. struct map_session_data *pl_sd;
  4818. nullpo_retr(-1, sd);
  4819. if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) {
  4820. clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
  4821. return -1;
  4822. }
  4823. if( map[sd->bl.m].flag.guildlock || map[sd->bl.m].flag.gvg_castle ) {
  4824. clif_displaymessage(fd, msg_txt(sd,1182)); // You cannot change guild leaders on this map.
  4825. return -1;
  4826. }
  4827. if( !message[0] ) {
  4828. clif_displaymessage(fd, msg_txt(sd,1183)); // Usage: @changegm <guild_member_name>
  4829. return -1;
  4830. }
  4831. if((pl_sd=map_nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
  4832. clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
  4833. return -1;
  4834. }
  4835. guild_gm_change(sd->status.guild_id, pl_sd);
  4836. return 0;
  4837. }
  4838. /*==========================================
  4839. * @changeleader by Skotlex
  4840. * Changes the leader of a party.
  4841. *------------------------------------------*/
  4842. ACMD_FUNC(changeleader)
  4843. {
  4844. nullpo_retr(-1, sd);
  4845. if( !message[0] )
  4846. {
  4847. clif_displaymessage(fd, msg_txt(sd,1185)); // Usage: @changeleader <party_member_name>
  4848. return -1;
  4849. }
  4850. if (party_changeleader(sd, map_nick2sd((char *) message)))
  4851. return 0;
  4852. return -1;
  4853. }
  4854. /*==========================================
  4855. * @partyoption by Skotlex
  4856. * Used to change the item share setting of a party.
  4857. *------------------------------------------*/
  4858. ACMD_FUNC(partyoption)
  4859. {
  4860. struct party_data *p;
  4861. int mi, option;
  4862. char w1[16], w2[16];
  4863. nullpo_retr(-1, sd);
  4864. if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
  4865. {
  4866. clif_displaymessage(fd, msg_txt(sd,282));
  4867. return -1;
  4868. }
  4869. ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
  4870. if (mi == MAX_PARTY)
  4871. return -1; //Shouldn't happen
  4872. if (!p->party.member[mi].leader)
  4873. {
  4874. clif_displaymessage(fd, msg_txt(sd,282));
  4875. return -1;
  4876. }
  4877. if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2)
  4878. {
  4879. clif_displaymessage(fd, msg_txt(sd,1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no>
  4880. return -1;
  4881. }
  4882. option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0);
  4883. //Change item share type.
  4884. if (option != p->party.item)
  4885. party_changeoption(sd, p->party.exp, option);
  4886. else
  4887. clif_displaymessage(fd, msg_txt(sd,286));
  4888. return 0;
  4889. }
  4890. /*==========================================
  4891. * @autoloot by Upa-Kun
  4892. * Turns on/off AutoLoot for a specific player
  4893. *------------------------------------------*/
  4894. ACMD_FUNC(autoloot)
  4895. {
  4896. int rate;
  4897. nullpo_retr(-1, sd);
  4898. // autoloot command without value
  4899. if(!message || !*message)
  4900. {
  4901. if (sd->state.autoloot)
  4902. rate = 0;
  4903. else
  4904. rate = 10000;
  4905. } else {
  4906. double drate;
  4907. drate = atof(message);
  4908. rate = (int)(drate*100);
  4909. }
  4910. if (rate < 0) rate = 0;
  4911. if (rate > 10000) rate = 10000;
  4912. sd->state.autoloot = rate;
  4913. if (sd->state.autoloot) {
  4914. 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.
  4915. clif_displaymessage(fd, atcmd_output);
  4916. }else
  4917. clif_displaymessage(fd, msg_txt(sd,1188)); // Autoloot is now off.
  4918. return 0;
  4919. }
  4920. /*==========================================
  4921. * @alootid
  4922. *------------------------------------------*/
  4923. ACMD_FUNC(autolootitem)
  4924. {
  4925. struct item_data *item_data = NULL;
  4926. int i;
  4927. int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
  4928. if (message && *message) {
  4929. if (message[0] == '+') {
  4930. message++;
  4931. action = 1;
  4932. }
  4933. else if (message[0] == '-') {
  4934. message++;
  4935. action = 2;
  4936. }
  4937. else if (!strcmp(message,"reset"))
  4938. action = 4;
  4939. }
  4940. if (action < 3) // add or remove
  4941. {
  4942. if ((item_data = itemdb_exists(atoi(message))) == NULL)
  4943. item_data = itemdb_searchname(message);
  4944. if (!item_data) {
  4945. // No items founds in the DB with Id or Name
  4946. clif_displaymessage(fd, msg_txt(sd,1189)); // Item not found.
  4947. return -1;
  4948. }
  4949. }
  4950. switch(action) {
  4951. case 1:
  4952. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4953. if (i != AUTOLOOTITEM_SIZE) {
  4954. clif_displaymessage(fd, msg_txt(sd,1190)); // You're already autolooting this item.
  4955. return -1;
  4956. }
  4957. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
  4958. if (i == AUTOLOOTITEM_SIZE) {
  4959. clif_displaymessage(fd, msg_txt(sd,1191)); // Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.
  4960. return -1;
  4961. }
  4962. sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
  4963. sprintf(atcmd_output, msg_txt(sd,1192), item_data->name, item_data->jname, item_data->nameid); // Autolooting item: '%s'/'%s' {%d}
  4964. clif_displaymessage(fd, atcmd_output);
  4965. sd->state.autolooting = 1;
  4966. break;
  4967. case 2:
  4968. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  4969. if (i == AUTOLOOTITEM_SIZE) {
  4970. clif_displaymessage(fd, msg_txt(sd,1193)); // You're currently not autolooting this item.
  4971. return -1;
  4972. }
  4973. sd->state.autolootid[i] = 0;
  4974. 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.
  4975. clif_displaymessage(fd, atcmd_output);
  4976. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4977. if (i == AUTOLOOTITEM_SIZE) {
  4978. sd->state.autolooting = 0;
  4979. }
  4980. break;
  4981. case 3:
  4982. sprintf(atcmd_output, msg_txt(sd,1195), AUTOLOOTITEM_SIZE); // You can have %d items on your autolootitem list.
  4983. clif_displaymessage(fd, atcmd_output);
  4984. 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>".
  4985. clif_displaymessage(fd, msg_txt(sd,1197)); // "@alootid reset" will clear your autolootitem list.
  4986. ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
  4987. if (i == AUTOLOOTITEM_SIZE) {
  4988. clif_displaymessage(fd, msg_txt(sd,1198)); // Your autolootitem list is empty.
  4989. } else {
  4990. clif_displaymessage(fd, msg_txt(sd,1199)); // Items on your autolootitem list:
  4991. for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  4992. {
  4993. if (sd->state.autolootid[i] == 0)
  4994. continue;
  4995. if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
  4996. 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);
  4997. continue;
  4998. }
  4999. sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  5000. clif_displaymessage(fd, atcmd_output);
  5001. }
  5002. }
  5003. break;
  5004. case 4:
  5005. memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
  5006. clif_displaymessage(fd, msg_txt(sd,1200)); // Your autolootitem list has been reset.
  5007. sd->state.autolooting = 0;
  5008. break;
  5009. }
  5010. return 0;
  5011. }
  5012. /**
  5013. * No longer available, keeping here just in case it's back someday. [Ind]
  5014. **/
  5015. /*==========================================
  5016. * It is made to rain.
  5017. *------------------------------------------*/
  5018. //ACMD_FUNC(rain)
  5019. //{
  5020. // nullpo_retr(-1, sd);
  5021. // if (map[sd->bl.m].flag.rain) {
  5022. // map[sd->bl.m].flag.rain=0;
  5023. // clif_weather(sd->bl.m);
  5024. // clif_displaymessage(fd, msg_txt(sd,1201)); // The rain has stopped.
  5025. // } else {
  5026. // map[sd->bl.m].flag.rain=1;
  5027. // clif_weather(sd->bl.m);
  5028. // clif_displaymessage(fd, msg_txt(sd,1202)); // It has started to rain.
  5029. // }
  5030. // return 0;
  5031. //}
  5032. /*==========================================
  5033. * It is made to snow.
  5034. *------------------------------------------*/
  5035. ACMD_FUNC(snow)
  5036. {
  5037. nullpo_retr(-1, sd);
  5038. if (map[sd->bl.m].flag.snow) {
  5039. map[sd->bl.m].flag.snow=0;
  5040. clif_weather(sd->bl.m);
  5041. clif_displaymessage(fd, msg_txt(sd,1203)); // Snow has stopped falling.
  5042. } else {
  5043. map[sd->bl.m].flag.snow=1;
  5044. clif_weather(sd->bl.m);
  5045. clif_displaymessage(fd, msg_txt(sd,1204)); // It has started to snow.
  5046. }
  5047. return 0;
  5048. }
  5049. /*==========================================
  5050. * Cherry tree snowstorm is made to fall. (Sakura)
  5051. *------------------------------------------*/
  5052. ACMD_FUNC(sakura)
  5053. {
  5054. nullpo_retr(-1, sd);
  5055. if (map[sd->bl.m].flag.sakura) {
  5056. map[sd->bl.m].flag.sakura=0;
  5057. clif_weather(sd->bl.m);
  5058. clif_displaymessage(fd, msg_txt(sd,1205)); // Cherry tree leaves no longer fall.
  5059. } else {
  5060. map[sd->bl.m].flag.sakura=1;
  5061. clif_weather(sd->bl.m);
  5062. clif_displaymessage(fd, msg_txt(sd,1206)); // Cherry tree leaves have begun to fall.
  5063. }
  5064. return 0;
  5065. }
  5066. /*==========================================
  5067. * Clouds appear.
  5068. *------------------------------------------*/
  5069. ACMD_FUNC(clouds)
  5070. {
  5071. nullpo_retr(-1, sd);
  5072. if (map[sd->bl.m].flag.clouds) {
  5073. map[sd->bl.m].flag.clouds=0;
  5074. clif_weather(sd->bl.m);
  5075. clif_displaymessage(fd, msg_txt(sd,1207)); // The clouds has disappear.
  5076. } else {
  5077. map[sd->bl.m].flag.clouds=1;
  5078. clif_weather(sd->bl.m);
  5079. clif_displaymessage(fd, msg_txt(sd,1208)); // Clouds appear.
  5080. }
  5081. return 0;
  5082. }
  5083. /*==========================================
  5084. * Different type of clouds using effect 516
  5085. *------------------------------------------*/
  5086. ACMD_FUNC(clouds2)
  5087. {
  5088. nullpo_retr(-1, sd);
  5089. if (map[sd->bl.m].flag.clouds2) {
  5090. map[sd->bl.m].flag.clouds2=0;
  5091. clif_weather(sd->bl.m);
  5092. clif_displaymessage(fd, msg_txt(sd,1209)); // The alternative clouds disappear.
  5093. } else {
  5094. map[sd->bl.m].flag.clouds2=1;
  5095. clif_weather(sd->bl.m);
  5096. clif_displaymessage(fd, msg_txt(sd,1210)); // Alternative clouds appear.
  5097. }
  5098. return 0;
  5099. }
  5100. /*==========================================
  5101. * Fog hangs over.
  5102. *------------------------------------------*/
  5103. ACMD_FUNC(fog)
  5104. {
  5105. nullpo_retr(-1, sd);
  5106. if (map[sd->bl.m].flag.fog) {
  5107. map[sd->bl.m].flag.fog=0;
  5108. clif_weather(sd->bl.m);
  5109. clif_displaymessage(fd, msg_txt(sd,1211)); // The fog has gone.
  5110. } else {
  5111. map[sd->bl.m].flag.fog=1;
  5112. clif_weather(sd->bl.m);
  5113. clif_displaymessage(fd, msg_txt(sd,1212)); // Fog hangs over.
  5114. }
  5115. return 0;
  5116. }
  5117. /*==========================================
  5118. * Fallen leaves fall.
  5119. *------------------------------------------*/
  5120. ACMD_FUNC(leaves)
  5121. {
  5122. nullpo_retr(-1, sd);
  5123. if (map[sd->bl.m].flag.leaves) {
  5124. map[sd->bl.m].flag.leaves=0;
  5125. clif_weather(sd->bl.m);
  5126. clif_displaymessage(fd, msg_txt(sd,1213)); // Leaves no longer fall.
  5127. } else {
  5128. map[sd->bl.m].flag.leaves=1;
  5129. clif_weather(sd->bl.m);
  5130. clif_displaymessage(fd, msg_txt(sd,1214)); // Fallen leaves fall.
  5131. }
  5132. return 0;
  5133. }
  5134. /*==========================================
  5135. * Fireworks appear.
  5136. *------------------------------------------*/
  5137. ACMD_FUNC(fireworks)
  5138. {
  5139. nullpo_retr(-1, sd);
  5140. if (map[sd->bl.m].flag.fireworks) {
  5141. map[sd->bl.m].flag.fireworks=0;
  5142. clif_weather(sd->bl.m);
  5143. clif_displaymessage(fd, msg_txt(sd,1215)); // Fireworks have ended.
  5144. } else {
  5145. map[sd->bl.m].flag.fireworks=1;
  5146. clif_weather(sd->bl.m);
  5147. clif_displaymessage(fd, msg_txt(sd,1216)); // Fireworks have launched.
  5148. }
  5149. return 0;
  5150. }
  5151. /*==========================================
  5152. * Clearing Weather Effects by Dexity
  5153. *------------------------------------------*/
  5154. ACMD_FUNC(clearweather)
  5155. {
  5156. nullpo_retr(-1, sd);
  5157. /**
  5158. * No longer available, keeping here just in case it's back someday. [Ind]
  5159. **/
  5160. //map[sd->bl.m].flag.rain=0;
  5161. map[sd->bl.m].flag.snow=0;
  5162. map[sd->bl.m].flag.sakura=0;
  5163. map[sd->bl.m].flag.clouds=0;
  5164. map[sd->bl.m].flag.clouds2=0;
  5165. map[sd->bl.m].flag.fog=0;
  5166. map[sd->bl.m].flag.fireworks=0;
  5167. map[sd->bl.m].flag.leaves=0;
  5168. clif_weather(sd->bl.m);
  5169. clif_displaymessage(fd, msg_txt(sd,291));
  5170. return 0;
  5171. }
  5172. /*===============================================================
  5173. * Sound Command - plays a sound for everyone around! [Codemaster]
  5174. *---------------------------------------------------------------*/
  5175. ACMD_FUNC(sound)
  5176. {
  5177. char sound_file[100];
  5178. memset(sound_file, '\0', sizeof(sound_file));
  5179. if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) {
  5180. clif_displaymessage(fd, msg_txt(sd,1217)); // Please enter a sound filename (usage: @sound <filename>).
  5181. return -1;
  5182. }
  5183. if(strstr(sound_file, ".wav") == NULL)
  5184. strcat(sound_file, ".wav");
  5185. clif_soundeffectall(&sd->bl, sound_file, 0, AREA);
  5186. return 0;
  5187. }
  5188. /*==========================================
  5189. * MOB Search
  5190. *------------------------------------------*/
  5191. ACMD_FUNC(mobsearch)
  5192. {
  5193. char mob_name[100];
  5194. int mob_id;
  5195. int number = 0;
  5196. struct s_mapiterator* it;
  5197. nullpo_retr(-1, sd);
  5198. if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) {
  5199. clif_displaymessage(fd, msg_txt(sd,1218)); // Please enter a monster name (usage: @mobsearch <monster name>).
  5200. return -1;
  5201. }
  5202. if ((mob_id = atoi(mob_name)) == 0)
  5203. mob_id = mobdb_searchname(mob_name);
  5204. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5205. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1219),mob_name); // Invalid mob ID %s!
  5206. clif_displaymessage(fd, atcmd_output);
  5207. return -1;
  5208. }
  5209. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5210. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5211. // strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5212. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
  5213. clif_displaymessage(fd, atcmd_output);
  5214. it = mapit_geteachmob();
  5215. for(;;)
  5216. {
  5217. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5218. if( md == NULL )
  5219. break;// no more mobs
  5220. if( md->bl.m != sd->bl.m )
  5221. continue;
  5222. if( mob_id != -1 && md->class_ != mob_id )
  5223. continue;
  5224. ++number;
  5225. if( md->spawn_timer == INVALID_TIMER )
  5226. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name);
  5227. else
  5228. snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%s] %s", number, "dead", md->name);
  5229. clif_displaymessage(fd, atcmd_output);
  5230. }
  5231. mapit_free(it);
  5232. return 0;
  5233. }
  5234. /*==========================================
  5235. * @cleanmap - cleans items on the ground
  5236. * @cleanarea - cleans items on the ground within an specified area
  5237. *------------------------------------------*/
  5238. static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  5239. {
  5240. nullpo_ret(bl);
  5241. map_clearflooritem(bl);
  5242. return 0;
  5243. }
  5244. ACMD_FUNC(cleanmap)
  5245. {
  5246. map_foreachinmap(atcommand_cleanfloor_sub, sd->bl.m, BL_ITEM);
  5247. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5248. return 0;
  5249. }
  5250. ACMD_FUNC(cleanarea)
  5251. {
  5252. int x0 = 0, y0 = 0, x1 = 0, y1 = 0;
  5253. if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) {
  5254. 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);
  5255. }
  5256. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) {
  5257. 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);
  5258. }
  5259. else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) {
  5260. map_foreachinarea(atcommand_cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM);
  5261. }
  5262. clif_displaymessage(fd, msg_txt(sd,1221)); // All dropped items have been cleaned up.
  5263. return 0;
  5264. }
  5265. /*==========================================
  5266. * make a NPC/PET talk
  5267. * @npctalkc [SnakeDrak]
  5268. *------------------------------------------*/
  5269. ACMD_FUNC(npctalk)
  5270. {
  5271. char name[NAME_LENGTH],mes[100],temp[100];
  5272. struct npc_data *nd;
  5273. bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
  5274. unsigned long color=0;
  5275. if (sd->sc.count && //no "chatting" while muted.
  5276. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5277. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5278. return -1;
  5279. if(!ifcolor) {
  5280. if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) {
  5281. clif_displaymessage(fd, msg_txt(sd,1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>).
  5282. return -1;
  5283. }
  5284. }
  5285. else {
  5286. if (!message || !*message || sscanf(message, "%lx %23[^,], %99[^\n]", &color, name, mes) < 3) {
  5287. clif_displaymessage(fd, msg_txt(sd,1223)); // Please enter the correct parameters (usage: @npctalkc <color> <npc name>, <message>).
  5288. return -1;
  5289. }
  5290. }
  5291. if (!(nd = npc_name2id(name))) {
  5292. clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist
  5293. return -1;
  5294. }
  5295. strtok(name, "#"); // discard extra name identifier if present
  5296. snprintf(temp, sizeof(temp), "%s : %s", name, mes);
  5297. if(ifcolor) clif_messagecolor(&nd->bl,color,temp);
  5298. else clif_disp_overhead(&nd->bl, temp);
  5299. return 0;
  5300. }
  5301. ACMD_FUNC(pettalk)
  5302. {
  5303. char mes[100],temp[100];
  5304. struct pet_data *pd;
  5305. nullpo_retr(-1, sd);
  5306. if ( battle_config.min_chat_delay ) {
  5307. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  5308. return 0;
  5309. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  5310. }
  5311. if(!sd->status.pet_id || !(pd=sd->pd))
  5312. {
  5313. clif_displaymessage(fd, msg_txt(sd,184));
  5314. return -1;
  5315. }
  5316. if (sd->sc.count && //no "chatting" while muted.
  5317. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  5318. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  5319. return -1;
  5320. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  5321. clif_displaymessage(fd, msg_txt(sd,1224)); // Please enter a message (usage: @pettalk <message>).
  5322. return -1;
  5323. }
  5324. if (message[0] == '/')
  5325. {// pet emotion processing
  5326. const char* emo[] = {
  5327. "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...",
  5328. "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2",
  5329. "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg",
  5330. "/kis", "/kis2", "/pif", "/ok", "-?-", "/indonesia", "/bzz", "/rice", "/awsm", "/meh",
  5331. "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/malaysia",
  5332. "/singapore", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", "-dice2",
  5333. "-dice3", "-dice4", "-dice5", "-dice6", "/india", "/love", "/russia", "-?-", "/mobile", "/mail",
  5334. "/chinese", "/antenna1", "/antenna2", "/antenna3", "/hum", "/abs", "/oops", "/spit", "/ene", "/panic",
  5335. "/whisp"
  5336. };
  5337. int i;
  5338. ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 );
  5339. if( i == E_DICE1 ) i = rnd()%6 + E_DICE1; // randomize /dice
  5340. if( i < ARRAYLENGTH(emo) )
  5341. {
  5342. if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
  5343. sd->emotionlasttime = time(NULL);
  5344. return 0;
  5345. }
  5346. sd->emotionlasttime = time(NULL);
  5347. clif_emotion(&pd->bl, i);
  5348. return 0;
  5349. }
  5350. }
  5351. snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes);
  5352. clif_disp_overhead(&pd->bl, temp);
  5353. return 0;
  5354. }
  5355. /// @users - displays the number of players present on each map (and percentage)
  5356. /// #users displays on the target user instead of self
  5357. ACMD_FUNC(users)
  5358. {
  5359. char buf[CHAT_SIZE_MAX];
  5360. int i;
  5361. int users[MAX_MAPINDEX];
  5362. int users_all;
  5363. struct s_mapiterator* iter;
  5364. memset(users, 0, sizeof(users));
  5365. users_all = 0;
  5366. // count users on each map
  5367. iter = mapit_getallusers();
  5368. for(;;)
  5369. {
  5370. struct map_session_data* sd2 = (struct map_session_data*)mapit_next(iter);
  5371. if( sd2 == NULL )
  5372. break;// no more users
  5373. if( sd2->mapindex >= MAX_MAPINDEX )
  5374. continue;// invalid mapindex
  5375. if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex];
  5376. if( users_all < INT_MAX ) ++users_all;
  5377. }
  5378. mapit_free(iter);
  5379. // display results for each map
  5380. for( i = 0; i < MAX_MAPINDEX; ++i )
  5381. {
  5382. if( users[i] == 0 )
  5383. continue;// empty
  5384. safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all));
  5385. clif_displaymessage(sd->fd, buf);
  5386. }
  5387. // display overall count
  5388. safesnprintf(buf, sizeof(buf), "all: %d", users_all);
  5389. clif_displaymessage(sd->fd, buf);
  5390. return 0;
  5391. }
  5392. /*==========================================
  5393. *
  5394. *------------------------------------------*/
  5395. ACMD_FUNC(reset)
  5396. {
  5397. pc_resetstate(sd);
  5398. pc_resetskill(sd,1);
  5399. sprintf(atcmd_output, msg_txt(sd,208), sd->status.name); // '%s' skill and stats points reseted!
  5400. clif_displaymessage(fd, atcmd_output);
  5401. return 0;
  5402. }
  5403. /*==========================================
  5404. *
  5405. *------------------------------------------*/
  5406. ACMD_FUNC(summon)
  5407. {
  5408. char name[NAME_LENGTH];
  5409. int mob_id = 0;
  5410. int duration = 0;
  5411. struct mob_data *md;
  5412. unsigned int tick=gettick();
  5413. nullpo_retr(-1, sd);
  5414. if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1)
  5415. {
  5416. clif_displaymessage(fd, msg_txt(sd,1225)); // Please enter a monster name (usage: @summon <monster name> {duration}).
  5417. return -1;
  5418. }
  5419. if (duration < 1)
  5420. duration =1;
  5421. else if (duration > 60)
  5422. duration =60;
  5423. if ((mob_id = atoi(name)) == 0)
  5424. mob_id = mobdb_searchname(name);
  5425. if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
  5426. {
  5427. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5428. return -1;
  5429. }
  5430. md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
  5431. if(!md)
  5432. return -1;
  5433. md->master_id=sd->bl.id;
  5434. md->special_state.ai=AI_ATTACK;
  5435. md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
  5436. clif_specialeffect(&md->bl,344,AREA);
  5437. mob_spawn(md);
  5438. sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
  5439. clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
  5440. clif_displaymessage(fd, msg_txt(sd,39)); // All monster summoned!
  5441. return 0;
  5442. }
  5443. /*==========================================
  5444. * @adjgroup
  5445. * Temporarily move player to another group
  5446. * Useful during beta testing to allow players to use GM commands for short periods of time
  5447. *------------------------------------------*/
  5448. ACMD_FUNC(adjgroup)
  5449. {
  5450. int new_group = 0;
  5451. nullpo_retr(-1, sd);
  5452. if (!message || !*message || sscanf(message, "%d", &new_group) != 1) {
  5453. clif_displaymessage(fd, msg_txt(sd,1226)); // Usage: @adjgroup <group_id>
  5454. return -1;
  5455. }
  5456. if (!pc_group_exists(new_group)) {
  5457. clif_displaymessage(fd, msg_txt(sd,1227)); // Specified group does not exist.
  5458. return -1;
  5459. }
  5460. sd->group_id = new_group;
  5461. pc_group_pc_load(sd);/* update cache */
  5462. clif_displaymessage(fd, msg_txt(sd,1228)); // Group changed successfully.
  5463. clif_displaymessage(sd->fd, msg_txt(sd,1229)); // Your group has changed.
  5464. return 0;
  5465. }
  5466. /*==========================================
  5467. * @trade by [MouseJstr]
  5468. * Open a trade window with a remote player
  5469. *------------------------------------------*/
  5470. ACMD_FUNC(trade)
  5471. {
  5472. struct map_session_data *pl_sd = NULL;
  5473. nullpo_retr(-1, sd);
  5474. if (!message || !*message) {
  5475. clif_displaymessage(fd, msg_txt(sd,1230)); // Please enter a player name (usage: @trade <char name>).
  5476. return -1;
  5477. }
  5478. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5479. {
  5480. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5481. return -1;
  5482. }
  5483. trade_traderequest(sd, pl_sd);
  5484. return 0;
  5485. }
  5486. /*==========================================
  5487. * @setbattleflag by [MouseJstr]
  5488. * set a battle_config flag without having to reboot
  5489. *------------------------------------------*/
  5490. ACMD_FUNC(setbattleflag)
  5491. {
  5492. char flag[128], value[128];
  5493. nullpo_retr(-1, sd);
  5494. if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) {
  5495. clif_displaymessage(fd, msg_txt(sd,1231)); // Usage: @setbattleflag <flag> <value>
  5496. return -1;
  5497. }
  5498. if (battle_set_value(flag, value) == 0)
  5499. {
  5500. clif_displaymessage(fd, msg_txt(sd,1232)); // Unknown battle_config flag.
  5501. return -1;
  5502. }
  5503. clif_displaymessage(fd, msg_txt(sd,1233)); // Set battle_config as requested.
  5504. return 0;
  5505. }
  5506. /*==========================================
  5507. * @unmute [Valaris]
  5508. *------------------------------------------*/
  5509. ACMD_FUNC(unmute)
  5510. {
  5511. struct map_session_data *pl_sd = NULL;
  5512. nullpo_retr(-1, sd);
  5513. if (!message || !*message) {
  5514. clif_displaymessage(fd, msg_txt(sd,1234)); // Please enter a player name (usage: @unmute <char name>).
  5515. return -1;
  5516. }
  5517. if ( (pl_sd = map_nick2sd((char *)message)) == NULL )
  5518. {
  5519. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5520. return -1;
  5521. }
  5522. if(!pl_sd->sc.data[SC_NOCHAT]) {
  5523. clif_displaymessage(sd->fd,msg_txt(sd,1235)); // Player is not muted.
  5524. return -1;
  5525. }
  5526. pl_sd->status.manner = 0;
  5527. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5528. clif_displaymessage(sd->fd,msg_txt(sd,1236)); // Player unmuted.
  5529. return 0;
  5530. }
  5531. /*==========================================
  5532. * @uptime by MC Cameri
  5533. *------------------------------------------*/
  5534. ACMD_FUNC(uptime)
  5535. {
  5536. unsigned long seconds = 0, day = 24*60*60, hour = 60*60,
  5537. minute = 60, days = 0, hours = 0, minutes = 0;
  5538. nullpo_retr(-1, sd);
  5539. seconds = get_uptime();
  5540. days = seconds/day;
  5541. seconds -= (seconds/day>0)?(seconds/day)*day:0;
  5542. hours = seconds/hour;
  5543. seconds -= (seconds/hour>0)?(seconds/hour)*hour:0;
  5544. minutes = seconds/minute;
  5545. seconds -= (seconds/minute>0)?(seconds/minute)*minute:0;
  5546. snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(sd,245), days, hours, minutes, seconds);
  5547. clif_displaymessage(fd, atcmd_output);
  5548. return 0;
  5549. }
  5550. /*==========================================
  5551. * @changesex <sex>
  5552. * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female.
  5553. *------------------------------------------*/
  5554. ACMD_FUNC(changesex)
  5555. {
  5556. int i;
  5557. nullpo_retr(-1, sd);
  5558. pc_resetskill(sd,4);
  5559. // to avoid any problem with equipment and invalid sex, equipment is unequiped.
  5560. for( i=0; i<EQI_MAX; i++ )
  5561. if( sd->equip_index[i] >= 0 ) pc_unequipitem(sd, sd->equip_index[i], 3);
  5562. chrif_changesex(sd);
  5563. return 0;
  5564. }
  5565. /*================================================
  5566. * @mute - Mutes a player for a set amount of time
  5567. *------------------------------------------------*/
  5568. ACMD_FUNC(mute)
  5569. {
  5570. struct map_session_data *pl_sd = NULL;
  5571. int manner;
  5572. nullpo_retr(-1, sd);
  5573. if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) {
  5574. clif_displaymessage(fd, msg_txt(sd,1237)); // Usage: @mute <time> <char name>
  5575. return -1;
  5576. }
  5577. if ( (pl_sd = map_nick2sd(atcmd_player_name)) == NULL )
  5578. {
  5579. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  5580. return -1;
  5581. }
  5582. if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
  5583. {
  5584. clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level don't authorise you to do this action on this player.
  5585. return -1;
  5586. }
  5587. clif_manner_message(sd, 0);
  5588. clif_manner_message(pl_sd, 5);
  5589. if( pl_sd->status.manner < manner ) {
  5590. pl_sd->status.manner -= manner;
  5591. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  5592. } else {
  5593. pl_sd->status.manner = 0;
  5594. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  5595. }
  5596. clif_GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0));
  5597. return 0;
  5598. }
  5599. /*==========================================
  5600. * @refresh (like @jumpto <<yourself>>)
  5601. *------------------------------------------*/
  5602. ACMD_FUNC(refresh)
  5603. {
  5604. nullpo_retr(-1, sd);
  5605. clif_refresh(sd);
  5606. return 0;
  5607. }
  5608. ACMD_FUNC(refreshall)
  5609. {
  5610. struct map_session_data* iter_sd;
  5611. struct s_mapiterator* iter;
  5612. nullpo_retr(-1, sd);
  5613. iter = mapit_getallusers();
  5614. for (iter_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); iter_sd = (TBL_PC*)mapit_next(iter))
  5615. clif_refresh(iter_sd);
  5616. mapit_free(iter);
  5617. return 0;
  5618. }
  5619. /*==========================================
  5620. * @identify
  5621. * => GM's magnifier.
  5622. *------------------------------------------*/
  5623. ACMD_FUNC(identify)
  5624. {
  5625. int i,num;
  5626. nullpo_retr(-1, sd);
  5627. for(i=num=0;i<MAX_INVENTORY;i++){
  5628. if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){
  5629. num++;
  5630. }
  5631. }
  5632. if (num > 0) {
  5633. clif_item_identify_list(sd);
  5634. } else {
  5635. clif_displaymessage(fd,msg_txt(sd,1238)); // There are no items to appraise.
  5636. }
  5637. return 0;
  5638. }
  5639. /*===============================================
  5640. * @identifyall
  5641. * => Indentify all items in inventory - Akinari
  5642. *-----------------------------------------------*/
  5643. ACMD_FUNC(identifyall)
  5644. {
  5645. int i;
  5646. nullpo_retr(-1, sd);
  5647. for(i=0; i<MAX_INVENTORY; i++) {
  5648. if (sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1) {
  5649. sd->status.inventory[i].identify=1;
  5650. clif_item_identified(sd,i,0);
  5651. }
  5652. }
  5653. return 0;
  5654. }
  5655. /*==========================================
  5656. * @gmotd (Global MOTD)
  5657. * by davidsiaw :P
  5658. *------------------------------------------*/
  5659. ACMD_FUNC(gmotd)
  5660. {
  5661. FILE* fp;
  5662. if( ( fp = fopen(motd_txt, "r") ) != NULL )
  5663. {
  5664. char buf[CHAT_SIZE_MAX];
  5665. size_t len;
  5666. while( fgets(buf, sizeof(buf), fp) )
  5667. {
  5668. if( buf[0] == '/' && buf[1] == '/' )
  5669. {
  5670. continue;
  5671. }
  5672. len = strlen(buf);
  5673. while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) )
  5674. {// strip trailing EOL characters
  5675. len--;
  5676. }
  5677. if( len )
  5678. {
  5679. buf[len] = 0;
  5680. intif_broadcast(buf, len+1, 0);
  5681. }
  5682. }
  5683. fclose(fp);
  5684. }
  5685. return 0;
  5686. }
  5687. ACMD_FUNC(misceffect)
  5688. {
  5689. int effect = 0;
  5690. nullpo_retr(-1, sd);
  5691. if (!message || !*message)
  5692. return -1;
  5693. if (sscanf(message, "%d", &effect) < 1)
  5694. return -1;
  5695. clif_misceffect(&sd->bl,effect);
  5696. return 0;
  5697. }
  5698. /*==========================================
  5699. * MAIL SYSTEM
  5700. *------------------------------------------*/
  5701. ACMD_FUNC(mail)
  5702. {
  5703. nullpo_ret(sd);
  5704. mail_openmail(sd);
  5705. return 0;
  5706. }
  5707. /*==========================================
  5708. * Show Monster DB Info v 1.0
  5709. * originally by [Lupus]
  5710. *------------------------------------------*/
  5711. ACMD_FUNC(mobinfo)
  5712. {
  5713. unsigned char msize[3][7] = {"Small", "Medium", "Large"};
  5714. unsigned char mrace[12][11] = {"Formless", "Undead", "Beast", "Plant", "Insect", "Fish", "Demon", "Demi-Human", "Angel", "Dragon", "Boss", "Non-Boss"};
  5715. unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
  5716. char atcmd_output2[CHAT_SIZE_MAX];
  5717. struct item_data *item_data;
  5718. struct mob_db *mob, *mob_array[MAX_SEARCH];
  5719. int count;
  5720. int i, j, k;
  5721. unsigned int base_exp, job_exp;
  5722. memset(atcmd_output, '\0', sizeof(atcmd_output));
  5723. memset(atcmd_output2, '\0', sizeof(atcmd_output2));
  5724. if (!message || !*message) {
  5725. clif_displaymessage(fd, msg_txt(sd,1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>).
  5726. return -1;
  5727. }
  5728. // If monster identifier/name argument is a name
  5729. if ((i = mobdb_checkid(atoi(message))))
  5730. {
  5731. mob_array[0] = mob_db(i);
  5732. count = 1;
  5733. } else
  5734. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  5735. if (!count) {
  5736. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  5737. return -1;
  5738. }
  5739. if (count > MAX_SEARCH) {
  5740. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  5741. clif_displaymessage(fd, atcmd_output);
  5742. count = MAX_SEARCH;
  5743. }
  5744. for (k = 0; k < count; k++) {
  5745. mob = mob_array[k];
  5746. base_exp = mob->base_exp;
  5747. job_exp = mob->job_exp;
  5748. #ifdef RENEWAL_EXP
  5749. if( battle_config.atcommand_mobinfo_type ) {
  5750. base_exp = base_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5751. job_exp = job_exp * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 1) / 100;
  5752. }
  5753. #endif
  5754. // stats
  5755. if (mob->mexp)
  5756. sprintf(atcmd_output, msg_txt(sd,1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
  5757. else
  5758. sprintf(atcmd_output, msg_txt(sd,1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
  5759. clif_displaymessage(fd, atcmd_output);
  5760. 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
  5761. clif_displaymessage(fd, atcmd_output);
  5762. sprintf(atcmd_output, msg_txt(sd,1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
  5763. mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
  5764. mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
  5765. clif_displaymessage(fd, atcmd_output);
  5766. sprintf(atcmd_output, msg_txt(sd,1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
  5767. mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
  5768. mob->range2 , mob->range3, msize[mob->status.size],
  5769. mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
  5770. clif_displaymessage(fd, atcmd_output);
  5771. // drops
  5772. clif_displaymessage(fd, msg_txt(sd,1245)); // Drops:
  5773. strcpy(atcmd_output, " ");
  5774. j = 0;
  5775. for (i = 0; i < MAX_MOB_DROP; i++) {
  5776. int droprate;
  5777. if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb_exists(mob->dropitem[i].nameid)) == NULL)
  5778. continue;
  5779. droprate = mob->dropitem[i].p;
  5780. #ifdef RENEWAL_DROP
  5781. if( battle_config.atcommand_mobinfo_type ) {
  5782. droprate = droprate * pc_level_penalty_mod(sd, mob->lv, mob->status.race, mob->status.mode, 2) / 100;
  5783. if (droprate <= 0 && !battle_config.drop_rate0item)
  5784. droprate = 1;
  5785. }
  5786. #endif
  5787. if (item_data->slot)
  5788. sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100);
  5789. else
  5790. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100);
  5791. strcat(atcmd_output, atcmd_output2);
  5792. if (++j % 3 == 0) {
  5793. clif_displaymessage(fd, atcmd_output);
  5794. strcpy(atcmd_output, " ");
  5795. }
  5796. }
  5797. if (j == 0)
  5798. clif_displaymessage(fd, msg_txt(sd,1246)); // This monster has no drops.
  5799. else if (j % 3 != 0)
  5800. clif_displaymessage(fd, atcmd_output);
  5801. // mvp
  5802. if (mob->mexp) {
  5803. sprintf(atcmd_output, msg_txt(sd,1247), mob->mexp); // MVP Bonus EXP:%u
  5804. clif_displaymessage(fd, atcmd_output);
  5805. strcpy(atcmd_output, msg_txt(sd,1248)); // MVP Items:
  5806. j = 0;
  5807. for (i = 0; i < MAX_MVP_DROP; i++) {
  5808. if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb_exists(mob->mvpitem[i].nameid)) == NULL)
  5809. continue;
  5810. if (mob->mvpitem[i].p > 0) {
  5811. j++;
  5812. if (j == 1)
  5813. sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5814. else
  5815. sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
  5816. strcat(atcmd_output, atcmd_output2);
  5817. }
  5818. }
  5819. if (j == 0)
  5820. clif_displaymessage(fd, msg_txt(sd,1249)); // This monster has no MVP prizes.
  5821. else
  5822. clif_displaymessage(fd, atcmd_output);
  5823. }
  5824. }
  5825. return 0;
  5826. }
  5827. /*=========================================
  5828. * @showmobs by KarLaeda
  5829. * => For 15 sec displays the mobs on minimap
  5830. *------------------------------------------*/
  5831. ACMD_FUNC(showmobs)
  5832. {
  5833. char mob_name[100];
  5834. int mob_id;
  5835. int number = 0;
  5836. struct s_mapiterator* it;
  5837. nullpo_retr(-1, sd);
  5838. if(sscanf(message, "%99[^\n]", mob_name) < 0)
  5839. return -1;
  5840. if((mob_id = atoi(mob_name)) == 0)
  5841. mob_id = mobdb_searchname(mob_name);
  5842. if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
  5843. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1250),mob_name); // Invalid mob id %s!
  5844. clif_displaymessage(fd, atcmd_output);
  5845. return 0;
  5846. }
  5847. 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.
  5848. clif_displaymessage(fd, msg_txt(sd,1251)); // Can't show boss mobs!
  5849. return 0;
  5850. }
  5851. if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
  5852. strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
  5853. //strcpy(mob_name,mob_db(mob_id)->name); // --en--
  5854. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1252), // Mob Search... %s %s
  5855. mob_name, mapindex_id2name(sd->mapindex));
  5856. clif_displaymessage(fd, atcmd_output);
  5857. it = mapit_geteachmob();
  5858. for(;;)
  5859. {
  5860. TBL_MOB* md = (TBL_MOB*)mapit_next(it);
  5861. if( md == NULL )
  5862. break;// no more mobs
  5863. if( md->bl.m != sd->bl.m )
  5864. continue;
  5865. if( mob_id != -1 && md->class_ != mob_id )
  5866. continue;
  5867. if( md->special_state.ai || md->master_id )
  5868. continue; // hide slaves and player summoned mobs
  5869. if( md->spawn_timer != INVALID_TIMER )
  5870. continue; // hide mobs waiting for respawn
  5871. ++number;
  5872. clif_viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF);
  5873. }
  5874. mapit_free(it);
  5875. return 0;
  5876. }
  5877. /*==========================================
  5878. * homunculus level up [orn]
  5879. *------------------------------------------*/
  5880. ACMD_FUNC(homlevel)
  5881. {
  5882. TBL_HOM * hd;
  5883. int level = 0, i = 0;
  5884. nullpo_retr(-1, sd);
  5885. if ( !message || !*message || ( level = atoi(message) ) < 1 ) {
  5886. clif_displaymessage(fd, msg_txt(sd,1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>).
  5887. return -1;
  5888. }
  5889. if ( !merc_is_hom_active(sd->hd) ) {
  5890. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5891. return -1;
  5892. }
  5893. hd = sd->hd;
  5894. for (i = 1; i <= level && hd->exp_next; i++){
  5895. hd->homunculus.exp += hd->exp_next;
  5896. if( !merc_hom_levelup(hd) ){
  5897. break;
  5898. }
  5899. }
  5900. status_calc_homunculus(hd,0);
  5901. status_percent_heal(&hd->bl, 100, 100);
  5902. clif_specialeffect(&hd->bl,568,AREA);
  5903. return 0;
  5904. }
  5905. /*==========================================
  5906. * homunculus evolution H [orn]
  5907. *------------------------------------------*/
  5908. ACMD_FUNC(homevolution)
  5909. {
  5910. nullpo_retr(-1, sd);
  5911. if ( !merc_is_hom_active(sd->hd) ) {
  5912. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5913. return -1;
  5914. }
  5915. if ( !merc_hom_evolution(sd->hd) ) {
  5916. clif_displaymessage(fd, msg_txt(sd,1255)); // Your homunculus doesn't evolve.
  5917. return -1;
  5918. }
  5919. clif_homskillinfoblock(sd);
  5920. return 0;
  5921. }
  5922. ACMD_FUNC(hommutate)
  5923. {
  5924. int homun_id, m_class = 0, m_id;
  5925. nullpo_retr(-1, sd);
  5926. if (!merc_is_hom_active(sd->hd)) {
  5927. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5928. return -1;
  5929. }
  5930. if (!message || !*message) {
  5931. homun_id = 6048 + (rnd() % 4);
  5932. } else {
  5933. homun_id = atoi(message);
  5934. }
  5935. m_class = hom_class2mapid(sd->hd->homunculus.class_);
  5936. m_id = hom_class2mapid(homun_id);
  5937. if (m_class != -1 && m_id != -1 && m_class&HOM_EVO && m_id&HOM_S && sd->hd->homunculus.level >= 99) {
  5938. hom_mutate(sd->hd, homun_id);
  5939. } else {
  5940. clif_emotion(&sd->hd->bl, E_SWT);
  5941. }
  5942. return 0;
  5943. }
  5944. /*==========================================
  5945. * call choosen homunculus [orn]
  5946. *------------------------------------------*/
  5947. ACMD_FUNC(makehomun)
  5948. {
  5949. int homunid;
  5950. nullpo_retr(-1, sd);
  5951. if ( sd->status.hom_id ) {
  5952. clif_displaymessage(fd, msg_txt(sd,450));
  5953. return -1;
  5954. }
  5955. if (!message || !*message) {
  5956. clif_displaymessage(fd, msg_txt(sd,1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>).
  5957. return -1;
  5958. }
  5959. homunid = atoi(message);
  5960. if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 )
  5961. {
  5962. clif_displaymessage(fd, msg_txt(sd,1257)); // Invalid Homunculus ID.
  5963. return -1;
  5964. }
  5965. merc_create_homunculus_request(sd,homunid);
  5966. return 0;
  5967. }
  5968. /*==========================================
  5969. * modify homunculus intimacy [orn]
  5970. *------------------------------------------*/
  5971. ACMD_FUNC(homfriendly)
  5972. {
  5973. int friendly = 0;
  5974. nullpo_retr(-1, sd);
  5975. if ( !merc_is_hom_active(sd->hd) ) {
  5976. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5977. return -1;
  5978. }
  5979. if (!message || !*message) {
  5980. clif_displaymessage(fd, msg_txt(sd,1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>).
  5981. return -1;
  5982. }
  5983. friendly = atoi(message);
  5984. friendly = cap_value(friendly, 0, 1000);
  5985. sd->hd->homunculus.intimacy = friendly * 100 ;
  5986. clif_send_homdata(sd,SP_INTIMATE,friendly);
  5987. return 0;
  5988. }
  5989. /*==========================================
  5990. * modify homunculus hunger [orn]
  5991. *------------------------------------------*/
  5992. ACMD_FUNC(homhungry)
  5993. {
  5994. int hungry = 0;
  5995. nullpo_retr(-1, sd);
  5996. if ( !merc_is_hom_active(sd->hd) ) {
  5997. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  5998. return -1;
  5999. }
  6000. if (!message || !*message) {
  6001. clif_displaymessage(fd, msg_txt(sd,1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>).
  6002. return -1;
  6003. }
  6004. hungry = atoi(message);
  6005. hungry = cap_value(hungry, 0, 100);
  6006. sd->hd->homunculus.hunger = hungry;
  6007. clif_send_homdata(sd,SP_HUNGRY,hungry);
  6008. return 0;
  6009. }
  6010. /*==========================================
  6011. * make the homunculus speak [orn]
  6012. *------------------------------------------*/
  6013. ACMD_FUNC(homtalk)
  6014. {
  6015. char mes[100],temp[100];
  6016. nullpo_retr(-1, sd);
  6017. if ( battle_config.min_chat_delay ) {
  6018. if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 )
  6019. return 0;
  6020. sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
  6021. }
  6022. if (sd->sc.count && //no "chatting" while muted.
  6023. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6024. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6025. return -1;
  6026. if ( !merc_is_hom_active(sd->hd) ) {
  6027. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6028. return -1;
  6029. }
  6030. if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
  6031. clif_displaymessage(fd, msg_txt(sd,1260)); // Please enter a message (usage: @homtalk <message>).
  6032. return -1;
  6033. }
  6034. snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes);
  6035. clif_disp_overhead(&sd->hd->bl, temp);
  6036. return 0;
  6037. }
  6038. /*==========================================
  6039. * Show homunculus stats
  6040. *------------------------------------------*/
  6041. ACMD_FUNC(hominfo)
  6042. {
  6043. struct homun_data *hd;
  6044. struct status_data *status;
  6045. nullpo_retr(-1, sd);
  6046. if ( !merc_is_hom_active(sd->hd) ) {
  6047. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6048. return -1;
  6049. }
  6050. hd = sd->hd;
  6051. status = status_get_status_data(&hd->bl);
  6052. clif_displaymessage(fd, msg_txt(sd,1261)); // Homunculus stats:
  6053. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1262), // HP: %d/%d - SP: %d/%d
  6054. status->hp, status->max_hp, status->sp, status->max_sp);
  6055. clif_displaymessage(fd, atcmd_output);
  6056. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1263), // ATK: %d - MATK: %d~%d
  6057. status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
  6058. clif_displaymessage(fd, atcmd_output);
  6059. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1264), // Hungry: %d - Intimacy: %u
  6060. hd->homunculus.hunger, hd->homunculus.intimacy/100);
  6061. clif_displaymessage(fd, atcmd_output);
  6062. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6063. msg_txt(sd,1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d
  6064. status->str, status->agi, status->vit,
  6065. status->int_, status->dex, status->luk);
  6066. clif_displaymessage(fd, atcmd_output);
  6067. return 0;
  6068. }
  6069. ACMD_FUNC(homstats)
  6070. {
  6071. struct homun_data *hd;
  6072. struct s_homunculus_db *db;
  6073. struct s_homunculus *hom;
  6074. int lv, min, max, evo;
  6075. nullpo_retr(-1, sd);
  6076. if ( !merc_is_hom_active(sd->hd) ) {
  6077. clif_displaymessage(fd, msg_txt(sd,1254)); // You do not have a homunculus.
  6078. return -1;
  6079. }
  6080. hd = sd->hd;
  6081. hom = &hd->homunculus;
  6082. db = hd->homunculusDB;
  6083. lv = hom->level;
  6084. snprintf(atcmd_output, sizeof(atcmd_output) ,
  6085. msg_txt(sd,1266), lv, db->name); // Homunculus growth stats (Lv %d %s):
  6086. clif_displaymessage(fd, atcmd_output);
  6087. lv--; //Since the first increase is at level 2.
  6088. evo = (hom->class_ == db->evo_class);
  6089. min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0);
  6090. max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);;
  6091. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1267), hom->max_hp, min, max); // Max HP: %d (%d~%d)
  6092. clif_displaymessage(fd, atcmd_output);
  6093. min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0);
  6094. max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);;
  6095. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1268), hom->max_sp, min, max); // Max SP: %d (%d~%d)
  6096. clif_displaymessage(fd, atcmd_output);
  6097. min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0);
  6098. max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);;
  6099. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1269), hom->str/10, min, max); // Str: %d (%d~%d)
  6100. clif_displaymessage(fd, atcmd_output);
  6101. min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0);
  6102. max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);;
  6103. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1270), hom->agi/10, min, max); // Agi: %d (%d~%d)
  6104. clif_displaymessage(fd, atcmd_output);
  6105. min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0);
  6106. max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);;
  6107. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1271), hom->vit/10, min, max); // Vit: %d (%d~%d)
  6108. clif_displaymessage(fd, atcmd_output);
  6109. min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0);
  6110. max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);;
  6111. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1272), hom->int_/10, min, max); // Int: %d (%d~%d)
  6112. clif_displaymessage(fd, atcmd_output);
  6113. min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0);
  6114. max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);;
  6115. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1273), hom->dex/10, min, max); // Dex: %d (%d~%d)
  6116. clif_displaymessage(fd, atcmd_output);
  6117. min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0);
  6118. max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);;
  6119. snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(sd,1274), hom->luk/10, min, max); // Luk: %d (%d~%d)
  6120. clif_displaymessage(fd, atcmd_output);
  6121. return 0;
  6122. }
  6123. ACMD_FUNC(homshuffle)
  6124. {
  6125. nullpo_retr(-1, sd);
  6126. if(!sd->hd)
  6127. return -1; // nothing to do
  6128. if(!merc_hom_shuffle(sd->hd))
  6129. return -1;
  6130. clif_displaymessage(sd->fd, msg_txt(sd,1275)); // Homunculus stats altered.
  6131. atcommand_homstats(fd, sd, command, message); //Print out the new stats
  6132. return 0;
  6133. }
  6134. /*==========================================
  6135. * Show Items DB Info v 1.0
  6136. * originally by [Lupus]
  6137. *------------------------------------------*/
  6138. ACMD_FUNC(iteminfo)
  6139. {
  6140. struct item_data *item_data, *item_array[MAX_SEARCH];
  6141. int i, count = 1;
  6142. if (!message || !*message) {
  6143. clif_displaymessage(fd, msg_txt(sd,1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>).
  6144. return -1;
  6145. }
  6146. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6147. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6148. if (!count) {
  6149. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6150. return -1;
  6151. }
  6152. if (count > MAX_SEARCH) {
  6153. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6154. clif_displaymessage(fd, atcmd_output);
  6155. count = MAX_SEARCH;
  6156. }
  6157. for (i = 0; i < count; i++) {
  6158. item_data = item_array[i];
  6159. sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
  6160. item_data->name,item_data->jname,item_data->slot,item_data->nameid,
  6161. itemdb_typename(item_data->type),
  6162. (item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
  6163. );
  6164. clif_displaymessage(fd, atcmd_output);
  6165. 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
  6166. clif_displaymessage(fd, atcmd_output);
  6167. if (item_data->maxchance == -1)
  6168. strcpy(atcmd_output, msg_txt(sd,1281)); // - Available in the shops only.
  6169. else if (!battle_config.atcommand_mobinfo_type && item_data->maxchance)
  6170. sprintf(atcmd_output, msg_txt(sd,1282), (float)item_data->maxchance / 100 ); // - Maximal monsters drop chance: %02.02f%%
  6171. else
  6172. strcpy(atcmd_output, msg_txt(sd,1283)); // - Monsters don't drop this item.
  6173. clif_displaymessage(fd, atcmd_output);
  6174. }
  6175. return 0;
  6176. }
  6177. /*==========================================
  6178. * Show who drops the item.
  6179. *------------------------------------------*/
  6180. ACMD_FUNC(whodrops)
  6181. {
  6182. struct item_data *item_data, *item_array[MAX_SEARCH];
  6183. int i,j, count = 1;
  6184. if (!message || !*message) {
  6185. clif_displaymessage(fd, msg_txt(sd,1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>).
  6186. return -1;
  6187. }
  6188. if ((item_array[0] = itemdb_exists(atoi(message))) == NULL)
  6189. count = itemdb_searchname_array(item_array, MAX_SEARCH, message);
  6190. if (!count) {
  6191. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  6192. return -1;
  6193. }
  6194. if (count > MAX_SEARCH) {
  6195. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count); // Displaying first %d out of %d matches
  6196. clif_displaymessage(fd, atcmd_output);
  6197. count = MAX_SEARCH;
  6198. }
  6199. for (i = 0; i < count; i++) {
  6200. item_data = item_array[i];
  6201. sprintf(atcmd_output, msg_txt(sd,1285), item_data->jname,item_data->slot); // Item: '%s'[%d]
  6202. clif_displaymessage(fd, atcmd_output);
  6203. if (item_data->mob[0].chance == 0) {
  6204. strcpy(atcmd_output, msg_txt(sd,1286)); // - Item is not dropped by mobs.
  6205. clif_displaymessage(fd, atcmd_output);
  6206. } else {
  6207. sprintf(atcmd_output, msg_txt(sd,1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed):
  6208. clif_displaymessage(fd, atcmd_output);
  6209. for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
  6210. {
  6211. int dropchance = item_data->mob[j].chance;
  6212. #ifdef RENEWAL_DROP
  6213. if( battle_config.atcommand_mobinfo_type )
  6214. 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;
  6215. #endif
  6216. sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, dropchance/100.);
  6217. clif_displaymessage(fd, atcmd_output);
  6218. }
  6219. }
  6220. }
  6221. return 0;
  6222. }
  6223. ACMD_FUNC(whereis)
  6224. {
  6225. struct mob_db *mob, *mob_array[MAX_SEARCH];
  6226. int count;
  6227. int i, j, k;
  6228. if (!message || !*message) {
  6229. clif_displaymessage(fd, msg_txt(sd,1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>).
  6230. return -1;
  6231. }
  6232. // If monster identifier/name argument is a name
  6233. if ((i = mobdb_checkid(atoi(message))))
  6234. {
  6235. mob_array[0] = mob_db(i);
  6236. count = 1;
  6237. } else
  6238. count = mobdb_searchname_array(mob_array, MAX_SEARCH, message);
  6239. if (!count) {
  6240. clif_displaymessage(fd, msg_txt(sd,40)); // Invalid monster ID or name.
  6241. return -1;
  6242. }
  6243. if (count > MAX_SEARCH) {
  6244. sprintf(atcmd_output, msg_txt(sd,269), MAX_SEARCH, count);
  6245. clif_displaymessage(fd, atcmd_output);
  6246. count = MAX_SEARCH;
  6247. }
  6248. for (k = 0; k < count; k++) {
  6249. mob = mob_array[k];
  6250. snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in:
  6251. clif_displaymessage(fd, atcmd_output);
  6252. for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
  6253. {
  6254. j = map_mapindex2mapid(mob->spawn[i].mapindex);
  6255. if (j < 0) continue;
  6256. snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
  6257. clif_displaymessage(fd, atcmd_output);
  6258. }
  6259. if (i == 0)
  6260. clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally.
  6261. }
  6262. return 0;
  6263. }
  6264. ACMD_FUNC(version)
  6265. {
  6266. const char * revision;
  6267. if ((revision = get_svn_revision()) != 0) {
  6268. sprintf(atcmd_output,msg_txt(sd,1295),revision); // rAthena Version SVN r%s
  6269. clif_displaymessage(fd,atcmd_output);
  6270. } else
  6271. clif_displaymessage(fd,msg_txt(sd,1296)); // Cannot determine SVN revision.
  6272. return 0;
  6273. }
  6274. /*==========================================
  6275. * @mutearea by MouseJstr
  6276. *------------------------------------------*/
  6277. static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
  6278. {
  6279. int time, id;
  6280. struct map_session_data *pl_sd = (struct map_session_data *)bl;
  6281. if (pl_sd == NULL)
  6282. return 0;
  6283. id = va_arg(ap, int);
  6284. time = va_arg(ap, int);
  6285. if (id != bl->id && !pc_get_group_level(pl_sd)) {
  6286. pl_sd->status.manner -= time;
  6287. if (pl_sd->status.manner < 0)
  6288. sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
  6289. else
  6290. status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER);
  6291. }
  6292. return 0;
  6293. }
  6294. ACMD_FUNC(mutearea)
  6295. {
  6296. int time;
  6297. nullpo_ret(sd);
  6298. if (!message || !*message) {
  6299. clif_displaymessage(fd, msg_txt(sd,1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>).
  6300. return -1;
  6301. }
  6302. time = atoi(message);
  6303. map_foreachinarea(atcommand_mutearea_sub,sd->bl.m,
  6304. sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE,
  6305. sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time);
  6306. return 0;
  6307. }
  6308. ACMD_FUNC(rates)
  6309. {
  6310. char buf[CHAT_SIZE_MAX];
  6311. nullpo_ret(sd);
  6312. memset(buf, '\0', sizeof(buf));
  6313. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1298), // Experience rates: Base %.2fx / Job %.2fx
  6314. battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.);
  6315. clif_displaymessage(fd, buf);
  6316. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1299), // Normal Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6317. battle_config.item_rate_common/100., battle_config.item_rate_heal/100., battle_config.item_rate_use/100., battle_config.item_rate_equip/100., battle_config.item_rate_card/100.);
  6318. clif_displaymessage(fd, buf);
  6319. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1300), // Boss Drop Rates: Common %.2fx / Healing %.2fx / Usable %.2fx / Equipment %.2fx / Card %.2fx
  6320. battle_config.item_rate_common_boss/100., battle_config.item_rate_heal_boss/100., battle_config.item_rate_use_boss/100., battle_config.item_rate_equip_boss/100., battle_config.item_rate_card_boss/100.);
  6321. clif_displaymessage(fd, buf);
  6322. snprintf(buf, CHAT_SIZE_MAX, msg_txt(sd,1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx
  6323. battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.);
  6324. clif_displaymessage(fd, buf);
  6325. return 0;
  6326. }
  6327. /*==========================================
  6328. * @me by lordalfa
  6329. * => Displays the OUTPUT string on top of the Visible players Heads.
  6330. *------------------------------------------*/
  6331. ACMD_FUNC(me)
  6332. {
  6333. char tempmes[CHAT_SIZE_MAX];
  6334. nullpo_retr(-1, sd);
  6335. memset(tempmes, '\0', sizeof(tempmes));
  6336. memset(atcmd_output, '\0', sizeof(atcmd_output));
  6337. if (sd->sc.count && //no "chatting" while muted.
  6338. (sd->sc.data[SC_BERSERK] || sd->sc.data[SC__BLOODYLUST] ||
  6339. (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT)))
  6340. return -1;
  6341. if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) {
  6342. clif_displaymessage(fd, msg_txt(sd,1302)); // Please enter a message (usage: @me <message>).
  6343. return -1;
  6344. }
  6345. sprintf(atcmd_output, msg_txt(sd,270), sd->status.name, tempmes); // *%s %s*
  6346. clif_disp_overhead(&sd->bl, atcmd_output);
  6347. return 0;
  6348. }
  6349. /*==========================================
  6350. * @size
  6351. * => Resize your character sprite. [Valaris]
  6352. *------------------------------------------*/
  6353. ACMD_FUNC(size)
  6354. {
  6355. int size = 0;
  6356. nullpo_retr(-1, sd);
  6357. size = cap_value(atoi(message),SZ_SMALL,SZ_BIG);
  6358. if(sd->state.size) {
  6359. sd->state.size = SZ_SMALL;
  6360. pc_setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT);
  6361. }
  6362. sd->state.size = size;
  6363. if( size == SZ_MEDIUM )
  6364. clif_specialeffect(&sd->bl,420,AREA);
  6365. else if( size == SZ_BIG )
  6366. clif_specialeffect(&sd->bl,422,AREA);
  6367. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6368. return 0;
  6369. }
  6370. ACMD_FUNC(sizeall)
  6371. {
  6372. int size;
  6373. struct map_session_data *pl_sd;
  6374. struct s_mapiterator* iter;
  6375. size = atoi(message);
  6376. size = cap_value(size,0,2);
  6377. iter = mapit_getallusers();
  6378. for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ) {
  6379. if( pl_sd->state.size != size ) {
  6380. if( pl_sd->state.size ) {
  6381. pl_sd->state.size = SZ_SMALL;
  6382. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6383. }
  6384. pl_sd->state.size = size;
  6385. if( size == SZ_MEDIUM )
  6386. clif_specialeffect(&pl_sd->bl,420,AREA);
  6387. else if( size == SZ_BIG )
  6388. clif_specialeffect(&pl_sd->bl,422,AREA);
  6389. }
  6390. }
  6391. mapit_free(iter);
  6392. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6393. return 0;
  6394. }
  6395. ACMD_FUNC(sizeguild)
  6396. {
  6397. int size = 0, i;
  6398. char guild[NAME_LENGTH];
  6399. struct map_session_data *pl_sd;
  6400. struct guild *g;
  6401. nullpo_retr(-1, sd);
  6402. memset(guild, '\0', sizeof(guild));
  6403. if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild) < 2 ) {
  6404. clif_displaymessage(fd, msg_txt(sd,1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>).
  6405. return -1;
  6406. }
  6407. if( (g = guild_searchname(guild)) == NULL && (g = guild_search(atoi(guild))) == NULL ) {
  6408. clif_displaymessage(fd, msg_txt(sd,94)); // Incorrect name/ID, or no one from the guild is online.
  6409. return -1;
  6410. }
  6411. size = cap_value(size,SZ_SMALL,SZ_BIG);
  6412. for( i = 0; i < g->max_member; i++ ) {
  6413. if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) {
  6414. if( pl_sd->state.size ) {
  6415. pl_sd->state.size = SZ_SMALL;
  6416. pc_setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT);
  6417. }
  6418. pl_sd->state.size = size;
  6419. if( size == SZ_MEDIUM )
  6420. clif_specialeffect(&pl_sd->bl,420,AREA);
  6421. else if( size == SZ_BIG )
  6422. clif_specialeffect(&pl_sd->bl,422,AREA);
  6423. }
  6424. }
  6425. clif_displaymessage(fd, msg_txt(sd,1303)); // Size change applied.
  6426. return 0;
  6427. }
  6428. /*==========================================
  6429. * @monsterignore
  6430. * => Makes monsters ignore you. [Valaris]
  6431. *------------------------------------------*/
  6432. ACMD_FUNC(monsterignore)
  6433. {
  6434. nullpo_retr(-1, sd);
  6435. if (!sd->state.monster_ignore) {
  6436. sd->state.monster_ignore = 1;
  6437. clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
  6438. } else {
  6439. sd->state.monster_ignore = 0;
  6440. clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
  6441. }
  6442. return 0;
  6443. }
  6444. /*==========================================
  6445. * @fakename
  6446. * => Gives your character a fake name. [Valaris]
  6447. *------------------------------------------*/
  6448. ACMD_FUNC(fakename)
  6449. {
  6450. nullpo_retr(-1, sd);
  6451. if( !message || !*message )
  6452. {
  6453. if( sd->fakename[0] )
  6454. {
  6455. sd->fakename[0] = '\0';
  6456. clif_charnameack(0, &sd->bl);
  6457. clif_displaymessage(sd->fd, msg_txt(sd,1307)); // Returned to real name.
  6458. return 0;
  6459. }
  6460. clif_displaymessage(sd->fd, msg_txt(sd,1308)); // You must enter a name.
  6461. return -1;
  6462. }
  6463. if( strlen(message) < 2 )
  6464. {
  6465. clif_displaymessage(sd->fd, msg_txt(sd,1309)); // Fake name must be at least two characters.
  6466. return -1;
  6467. }
  6468. safestrncpy(sd->fakename, message, sizeof(sd->fakename));
  6469. clif_charnameack(0, &sd->bl);
  6470. clif_displaymessage(sd->fd, msg_txt(sd,1310)); // Fake name enabled.
  6471. return 0;
  6472. }
  6473. /*==========================================
  6474. * Ragnarok Resources
  6475. *------------------------------------------*/
  6476. ACMD_FUNC(mapflag) {
  6477. #define checkflag( cmd ) if ( map[ sd->bl.m ].flag.cmd ) clif_displaymessage(sd->fd,#cmd)
  6478. #define setflag( cmd ) \
  6479. if ( strcmp( flag_name , #cmd ) == 0 ){\
  6480. map[ sd->bl.m ].flag.cmd = flag;\
  6481. sprintf(atcmd_output,"[ @mapflag ] %s flag has been set to %s value = %hd",#cmd,flag?"On":"Off",flag);\
  6482. clif_displaymessage(sd->fd,atcmd_output);\
  6483. return 0;\
  6484. }
  6485. char flag_name[100];
  6486. short flag=0,i;
  6487. nullpo_retr(-1, sd);
  6488. memset(flag_name, '\0', sizeof(flag_name));
  6489. if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) {
  6490. clif_displaymessage(sd->fd,msg_txt(sd,1311)); // Enabled Mapflags in this map:
  6491. clif_displaymessage(sd->fd,"----------------------------------");
  6492. checkflag(autotrade); checkflag(allowks); checkflag(nomemo); checkflag(noteleport);
  6493. checkflag(noreturn); checkflag(monster_noteleport); checkflag(nosave); checkflag(nobranch);
  6494. checkflag(noexppenalty); checkflag(pvp); checkflag(pvp_noparty); checkflag(pvp_noguild);
  6495. checkflag(pvp_nightmaredrop); checkflag(pvp_nocalcrank); checkflag(gvg_castle); checkflag(gvg);
  6496. checkflag(gvg_dungeon); checkflag(gvg_noparty); checkflag(battleground);checkflag(nozenypenalty);
  6497. checkflag(notrade); checkflag(noskill); checkflag(nowarp); checkflag(nowarpto);
  6498. checkflag(noicewall); checkflag(snow); checkflag(clouds); checkflag(clouds2);
  6499. checkflag(fog); checkflag(fireworks); checkflag(sakura); checkflag(leaves);
  6500. checkflag(nogo); checkflag(nobaseexp);
  6501. checkflag(nojobexp); checkflag(nomobloot); checkflag(nomvploot); checkflag(nightenabled);
  6502. checkflag(restricted); checkflag(nodrop); checkflag(novending); checkflag(loadevent);
  6503. checkflag(nochat); checkflag(partylock); checkflag(guildlock); checkflag(src4instance);
  6504. clif_displaymessage(sd->fd," ");
  6505. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6506. clif_displaymessage(sd->fd,msg_txt(sd,1313)); // Type "@mapflag available" to list the available mapflags.
  6507. return 1;
  6508. }
  6509. for (i = 0; flag_name[i]; i++) flag_name[i] = (char)tolower(flag_name[i]); //lowercase
  6510. setflag(autotrade); setflag(allowks); setflag(nomemo); setflag(noteleport);
  6511. setflag(noreturn); setflag(monster_noteleport);setflag(nosave); setflag(nobranch);
  6512. setflag(noexppenalty); setflag(pvp); setflag(pvp_noparty); setflag(pvp_noguild);
  6513. setflag(pvp_nightmaredrop); setflag(pvp_nocalcrank); setflag(gvg_castle); setflag(gvg);
  6514. setflag(gvg_dungeon); setflag(gvg_noparty); setflag(battleground); setflag(nozenypenalty);
  6515. setflag(notrade); setflag(noskill); setflag(nowarp); setflag(nowarpto);
  6516. setflag(noicewall); setflag(snow); setflag(clouds); setflag(clouds2);
  6517. setflag(fog); setflag(fireworks); setflag(sakura); setflag(leaves);
  6518. setflag(nogo); setflag(nobaseexp);
  6519. setflag(nojobexp); setflag(nomobloot); setflag(nomvploot); setflag(nightenabled);
  6520. setflag(restricted); setflag(nodrop); setflag(novending); setflag(loadevent);
  6521. setflag(nochat); setflag(partylock); setflag(guildlock); setflag(src4instance);
  6522. clif_displaymessage(sd->fd,msg_txt(sd,1314)); // Invalid flag name or flag.
  6523. clif_displaymessage(sd->fd,msg_txt(sd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
  6524. clif_displaymessage(sd->fd,msg_txt(sd,1315)); // Available Flags:
  6525. clif_displaymessage(sd->fd,"----------------------------------");
  6526. clif_displaymessage(sd->fd,"town, autotrade, allowks, nomemo, noteleport, noreturn, monster_noteleport, nosave,");
  6527. clif_displaymessage(sd->fd,"nobranch, noexppenalty, pvp, pvp_noparty, pvp_noguild, pvp_nightmaredrop,");
  6528. clif_displaymessage(sd->fd,"pvp_nocalcrank, gvg_castle, gvg, gvg_dungeon, gvg_noparty, battleground,");
  6529. clif_displaymessage(sd->fd,"nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
  6530. clif_displaymessage(sd->fd,"fog, fireworks, sakura, leaves, nogo, nobaseexp, nojobexp, nomobloot,");
  6531. clif_displaymessage(sd->fd,"nomvploot, nightenabled, restricted, nodrop, novending, loadevent, nochat, partylock,");
  6532. clif_displaymessage(sd->fd,"guildlock, src4instance");
  6533. #undef checkflag
  6534. #undef setflag
  6535. return 0;
  6536. }
  6537. /*===================================
  6538. * Remove some messages
  6539. *-----------------------------------*/
  6540. ACMD_FUNC(showexp)
  6541. {
  6542. if (sd->state.showexp) {
  6543. sd->state.showexp = 0;
  6544. clif_displaymessage(fd, msg_txt(sd,1316)); // Gained exp will not be shown.
  6545. return 0;
  6546. }
  6547. sd->state.showexp = 1;
  6548. clif_displaymessage(fd, msg_txt(sd,1317)); // Gained exp is now shown.
  6549. return 0;
  6550. }
  6551. ACMD_FUNC(showzeny)
  6552. {
  6553. if (sd->state.showzeny) {
  6554. sd->state.showzeny = 0;
  6555. clif_displaymessage(fd, msg_txt(sd,1318)); // Gained zeny will not be shown.
  6556. return 0;
  6557. }
  6558. sd->state.showzeny = 1;
  6559. clif_displaymessage(fd, msg_txt(sd,1319)); // Gained zeny is now shown.
  6560. return 0;
  6561. }
  6562. ACMD_FUNC(showdelay)
  6563. {
  6564. if (sd->state.showdelay) {
  6565. sd->state.showdelay = 0;
  6566. clif_displaymessage(fd, msg_txt(sd,1320)); // Skill delay failures will not be shown.
  6567. return 0;
  6568. }
  6569. sd->state.showdelay = 1;
  6570. clif_displaymessage(fd, msg_txt(sd,1321)); // Skill delay failures are now shown.
  6571. return 0;
  6572. }
  6573. /*==========================================
  6574. * Duel organizing functions [LuzZza]
  6575. *
  6576. * @duel [limit|nick] - create a duel
  6577. * @invite <nick> - invite player
  6578. * @accept - accept invitation
  6579. * @reject - reject invitation
  6580. * @leave - leave duel
  6581. *------------------------------------------*/
  6582. ACMD_FUNC(invite)
  6583. {
  6584. unsigned int did = sd->duel_group;
  6585. struct map_session_data *target_sd = map_nick2sd((char *)message);
  6586. if(did == 0) {
  6587. // "Duel: @invite without @duel."
  6588. clif_displaymessage(fd, msg_txt(sd,350));
  6589. return 0;
  6590. }
  6591. if(duel_list[did].max_players_limit > 0 &&
  6592. duel_list[did].members_count >= duel_list[did].max_players_limit) {
  6593. // "Duel: Limit of players is reached."
  6594. clif_displaymessage(fd, msg_txt(sd,351));
  6595. return 0;
  6596. }
  6597. if(target_sd == NULL) {
  6598. // "Duel: Player not found."
  6599. clif_displaymessage(fd, msg_txt(sd,352));
  6600. return 0;
  6601. }
  6602. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6603. // "Duel: Player already in duel."
  6604. clif_displaymessage(fd, msg_txt(sd,353));
  6605. return 0;
  6606. }
  6607. if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m)
  6608. {
  6609. sprintf(atcmd_output, msg_txt(sd,364), message);
  6610. clif_displaymessage(fd, atcmd_output);
  6611. return 0;
  6612. }
  6613. duel_invite(did, sd, target_sd);
  6614. // "Duel: Invitation has been sent."
  6615. clif_displaymessage(fd, msg_txt(sd,354));
  6616. return 0;
  6617. }
  6618. ACMD_FUNC(duel)
  6619. {
  6620. unsigned int maxpl = 0;
  6621. if(sd->duel_group > 0) {
  6622. duel_showinfo(sd->duel_group, sd);
  6623. return 0;
  6624. }
  6625. if(sd->duel_invite > 0) {
  6626. // "Duel: @duel without @reject."
  6627. clif_displaymessage(fd, msg_txt(sd,355));
  6628. return 0;
  6629. }
  6630. if(!duel_checktime(sd)) {
  6631. char output[CHAT_SIZE_MAX];
  6632. // "Duel: You can take part in duel only one time per %d minutes."
  6633. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6634. clif_displaymessage(fd, output);
  6635. return 0;
  6636. }
  6637. if( message[0] ) {
  6638. if(sscanf(message, "%d", &maxpl) >= 1) {
  6639. if(maxpl < 2 || maxpl > 65535) {
  6640. clif_displaymessage(fd, msg_txt(sd,357)); // "Duel: Invalid value."
  6641. return 0;
  6642. }
  6643. duel_create(sd, maxpl);
  6644. } else {
  6645. struct map_session_data *target_sd;
  6646. target_sd = map_nick2sd((char *)message);
  6647. if(target_sd != NULL) {
  6648. unsigned int maxpl=0, newduel;
  6649. if((newduel = duel_create(sd, 2)) != -1) {
  6650. if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) {
  6651. clif_displaymessage(fd, msg_txt(sd,353)); // "Duel: Player already in duel."
  6652. return 0;
  6653. }
  6654. duel_invite(newduel, sd, target_sd);
  6655. clif_displaymessage(fd, msg_txt(sd,354)); // "Duel: Invitation has been sent."
  6656. }
  6657. } else {
  6658. // "Duel: Player not found."
  6659. clif_displaymessage(fd, msg_txt(sd,352));
  6660. return 0;
  6661. }
  6662. }
  6663. } else
  6664. duel_create(sd, 0);
  6665. return 0;
  6666. }
  6667. ACMD_FUNC(leave)
  6668. {
  6669. if(sd->duel_group <= 0) {
  6670. // "Duel: @leave without @duel."
  6671. clif_displaymessage(fd, msg_txt(sd,358));
  6672. return 0;
  6673. }
  6674. duel_leave(sd->duel_group, sd);
  6675. clif_displaymessage(fd, msg_txt(sd,359)); // "Duel: You left the duel."
  6676. return 0;
  6677. }
  6678. ACMD_FUNC(accept)
  6679. {
  6680. if(!duel_checktime(sd)) {
  6681. char output[CHAT_SIZE_MAX];
  6682. // "Duel: You can take part in duel only one time per %d minutes."
  6683. sprintf(output, msg_txt(sd,356), battle_config.duel_time_interval);
  6684. clif_displaymessage(fd, output);
  6685. return 0;
  6686. }
  6687. if(sd->duel_invite <= 0) {
  6688. // "Duel: @accept without invititation."
  6689. clif_displaymessage(fd, msg_txt(sd,360));
  6690. return 0;
  6691. }
  6692. 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 )
  6693. {
  6694. // "Duel: Limit of players is reached."
  6695. clif_displaymessage(fd, msg_txt(sd,351));
  6696. return 0;
  6697. }
  6698. duel_accept(sd->duel_invite, sd);
  6699. // "Duel: Invitation has been accepted."
  6700. clif_displaymessage(fd, msg_txt(sd,361));
  6701. return 0;
  6702. }
  6703. ACMD_FUNC(reject)
  6704. {
  6705. if(sd->duel_invite <= 0) {
  6706. // "Duel: @reject without invititation."
  6707. clif_displaymessage(fd, msg_txt(sd,362));
  6708. return 0;
  6709. }
  6710. duel_reject(sd->duel_invite, sd);
  6711. // "Duel: Invitation has been rejected."
  6712. clif_displaymessage(fd, msg_txt(sd,363));
  6713. return 0;
  6714. }
  6715. /*===================================
  6716. * Cash Points
  6717. *-----------------------------------*/
  6718. ACMD_FUNC(cash)
  6719. {
  6720. char output[128];
  6721. int value;
  6722. int ret=0;
  6723. nullpo_retr(-1, sd);
  6724. if( !message || !*message || (value = atoi(message)) == 0 ) {
  6725. clif_displaymessage(fd, msg_txt(sd,1322)); // Please enter an amount.
  6726. return -1;
  6727. }
  6728. if( !strcmpi(command+1,"cash") )
  6729. {
  6730. if( value > 0 ) {
  6731. if( (ret=pc_getcash(sd, value, 0, LOG_TYPE_COMMAND)) >= 0){
  6732. // If this option is set, the message is already sent by pc function
  6733. if( !battle_config.cashshop_show_points ){
  6734. sprintf(output, msg_txt(sd,505), ret, sd->cashPoints);
  6735. clif_disp_onlyself(sd, output, strlen(output));
  6736. }
  6737. }
  6738. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6739. } else {
  6740. if( (ret=pc_paycash(sd, -value, 0, LOG_TYPE_COMMAND)) >= 0){
  6741. // If this option is set, the message is already sent by pc function
  6742. if( !battle_config.cashshop_show_points ){
  6743. sprintf(output, msg_txt(sd,410), ret, sd->cashPoints);
  6744. clif_disp_onlyself(sd, output, strlen(output));
  6745. }
  6746. }
  6747. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6748. }
  6749. }
  6750. else
  6751. { // @points
  6752. if( value > 0 ) {
  6753. if( (ret=pc_getcash(sd, 0, value, LOG_TYPE_COMMAND)) >= 0){
  6754. sprintf(output, msg_txt(sd,506), ret, sd->kafraPoints);
  6755. clif_disp_onlyself(sd, output, strlen(output));
  6756. }
  6757. else clif_displaymessage(fd, msg_txt(sd,149)); // Unable to decrease the number/value.
  6758. } else {
  6759. if( (ret=pc_paycash(sd, -value, -value, LOG_TYPE_COMMAND)) >= 0){
  6760. sprintf(output, msg_txt(sd,411), ret, sd->kafraPoints);
  6761. clif_disp_onlyself(sd, output, strlen(output));
  6762. }
  6763. else clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
  6764. }
  6765. }
  6766. return 0;
  6767. }
  6768. // @clone/@slaveclone/@evilclone <playername> [Valaris]
  6769. ACMD_FUNC(clone)
  6770. {
  6771. int x=0,y=0,flag=0,master=0,i=0;
  6772. struct map_session_data *pl_sd=NULL;
  6773. if (!message || !*message) {
  6774. clif_displaymessage(sd->fd,msg_txt(sd,1323)); // You must enter a player name or ID.
  6775. return 0;
  6776. }
  6777. if((pl_sd=map_nick2sd((char *)message)) == NULL && (pl_sd=map_charid2sd(atoi(message))) == NULL) {
  6778. clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
  6779. return 0;
  6780. }
  6781. if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) {
  6782. clif_displaymessage(fd, msg_txt(sd,126)); // Cannot clone a player of higher GM level than yourself.
  6783. return 0;
  6784. }
  6785. if (strcmpi(command+1, "clone") == 0)
  6786. flag = 1;
  6787. else if (strcmpi(command+1, "slaveclone") == 0) {
  6788. flag = 2;
  6789. if(pc_isdead(sd)){
  6790. clif_displaymessage(fd, msg_txt(sd,129+flag*2));
  6791. return 0;
  6792. }
  6793. master = sd->bl.id;
  6794. if (battle_config.atc_slave_clone_limit
  6795. && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
  6796. clif_displaymessage(fd, msg_txt(sd,127)); // You've reached your slave clones limit.
  6797. return 0;
  6798. }
  6799. }
  6800. do {
  6801. x = sd->bl.x + (rnd() % 10 - 5);
  6802. y = sd->bl.y + (rnd() % 10 - 5);
  6803. } while (map_getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10);
  6804. if (i >= 10) {
  6805. x = sd->bl.x;
  6806. y = sd->bl.y;
  6807. }
  6808. if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
  6809. clif_displaymessage(fd, msg_txt(sd,128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
  6810. return 0;
  6811. }
  6812. clif_displaymessage(fd, msg_txt(sd,129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone.
  6813. return 0;
  6814. }
  6815. /*=====================================
  6816. * Autorejecting Invites/Deals [LuzZza]
  6817. * Usage: @noask
  6818. *-------------------------------------*/
  6819. ACMD_FUNC(noask)
  6820. {
  6821. if(sd->state.noask) {
  6822. clif_displaymessage(fd, msg_txt(sd,391)); // Autorejecting is deactivated.
  6823. sd->state.noask = 0;
  6824. } else {
  6825. clif_displaymessage(fd, msg_txt(sd,390)); // Autorejecting is activated.
  6826. sd->state.noask = 1;
  6827. }
  6828. return 0;
  6829. }
  6830. /*=====================================
  6831. * Send a @request message to all GMs of lowest_gm_level.
  6832. * Usage: @request <petition>
  6833. *-------------------------------------*/
  6834. ACMD_FUNC(request)
  6835. {
  6836. if (!message || !*message) {
  6837. clif_displaymessage(sd->fd,msg_txt(sd,277)); // Usage: @request <petition/message to online GMs>.
  6838. return -1;
  6839. }
  6840. sprintf(atcmd_output, msg_txt(sd,278), message); // (@request): %s
  6841. intif_wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output);
  6842. clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output));
  6843. clif_displaymessage(sd->fd,msg_txt(sd,279)); // @request sent.
  6844. return 0;
  6845. }
  6846. /*==========================================
  6847. * Feel (SG save map) Reset [HiddenDragon]
  6848. *------------------------------------------*/
  6849. ACMD_FUNC(feelreset)
  6850. {
  6851. pc_resetfeel(sd);
  6852. clif_displaymessage(fd, msg_txt(sd,1324)); // Reset 'Feeling' maps.
  6853. return 0;
  6854. }
  6855. /*==========================================
  6856. * AUCTION SYSTEM
  6857. *------------------------------------------*/
  6858. ACMD_FUNC(auction)
  6859. {
  6860. nullpo_ret(sd);
  6861. clif_Auction_openwindow(sd);
  6862. return 0;
  6863. }
  6864. /*==========================================
  6865. * Kill Steal Protection
  6866. *------------------------------------------*/
  6867. ACMD_FUNC(ksprotection)
  6868. {
  6869. nullpo_retr(-1,sd);
  6870. if( sd->state.noks ) {
  6871. sd->state.noks = 0;
  6872. clif_displaymessage(fd, msg_txt(sd,1325)); // [ K.S Protection Inactive ]
  6873. }
  6874. else
  6875. {
  6876. if( !message || !*message || !strcmpi(message, "party") )
  6877. { // Default is Party
  6878. sd->state.noks = 2;
  6879. clif_displaymessage(fd, msg_txt(sd,1326)); // [ K.S Protection Active - Option: Party ]
  6880. }
  6881. else if( !strcmpi(message, "self") )
  6882. {
  6883. sd->state.noks = 1;
  6884. clif_displaymessage(fd, msg_txt(sd,1327)); // [ K.S Protection Active - Option: Self ]
  6885. }
  6886. else if( !strcmpi(message, "guild") )
  6887. {
  6888. sd->state.noks = 3;
  6889. clif_displaymessage(fd, msg_txt(sd,1328)); // [ K.S Protection Active - Option: Guild ]
  6890. }
  6891. else
  6892. clif_displaymessage(fd, msg_txt(sd,1329)); // Usage: @noks <self|party|guild>
  6893. }
  6894. return 0;
  6895. }
  6896. /*==========================================
  6897. * Map Kill Steal Protection Setting
  6898. *------------------------------------------*/
  6899. ACMD_FUNC(allowks)
  6900. {
  6901. nullpo_retr(-1,sd);
  6902. if( map[sd->bl.m].flag.allowks ) {
  6903. map[sd->bl.m].flag.allowks = 0;
  6904. clif_displaymessage(fd, msg_txt(sd,1330)); // [ Map K.S Protection Active ]
  6905. } else {
  6906. map[sd->bl.m].flag.allowks = 1;
  6907. clif_displaymessage(fd, msg_txt(sd,1331)); // [ Map K.S Protection Inactive ]
  6908. }
  6909. return 0;
  6910. }
  6911. ACMD_FUNC(resetstat)
  6912. {
  6913. nullpo_retr(-1, sd);
  6914. pc_resetstate(sd);
  6915. sprintf(atcmd_output, msg_txt(sd,207), sd->status.name);
  6916. clif_displaymessage(fd, atcmd_output);
  6917. return 0;
  6918. }
  6919. ACMD_FUNC(resetskill)
  6920. {
  6921. nullpo_retr(-1,sd);
  6922. pc_resetskill(sd,1);
  6923. sprintf(atcmd_output, msg_txt(sd,206), sd->status.name);
  6924. clif_displaymessage(fd, atcmd_output);
  6925. return 0;
  6926. }
  6927. /*==========================================
  6928. * #storagelist: Displays the items list of a player's storage.
  6929. * #cartlist: Displays contents of target's cart.
  6930. * #itemlist: Displays contents of target's inventory.
  6931. *------------------------------------------*/
  6932. ACMD_FUNC(itemlist)
  6933. {
  6934. int i, j, count, counter;
  6935. const char* location;
  6936. const struct item* items;
  6937. int size;
  6938. StringBuf buf;
  6939. nullpo_retr(-1, sd);
  6940. if( strcmp(command+1, "storagelist") == 0 )
  6941. {
  6942. location = "storage";
  6943. items = sd->status.storage.items;
  6944. size = MAX_STORAGE;
  6945. }
  6946. else
  6947. if( strcmp(command+1, "cartlist") == 0 )
  6948. {
  6949. location = "cart";
  6950. items = sd->status.cart;
  6951. size = MAX_CART;
  6952. }
  6953. else
  6954. if( strcmp(command+1, "itemlist") == 0 )
  6955. {
  6956. location = "inventory";
  6957. items = sd->status.inventory;
  6958. size = MAX_INVENTORY;
  6959. }
  6960. else
  6961. return 1;
  6962. StringBuf_Init(&buf);
  6963. count = 0; // total slots occupied
  6964. counter = 0; // total items found
  6965. for( i = 0; i < size; ++i )
  6966. {
  6967. const struct item* it = &items[i];
  6968. struct item_data* itd;
  6969. if( it->nameid == 0 || (itd = itemdb_exists(it->nameid)) == NULL )
  6970. continue;
  6971. counter += it->amount;
  6972. count++;
  6973. if( count == 1 )
  6974. {
  6975. StringBuf_Printf(&buf, msg_txt(sd,1332), location, sd->status.name); // ------ %s items list of '%s' ------
  6976. clif_displaymessage(fd, StringBuf_Value(&buf));
  6977. StringBuf_Clear(&buf);
  6978. }
  6979. if( it->refine )
  6980. StringBuf_Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid);
  6981. else
  6982. StringBuf_Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid);
  6983. if( it->equip )
  6984. {
  6985. char equipstr[CHAT_SIZE_MAX];
  6986. strcpy(equipstr, msg_txt(sd,1333)); // | equipped:
  6987. if( it->equip & EQP_GARMENT )
  6988. strcat(equipstr, msg_txt(sd,1334)); // garment,
  6989. if( it->equip & EQP_ACC_L )
  6990. strcat(equipstr, msg_txt(sd,1335)); // left accessory,
  6991. if( it->equip & EQP_ARMOR )
  6992. strcat(equipstr, msg_txt(sd,1336)); // body/armor,
  6993. if( (it->equip & EQP_ARMS) == EQP_HAND_R )
  6994. strcat(equipstr, msg_txt(sd,1337)); // right hand,
  6995. if( (it->equip & EQP_ARMS) == EQP_HAND_L )
  6996. strcat(equipstr, msg_txt(sd,1338)); // left hand,
  6997. if( (it->equip & EQP_ARMS) == EQP_ARMS )
  6998. strcat(equipstr, msg_txt(sd,1339)); // both hands,
  6999. if( it->equip & EQP_SHOES )
  7000. strcat(equipstr, msg_txt(sd,1340)); // feet,
  7001. if( it->equip & EQP_ACC_R )
  7002. strcat(equipstr, msg_txt(sd,1341)); // right accessory,
  7003. if( (it->equip & EQP_HELM) == EQP_HEAD_LOW )
  7004. strcat(equipstr, msg_txt(sd,1342)); // lower head,
  7005. if( (it->equip & EQP_HELM) == EQP_HEAD_TOP )
  7006. strcat(equipstr, msg_txt(sd,1343)); // top head,
  7007. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP) )
  7008. strcat(equipstr, msg_txt(sd,1344)); // lower/top head,
  7009. if( (it->equip & EQP_HELM) == EQP_HEAD_MID )
  7010. strcat(equipstr, msg_txt(sd,1345)); // mid head,
  7011. if( (it->equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID) )
  7012. strcat(equipstr, msg_txt(sd,1346)); // lower/mid head,
  7013. if( (it->equip & EQP_HELM) == EQP_HELM )
  7014. strcat(equipstr, msg_txt(sd,1347)); // lower/mid/top head,
  7015. // remove final ', '
  7016. equipstr[strlen(equipstr) - 2] = '\0';
  7017. StringBuf_AppendStr(&buf, equipstr);
  7018. }
  7019. clif_displaymessage(fd, StringBuf_Value(&buf));
  7020. StringBuf_Clear(&buf);
  7021. if( it->card[0] == CARD0_PET )
  7022. {// pet egg
  7023. if (it->card[3])
  7024. StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, named)
  7025. else
  7026. StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); // -> (pet egg, pet id: %u, unnamed)
  7027. }
  7028. else
  7029. if(it->card[0] == CARD0_FORGE)
  7030. {// forged item
  7031. 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)
  7032. }
  7033. else
  7034. if(it->card[0] == CARD0_CREATE)
  7035. {// created item
  7036. StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); // -> (produced item, creator id: %u)
  7037. }
  7038. else
  7039. {// normal item
  7040. int counter2 = 0;
  7041. for( j = 0; j < itd->slot; ++j )
  7042. {
  7043. struct item_data* card;
  7044. if( it->card[j] == 0 || (card = itemdb_exists(it->card[j])) == NULL )
  7045. continue;
  7046. counter2++;
  7047. if( counter2 == 1 )
  7048. StringBuf_AppendStr(&buf, msg_txt(sd,1352)); // -> (card(s):
  7049. if( counter2 != 1 )
  7050. StringBuf_AppendStr(&buf, ", ");
  7051. StringBuf_Printf(&buf, "#%d %s (id: %d)", counter2, card->jname, card->nameid);
  7052. }
  7053. if( counter2 > 0 )
  7054. StringBuf_AppendStr(&buf, ")");
  7055. }
  7056. if( StringBuf_Length(&buf) > 0 )
  7057. clif_displaymessage(fd, StringBuf_Value(&buf));
  7058. StringBuf_Clear(&buf);
  7059. }
  7060. if( count == 0 )
  7061. StringBuf_Printf(&buf, msg_txt(sd,1353), location); // No item found in this player's %s.
  7062. else
  7063. StringBuf_Printf(&buf, msg_txt(sd,1354), counter, count, location); // %d item(s) found in %d %s slots.
  7064. clif_displaymessage(fd, StringBuf_Value(&buf));
  7065. StringBuf_Destroy(&buf);
  7066. return 0;
  7067. }
  7068. ACMD_FUNC(stats)
  7069. {
  7070. char job_jobname[100];
  7071. char output[CHAT_SIZE_MAX];
  7072. int i;
  7073. struct {
  7074. const char* format;
  7075. int value;
  7076. } output_table[] = {
  7077. { "Base Level - %d", 0 },
  7078. { NULL, 0 },
  7079. { "Hp - %d", 0 },
  7080. { "MaxHp - %d", 0 },
  7081. { "Sp - %d", 0 },
  7082. { "MaxSp - %d", 0 },
  7083. { "Str - %3d", 0 },
  7084. { "Agi - %3d", 0 },
  7085. { "Vit - %3d", 0 },
  7086. { "Int - %3d", 0 },
  7087. { "Dex - %3d", 0 },
  7088. { "Luk - %3d", 0 },
  7089. { "Zeny - %d", 0 },
  7090. { "Free SK Points - %d", 0 },
  7091. { "JobChangeLvl (2nd) - %d", 0 },
  7092. { "JobChangeLvl (3rd) - %d", 0 },
  7093. { NULL, 0 }
  7094. };
  7095. memset(job_jobname, '\0', sizeof(job_jobname));
  7096. memset(output, '\0', sizeof(output));
  7097. //direct array initialization with variables is not standard C compliant.
  7098. output_table[0].value = sd->status.base_level;
  7099. output_table[1].format = job_jobname;
  7100. output_table[1].value = sd->status.job_level;
  7101. output_table[2].value = sd->status.hp;
  7102. output_table[3].value = sd->status.max_hp;
  7103. output_table[4].value = sd->status.sp;
  7104. output_table[5].value = sd->status.max_sp;
  7105. output_table[6].value = sd->status.str;
  7106. output_table[7].value = sd->status.agi;
  7107. output_table[8].value = sd->status.vit;
  7108. output_table[9].value = sd->status.int_;
  7109. output_table[10].value = sd->status.dex;
  7110. output_table[11].value = sd->status.luk;
  7111. output_table[12].value = sd->status.zeny;
  7112. output_table[13].value = sd->status.skill_point;
  7113. output_table[14].value = sd->change_level_2nd;
  7114. output_table[15].value = sd->change_level_3rd;
  7115. sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
  7116. sprintf(output, msg_txt(sd,53), sd->status.name); // '%s' stats:
  7117. clif_displaymessage(fd, output);
  7118. for (i = 0; output_table[i].format != NULL; i++) {
  7119. sprintf(output, output_table[i].format, output_table[i].value);
  7120. clif_displaymessage(fd, output);
  7121. }
  7122. return 0;
  7123. }
  7124. ACMD_FUNC(delitem)
  7125. {
  7126. char item_name[100];
  7127. int nameid, amount = 0, total, idx;
  7128. struct item_data* id;
  7129. nullpo_retr(-1, sd);
  7130. if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 )
  7131. {
  7132. 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>).
  7133. return -1;
  7134. }
  7135. if( ( id = itemdb_searchname(item_name) ) != NULL || ( id = itemdb_exists(atoi(item_name)) ) != NULL )
  7136. {
  7137. nameid = id->nameid;
  7138. }
  7139. else
  7140. {
  7141. clif_displaymessage(fd, msg_txt(sd,19)); // Invalid item ID or name.
  7142. return -1;
  7143. }
  7144. total = amount;
  7145. // delete items
  7146. while( amount && ( idx = pc_search_inventory(sd, nameid) ) != -1 )
  7147. {
  7148. int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount;
  7149. if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET )
  7150. {// delete pet
  7151. intif_delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
  7152. }
  7153. pc_delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND);
  7154. amount-= delamount;
  7155. }
  7156. // notify target
  7157. sprintf(atcmd_output, msg_txt(sd,113), total-amount); // %d item(s) removed by a GM.
  7158. clif_displaymessage(sd->fd, atcmd_output);
  7159. // notify source
  7160. if( amount == total )
  7161. {
  7162. clif_displaymessage(fd, msg_txt(sd,116)); // Character does not have the item.
  7163. }
  7164. else if( amount )
  7165. {
  7166. sprintf(atcmd_output, msg_txt(sd,115), total-amount, total-amount, total); // %d item(s) removed. Player had only %d on %d items.
  7167. clif_displaymessage(fd, atcmd_output);
  7168. }
  7169. else
  7170. {
  7171. sprintf(atcmd_output, msg_txt(sd,114), total); // %d item(s) removed from the player.
  7172. clif_displaymessage(fd, atcmd_output);
  7173. }
  7174. return 0;
  7175. }
  7176. /*==========================================
  7177. * Custom Fonts
  7178. *------------------------------------------*/
  7179. ACMD_FUNC(font)
  7180. {
  7181. int font_id;
  7182. nullpo_retr(-1,sd);
  7183. font_id = atoi(message);
  7184. if( font_id == 0 )
  7185. {
  7186. if( sd->user_font )
  7187. {
  7188. sd->user_font = 0;
  7189. clif_displaymessage(fd, msg_txt(sd,1356)); // Returning to normal font.
  7190. clif_font(sd);
  7191. }
  7192. else
  7193. {
  7194. clif_displaymessage(fd, msg_txt(sd,1357)); // Use @font <1-9> to change your message font.
  7195. clif_displaymessage(fd, msg_txt(sd,1358)); // Use 0 or no parameter to return to normal font.
  7196. }
  7197. }
  7198. else if( font_id < 0 || font_id > 9 )
  7199. clif_displaymessage(fd, msg_txt(sd,1359)); // Invalid font. Use a value from 0 to 9.
  7200. else if( font_id != sd->user_font )
  7201. {
  7202. sd->user_font = font_id;
  7203. clif_font(sd);
  7204. clif_displaymessage(fd, msg_txt(sd,1360)); // Font changed.
  7205. }
  7206. else
  7207. clif_displaymessage(fd, msg_txt(sd,1361)); // Already using this font.
  7208. return 0;
  7209. }
  7210. /*==========================================
  7211. * type: 1 = commands (@), 2 = charcommands (#)
  7212. *------------------------------------------*/
  7213. static void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type)
  7214. {
  7215. char line_buff[CHATBOX_SIZE];
  7216. char* cur = line_buff;
  7217. AtCommandInfo* cmd;
  7218. DBIterator *iter = db_iterator(atcommand_db);
  7219. int count = 0;
  7220. memset(line_buff,' ',CHATBOX_SIZE);
  7221. line_buff[CHATBOX_SIZE-1] = 0;
  7222. clif_displaymessage(fd, msg_txt(sd,273)); // "Commands available:"
  7223. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  7224. unsigned int slen = 0;
  7225. switch( type ) {
  7226. case COMMAND_CHARCOMMAND:
  7227. if( cmd->char_groups[sd->group_pos] == 0 )
  7228. continue;
  7229. break;
  7230. case COMMAND_ATCOMMAND:
  7231. if( cmd->at_groups[sd->group_pos] == 0 )
  7232. continue;
  7233. break;
  7234. default:
  7235. continue;
  7236. }
  7237. slen = strlen(cmd->command);
  7238. // flush the text buffer if this command won't fit into it
  7239. if (slen + cur - line_buff >= CHATBOX_SIZE) {
  7240. clif_displaymessage(fd,line_buff);
  7241. cur = line_buff;
  7242. memset(line_buff,' ',CHATBOX_SIZE);
  7243. line_buff[CHATBOX_SIZE-1] = 0;
  7244. }
  7245. memcpy(cur,cmd->command,slen);
  7246. cur += slen+(10-slen%10);
  7247. count++;
  7248. }
  7249. dbi_destroy(iter);
  7250. clif_displaymessage(fd,line_buff);
  7251. sprintf(atcmd_output, msg_txt(sd,274), count); // "%d commands found."
  7252. clif_displaymessage(fd, atcmd_output);
  7253. return;
  7254. }
  7255. /*==========================================
  7256. * @commands Lists available @ commands to you
  7257. *------------------------------------------*/
  7258. ACMD_FUNC(commands)
  7259. {
  7260. atcommand_commands_sub(sd, fd, COMMAND_ATCOMMAND);
  7261. return 0;
  7262. }
  7263. /*==========================================
  7264. * @charcommands Lists available # commands to you
  7265. *------------------------------------------*/
  7266. ACMD_FUNC(charcommands)
  7267. {
  7268. atcommand_commands_sub(sd, fd, COMMAND_CHARCOMMAND);
  7269. return 0;
  7270. }
  7271. /* for new mounts */
  7272. ACMD_FUNC(mount2) {
  7273. clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
  7274. if( !(sd->sc.option&OPTION_MOUNTING) ) {
  7275. clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
  7276. pc_setoption(sd, sd->sc.option|OPTION_MOUNTING);
  7277. } else {
  7278. clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
  7279. pc_setoption(sd, sd->sc.option&~OPTION_MOUNTING);
  7280. }
  7281. return 0;
  7282. }
  7283. ACMD_FUNC(accinfo) {
  7284. char query[NAME_LENGTH];
  7285. if (!message || !*message || strlen(message) > NAME_LENGTH ) {
  7286. clif_displaymessage(fd, msg_txt(sd,1365)); // Usage: @accinfo/@accountinfo <account_id/char name>
  7287. 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".
  7288. return -1;
  7289. }
  7290. //remove const type
  7291. safestrncpy(query, message, NAME_LENGTH);
  7292. intif_request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query );
  7293. return 0;
  7294. }
  7295. /* [Ind] */
  7296. ACMD_FUNC(set) {
  7297. char reg[32], val[128];
  7298. struct script_data* data;
  7299. int toset = 0, len;
  7300. bool is_str = false;
  7301. if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) {
  7302. clif_displaymessage(fd, msg_txt(sd,1367)); // Usage: @set <variable name> <value>
  7303. clif_displaymessage(fd, msg_txt(sd,1368)); // Usage: ex. "@set PoringCharVar 50"
  7304. clif_displaymessage(fd, msg_txt(sd,1369)); // Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
  7305. clif_displaymessage(fd, msg_txt(sd,1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
  7306. return -1;
  7307. }
  7308. /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */
  7309. if( reg[0] == '.' ) {
  7310. clif_displaymessage(fd, msg_txt(sd,1371)); // NPC variables may not be used with @set.
  7311. return -1;
  7312. } else if( reg[0] == '\'' ) {
  7313. clif_displaymessage(fd, msg_txt(sd,1372)); // Instance variables may not be used with @set.
  7314. return -1;
  7315. }
  7316. is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false;
  7317. if( ( len = strlen(val) ) > 1 ) {
  7318. if( val[0] == '"' && val[len-1] == '"') {
  7319. val[len-1] = '\0'; //Strip quotes.
  7320. memmove(val, val+1, len-1);
  7321. }
  7322. }
  7323. if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */
  7324. if( is_str )
  7325. set_var(sd, reg, (void*) val);
  7326. else
  7327. set_var(sd, reg, (void*)__64BPRTSIZE((atoi(val))));
  7328. }
  7329. CREATE(data, struct script_data,1);
  7330. if( is_str ) {// string variable
  7331. switch( reg[0] ) {
  7332. case '@':
  7333. data->u.str = pc_readregstr(sd, add_str(reg));
  7334. break;
  7335. case '$':
  7336. data->u.str = mapreg_readregstr(add_str(reg));
  7337. break;
  7338. case '#':
  7339. if( reg[1] == '#' )
  7340. data->u.str = pc_readaccountreg2str(sd, reg);// global
  7341. else
  7342. data->u.str = pc_readaccountregstr(sd, reg);// local
  7343. break;
  7344. default:
  7345. data->u.str = pc_readglobalreg_str(sd, reg);
  7346. break;
  7347. }
  7348. if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
  7349. data->type = C_CONSTSTR;
  7350. data->u.str = "";
  7351. } else {// duplicate string
  7352. data->type = C_STR;
  7353. data->u.str = aStrdup(data->u.str);
  7354. }
  7355. } else {// integer variable
  7356. data->type = C_INT;
  7357. switch( reg[0] ) {
  7358. case '@':
  7359. data->u.num = pc_readreg(sd, add_str(reg));
  7360. break;
  7361. case '$':
  7362. data->u.num = mapreg_readreg(add_str(reg));
  7363. break;
  7364. case '#':
  7365. if( reg[1] == '#' )
  7366. data->u.num = pc_readaccountreg2(sd, reg);// global
  7367. else
  7368. data->u.num = pc_readaccountreg(sd, reg);// local
  7369. break;
  7370. default:
  7371. data->u.num = pc_readglobalreg(sd, reg);
  7372. break;
  7373. }
  7374. }
  7375. switch( data->type ) {
  7376. case C_INT:
  7377. sprintf(atcmd_output,msg_txt(sd,1373),reg,data->u.num); // %s value is now :%d
  7378. break;
  7379. case C_STR:
  7380. sprintf(atcmd_output,msg_txt(sd,1374),reg,data->u.str); // %s value is now :%s
  7381. break;
  7382. case C_CONSTSTR:
  7383. sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
  7384. break;
  7385. default:
  7386. sprintf(atcmd_output,msg_txt(sd,1376),reg,data->type); // %s data type is not supported :%u
  7387. break;
  7388. }
  7389. clif_displaymessage(fd, atcmd_output);
  7390. aFree(data);
  7391. return 0;
  7392. }
  7393. ACMD_FUNC(addperm) {
  7394. int perm_size = ARRAYLENGTH(pc_g_permission_name);
  7395. bool add = (strcmpi(command+1, "addperm") == 0) ? true : false;
  7396. int i;
  7397. if( !message || !*message ) {
  7398. sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s <permission_name>
  7399. clif_displaymessage(fd, atcmd_output);
  7400. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7401. for( i = 0; i < perm_size; i++ ) {
  7402. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7403. clif_displaymessage(fd, atcmd_output);
  7404. }
  7405. return -1;
  7406. }
  7407. ARR_FIND(0, perm_size, i, strcmpi(pc_g_permission_name[i].name, message) == 0);
  7408. if( i == perm_size ) {
  7409. sprintf(atcmd_output,msg_txt(sd,1380),message); // '%s' is not a known permission.
  7410. clif_displaymessage(fd, atcmd_output);
  7411. clif_displaymessage(fd, msg_txt(sd,1379)); // -- Permission List
  7412. for( i = 0; i < perm_size; i++ ) {
  7413. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7414. clif_displaymessage(fd, atcmd_output);
  7415. }
  7416. return -1;
  7417. }
  7418. if( add && (sd->permissions&pc_g_permission_name[i].permission) ) {
  7419. sprintf(atcmd_output, msg_txt(sd,1381),sd->status.name,pc_g_permission_name[i].name); // User '%s' already possesses the '%s' permission.
  7420. clif_displaymessage(fd, atcmd_output);
  7421. return -1;
  7422. } else if ( !add && !(sd->permissions&pc_g_permission_name[i].permission) ) {
  7423. sprintf(atcmd_output, msg_txt(sd,1382),sd->status.name,pc_g_permission_name[i].name); // User '%s' doesn't possess the '%s' permission.
  7424. clif_displaymessage(fd, atcmd_output);
  7425. sprintf(atcmd_output,msg_txt(sd,1383),sd->status.name); // -- User '%s' Permissions
  7426. clif_displaymessage(fd, atcmd_output);
  7427. for( i = 0; i < perm_size; i++ ) {
  7428. if( sd->permissions&pc_g_permission_name[i].permission ) {
  7429. sprintf(atcmd_output,"- %s",pc_g_permission_name[i].name);
  7430. clif_displaymessage(fd, atcmd_output);
  7431. }
  7432. }
  7433. return -1;
  7434. }
  7435. if( add )
  7436. sd->permissions |= pc_g_permission_name[i].permission;
  7437. else
  7438. sd->permissions &=~ pc_g_permission_name[i].permission;
  7439. sprintf(atcmd_output, msg_txt(sd,1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary.
  7440. clif_displaymessage(fd, atcmd_output);
  7441. return 0;
  7442. }
  7443. ACMD_FUNC(unloadnpcfile) {
  7444. if( !message || !*message ) {
  7445. clif_displaymessage(fd, msg_txt(sd,1385)); // Usage: @unloadnpcfile <file name>
  7446. return -1;
  7447. }
  7448. if( npc_unloadfile(message) )
  7449. clif_displaymessage(fd, msg_txt(sd,1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
  7450. else {
  7451. clif_displaymessage(fd, msg_txt(sd,1387)); // File not found.
  7452. return -1;
  7453. }
  7454. return 0;
  7455. }
  7456. ACMD_FUNC(cart) {
  7457. #define MC_CART_MDFY(x) \
  7458. sd->status.skill[MC_PUSHCART].id = x?MC_PUSHCART:0; \
  7459. sd->status.skill[MC_PUSHCART].lv = x?1:0; \
  7460. sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
  7461. int val = atoi(message);
  7462. bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true;
  7463. if( !message || !*message || val < 0 || val > MAX_CARTS ) {
  7464. sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>).
  7465. clif_displaymessage(fd, atcmd_output);
  7466. return -1;
  7467. }
  7468. if( val == 0 && !pc_iscarton(sd) ) {
  7469. clif_displaymessage(fd, msg_txt(sd,1391)); // You do not possess a cart to be removed
  7470. return -1;
  7471. }
  7472. if( need_skill ) {
  7473. MC_CART_MDFY(1);
  7474. }
  7475. if( pc_setcart(sd, val) ) {
  7476. if( need_skill ) {
  7477. MC_CART_MDFY(0);
  7478. }
  7479. return -1;/* @cart failed */
  7480. }
  7481. if( need_skill ) {
  7482. MC_CART_MDFY(0);
  7483. }
  7484. clif_displaymessage(fd, msg_txt(sd,1392)); // Cart Added
  7485. return 0;
  7486. #undef MC_CART_MDFY
  7487. }
  7488. /* Channel System [Ind] */
  7489. ACMD_FUNC(join){
  7490. char chname[CHAN_NAME_LENGTH], pass[CHAN_NAME_LENGTH];
  7491. if( !message || !*message || sscanf(message, "%s %s", chname, pass) < 1 ) {
  7492. sprintf(atcmd_output, msg_txt(sd,1399),command); // Unknown channel (usage: %s <#channel_name>).
  7493. clif_displaymessage(fd, atcmd_output);
  7494. return -1;
  7495. }
  7496. return channel_pcjoin(sd, chname, pass);
  7497. }
  7498. /*
  7499. * Display available option for @channel command
  7500. * @command : the name of used command (for alias case)
  7501. */
  7502. static inline void atcmd_channel_help(struct map_session_data *sd, const char *command)
  7503. {
  7504. int fd = sd->fd;
  7505. bool can_delete = pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN);
  7506. bool can_create = (can_delete || Channel_Config.user_chenable);
  7507. clif_displaymessage(fd, msg_txt(sd,1414));// ---- Available options:
  7508. //option create
  7509. if( can_create ) {
  7510. sprintf(atcmd_output, msg_txt(sd,1415),command);// * %s create <#channel_name> <channel_password>
  7511. clif_displaymessage(fd, atcmd_output);
  7512. clif_displaymessage(fd, msg_txt(sd,1416));// -- Creates a new channel.
  7513. }
  7514. //option delete
  7515. if(can_delete){
  7516. sprintf(atcmd_output, msg_txt(sd,1469),command);// * %s delete <#channel_name>
  7517. clif_displaymessage(fd, atcmd_output);
  7518. clif_displaymessage(fd, msg_txt(sd,1470)); // -- Destroys the specified channel.
  7519. }
  7520. //option list
  7521. sprintf(atcmd_output, msg_txt(sd,1417),command);// * %s list
  7522. clif_displaymessage(fd, atcmd_output);
  7523. clif_displaymessage(fd, msg_txt(sd,1418));// -- Lists all public channels.
  7524. sprintf(atcmd_output, msg_txt(sd,1471),command);// * %s list mine
  7525. clif_displaymessage(fd, atcmd_output);
  7526. clif_displaymessage(fd, msg_txt(sd,1472));// -- Lists all channels you have joined.
  7527. if( can_create ) {
  7528. sprintf(atcmd_output, msg_txt(sd,1419),command);// * %s list colors
  7529. clif_displaymessage(fd, atcmd_output);
  7530. clif_displaymessage(fd, msg_txt(sd,1420));// -- Lists all available colors for custom channels.
  7531. }
  7532. //option setcolor
  7533. if(can_create){
  7534. sprintf(atcmd_output, msg_txt(sd,1421),command);// * %s setcolor <#channel_name> <color_name>
  7535. clif_displaymessage(fd, atcmd_output);
  7536. clif_displaymessage(fd, msg_txt(sd,1422));// -- Changes channel text to the specified color (channel owners only).
  7537. }
  7538. //option join
  7539. sprintf(atcmd_output, msg_txt(sd,1473),command);// * %s join <#channel_name> <channel_password>
  7540. clif_displaymessage(fd, atcmd_output);
  7541. clif_displaymessage(fd, msg_txt(sd,1474));// -- Joins the specified channel.
  7542. //option leave
  7543. sprintf(atcmd_output, msg_txt(sd,1423),command);// * %s leave <#channel_name>
  7544. clif_displaymessage(fd, atcmd_output);
  7545. clif_displaymessage(fd, msg_txt(sd,1424));// -- Leaves the specified channel.
  7546. //option bindto
  7547. sprintf(atcmd_output, msg_txt(sd,1427),command);// * %s bindto <#channel_name>
  7548. clif_displaymessage(fd, atcmd_output);
  7549. clif_displaymessage(fd, msg_txt(sd,1428));// -- Binds your global chat to the specified channel, sending all global messages to that channel.
  7550. //option unbind
  7551. sprintf(atcmd_output, msg_txt(sd,1429),command);// * %s unbind
  7552. clif_displaymessage(fd, atcmd_output);
  7553. clif_displaymessage(fd, msg_txt(sd,1430));// -- Unbinds your global chat from the attached channel, if any.
  7554. //option ban/unban/banlist
  7555. if( can_create ) {
  7556. sprintf(atcmd_output, msg_txt(sd,1456),command);// * %s ban <#channel_name> <player>
  7557. clif_displaymessage(fd, atcmd_output);
  7558. clif_displaymessage(fd, msg_txt(sd,1457));// -- Bans the specified player from the channel.
  7559. sprintf(atcmd_output, msg_txt(sd,1458),command);// * %s banlist <#channel_name>
  7560. clif_displaymessage(fd, atcmd_output);
  7561. clif_displaymessage(fd, msg_txt(sd,1459));// -- Lists all players banned from the specified channel.
  7562. sprintf(atcmd_output, msg_txt(sd,1460),command);// * %s unban <#channel_name> <player>
  7563. clif_displaymessage(fd, atcmd_output);
  7564. clif_displaymessage(fd, msg_txt(sd,1461));// -- Unbans the specified player from the channel.
  7565. sprintf(atcmd_output, msg_txt(sd,1467),command);// * %s unbanall <#channel_name>
  7566. clif_displaymessage(fd, atcmd_output);
  7567. clif_displaymessage(fd, msg_txt(sd,1468));// -- Clears all bans from the specified channel.
  7568. }
  7569. //option setopt
  7570. if(can_create){
  7571. sprintf(atcmd_output, msg_txt(sd,1462),command);// * %s setopt <#channel_name> <option> <value>
  7572. clif_displaymessage(fd, atcmd_output);
  7573. clif_displaymessage(fd, msg_txt(sd,1463));// -- Sets an option and value for the specified channel.
  7574. }
  7575. sprintf(atcmd_output, msg_txt(sd,1404),command); // %s failed.
  7576. clif_displaymessage(fd, atcmd_output);
  7577. }
  7578. ACMD_FUNC(channel) {
  7579. char key[CHAN_NAME_LENGTH], sub1[CHAN_NAME_LENGTH], sub2[CHAN_NAME_LENGTH], sub3[CHAN_NAME_LENGTH];
  7580. sub1[0] = sub2[0] = sub3[0] = '\0';
  7581. if( !message || !*message || sscanf(message, "%s %s %s %s", key, sub1, sub2, sub3) < 1 ) {
  7582. atcmd_channel_help(sd,command);
  7583. return 0;
  7584. }
  7585. if( strcmpi(key,"create") == 0 && ( Channel_Config.user_chenable || pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) ) {
  7586. if(sub3[0] != '\0'){
  7587. clif_displaymessage(fd, msg_txt(sd,1408)); // Channel password may not contain spaces.
  7588. return -1;
  7589. }
  7590. return channel_pccreate(sd,sub1,sub2);
  7591. } else if( strcmpi(key,"delete") == 0 && pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
  7592. return channel_pcdelete(sd,sub1);
  7593. } else if ( strcmpi(key,"list") == 0 ) {
  7594. return channel_display_list(sd,sub1);
  7595. } else if ( strcmpi(key,"setcolor") == 0 ) {
  7596. return channel_pccolor(sd, sub1, sub2);
  7597. } else if ( strcmpi(key,"join") == 0 ) {
  7598. return channel_pcjoin(sd, sub1, sub2);
  7599. }else if ( strcmpi(key,"leave") == 0 ) {
  7600. return channel_pcleave(sd, sub1);
  7601. } else if ( strcmpi(key,"bindto") == 0 ) {
  7602. return channel_pcbind(sd, sub1);
  7603. } else if ( strcmpi(key,"unbind") == 0 ) {
  7604. return channel_pcunbind(sd);
  7605. } else if ( strcmpi(key,"ban") == 0 ) {
  7606. return channel_pcban(sd,sub1,map_nick2sd(sub2),0);
  7607. } else if ( strcmpi(key,"banlist") == 0 ) {
  7608. return channel_pcban(sd,sub1,NULL,3);
  7609. } else if ( strcmpi(key,"unban") == 0 ) {
  7610. return channel_pcban(sd,sub1,map_nick2sd(sub2),1);
  7611. } else if ( strcmpi(key,"unbanall") == 0 ) {
  7612. return channel_pcban(sd,sub1,NULL,2);
  7613. } else if ( strcmpi(key,"setopt") == 0 ) {
  7614. return channel_pcsetopt(sd,sub1,sub2,sub3);
  7615. } else {
  7616. atcmd_channel_help(sd,command);
  7617. }
  7618. return 0;
  7619. }
  7620. ACMD_FUNC(fontcolor)
  7621. {
  7622. unsigned char k;
  7623. if( !message || !*message ) {
  7624. channel_display_list(sd,"colors");
  7625. return -1;
  7626. }
  7627. if( strcmpi(message,"Normal") == 0 ) {
  7628. sd->fontcolor = 0;
  7629. } else {
  7630. ARR_FIND(0,Channel_Config.colors_count,k,( strcmpi(message,Channel_Config.colors_name[k]) == 0 ));
  7631. if( k == Channel_Config.colors_count ) {
  7632. sprintf(atcmd_output, msg_txt(sd,1411), message);// Unknown color '%s'.
  7633. clif_displaymessage(fd, atcmd_output);
  7634. return -1;
  7635. }
  7636. sd->fontcolor = k;
  7637. }
  7638. sprintf(atcmd_output, msg_txt(sd,1454), message);// Color set to '%s'.
  7639. clif_displaymessage(fd, atcmd_output);
  7640. return 0;
  7641. }
  7642. ACMD_FUNC(langtype)
  7643. {
  7644. char langstr[8];
  7645. int i=0, test=0;
  7646. memset(langstr, '\0', sizeof(langstr));
  7647. if(sscanf(message, "%3s", langstr) >= 1){
  7648. int lang=-1;
  7649. lang = msg_langstr2langtype(langstr); //Switch langstr to associated langtype
  7650. if( msg_checklangtype(lang,false) == 1 ){ //Verify it's enabled and set it
  7651. char output[100];
  7652. pc_setaccountreg(sd, "#langtype", lang); //For login/char
  7653. sd->langtype = lang;
  7654. sprintf(output,msg_txt(sd,461),msg_langtype2langstr(lang)); // Language is now set to %s.
  7655. clif_displaymessage(fd,output);
  7656. return 0;
  7657. } else if (lang != -1) { //defined langage but failed check
  7658. clif_displaymessage(fd,msg_txt(sd,462)); // This langage is currently disabled.
  7659. return -1;
  7660. }
  7661. }
  7662. //wrong or no entry
  7663. clif_displaymessage(fd,msg_txt(sd,460)); // Please enter a valid language (usage: @langtype <language>).
  7664. clif_displaymessage(fd,msg_txt(sd,464)); // ---- Available languages:
  7665. while(test!=-1){ //out of range
  7666. test = msg_checklangtype(i,false);
  7667. if(test == 1)
  7668. clif_displaymessage(fd,msg_langtype2langstr(i));
  7669. i++;
  7670. }
  7671. return -1;
  7672. }
  7673. /**
  7674. * Fills the reference of available commands in atcommand DBMap
  7675. **/
  7676. #define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL }
  7677. #define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL }
  7678. void atcommand_basecommands(void) {
  7679. /**
  7680. * Command reference list, place the base of your commands here
  7681. **/
  7682. AtCommandInfo atcommand_base[] = {
  7683. ACMD_DEF2("warp", mapmove),
  7684. ACMD_DEF(where),
  7685. ACMD_DEF(jumpto),
  7686. ACMD_DEF(jump),
  7687. ACMD_DEF(who),
  7688. ACMD_DEF2("who2", who),
  7689. ACMD_DEF2("who3", who),
  7690. ACMD_DEF2("whomap", who),
  7691. ACMD_DEF2("whomap2", who),
  7692. ACMD_DEF2("whomap3", who),
  7693. ACMD_DEF(whogm),
  7694. ACMD_DEF(save),
  7695. ACMD_DEF(load),
  7696. ACMD_DEF(speed),
  7697. ACMD_DEF(storage),
  7698. ACMD_DEF(guildstorage),
  7699. ACMD_DEF(option),
  7700. ACMD_DEF(hide), // + /hide
  7701. ACMD_DEF(jobchange),
  7702. ACMD_DEF(kill),
  7703. ACMD_DEF(alive),
  7704. ACMD_DEF(kami),
  7705. ACMD_DEF2("kamib", kami),
  7706. ACMD_DEF2("kamic", kami),
  7707. ACMD_DEF2("lkami", kami),
  7708. ACMD_DEF(heal),
  7709. ACMD_DEF(item),
  7710. ACMD_DEF(item2),
  7711. ACMD_DEF(itemreset),
  7712. ACMD_DEF(clearstorage),
  7713. ACMD_DEF(cleargstorage),
  7714. ACMD_DEF(clearcart),
  7715. ACMD_DEF2("blvl", baselevelup),
  7716. ACMD_DEF2("jlvl", joblevelup),
  7717. ACMD_DEF(help),
  7718. ACMD_DEF(pvpoff),
  7719. ACMD_DEF(pvpon),
  7720. ACMD_DEF(gvgoff),
  7721. ACMD_DEF(gvgon),
  7722. ACMD_DEF(model),
  7723. ACMD_DEF(go),
  7724. ACMD_DEF(monster),
  7725. ACMD_DEF2("monstersmall", monster),
  7726. ACMD_DEF2("monsterbig", monster),
  7727. ACMD_DEF(killmonster),
  7728. ACMD_DEF2("killmonster2", killmonster),
  7729. ACMD_DEF(refine),
  7730. ACMD_DEF(produce),
  7731. ACMD_DEF(memo),
  7732. ACMD_DEF(gat),
  7733. ACMD_DEF(displaystatus),
  7734. ACMD_DEF2("stpoint", statuspoint),
  7735. ACMD_DEF2("skpoint", skillpoint),
  7736. ACMD_DEF(zeny),
  7737. ACMD_DEF2("str", param),
  7738. ACMD_DEF2("agi", param),
  7739. ACMD_DEF2("vit", param),
  7740. ACMD_DEF2("int", param),
  7741. ACMD_DEF2("dex", param),
  7742. ACMD_DEF2("luk", param),
  7743. ACMD_DEF2("glvl", guildlevelup),
  7744. ACMD_DEF(makeegg),
  7745. ACMD_DEF(hatch),
  7746. ACMD_DEF(petfriendly),
  7747. ACMD_DEF(pethungry),
  7748. ACMD_DEF(petrename),
  7749. ACMD_DEF(recall), // + /recall
  7750. ACMD_DEF(night),
  7751. ACMD_DEF(day),
  7752. ACMD_DEF(doom),
  7753. ACMD_DEF(doommap),
  7754. ACMD_DEF(raise),
  7755. ACMD_DEF(raisemap),
  7756. ACMD_DEF(kick), // + right click menu for GM "(name) force to quit"
  7757. ACMD_DEF(kickall),
  7758. ACMD_DEF(allskill),
  7759. ACMD_DEF(questskill),
  7760. ACMD_DEF(lostskill),
  7761. ACMD_DEF(spiritball),
  7762. ACMD_DEF(party),
  7763. ACMD_DEF(guild),
  7764. ACMD_DEF(breakguild),
  7765. ACMD_DEF(agitstart),
  7766. ACMD_DEF(agitend),
  7767. ACMD_DEF(mapexit),
  7768. ACMD_DEF(idsearch),
  7769. ACMD_DEF(broadcast), // + /b and /nb
  7770. ACMD_DEF(localbroadcast), // + /lb and /nlb
  7771. ACMD_DEF(recallall),
  7772. ACMD_DEF(reload),
  7773. ACMD_DEF2("reloaditemdb", reload),
  7774. ACMD_DEF2("reloadmobdb", reload),
  7775. ACMD_DEF2("reloadskilldb", reload),
  7776. ACMD_DEF2("reloadscript", reload),
  7777. ACMD_DEF2("reloadatcommand", reload),
  7778. ACMD_DEF2("reloadbattleconf", reload),
  7779. ACMD_DEF2("reloadstatusdb", reload),
  7780. ACMD_DEF2("reloadpcdb", reload),
  7781. ACMD_DEF2("reloadmotd", reload),
  7782. ACMD_DEF2("reloadquestdb", reload),
  7783. ACMD_DEF2("reloadmsgconf", reload),
  7784. ACMD_DEF2("reloadpacketdb", reload),
  7785. ACMD_DEF(mapinfo),
  7786. ACMD_DEF(dye),
  7787. ACMD_DEF2("hairstyle", hair_style),
  7788. ACMD_DEF2("haircolor", hair_color),
  7789. ACMD_DEF2("allstats", stat_all),
  7790. ACMD_DEF2("block", char_block),
  7791. ACMD_DEF2("ban", char_ban),
  7792. ACMD_DEF2("unblock", char_unblock),
  7793. ACMD_DEF2("unban", char_unban),
  7794. ACMD_DEF2("mount", mount_peco),
  7795. ACMD_DEF(guildspy),
  7796. ACMD_DEF(partyspy),
  7797. ACMD_DEF(repairall),
  7798. ACMD_DEF(guildrecall),
  7799. ACMD_DEF(partyrecall),
  7800. ACMD_DEF(nuke),
  7801. ACMD_DEF(shownpc),
  7802. ACMD_DEF(hidenpc),
  7803. ACMD_DEF(loadnpc),
  7804. ACMD_DEF(unloadnpc),
  7805. ACMD_DEF2("time", servertime),
  7806. ACMD_DEF(jail),
  7807. ACMD_DEF(unjail),
  7808. ACMD_DEF(jailfor),
  7809. ACMD_DEF(jailtime),
  7810. ACMD_DEF(disguise),
  7811. ACMD_DEF(undisguise),
  7812. ACMD_DEF(email),
  7813. ACMD_DEF(effect),
  7814. ACMD_DEF(follow),
  7815. ACMD_DEF(addwarp),
  7816. ACMD_DEF(skillon),
  7817. ACMD_DEF(skilloff),
  7818. ACMD_DEF(killer),
  7819. ACMD_DEF(npcmove),
  7820. ACMD_DEF(killable),
  7821. ACMD_DEF(dropall),
  7822. ACMD_DEF(storeall),
  7823. ACMD_DEF(skillid),
  7824. ACMD_DEF(useskill),
  7825. ACMD_DEF(displayskill),
  7826. ACMD_DEF(snow),
  7827. ACMD_DEF(sakura),
  7828. ACMD_DEF(clouds),
  7829. ACMD_DEF(clouds2),
  7830. ACMD_DEF(fog),
  7831. ACMD_DEF(fireworks),
  7832. ACMD_DEF(leaves),
  7833. ACMD_DEF(summon),
  7834. ACMD_DEF(adjgroup),
  7835. ACMD_DEF(trade),
  7836. ACMD_DEF(send),
  7837. ACMD_DEF(setbattleflag),
  7838. ACMD_DEF(unmute),
  7839. ACMD_DEF(clearweather),
  7840. ACMD_DEF(uptime),
  7841. ACMD_DEF(changesex),
  7842. ACMD_DEF(mute),
  7843. ACMD_DEF(refresh),
  7844. ACMD_DEF(refreshall),
  7845. ACMD_DEF(identify),
  7846. ACMD_DEF(identifyall),
  7847. ACMD_DEF(gmotd),
  7848. ACMD_DEF(misceffect),
  7849. ACMD_DEF(mobsearch),
  7850. ACMD_DEF(cleanmap),
  7851. ACMD_DEF(cleanarea),
  7852. ACMD_DEF(npctalk),
  7853. ACMD_DEF(pettalk),
  7854. ACMD_DEF(users),
  7855. ACMD_DEF(reset),
  7856. ACMD_DEF(skilltree),
  7857. ACMD_DEF(marry),
  7858. ACMD_DEF(divorce),
  7859. ACMD_DEF(sound),
  7860. ACMD_DEF(undisguiseall),
  7861. ACMD_DEF(disguiseall),
  7862. ACMD_DEF(changelook),
  7863. ACMD_DEF(autoloot),
  7864. ACMD_DEF2("alootid", autolootitem),
  7865. ACMD_DEF(mobinfo),
  7866. ACMD_DEF(exp),
  7867. ACMD_DEF(version),
  7868. ACMD_DEF(mutearea),
  7869. ACMD_DEF(rates),
  7870. ACMD_DEF(iteminfo),
  7871. ACMD_DEF(whodrops),
  7872. ACMD_DEF(whereis),
  7873. ACMD_DEF(mapflag),
  7874. ACMD_DEF(me),
  7875. ACMD_DEF(monsterignore),
  7876. ACMD_DEF(fakename),
  7877. ACMD_DEF(size),
  7878. ACMD_DEF(showexp),
  7879. ACMD_DEF(showzeny),
  7880. ACMD_DEF(showdelay),
  7881. ACMD_DEF(autotrade),
  7882. ACMD_DEF(changegm),
  7883. ACMD_DEF(changeleader),
  7884. ACMD_DEF(partyoption),
  7885. ACMD_DEF(invite),
  7886. ACMD_DEF(duel),
  7887. ACMD_DEF(leave),
  7888. ACMD_DEF(accept),
  7889. ACMD_DEF(reject),
  7890. ACMD_DEF(clone),
  7891. ACMD_DEF2("slaveclone", clone),
  7892. ACMD_DEF2("evilclone", clone),
  7893. ACMD_DEF(tonpc),
  7894. ACMD_DEF(commands),
  7895. ACMD_DEF(noask),
  7896. ACMD_DEF(request),
  7897. ACMD_DEF(homlevel),
  7898. ACMD_DEF(homevolution),
  7899. ACMD_DEF(hommutate),
  7900. ACMD_DEF(makehomun),
  7901. ACMD_DEF(homfriendly),
  7902. ACMD_DEF(homhungry),
  7903. ACMD_DEF(homtalk),
  7904. ACMD_DEF(hominfo),
  7905. ACMD_DEF(homstats),
  7906. ACMD_DEF(homshuffle),
  7907. ACMD_DEF(showmobs),
  7908. ACMD_DEF(feelreset),
  7909. ACMD_DEF(auction),
  7910. ACMD_DEF(mail),
  7911. ACMD_DEF2("noks", ksprotection),
  7912. ACMD_DEF(allowks),
  7913. ACMD_DEF(cash),
  7914. ACMD_DEF2("points", cash),
  7915. ACMD_DEF(agitstart2),
  7916. ACMD_DEF(agitend2),
  7917. ACMD_DEF2("skreset", resetskill),
  7918. ACMD_DEF2("streset", resetstat),
  7919. ACMD_DEF2("storagelist", itemlist),
  7920. ACMD_DEF2("cartlist", itemlist),
  7921. ACMD_DEF2("itemlist", itemlist),
  7922. ACMD_DEF(stats),
  7923. ACMD_DEF(delitem),
  7924. ACMD_DEF(charcommands),
  7925. ACMD_DEF(font),
  7926. ACMD_DEF(accinfo),
  7927. ACMD_DEF(set),
  7928. ACMD_DEF(undisguiseguild),
  7929. ACMD_DEF(disguiseguild),
  7930. ACMD_DEF(sizeall),
  7931. ACMD_DEF(sizeguild),
  7932. ACMD_DEF(addperm),
  7933. ACMD_DEF2("rmvperm", addperm),
  7934. ACMD_DEF(unloadnpcfile),
  7935. ACMD_DEF(cart),
  7936. ACMD_DEF(mount2),
  7937. ACMD_DEF(join),
  7938. ACMD_DEF(channel),
  7939. ACMD_DEF(fontcolor),
  7940. ACMD_DEF(langtype),
  7941. };
  7942. AtCommandInfo* atcommand;
  7943. int i;
  7944. for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) {
  7945. if(atcommand_exists(atcommand_base[i].command)) { // Should not happen if atcommand_base[] array is OK
  7946. ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command);
  7947. continue;
  7948. }
  7949. CREATE(atcommand, AtCommandInfo, 1);
  7950. safestrncpy(atcommand->command, atcommand_base[i].command, sizeof(atcommand->command));
  7951. atcommand->func = atcommand_base[i].func;
  7952. strdb_put(atcommand_db, atcommand->command, atcommand);
  7953. }
  7954. return;
  7955. }
  7956. /*==========================================
  7957. * Command lookup functions
  7958. *------------------------------------------*/
  7959. bool atcommand_exists(const char* name)
  7960. {
  7961. return strdb_exists(atcommand_db, name);
  7962. }
  7963. static AtCommandInfo* get_atcommandinfo_byname(const char *name)
  7964. {
  7965. if (strdb_exists(atcommand_db, name))
  7966. return (AtCommandInfo*)strdb_get(atcommand_db, name);
  7967. return NULL;
  7968. }
  7969. static const char* atcommand_checkalias(const char *aliasname)
  7970. {
  7971. AliasInfo *alias_info = NULL;
  7972. if ((alias_info = (AliasInfo*)strdb_get(atcommand_alias_db, aliasname)) != NULL)
  7973. return alias_info->command->command;
  7974. return aliasname;
  7975. }
  7976. /// AtCommand suggestion
  7977. static void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bool atcommand) {
  7978. DBIterator* atcommand_iter;
  7979. DBIterator* alias_iter;
  7980. AtCommandInfo* command_info = NULL;
  7981. AliasInfo* alias_info = NULL;
  7982. AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
  7983. char* full_match[MAX_SUGGESTIONS];
  7984. char* suggestions[MAX_SUGGESTIONS];
  7985. char* match;
  7986. int prefix_count = 0, full_count = 0;
  7987. bool can_use;
  7988. if (!battle_config.atcommand_suggestions_enabled)
  7989. return;
  7990. atcommand_iter = db_iterator(atcommand_db);
  7991. alias_iter = db_iterator(atcommand_alias_db);
  7992. // Build the matches
  7993. for (command_info = dbi_first(atcommand_iter); dbi_exists(atcommand_iter); command_info = dbi_next(atcommand_iter)) {
  7994. match = strstr(command_info->command, name);
  7995. can_use = pc_can_use_command(sd, command_info->command, type);
  7996. if ( prefix_count < MAX_SUGGESTIONS && match == command_info->command && can_use ) {
  7997. suggestions[prefix_count] = command_info->command;
  7998. ++prefix_count;
  7999. }
  8000. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
  8001. full_match[full_count] = command_info->command;
  8002. ++full_count;
  8003. }
  8004. }
  8005. for (alias_info = dbi_first(alias_iter); dbi_exists(alias_iter); alias_info = dbi_next(alias_iter)) {
  8006. match = strstr(alias_info->alias, name);
  8007. can_use = pc_can_use_command(sd, alias_info->command->command, type);
  8008. if ( prefix_count < MAX_SUGGESTIONS && match == alias_info->alias && can_use) {
  8009. suggestions[prefix_count] = alias_info->alias;
  8010. ++prefix_count;
  8011. }
  8012. if ( full_count < MAX_SUGGESTIONS && match != NULL && match != alias_info->alias && can_use ) {
  8013. full_match[full_count] = alias_info->alias;
  8014. ++full_count;
  8015. }
  8016. }
  8017. if ((full_count+prefix_count) > 0) {
  8018. char buffer[512];
  8019. int i;
  8020. // Merge full match and prefix match results
  8021. if (prefix_count < MAX_SUGGESTIONS) {
  8022. memmove(&suggestions[prefix_count], full_match, sizeof(char*) * (MAX_SUGGESTIONS-prefix_count));
  8023. prefix_count = min(prefix_count+full_count, MAX_SUGGESTIONS);
  8024. }
  8025. // Build the suggestion string
  8026. strcpy(buffer, msg_txt(sd,205));
  8027. strcat(buffer,"\n");
  8028. for(i=0; i < prefix_count; ++i) {
  8029. strcat(buffer,suggestions[i]);
  8030. strcat(buffer," ");
  8031. }
  8032. clif_displaymessage(sd->fd, buffer);
  8033. }
  8034. dbi_destroy(atcommand_iter);
  8035. dbi_destroy(alias_iter);
  8036. }
  8037. /// Executes an at-command.
  8038. bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
  8039. {
  8040. char charname[NAME_LENGTH], params[100];
  8041. char charname2[NAME_LENGTH], params2[100];
  8042. char command[100];
  8043. char output[CHAT_SIZE_MAX];
  8044. //Reconstructed message
  8045. char atcmd_msg[CHAT_SIZE_MAX];
  8046. TBL_PC * ssd = NULL; //sd for target
  8047. AtCommandInfo * info;
  8048. nullpo_retr(false, sd);
  8049. //Shouldn't happen
  8050. if ( !message || !*message )
  8051. return false;
  8052. //Block NOCHAT but do not display it as a normal message
  8053. if ( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCOMMAND )
  8054. return true;
  8055. // skip 10/11-langtype's codepage indicator, if detected
  8056. if ( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )
  8057. message += 3;
  8058. //Should display as a normal message
  8059. if ( *message != atcommand_symbol && *message != charcommand_symbol )
  8060. return false;
  8061. // type value 0 = server invoked: bypass restrictions
  8062. // 1 = player invoked
  8063. if ( type == 1) {
  8064. //Commands are disabled on maps flagged as 'nocommand'
  8065. if ( map[sd->bl.m].nocommand && pc_get_group_level(sd) < map[sd->bl.m].nocommand ) {
  8066. clif_displaymessage(fd, msg_txt(sd,143));
  8067. return false;
  8068. }
  8069. }
  8070. if (*message == charcommand_symbol) {
  8071. do {
  8072. int x, y, z;
  8073. //Checks to see if #command has a name or a name + parameters.
  8074. x = sscanf(message, "%99s \"%23[^\"]\" %99[^\n]", command, charname, params);
  8075. y = sscanf(message, "%99s %23s %99[^\n]", command, charname2, params2);
  8076. //z always has the value of the scan that was successful
  8077. z = ( x > 1 ) ? x : y;
  8078. //#command + name means the sufficient target was used and anything else after
  8079. //can be looked at by the actual command function since most scan to see if the
  8080. //right parameters are used.
  8081. if ( x > 2 ) {
  8082. sprintf(atcmd_msg, "%s %s", command, params);
  8083. break;
  8084. }
  8085. else if ( y > 2 ) {
  8086. sprintf(atcmd_msg, "%s %s", command, params2);
  8087. break;
  8088. }
  8089. //Regardless of what style the #command is used, if it's correct, it will always have
  8090. //this value if there is no parameter. Send it as just the #command
  8091. else if ( z == 2 ) {
  8092. sprintf(atcmd_msg, "%s", command);
  8093. break;
  8094. }
  8095. if( !pc_get_group_level(sd) ) {
  8096. if( x >= 1 || y >= 1 ) { /* we have command */
  8097. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8098. 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 */
  8099. return false;
  8100. } else
  8101. return false;/* display as normal message */
  8102. }
  8103. sprintf(output, msg_txt(sd,1388), charcommand_symbol); // Charcommand failed (usage: %c<command> <char name> <parameters>).
  8104. clif_displaymessage(fd, output);
  8105. return true;
  8106. } while(0);
  8107. }
  8108. else if (*message == atcommand_symbol) {
  8109. //atcmd_msg is constructed above differently for charcommands
  8110. //it's copied from message if not a charcommand so it can
  8111. //pass through the rest of the code compatible with both symbols
  8112. sprintf(atcmd_msg, "%s", message);
  8113. }
  8114. //Clearing these to be used once more.
  8115. memset(command, '\0', sizeof(command));
  8116. memset(params, '\0', sizeof(params));
  8117. //check to see if any params exist within this command
  8118. if( sscanf(atcmd_msg, "%99s %99[^\n]", command, params) < 2 )
  8119. params[0] = '\0';
  8120. // @commands (script based)
  8121. if(type == 1 && atcmd_binding_count > 0) {
  8122. struct atcmd_binding_data * binding;
  8123. // Check if the command initiated is a character command
  8124. if (*message == charcommand_symbol &&
  8125. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8126. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8127. clif_displaymessage(fd, output);
  8128. return true;
  8129. }
  8130. // Get atcommand binding
  8131. binding = get_atcommandbind_byname(command);
  8132. // Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
  8133. if( binding != NULL && binding->npc_event[0] &&
  8134. ((*atcmd_msg == atcommand_symbol && pc_get_group_level(sd) >= binding->level) ||
  8135. (*atcmd_msg == charcommand_symbol && pc_get_group_level(sd) >= binding->level2)))
  8136. {
  8137. // Check if self or character invoking; if self == character invoked, then self invoke.
  8138. bool invokeFlag = ((*atcmd_msg == atcommand_symbol) ? 1 : 0);
  8139. npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
  8140. return true;
  8141. }
  8142. }
  8143. //Grab the command information and check for the proper GM level required to use it or if the command exists
  8144. info = get_atcommandinfo_byname(atcommand_checkalias(command + 1));
  8145. if (info == NULL) {
  8146. if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission
  8147. sprintf(output, msg_txt(sd,153), command); // "%s is Unknown Command."
  8148. clif_displaymessage(fd, output);
  8149. atcommand_get_suggestions(sd, command + 1, *message == atcommand_symbol);
  8150. return true;
  8151. } else
  8152. return false;
  8153. }
  8154. // type == 1 : player invoked
  8155. if (type == 1) {
  8156. if ((*command == atcommand_symbol && info->at_groups[sd->group_pos] == 0) ||
  8157. (*command == charcommand_symbol && info->char_groups[sd->group_pos] == 0) ) {
  8158. return false;
  8159. }
  8160. if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) {
  8161. clif_displaymessage(fd, msg_txt(sd,1393)); // You can't use commands while dead
  8162. return true;
  8163. }
  8164. }
  8165. // Check if target is valid only if confirmed that player can use command.
  8166. if (*message == charcommand_symbol &&
  8167. (ssd = map_nick2sd(charname)) == NULL && (ssd = map_nick2sd(charname2)) == NULL ) {
  8168. sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
  8169. clif_displaymessage(fd, output);
  8170. return true;
  8171. }
  8172. //Attempt to use the command
  8173. if ( (info->func(fd, (*atcmd_msg == atcommand_symbol) ? sd : ssd, command, params) != 0) )
  8174. {
  8175. sprintf(output,msg_txt(sd,154), command); // %s failed.
  8176. clif_displaymessage(fd, output);
  8177. return true;
  8178. }
  8179. //Log only if successful.
  8180. if ( *atcmd_msg == atcommand_symbol )
  8181. log_atcommand(sd, atcmd_msg);
  8182. else if ( *atcmd_msg == charcommand_symbol )
  8183. log_atcommand(sd, message);
  8184. return true;
  8185. }
  8186. /*==========================================
  8187. *
  8188. *------------------------------------------*/
  8189. static void atcommand_config_read(const char* config_filename)
  8190. {
  8191. config_setting_t *aliases = NULL, *help = NULL;
  8192. const char *symbol = NULL;
  8193. int num_aliases = 0;
  8194. if (conf_read_file(&atcommand_config, config_filename))
  8195. return;
  8196. // Command symbols
  8197. if (config_lookup_string(&atcommand_config, "atcommand_symbol", &symbol)) {
  8198. if (ISPRINT(*symbol) && // no control characters
  8199. *symbol != '/' && // symbol of client commands
  8200. *symbol != '%' && // symbol of party chat
  8201. *symbol != '$' && // symbol of guild chat
  8202. *symbol != charcommand_symbol)
  8203. atcommand_symbol = *symbol;
  8204. }
  8205. if (config_lookup_string(&atcommand_config, "charcommand_symbol", &symbol)) {
  8206. if (ISPRINT(*symbol) && // no control characters
  8207. *symbol != '/' && // symbol of client commands
  8208. *symbol != '%' && // symbol of party chat
  8209. *symbol != '$' && // symbol of guild chat
  8210. *symbol != atcommand_symbol)
  8211. charcommand_symbol = *symbol;
  8212. }
  8213. // Command aliases
  8214. aliases = config_lookup(&atcommand_config, "aliases");
  8215. if (aliases != NULL) {
  8216. int i = 0;
  8217. int count = config_setting_length(aliases);
  8218. for (i = 0; i < count; ++i) {
  8219. config_setting_t *command;
  8220. const char *commandname = NULL;
  8221. int j = 0, alias_count = 0;
  8222. AtCommandInfo *commandinfo = NULL;
  8223. command = config_setting_get_elem(aliases, i);
  8224. if (config_setting_type(command) != CONFIG_TYPE_ARRAY)
  8225. continue;
  8226. commandname = config_setting_name(command);
  8227. if (!atcommand_exists(commandname)) {
  8228. ShowConfigWarning(command, "atcommand_config_read: can not set alias for non-existent command %s", commandname);
  8229. continue;
  8230. }
  8231. commandinfo = get_atcommandinfo_byname(commandname);
  8232. alias_count = config_setting_length(command);
  8233. for (j = 0; j < alias_count; ++j) {
  8234. const char *alias = config_setting_get_string_elem(command, j);
  8235. if (alias != NULL) {
  8236. AliasInfo *alias_info;
  8237. if (strdb_exists(atcommand_alias_db, alias)) {
  8238. ShowConfigWarning(command, "atcommand_config_read: alias %s already exists", alias);
  8239. continue;
  8240. }
  8241. CREATE(alias_info, AliasInfo, 1);
  8242. alias_info->command = commandinfo;
  8243. safestrncpy(alias_info->alias, alias, sizeof(alias_info->alias));
  8244. strdb_put(atcommand_alias_db, alias, alias_info);
  8245. ++num_aliases;
  8246. }
  8247. }
  8248. }
  8249. }
  8250. // Commands help
  8251. // We only check if all commands exist
  8252. help = config_lookup(&atcommand_config, "help");
  8253. if (help != NULL) {
  8254. int count = config_setting_length(help);
  8255. int i;
  8256. for (i = 0; i < count; ++i) {
  8257. config_setting_t *command;
  8258. const char *commandname;
  8259. command = config_setting_get_elem(help, i);
  8260. commandname = config_setting_name(command);
  8261. if (!atcommand_exists(commandname))
  8262. ShowConfigWarning(command, "atcommand_config_read: command %s does not exist", commandname);
  8263. }
  8264. }
  8265. ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename);
  8266. return;
  8267. }
  8268. void atcommand_db_load_groups(int* group_ids) {
  8269. DBIterator *iter = db_iterator(atcommand_db);
  8270. AtCommandInfo* cmd;
  8271. int i;
  8272. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8273. cmd->at_groups = aMalloc( pc_group_max * sizeof(char) );
  8274. cmd->char_groups = aMalloc( pc_group_max * sizeof(char) );
  8275. for(i = 0; i < pc_group_max; i++) {
  8276. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_ATCOMMAND ) )
  8277. cmd->at_groups[i] = 1;
  8278. else
  8279. cmd->at_groups[i] = 0;
  8280. if( pc_group_can_use_command(group_ids[i], cmd->command, COMMAND_CHARCOMMAND ) )
  8281. cmd->char_groups[i] = 1;
  8282. else
  8283. cmd->char_groups[i] = 0;
  8284. }
  8285. }
  8286. dbi_destroy(iter);
  8287. return;
  8288. }
  8289. void atcommand_db_clear(void) {
  8290. if (atcommand_db != NULL) {
  8291. DBIterator *iter = db_iterator(atcommand_db);
  8292. AtCommandInfo* cmd;
  8293. for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) {
  8294. aFree(cmd->at_groups);
  8295. aFree(cmd->char_groups);
  8296. }
  8297. dbi_destroy(iter);
  8298. db_destroy(atcommand_db);
  8299. }
  8300. if (atcommand_alias_db != NULL)
  8301. db_destroy(atcommand_alias_db);
  8302. config_destroy(&atcommand_config);
  8303. }
  8304. void atcommand_doload(void) {
  8305. atcommand_db_clear();
  8306. atcommand_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8307. atcommand_alias_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, ATCOMMAND_LENGTH);
  8308. atcommand_basecommands(); //fills initial atcommand_db with known commands
  8309. atcommand_config_read(ATCOMMAND_CONF_FILENAME);
  8310. }
  8311. void do_init_atcommand(void) {
  8312. atcommand_doload();
  8313. }
  8314. void do_final_atcommand(void) {
  8315. atcommand_db_clear();
  8316. }